From 27f76ef52eb7a450f7fb25a540a0299ac75498ee Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 11:43:04 +0200 Subject: [PATCH 01/86] wip orval msw generate --- .../_dataResponseSupplementalDetails.ts | 24 +- ... _dataResponseSupplementalDetailsOneOf.ts} | 2 +- ...taResponseSupplementalDetailsOneOfFive.ts} | 2 +- ...taResponseSupplementalDetailsOneOfFour.ts} | 2 +- ...ataResponseSupplementalDetailsOneOfSix.ts} | 2 +- ...aResponseSupplementalDetailsOneOfThree.ts} | 2 +- ...ataResponseSupplementalDetailsOneOfTwo.ts} | 2 +- jsapp/js/api/models/meListResponse.ts | 3 +- jsapp/js/api/models/meListResponseGitRev.ts | 8 +- .../api/models/meListResponseGitRevOneOf.ts | 22 + .../models/meListResponseGitRevOneOfBranch.ts | 13 + .../models/meListResponseGitRevOneOfLong.ts | 13 + .../models/meListResponseGitRevOneOfShort.ts | 13 + .../models/meListResponseGitRevOneOfTag.ts | 13 + jsapp/js/api/orval.operationName.js | 6 +- .../authentication-allauth-headless.ts | 4300 ++++++++++++++++- jsapp/js/api/react-query/configuration.ts | 130 + jsapp/js/api/react-query/form-content.ts | 560 ++- .../js/api/react-query/library-collections.ts | 127 +- jsapp/js/api/react-query/logging.ts | 397 ++ .../js/api/react-query/manage-permissions.ts | 196 + .../manage-projects-and-library-content.ts | 2656 +++++++++- jsapp/js/api/react-query/other.ts | 1073 +++- jsapp/js/api/react-query/scim.ts | 519 +- .../api/react-query/server-logs-superusers.ts | 1060 +++- .../react-query/survey-data-rest-services.ts | 436 +- jsapp/js/api/react-query/survey-data.ts | 3117 +++++++++++- .../user-team-organization-usage.ts | 1988 +++++++- jsapp/js/assetUtils.tests.js | 5 +- .../AssetTagsModal/AssetTagsModal.stories.tsx | 9 +- .../activity/FormActivity.stories.tsx | 37 +- .../components/map/FormMapWrapper.stories.tsx | 20 +- .../components/reports/reports.utils.tests.ts | 9 +- .../BulkProcessingBanner.stories.tsx | 36 +- .../submissions/DataTableWrapper.stories.tsx | 48 +- .../DataTableWrapperPollingStoriesUtils.tsx | 28 +- .../useDataTableBulkActions.tests.ts | 32 +- jsapp/js/endpoints/asset.factory.ts | 56 - jsapp/js/endpoints/asset.mocks.ts | 204 +- jsapp/js/endpoints/assetData.factory.ts | 6 + jsapp/js/endpoints/assetData.mocks.ts | 6 + jsapp/js/endpoints/assetHistory.mocks.ts | 48 +- .../js/endpoints/assetHistoryActions.mocks.ts | 28 - jsapp/js/endpoints/assetHistoryLog.factory.ts | 26 - jsapp/js/endpoints/assets.mocks.ts | 58 +- jsapp/js/endpoints/assets.templates.ts | 8 +- jsapp/js/endpoints/bulkAction.factory.ts | 38 - jsapp/js/endpoints/bulkActions.mocks.ts | 30 +- jsapp/js/endpoints/environment.mocks.ts | 21 +- jsapp/js/endpoints/formMedia.factory.ts | 35 - jsapp/js/endpoints/formMedia.mocks.ts | 120 +- jsapp/js/endpoints/languageDetail.mocks.ts | 48 +- jsapp/js/endpoints/me.mocks.ts | 20 +- jsapp/js/endpoints/organization.mocks.ts | 35 +- .../organizationServiceUsage.factory.ts | 6 + .../organizationServiceUsage.mocks.ts | 7 +- jsapp/js/endpoints/serviceUsage.factory.ts | 5 + jsapp/js/endpoints/subscription.mocks.ts | 5 + .../project/FormMedia/FormMedia.stories.tsx | 11 +- kpi/schema_extensions/v2/data/extensions.py | 131 +- kpi/schema_extensions/v2/me/extensions.py | 24 +- kpi/schema_extensions/v2/me/serializers.py | 2 +- orval.config.js | 6 +- scripts/generate_api.sh | 8 + static/openapi/schema_v2.json | 238 +- static/openapi/schema_v2.yaml | 151 +- 66 files changed, 17226 insertions(+), 1065 deletions(-) rename jsapp/js/api/models/{supplementalDetailsManualTranscription.ts => _dataResponseSupplementalDetailsOneOf.ts} (94%) rename jsapp/js/api/models/{supplementalDetailsManualQual.ts => _dataResponseSupplementalDetailsOneOfFive.ts} (94%) rename jsapp/js/api/models/{supplementalDetailsAutomaticTranslation.ts => _dataResponseSupplementalDetailsOneOfFour.ts} (94%) rename jsapp/js/api/models/{supplementalDetailsAutomaticQual.ts => _dataResponseSupplementalDetailsOneOfSix.ts} (94%) rename jsapp/js/api/models/{supplementalDetailsAutomaticTranscription.ts => _dataResponseSupplementalDetailsOneOfThree.ts} (94%) rename jsapp/js/api/models/{supplementalDetailsManualTranslation.ts => _dataResponseSupplementalDetailsOneOfTwo.ts} (94%) create mode 100644 jsapp/js/api/models/meListResponseGitRevOneOf.ts create mode 100644 jsapp/js/api/models/meListResponseGitRevOneOfBranch.ts create mode 100644 jsapp/js/api/models/meListResponseGitRevOneOfLong.ts create mode 100644 jsapp/js/api/models/meListResponseGitRevOneOfShort.ts create mode 100644 jsapp/js/api/models/meListResponseGitRevOneOfTag.ts delete mode 100644 jsapp/js/endpoints/asset.factory.ts delete mode 100644 jsapp/js/endpoints/assetHistoryActions.mocks.ts delete mode 100644 jsapp/js/endpoints/assetHistoryLog.factory.ts delete mode 100644 jsapp/js/endpoints/bulkAction.factory.ts delete mode 100644 jsapp/js/endpoints/formMedia.factory.ts diff --git a/jsapp/js/api/models/_dataResponseSupplementalDetails.ts b/jsapp/js/api/models/_dataResponseSupplementalDetails.ts index 413dc9c2ed..18ad181237 100644 --- a/jsapp/js/api/models/_dataResponseSupplementalDetails.ts +++ b/jsapp/js/api/models/_dataResponseSupplementalDetails.ts @@ -1,7 +1,3 @@ -import type { SupplementalDetailsAutomaticQual } from './supplementalDetailsAutomaticQual' -import type { SupplementalDetailsAutomaticTranscription } from './supplementalDetailsAutomaticTranscription' -import type { SupplementalDetailsAutomaticTranslation } from './supplementalDetailsAutomaticTranslation' -import type { SupplementalDetailsManualQual } from './supplementalDetailsManualQual' /** * Generated by orval v7.10.0 🍺 * Do not edit manually. @@ -13,18 +9,22 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import type { SupplementalDetailsManualTranscription } from './supplementalDetailsManualTranscription' -import type { SupplementalDetailsManualTranslation } from './supplementalDetailsManualTranslation' +import type { _DataResponseSupplementalDetailsOneOf } from './_dataResponseSupplementalDetailsOneOf' +import type { _DataResponseSupplementalDetailsOneOfFive } from './_dataResponseSupplementalDetailsOneOfFive' +import type { _DataResponseSupplementalDetailsOneOfFour } from './_dataResponseSupplementalDetailsOneOfFour' +import type { _DataResponseSupplementalDetailsOneOfSix } from './_dataResponseSupplementalDetailsOneOfSix' +import type { _DataResponseSupplementalDetailsOneOfThree } from './_dataResponseSupplementalDetailsOneOfThree' +import type { _DataResponseSupplementalDetailsOneOfTwo } from './_dataResponseSupplementalDetailsOneOfTwo' /** * Action-specific supplemental data attached to this submission. Structure varies by action type (transcription, translation, qual). Top-level keys are question XPaths, values are action objects. * @nullable */ export type _DataResponseSupplementalDetails = - | SupplementalDetailsManualTranscription - | SupplementalDetailsManualTranslation - | SupplementalDetailsAutomaticTranscription - | SupplementalDetailsAutomaticTranslation - | SupplementalDetailsManualQual - | SupplementalDetailsAutomaticQual + | _DataResponseSupplementalDetailsOneOf + | _DataResponseSupplementalDetailsOneOfTwo + | _DataResponseSupplementalDetailsOneOfThree + | _DataResponseSupplementalDetailsOneOfFour + | _DataResponseSupplementalDetailsOneOfFive + | _DataResponseSupplementalDetailsOneOfSix | null diff --git a/jsapp/js/api/models/supplementalDetailsManualTranscription.ts b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOf.ts similarity index 94% rename from jsapp/js/api/models/supplementalDetailsManualTranscription.ts rename to jsapp/js/api/models/_dataResponseSupplementalDetailsOneOf.ts index 232bc81bcf..186d3df07f 100644 --- a/jsapp/js/api/models/supplementalDetailsManualTranscription.ts +++ b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOf.ts @@ -14,7 +14,7 @@ import type { SupplementalDataManualTranscription } from './supplementalDataManu /** * Manual transcription supplemental details */ -export interface SupplementalDetailsManualTranscription { +export type _DataResponseSupplementalDetailsOneOf = { [key: string]: { manual_transcription: SupplementalDataManualTranscription } diff --git a/jsapp/js/api/models/supplementalDetailsManualQual.ts b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfFive.ts similarity index 94% rename from jsapp/js/api/models/supplementalDetailsManualQual.ts rename to jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfFive.ts index 23db7e10da..74a7615b53 100644 --- a/jsapp/js/api/models/supplementalDetailsManualQual.ts +++ b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfFive.ts @@ -14,7 +14,7 @@ import type { SupplementalDataManualQual } from './supplementalDataManualQual' /** * Manual qualitative supplemental details */ -export interface SupplementalDetailsManualQual { +export type _DataResponseSupplementalDetailsOneOfFive = { [key: string]: { manual_qual: SupplementalDataManualQual } diff --git a/jsapp/js/api/models/supplementalDetailsAutomaticTranslation.ts b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfFour.ts similarity index 94% rename from jsapp/js/api/models/supplementalDetailsAutomaticTranslation.ts rename to jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfFour.ts index 674af6ea2b..62bfef30b7 100644 --- a/jsapp/js/api/models/supplementalDetailsAutomaticTranslation.ts +++ b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfFour.ts @@ -14,7 +14,7 @@ import type { SupplementalDataAutomaticTranslation } from './supplementalDataAut /** * Automatic translation supplemental details */ -export interface SupplementalDetailsAutomaticTranslation { +export type _DataResponseSupplementalDetailsOneOfFour = { [key: string]: { automatic_google_translation: SupplementalDataAutomaticTranslation } diff --git a/jsapp/js/api/models/supplementalDetailsAutomaticQual.ts b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfSix.ts similarity index 94% rename from jsapp/js/api/models/supplementalDetailsAutomaticQual.ts rename to jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfSix.ts index 8d384cbf6f..f00733571f 100644 --- a/jsapp/js/api/models/supplementalDetailsAutomaticQual.ts +++ b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfSix.ts @@ -14,7 +14,7 @@ import type { SupplementalDataAutomaticQual } from './supplementalDataAutomaticQ /** * Automatic qualitative supplemental details */ -export interface SupplementalDetailsAutomaticQual { +export type _DataResponseSupplementalDetailsOneOfSix = { [key: string]: { automatic_bedrock_qual: SupplementalDataAutomaticQual } diff --git a/jsapp/js/api/models/supplementalDetailsAutomaticTranscription.ts b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfThree.ts similarity index 94% rename from jsapp/js/api/models/supplementalDetailsAutomaticTranscription.ts rename to jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfThree.ts index a4ecc60813..1396668554 100644 --- a/jsapp/js/api/models/supplementalDetailsAutomaticTranscription.ts +++ b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfThree.ts @@ -14,7 +14,7 @@ import type { SupplementalDataAutomaticTranscription } from './supplementalDataA /** * Automatic transcription supplemental details */ -export interface SupplementalDetailsAutomaticTranscription { +export type _DataResponseSupplementalDetailsOneOfThree = { [key: string]: { automatic_google_transcription: SupplementalDataAutomaticTranscription } diff --git a/jsapp/js/api/models/supplementalDetailsManualTranslation.ts b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfTwo.ts similarity index 94% rename from jsapp/js/api/models/supplementalDetailsManualTranslation.ts rename to jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfTwo.ts index fe2b39d204..99273df07c 100644 --- a/jsapp/js/api/models/supplementalDetailsManualTranslation.ts +++ b/jsapp/js/api/models/_dataResponseSupplementalDetailsOneOfTwo.ts @@ -14,7 +14,7 @@ import type { SupplementalDataManualTranslation } from './supplementalDataManual /** * Manual translation supplemental details */ -export interface SupplementalDetailsManualTranslation { +export type _DataResponseSupplementalDetailsOneOfTwo = { [key: string]: { manual_translation: SupplementalDataManualTranslation } diff --git a/jsapp/js/api/models/meListResponse.ts b/jsapp/js/api/models/meListResponse.ts index 542ca14907..9275b0d8bd 100644 --- a/jsapp/js/api/models/meListResponse.ts +++ b/jsapp/js/api/models/meListResponse.ts @@ -23,7 +23,8 @@ export interface MeListResponse { date_joined: string projects_url: string gravatar: string - last_login: string + /** @nullable */ + last_login: string | null extra_details: MeListResponseExtraDetails git_rev: MeListResponseGitRev social_accounts: MeListResponseSocialAccountsItem[] diff --git a/jsapp/js/api/models/meListResponseGitRev.ts b/jsapp/js/api/models/meListResponseGitRev.ts index 7583ddaf3b..8326c026e3 100644 --- a/jsapp/js/api/models/meListResponseGitRev.ts +++ b/jsapp/js/api/models/meListResponseGitRev.ts @@ -9,10 +9,6 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { MeListResponseGitRevOneOf } from './meListResponseGitRevOneOf' -export type MeListResponseGitRev = { - short?: string - long?: string - branch?: string - tag?: string -} +export type MeListResponseGitRev = boolean | MeListResponseGitRevOneOf diff --git a/jsapp/js/api/models/meListResponseGitRevOneOf.ts b/jsapp/js/api/models/meListResponseGitRevOneOf.ts new file mode 100644 index 0000000000..517c1ef2ec --- /dev/null +++ b/jsapp/js/api/models/meListResponseGitRevOneOf.ts @@ -0,0 +1,22 @@ +import type { MeListResponseGitRevOneOfBranch } from './meListResponseGitRevOneOfBranch' +import type { MeListResponseGitRevOneOfLong } from './meListResponseGitRevOneOfLong' +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { MeListResponseGitRevOneOfShort } from './meListResponseGitRevOneOfShort' +import type { MeListResponseGitRevOneOfTag } from './meListResponseGitRevOneOfTag' + +export type MeListResponseGitRevOneOf = { + short?: MeListResponseGitRevOneOfShort + long?: MeListResponseGitRevOneOfLong + branch?: MeListResponseGitRevOneOfBranch + tag?: MeListResponseGitRevOneOfTag +} diff --git a/jsapp/js/api/models/meListResponseGitRevOneOfBranch.ts b/jsapp/js/api/models/meListResponseGitRevOneOfBranch.ts new file mode 100644 index 0000000000..ee29e9b7a3 --- /dev/null +++ b/jsapp/js/api/models/meListResponseGitRevOneOfBranch.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type MeListResponseGitRevOneOfBranch = string | boolean diff --git a/jsapp/js/api/models/meListResponseGitRevOneOfLong.ts b/jsapp/js/api/models/meListResponseGitRevOneOfLong.ts new file mode 100644 index 0000000000..52197c475d --- /dev/null +++ b/jsapp/js/api/models/meListResponseGitRevOneOfLong.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type MeListResponseGitRevOneOfLong = string | boolean diff --git a/jsapp/js/api/models/meListResponseGitRevOneOfShort.ts b/jsapp/js/api/models/meListResponseGitRevOneOfShort.ts new file mode 100644 index 0000000000..30e62492cc --- /dev/null +++ b/jsapp/js/api/models/meListResponseGitRevOneOfShort.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type MeListResponseGitRevOneOfShort = string | boolean diff --git a/jsapp/js/api/models/meListResponseGitRevOneOfTag.ts b/jsapp/js/api/models/meListResponseGitRevOneOfTag.ts new file mode 100644 index 0000000000..a5a800f9c1 --- /dev/null +++ b/jsapp/js/api/models/meListResponseGitRevOneOfTag.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type MeListResponseGitRevOneOfTag = string | boolean diff --git a/jsapp/js/api/orval.operationName.js b/jsapp/js/api/orval.operationName.js index c4206977bb..6c1c9be64d 100644 --- a/jsapp/js/api/orval.operationName.js +++ b/jsapp/js/api/orval.operationName.js @@ -109,7 +109,5 @@ const getOperationId = (operation, route, verb) => { ) } -module.exports = { - operationName: (operation, route, verb) => - sanitize(camel(getOperationId(operation, route, verb)), { es5keyword: true }), -} +export const operationName = (operation, route, verb) => + sanitize(camel(getOperationId(operation, route, verb)), { es5keyword: true }) diff --git a/jsapp/js/api/react-query/authentication-allauth-headless.ts b/jsapp/js/api/react-query/authentication-allauth-headless.ts index 23dc31edad..dbbaef1a24 100644 --- a/jsapp/js/api/react-query/authentication-allauth-headless.ts +++ b/jsapp/js/api/react-query/authentication-allauth-headless.ts @@ -21,34 +21,18 @@ import type { import type { AddAuthenticatorConflictResponse } from '../models/addAuthenticatorConflictResponse' -import type { AuthenticatedByCodeResponse } from '../models/authenticatedByCodeResponse' - -import type { AuthenticatedByPasswordAnd2FAResponse } from '../models/authenticatedByPasswordAnd2FAResponse' - -import type { AuthenticatedByPasswordResponse } from '../models/authenticatedByPasswordResponse' - -import type { AuthenticatedResponse } from '../models/authenticatedResponse' - import type { AuthenticationOrReauthenticationResponse } from '../models/authenticationOrReauthenticationResponse' import type { AuthenticationResponse } from '../models/authenticationResponse' -import type { AuthenticatorsResponse } from '../models/authenticatorsResponse' - import type { ChangePasswordBody } from '../models/changePasswordBody' -import type { ConfigurationResponse } from '../models/configurationResponse' - import type { ConfirmLoginCodeBody } from '../models/confirmLoginCodeBody' import type { ConflictResponse } from '../models/conflictResponse' -import type { EmailAddressesResponse } from '../models/emailAddressesResponse' - import type { EmailBody } from '../models/emailBody' -import type { EmailVerificationInfoResponse } from '../models/emailVerificationInfoResponse' - import type { EndSessionsBody } from '../models/endSessionsBody' import type { ErrorResponse } from '../models/errorResponse' @@ -63,54 +47,34 @@ import type { MarkPrimaryEmailBody } from '../models/markPrimaryEmailBody' import type { NotFoundResponse } from '../models/notFoundResponse' -import type { PasswordResetInfoResponse } from '../models/passwordResetInfoResponse' - import type { PhoneBody } from '../models/phoneBody' -import type { PhoneNumberChangeResponse } from '../models/phoneNumberChangeResponse' - -import type { PhoneNumbersResponse } from '../models/phoneNumbersResponse' - import type { ProviderAccountBody } from '../models/providerAccountBody' -import type { ProviderAccountsResponse } from '../models/providerAccountsResponse' - import type { ProviderRedirectBody } from '../models/providerRedirectBody' import type { ProviderSignupBody } from '../models/providerSignupBody' -import type { ProviderSignupResponse } from '../models/providerSignupResponse' - import type { ProviderTokenBody } from '../models/providerTokenBody' import type { ReauthenticateBody } from '../models/reauthenticateBody' import type { ReauthenticationRequiredResponse } from '../models/reauthenticationRequiredResponse' -import type { RecoveryCodesResponse } from '../models/recoveryCodesResponse' - import type { RefreshTokenBody } from '../models/refreshTokenBody' -import type { RefreshTokenResponse } from '../models/refreshTokenResponse' - import type { RequestPasswordBody } from '../models/requestPasswordBody' import type { ResetPasswordBody } from '../models/resetPasswordBody' import type { SessionGoneResponse } from '../models/sessionGoneResponse' -import type { SessionsResponse } from '../models/sessionsResponse' - import type { SetupTOTPBody } from '../models/setupTOTPBody' import type { SignupBody } from '../models/signupBody' -import type { StatusOKResponse } from '../models/statusOKResponse' - import type { TOTPAuthenticatorNotFoundResponse } from '../models/tOTPAuthenticatorNotFoundResponse' -import type { TOTPAuthenticatorResponse } from '../models/tOTPAuthenticatorResponse' - import type { TooManyRequestsResponse } from '../models/tooManyRequestsResponse' import type { UnauthenticatedResponse } from '../models/unauthenticatedResponse' @@ -119,6 +83,54 @@ import type { VerifyEmailBody } from '../models/verifyEmailBody' import type { VerifyPhoneBody } from '../models/verifyPhoneBody' +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + +import type { AuthenticatedByCodeResponse } from '../models/authenticatedByCodeResponse' + +import type { AuthenticatedByPasswordAnd2FAResponse } from '../models/authenticatedByPasswordAnd2FAResponse' + +import type { AuthenticatedByPasswordResponse } from '../models/authenticatedByPasswordResponse' + +import type { AuthenticatedResponse } from '../models/authenticatedResponse' + +import { AuthenticatorType } from '../models/authenticatorType' + +import type { AuthenticatorsResponse } from '../models/authenticatorsResponse' + +import type { ConfigurationResponse } from '../models/configurationResponse' + +import type { EmailAddressesResponse } from '../models/emailAddressesResponse' + +import type { EmailVerificationInfoResponse } from '../models/emailVerificationInfoResponse' + +import type { PasswordResetInfoResponse } from '../models/passwordResetInfoResponse' + +import type { PhoneNumberChangeResponse } from '../models/phoneNumberChangeResponse' + +import type { PhoneNumbersResponse } from '../models/phoneNumbersResponse' + +import type { ProviderAccountsResponse } from '../models/providerAccountsResponse' + +import type { ProviderSignupResponse } from '../models/providerSignupResponse' + +import type { RecoveryCodesAuthenticator } from '../models/recoveryCodesAuthenticator' + +import type { RecoveryCodesResponse } from '../models/recoveryCodesResponse' + +import type { RefreshTokenResponse } from '../models/refreshTokenResponse' + +import type { SessionsResponse } from '../models/sessionsResponse' + +import type { StatusOKResponse } from '../models/statusOKResponse' + +import type { TOTPAuthenticator } from '../models/tOTPAuthenticator' + +import type { TOTPAuthenticatorResponse } from '../models/tOTPAuthenticatorResponse' + +import type { WebAuthnAuthenticator } from '../models/webAuthnAuthenticator' + import { fetchWithAuth } from '../orval.mutator' type SecondParameter unknown> = Parameters[1] @@ -8110,3 +8122,4219 @@ export const useAllauthAppV1AuthSessionsDelete = = {}, +): ConfigurationResponse => ({ + data: { + account: { + login_methods: faker.helpers.arrayElement([ + faker.helpers.arrayElements(['email', 'username'] as const), + undefined, + ]), + is_open_for_signup: faker.datatype.boolean(), + email_verification_by_code_enabled: faker.datatype.boolean(), + login_by_code_enabled: faker.datatype.boolean(), + password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + socialaccount: faker.helpers.arrayElement([ + { + providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + })), + }, + undefined, + ]), + mfa: faker.helpers.arrayElement([ + { supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType)) }, + undefined, + ]), + usersessions: faker.helpers.arrayElement([{ track_activity: faker.datatype.boolean() }, undefined]), + }, + status: faker.helpers.arrayElement([200] as const), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1ConfigGetResponseMock = ( + overrideResponse: Partial = {}, +): ConfigurationResponse => ({ + data: { + account: { + login_methods: faker.helpers.arrayElement([ + faker.helpers.arrayElements(['email', 'username'] as const), + undefined, + ]), + is_open_for_signup: faker.datatype.boolean(), + email_verification_by_code_enabled: faker.datatype.boolean(), + login_by_code_enabled: faker.datatype.boolean(), + password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + socialaccount: faker.helpers.arrayElement([ + { + providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + })), + }, + undefined, + ]), + mfa: faker.helpers.arrayElement([ + { supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType)) }, + undefined, + ]), + usersessions: faker.helpers.arrayElement([{ track_activity: faker.datatype.boolean() }, undefined]), + }, + status: faker.helpers.arrayElement([200] as const), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthLoginPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthLoginPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailVerificationInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + meta: { is_authenticating: faker.datatype.boolean() }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailVerificationInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + meta: { is_authenticating: faker.datatype.boolean() }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock = ( + overrideResponse: Partial = {}, +): PasswordResetInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: faker.helpers.arrayElement([ + { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthPasswordResetGetResponseMock = ( + overrideResponse: Partial = {}, +): PasswordResetInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: faker.helpers.arrayElement([ + { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthPasswordResetPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthProviderTokenPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderSignupResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + account: { + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + }, + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthProviderSignupGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderSignupResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + account: { + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + }, + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthProviderSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByCodeResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByCodeResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountProvidersGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountProvidersGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountProvidersDeleteResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailPostResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailPutResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AccountEmailPatchResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailPostResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailPutResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AccountEmailPatchResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailDeleteResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountPhoneGetResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumbersResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountPhonePostResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumberChangeResponse => ({ + status: faker.helpers.arrayElement([202] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountPhoneGetResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumbersResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountPhonePostResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumberChangeResponse => ({ + status: faker.helpers.arrayElement([202] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = ( + overrideResponse: Partial = {}, +): WebAuthnAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['webauthn'] as const), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatorsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock() }, + { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock() }, + { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock() }, + ]), + ), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = ( + overrideResponse: Partial = {}, +): WebAuthnAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['webauthn'] as const), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatorsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock() }, + { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock() }, + { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock() }, + ]), + ), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...{ + unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...{ + unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSessionGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSessionGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1TokensRefreshPostResponseMock = ( + overrideResponse: Partial = {}, +): RefreshTokenResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + access_token: faker.string.alpha({ length: { min: 10, max: 20 } }), + refresh_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSessionsGetResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSessionsGetResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSessionsDeleteResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1ConfigGetMockHandler = ( + overrideResponse?: + | ConfigurationResponse + | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/config', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1ConfigGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1ConfigGetMockHandler = ( + overrideResponse?: + | ConfigurationResponse + | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/config', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1ConfigGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthLoginPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/login', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthLoginPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthLoginPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/login', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthLoginPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/signup', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/signup', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler = ( + overrideResponse?: + | EmailVerificationInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailVerificationInfoResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler = ( + overrideResponse?: + | EmailVerificationInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailVerificationInfoResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/email/verify/resend', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/email/verify/resend', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/phone/verify', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify/resend', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/phone/verify/resend', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/reauthenticate', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/reauthenticate', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/password/request', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/password/request', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler = ( + overrideResponse?: + | PasswordResetInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PasswordResetInfoResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthPasswordResetGetMockHandler = ( + overrideResponse?: + | PasswordResetInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PasswordResetInfoResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPasswordResetGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthPasswordResetPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPasswordResetPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/redirect', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/token', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthProviderTokenPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/provider/token', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthProviderTokenPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler = ( + overrideResponse?: + | ProviderSignupResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderSignupResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthProviderSignupGetMockHandler = ( + overrideResponse?: + | ProviderSignupResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderSignupResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthProviderSignupGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthProviderSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthProviderSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/2fa/authenticate', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/2fa/authenticate', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/2fa/reauthenticate', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/2fa/reauthenticate', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler = ( + overrideResponse?: + | AuthenticatedByCodeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByCodeResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/code/confirm', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler = ( + overrideResponse?: + | AuthenticatedByCodeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByCodeResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/code/confirm', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountProvidersGetMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/providers', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountProvidersGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/account/providers', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountProvidersGetMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/providers', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountProvidersGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountProvidersDeleteMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/account/providers', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountProvidersDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailGetMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/email', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailPostMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/email', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailPutMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.put('*/api/v2/allauth/browser/v1/account/email', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailPutResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailPatchMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.patch('*/api/v2/allauth/browser/v1/account/email', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailPatchResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/account/email', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountEmailGetMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/email', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountEmailPostMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/account/email', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountEmailPutMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.put('*/api/v2/allauth/app/v1/account/email', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailPutResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountEmailPatchMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.patch('*/api/v2/allauth/app/v1/account/email', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailPatchResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountEmailDeleteMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/account/email', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountPhoneGetMockHandler = ( + overrideResponse?: + | PhoneNumbersResponse + | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/phone', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountPhoneGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountPhonePostMockHandler = ( + overrideResponse?: + | PhoneNumberChangeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PhoneNumberChangeResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/phone', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountPhonePostResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountPhoneGetMockHandler = ( + overrideResponse?: + | PhoneNumbersResponse + | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/phone', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountPhoneGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountPhonePostMockHandler = ( + overrideResponse?: + | PhoneNumberChangeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PhoneNumberChangeResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/account/phone', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountPhonePostResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler = ( + overrideResponse?: + | AuthenticatorsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatorsResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler = ( + overrideResponse?: + | AuthenticatorsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatorsResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler = ( + overrideResponse?: + | RecoveryCodesResponse + | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler = ( + overrideResponse?: + | RecoveryCodesResponse + | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionGetMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/session', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSessionGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.delete('*/api/v2/allauth/browser/v1/auth/session', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthAppV1AuthSessionGetMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/session', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSessionGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthSessionDeleteMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.delete('*/api/v2/allauth/app/v1/auth/session', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthAppV1TokensRefreshPostMockHandler = ( + overrideResponse?: + | RefreshTokenResponse + | ((info: Parameters[1]>[0]) => Promise | RefreshTokenResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/tokens/refresh', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1TokensRefreshPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/password/change', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthAppV1AccountPasswordChangePostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/app/v1/account/password/change', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionsGetMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSessionsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthSessionsGetMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSessionsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthSessionsDeleteMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSessionsDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getAuthenticationAllauthHeadlessMock = () => [ + getApiV2AllauthBrowserV1ConfigGetMockHandler(), + getApiV2AllauthAppV1ConfigGetMockHandler(), + getApiV2AllauthBrowserV1AuthLoginPostMockHandler(), + getApiV2AllauthAppV1AuthLoginPostMockHandler(), + getApiV2AllauthBrowserV1AuthSignupPostMockHandler(), + getApiV2AllauthAppV1AuthSignupPostMockHandler(), + getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler(), + getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler(), + getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler(), + getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler(), + getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler(), + getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler(), + getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler(), + getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler(), + getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler(), + getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler(), + getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler(), + getApiV2AllauthAppV1AuthReauthenticatePostMockHandler(), + getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler(), + getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler(), + getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler(), + getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler(), + getApiV2AllauthAppV1AuthPasswordResetGetMockHandler(), + getApiV2AllauthAppV1AuthPasswordResetPostMockHandler(), + getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler(), + getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler(), + getApiV2AllauthAppV1AuthProviderTokenPostMockHandler(), + getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler(), + getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler(), + getApiV2AllauthAppV1AuthProviderSignupGetMockHandler(), + getApiV2AllauthAppV1AuthProviderSignupPostMockHandler(), + getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler(), + getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler(), + getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler(), + getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler(), + getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler(), + getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler(), + getApiV2AllauthBrowserV1AccountProvidersGetMockHandler(), + getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler(), + getApiV2AllauthAppV1AccountProvidersGetMockHandler(), + getApiV2AllauthAppV1AccountProvidersDeleteMockHandler(), + getApiV2AllauthBrowserV1AccountEmailGetMockHandler(), + getApiV2AllauthBrowserV1AccountEmailPostMockHandler(), + getApiV2AllauthBrowserV1AccountEmailPutMockHandler(), + getApiV2AllauthBrowserV1AccountEmailPatchMockHandler(), + getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler(), + getApiV2AllauthAppV1AccountEmailGetMockHandler(), + getApiV2AllauthAppV1AccountEmailPostMockHandler(), + getApiV2AllauthAppV1AccountEmailPutMockHandler(), + getApiV2AllauthAppV1AccountEmailPatchMockHandler(), + getApiV2AllauthAppV1AccountEmailDeleteMockHandler(), + getApiV2AllauthBrowserV1AccountPhoneGetMockHandler(), + getApiV2AllauthBrowserV1AccountPhonePostMockHandler(), + getApiV2AllauthAppV1AccountPhoneGetMockHandler(), + getApiV2AllauthAppV1AccountPhonePostMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler(), + getApiV2AllauthBrowserV1AuthSessionGetMockHandler(), + getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler(), + getApiV2AllauthAppV1AuthSessionGetMockHandler(), + getApiV2AllauthAppV1AuthSessionDeleteMockHandler(), + getApiV2AllauthAppV1TokensRefreshPostMockHandler(), + getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler(), + getApiV2AllauthAppV1AccountPasswordChangePostMockHandler(), + getApiV2AllauthBrowserV1AuthSessionsGetMockHandler(), + getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler(), + getApiV2AllauthAppV1AuthSessionsGetMockHandler(), + getApiV2AllauthAppV1AuthSessionsDeleteMockHandler(), +] diff --git a/jsapp/js/api/react-query/configuration.ts b/jsapp/js/api/react-query/configuration.ts index 1ec1a26109..53faa4ed72 100644 --- a/jsapp/js/api/react-query/configuration.ts +++ b/jsapp/js/api/react-query/configuration.ts @@ -12,6 +12,10 @@ The endpoints are grouped by area of intended use. Each category contains relate import { useQuery } from '@tanstack/react-query' import type { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query' +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + import type { EnvironmentResponse } from '../models/environmentResponse' import { fetchWithAuth } from '../orval.mutator' @@ -95,3 +99,129 @@ export function useEnvironmentRetrieve< return query } + +export const getApiV2EnvironmentRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnvironmentResponse => ({ + terms_of_service_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + privacy_policy_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + source_code_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + support_email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + support_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + academy_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + community_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + frontend_min_retry_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + frontend_max_retry_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + use_team_label: faker.datatype.boolean(), + usage_limit_enforcement: faker.datatype.boolean(), + allow_self_account_deletion: faker.datatype.boolean(), + project_history_log_lifespan: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + sector_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + operational_purpose_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + country_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + interface_languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + mfa_localized_help_text: faker.string.alpha({ length: { min: 10, max: 20 } }), + mfa_enabled: faker.datatype.boolean(), + mfa_code_length: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + superuser_auth_enforcement: faker.datatype.boolean(), + enable_password_entropy_meter: faker.datatype.boolean(), + enable_custom_password_guidance_text: faker.datatype.boolean(), + custom_password_localized_help_text: faker.string.alpha({ length: { min: 10, max: 20 } }), + project_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + options: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + })), + undefined, + ]), + })), + extra_project_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + options: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + })), + undefined, + ]), + }), + ), + user_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + options: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + })), + undefined, + ]), + })), + social_apps: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + asr_mt_features_enabled: faker.datatype.boolean(), + submission_placeholder: faker.string.alpha({ length: { min: 10, max: 20 } }), + stripe_public_key: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + terms_of_service__sitewidemessage__exists: faker.datatype.boolean(), + open_rosa_server: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2EnvironmentRetrieveMockHandler = ( + overrideResponse?: + | EnvironmentResponse + | ((info: Parameters[1]>[0]) => Promise | EnvironmentResponse), +) => { + return http.get('*/api/v2/environment/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2EnvironmentRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getConfigurationMock = () => [getApiV2EnvironmentRetrieveMockHandler()] diff --git a/jsapp/js/api/react-query/form-content.ts b/jsapp/js/api/react-query/form-content.ts index 3fdcda034f..ffa8ae17a3 100644 --- a/jsapp/js/api/react-query/form-content.ts +++ b/jsapp/js/api/react-query/form-content.ts @@ -21,20 +21,24 @@ import type { import type { AssetSnapshotCreateRequest } from '../models/assetSnapshotCreateRequest' -import type { AssetSnapshotResponse } from '../models/assetSnapshotResponse' - import type { AssetSnapshotsListParams } from '../models/assetSnapshotsListParams' import type { AssetSnapshotsRetrieveParams } from '../models/assetSnapshotsRetrieveParams' -import type { AssetValidContentResponse } from '../models/assetValidContentResponse' - -import type { ContentResponse } from '../models/contentResponse' - import type { ErrorDetail } from '../models/errorDetail' import type { ErrorObject } from '../models/errorObject' +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + +import type { AssetSnapshotResponse } from '../models/assetSnapshotResponse' + +import type { AssetValidContentResponse } from '../models/assetValidContentResponse' + +import type { ContentResponse } from '../models/contentResponse' + import type { OpenRosaXFormResponse } from '../models/openRosaXFormResponse' import type { PaginatedAssetSnapshotResponseList } from '../models/paginatedAssetSnapshotResponseList' @@ -1033,3 +1037,547 @@ export function useAssetsXlsRetrieve = {}, +): PaginatedAssetSnapshotResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + xml: faker.internet.url(), + enketopreviewlink: faker.internet.url(), + asset: faker.internet.url(), + asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + details: { + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + warnings: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + source: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetSnapshotsCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetSnapshotResponse => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + xml: faker.internet.url(), + enketopreviewlink: faker.internet.url(), + asset: faker.internet.url(), + asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + details: { + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + warnings: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + source: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetSnapshotsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetSnapshotResponse => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + xml: faker.internet.url(), + enketopreviewlink: faker.internet.url(), + asset: faker.internet.url(), + asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + details: { + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + warnings: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + source: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetSnapshotsXformRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OpenRosaXFormResponse => ({ + html: { + head: faker.helpers.arrayElement([ + { + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + model: faker.helpers.arrayElement([ + { + instance: faker.helpers.arrayElement([ + { + instanceUuid: faker.helpers.arrayElement([ + { + fieldName: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + meta: faker.helpers.arrayElement([ + { + instanceID: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + body: faker.helpers.arrayElement([ + { + input: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + hint: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OpenRosaXFormResponse => ({ + html: { + head: faker.helpers.arrayElement([ + { + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + model: faker.helpers.arrayElement([ + { + instance: faker.helpers.arrayElement([ + { + instanceUuid: faker.helpers.arrayElement([ + { + fieldName: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + meta: faker.helpers.arrayElement([ + { + instanceID: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + body: faker.helpers.arrayElement([ + { + input: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + hint: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsContentRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ContentResponse => ({ + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + data: { + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsTableViewRetrieveResponseMock = (): string => faker.word.sample() + +export const getApiV2AssetsValidContentRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetValidContentResponse => ({ + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + data: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsXlsRetrieveResponseMock = (): string => faker.word.sample() + +export const getApiV2AssetSnapshotsListMockHandler = ( + overrideResponse?: + | PaginatedAssetSnapshotResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetSnapshotResponseList), +) => { + return http.get('*/api/v2/asset_snapshots/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSnapshotsCreateMockHandler = ( + overrideResponse?: + | AssetSnapshotResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetSnapshotResponse), +) => { + return http.post('*/api/v2/asset_snapshots/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSnapshotsRetrieveMockHandler = ( + overrideResponse?: + | AssetSnapshotResponse + | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSnapshotsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetSnapshotsPreviewRetrieveMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AssetSnapshotsXformRetrieveMockHandler = ( + overrideResponse?: + | OpenRosaXFormResponse + | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsXformRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler = ( + overrideResponse?: + | OpenRosaXFormResponse + | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsContentRetrieveMockHandler = ( + overrideResponse?: + | ContentResponse + | ((info: Parameters[1]>[0]) => Promise | ContentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/content/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsContentRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsTableViewRetrieveMockHandler = ( + overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), +) => { + return http.get('*/api/v2/assets/:uidAsset/table_view/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsTableViewRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsValidContentRetrieveMockHandler = ( + overrideResponse?: + | AssetValidContentResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetValidContentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/valid_content/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsValidContentRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsXlsRetrieveMockHandler = ( + overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), +) => { + return http.get('*/api/v2/assets/:uidAsset/xls/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsXlsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getFormContentMock = () => [ + getApiV2AssetSnapshotsListMockHandler(), + getApiV2AssetSnapshotsCreateMockHandler(), + getApiV2AssetSnapshotsRetrieveMockHandler(), + getApiV2AssetSnapshotsDestroyMockHandler(), + getApiV2AssetSnapshotsPreviewRetrieveMockHandler(), + getApiV2AssetSnapshotsXformRetrieveMockHandler(), + getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler(), + getApiV2AssetsContentRetrieveMockHandler(), + getApiV2AssetsTableViewRetrieveMockHandler(), + getApiV2AssetsValidContentRetrieveMockHandler(), + getApiV2AssetsXlsRetrieveMockHandler(), +] diff --git a/jsapp/js/api/react-query/library-collections.ts b/jsapp/js/api/react-query/library-collections.ts index 4fe65d0299..332c1ff200 100644 --- a/jsapp/js/api/react-query/library-collections.ts +++ b/jsapp/js/api/react-query/library-collections.ts @@ -21,14 +21,18 @@ import type { import type { AssetSubscriptionRequest } from '../models/assetSubscriptionRequest' -import type { AssetSubscriptionResponse } from '../models/assetSubscriptionResponse' - import type { AssetSubscriptionsListParams } from '../models/assetSubscriptionsListParams' import type { ErrorDetail } from '../models/errorDetail' import type { ErrorObject } from '../models/errorObject' +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + +import type { AssetSubscriptionResponse } from '../models/assetSubscriptionResponse' + import type { PaginatedAssetSubscriptionResponseList } from '../models/paginatedAssetSubscriptionResponseList' import { fetchWithAuth } from '../orval.mutator' @@ -387,3 +391,122 @@ export const useAssetSubscriptionsDestroy = = {}, +): PaginatedAssetSubscriptionResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2AssetSubscriptionsCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetSubscriptionResponse => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetSubscriptionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetSubscriptionResponse => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetSubscriptionsListMockHandler = ( + overrideResponse?: + | PaginatedAssetSubscriptionResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetSubscriptionResponseList), +) => { + return http.get('*/api/v2/asset_subscriptions/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSubscriptionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSubscriptionsCreateMockHandler = ( + overrideResponse?: + | AssetSubscriptionResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetSubscriptionResponse), +) => { + return http.post('*/api/v2/asset_subscriptions/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSubscriptionsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSubscriptionsRetrieveMockHandler = ( + overrideResponse?: + | AssetSubscriptionResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetSubscriptionResponse), +) => { + return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSubscriptionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSubscriptionsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} +export const getLibraryCollectionsMock = () => [ + getApiV2AssetSubscriptionsListMockHandler(), + getApiV2AssetSubscriptionsCreateMockHandler(), + getApiV2AssetSubscriptionsRetrieveMockHandler(), + getApiV2AssetSubscriptionsDestroyMockHandler(), +] diff --git a/jsapp/js/api/react-query/logging.ts b/jsapp/js/api/react-query/logging.ts index 114f17a663..f06b368ef5 100644 --- a/jsapp/js/api/react-query/logging.ts +++ b/jsapp/js/api/react-query/logging.ts @@ -25,6 +25,10 @@ import type { AssetsHistoryListParams } from '../models/assetsHistoryListParams' import type { ErrorDetail } from '../models/errorDetail' +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + import type { ExportCreateResponse } from '../models/exportCreateResponse' import type { ExportListResponse } from '../models/exportListResponse' @@ -707,3 +711,396 @@ export const useAssetsHistoryExportCreate = = {}, +): PaginatedAccessLogResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + initial_user_username: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + authorized_app_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2AccessLogsMeExportListResponseMock = (): ExportListResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 24 } }), + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })) + +export const getApiV2AccessLogsMeExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportCreateResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 32 } }), ...overrideResponse }) + +export const getApiV2AssetsHistoryListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedHistoryListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user: faker.internet.url(), + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + old: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + removed: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + description: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + 'data-table': faker.helpers.arrayElement([ + { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + }, + undefined, + ]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'asset-files': faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + permissions: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + latest_deployed_version_uid: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + submission: faker.helpers.arrayElement([ + { + root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + hook: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + bulk_action: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + params: faker.helpers.arrayElement([{}, undefined]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + total_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + processed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + completed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + failed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + cancelled_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + name: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + shared_fields: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsHistoryActionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): HistoryActionResponse => ({ + actions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsHistoryExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): HistoryExportResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AccessLogsMeListMockHandler = ( + overrideResponse?: + | PaginatedAccessLogResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAccessLogResponseList), +) => { + return http.get('*/api/v2/access-logs/me/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsMeListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AccessLogsMeExportListMockHandler = ( + overrideResponse?: + | ExportListResponse[] + | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), +) => { + return http.get('*/api/v2/access-logs/me/export/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsMeExportListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AccessLogsMeExportCreateMockHandler = ( + overrideResponse?: + | ExportCreateResponse + | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), +) => { + return http.post('*/api/v2/access-logs/me/export/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsMeExportCreateResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHistoryListMockHandler = ( + overrideResponse?: + | PaginatedHistoryListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedHistoryListResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/history/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHistoryListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHistoryActionsRetrieveMockHandler = ( + overrideResponse?: + | HistoryActionResponse + | ((info: Parameters[1]>[0]) => Promise | HistoryActionResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/history/actions/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHistoryActionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHistoryExportCreateMockHandler = ( + overrideResponse?: + | HistoryExportResponse + | (( + info: Parameters[1]>[0], + ) => Promise | HistoryExportResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/history/export/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHistoryExportCreateResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getLoggingMock = () => [ + getApiV2AccessLogsMeListMockHandler(), + getApiV2AccessLogsMeExportListMockHandler(), + getApiV2AccessLogsMeExportCreateMockHandler(), + getApiV2AssetsHistoryListMockHandler(), + getApiV2AssetsHistoryActionsRetrieveMockHandler(), + getApiV2AssetsHistoryExportCreateMockHandler(), +] diff --git a/jsapp/js/api/react-query/manage-permissions.ts b/jsapp/js/api/react-query/manage-permissions.ts index 3e82a76189..2cf3749e38 100644 --- a/jsapp/js/api/react-query/manage-permissions.ts +++ b/jsapp/js/api/react-query/manage-permissions.ts @@ -29,6 +29,10 @@ import type { PermissionAssignmentBulkRequest } from '../models/permissionAssign import type { PermissionAssignmentCreateRequest } from '../models/permissionAssignmentCreateRequest' +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + import type { PermissionAssignmentResponse } from '../models/permissionAssignmentResponse' import { fetchWithAuth } from '../orval.mutator' @@ -751,3 +755,195 @@ export const useAssetsPermissionAssignmentsClonePartialUpdate = < return useMutation(mutationOptions) } + +export const getApiV2AssetsPermissionAssignmentsListResponseMock = (): PermissionAssignmentResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsPermissionAssignmentsCreateResponseMock = ( + overrideResponse: Partial = {}, +): PermissionAssignmentResponse => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsPermissionAssignmentsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PermissionAssignmentResponse => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock = (): PermissionAssignmentResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock = (): PermissionAssignmentResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsPermissionAssignmentsListMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse[]), +) => { + return http.get('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPermissionAssignmentsCreateMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPermissionAssignmentsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse[]), +) => { + return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse[]), +) => { + return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getManagePermissionsMock = () => [ + getApiV2AssetsPermissionAssignmentsListMockHandler(), + getApiV2AssetsPermissionAssignmentsCreateMockHandler(), + getApiV2AssetsPermissionAssignmentsRetrieveMockHandler(), + getApiV2AssetsPermissionAssignmentsDestroyMockHandler(), + getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler(), + getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler(), + getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler(), +] diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 7a58dfdf50..3317c99828 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -19,18 +19,10 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { Asset } from '../models/asset' - import type { AssetBulkRequest } from '../models/assetBulkRequest' -import type { AssetBulkResponse } from '../models/assetBulkResponse' - import type { AssetCreateRequest } from '../models/assetCreateRequest' -import type { AssetListCount } from '../models/assetListCount' - -import type { AssetMetadataResponse } from '../models/assetMetadataResponse' - import type { AssetsCountsListParams } from '../models/assetsCountsListParams' import type { AssetsListParams } from '../models/assetsListParams' @@ -43,21 +35,51 @@ import type { AssetsVersionsListParams } from '../models/assetsVersionsListParam import type { DeploymentCreateRequest } from '../models/deploymentCreateRequest' -import type { DeploymentResponse } from '../models/deploymentResponse' - import type { ErrorDetail } from '../models/errorDetail' import type { ErrorObject } from '../models/errorObject' -import type { HashResponse } from '../models/hashResponse' - import type { ImportCreateRequest } from '../models/importCreateRequest' +import type { ImportsListParams } from '../models/importsListParams' + +import type { PatchedAssetPatchRequest } from '../models/patchedAssetPatchRequest' + +import type { PatchedDeploymentPatchRequest } from '../models/patchedDeploymentPatchRequest' + +import type { PatchedInviteUpdatePayload } from '../models/patchedInviteUpdatePayload' + +import type { ProjectInviteCreatePayload } from '../models/projectInviteCreatePayload' + +import type { ProjectOwnershipInvitesListParams } from '../models/projectOwnershipInvitesListParams' + +import type { TagsListParams } from '../models/tagsListParams' + +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + +import type { Asset } from '../models/asset' + +import type { AssetBulkResponse } from '../models/assetBulkResponse' + +import { AssetDeploymentStatusEnum } from '../models/assetDeploymentStatusEnum' + +import type { AssetListCount } from '../models/assetListCount' + +import type { AssetMetadataResponse } from '../models/assetMetadataResponse' + +import { AssetTypeEnum } from '../models/assetTypeEnum' + +import type { DeploymentResponse } from '../models/deploymentResponse' + +import type { HashResponse } from '../models/hashResponse' + import type { ImportCreateResponse } from '../models/importCreateResponse' import type { ImportResponse } from '../models/importResponse' -import type { ImportsListParams } from '../models/importsListParams' +import { InviteStatusChoicesEnum } from '../models/inviteStatusChoicesEnum' import type { PaginatedAssetCountResponseList } from '../models/paginatedAssetCountResponseList' @@ -73,22 +95,10 @@ import type { PaginatedTagListResponseList } from '../models/paginatedTagListRes import type { PaginatedVersionListResponseList } from '../models/paginatedVersionListResponseList' -import type { PatchedAssetPatchRequest } from '../models/patchedAssetPatchRequest' - -import type { PatchedDeploymentPatchRequest } from '../models/patchedDeploymentPatchRequest' - -import type { PatchedInviteUpdatePayload } from '../models/patchedInviteUpdatePayload' - -import type { ProjectInviteCreatePayload } from '../models/projectInviteCreatePayload' - import type { ProjectInviteResponse } from '../models/projectInviteResponse' -import type { ProjectOwnershipInvitesListParams } from '../models/projectOwnershipInvitesListParams' - import type { TagRetrieveResponse } from '../models/tagRetrieveResponse' -import type { TagsListParams } from '../models/tagsListParams' - import type { TransferListResponse } from '../models/transferListResponse' import type { VersionRetrieveResponse } from '../models/versionRetrieveResponse' @@ -2670,3 +2680,2599 @@ export function useTagsRetrieve> return query } + +export const getApiV2AssetsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([{}, undefined]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([{}, undefined]), + default_translation: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + version__content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployed_versions: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + results: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + undefined, + ]), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: {}, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([{}, undefined]), + specified: faker.helpers.arrayElement([ + { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + kuid_names: faker.helpers.arrayElement([ + { + end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([{}, undefined]), + map_styles: faker.helpers.arrayElement([{}, undefined]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + analysis_form_json: { + additional_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({}), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial = {}): Asset => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([{}, undefined]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([{}, undefined]), + default_translation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + version__content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployed_versions: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + results: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + undefined, + ]), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: {}, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([{}, undefined]), + specified: faker.helpers.arrayElement([ + { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + kuid_names: faker.helpers.arrayElement([ + { + end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([{}, undefined]), + map_styles: faker.helpers.arrayElement([{}, undefined]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + analysis_form_json: { + additional_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({}), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ...overrideResponse, +}) + +export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial = {}): Asset => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([{}, undefined]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([{}, undefined]), + default_translation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + version__content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployed_versions: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + results: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + undefined, + ]), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: {}, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([{}, undefined]), + specified: faker.helpers.arrayElement([ + { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + kuid_names: faker.helpers.arrayElement([ + { + end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([{}, undefined]), + map_styles: faker.helpers.arrayElement([{}, undefined]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + analysis_form_json: { + additional_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({}), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ...overrideResponse, +}) + +export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partial = {}): Asset => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([{}, undefined]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([{}, undefined]), + default_translation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + version__content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployed_versions: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + results: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + undefined, + ]), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: {}, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([{}, undefined]), + specified: faker.helpers.arrayElement([ + { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + kuid_names: faker.helpers.arrayElement([ + { + end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([{}, undefined]), + map_styles: faker.helpers.arrayElement([{}, undefined]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + analysis_form_json: { + additional_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({}), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ...overrideResponse, +}) + +export const getApiV2AssetsCountsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetCountResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + daily_submission_count: { + '2020-10-20': faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + total_submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsDeploymentRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): DeploymentResponse => ({ + backend: faker.string.alpha({ length: { min: 10, max: 20 } }), + active: faker.datatype.boolean(), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + asset: { + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([{}, undefined]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([{}, undefined]), + default_translation: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + version__content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployed_versions: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + results: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + undefined, + ]), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: {}, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([{}, undefined]), + specified: faker.helpers.arrayElement([ + { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + kuid_names: faker.helpers.arrayElement([ + { + end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([{}, undefined]), + map_styles: faker.helpers.arrayElement([{}, undefined]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + analysis_form_json: { + additional_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({}), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDeploymentCreateResponseMock = ( + overrideResponse: Partial = {}, +): DeploymentResponse => ({ + backend: faker.string.alpha({ length: { min: 10, max: 20 } }), + active: faker.datatype.boolean(), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + asset: { + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([{}, undefined]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([{}, undefined]), + default_translation: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + version__content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployed_versions: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + results: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + undefined, + ]), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: {}, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([{}, undefined]), + specified: faker.helpers.arrayElement([ + { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + kuid_names: faker.helpers.arrayElement([ + { + end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([{}, undefined]), + map_styles: faker.helpers.arrayElement([{}, undefined]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + analysis_form_json: { + additional_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({}), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DeploymentResponse => ({ + backend: faker.string.alpha({ length: { min: 10, max: 20 } }), + active: faker.datatype.boolean(), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + asset: { + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([{}, undefined]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([{}, undefined]), + default_translation: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + version__content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployed_versions: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + results: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + undefined, + ]), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: {}, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([{}, undefined]), + specified: faker.helpers.arrayElement([ + { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + kuid_names: faker.helpers.arrayElement([ + { + end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([{}, undefined]), + map_styles: faker.helpers.arrayElement([{}, undefined]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + analysis_form_json: { + additional_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({}), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsVersionsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedVersionListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsVersionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): VersionRetrieveResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + default_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsXformRetrieveResponseMock = (): string => faker.word.sample() + +export const getApiV2AssetsBulkCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetBulkResponse => ({ detail: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AssetsCountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetListCount => ({ + deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2AssetsHashRetrieveResponseMock = (overrideResponse: Partial = {}): HashResponse => ({ + hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsMetadataRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetMetadataResponse => ({ + languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + sectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + organizations: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsMinimalListRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetMinimalListList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 22 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2ImportsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedImportResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + messages: { + updated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kind: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + summary: faker.helpers.arrayElement([ + { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + language: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + first: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + owner__username: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + 'audit-logs': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset_id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + new_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) + +export const getApiV2ImportsCreateResponseMock = ( + overrideResponse: Partial = {}, +): ImportCreateResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2ImportsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ImportResponse => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + messages: { + updated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kind: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + summary: faker.helpers.arrayElement([ + { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + language: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + first: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + owner__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + 'audit-logs': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset_id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + new_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + ...overrideResponse, +}) + +export const getApiV2ProjectOwnershipInvitesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectInviteResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + 'sender | recipient': faker.internet.url(), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectOwnershipInvitesCreateResponseMock = ( + overrideResponse: Partial = {}, +): ProjectInviteResponse => ({ + url: faker.internet.url(), + 'sender | recipient': faker.internet.url(), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectOwnershipInvitesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ProjectInviteResponse => ({ + url: faker.internet.url(), + 'sender | recipient': faker.internet.url(), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectOwnershipInvitesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): ProjectInviteResponse => ({ + url: faker.internet.url(), + 'sender | recipient': faker.internet.url(), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectOwnershipInvitesTransfersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TransferListResponse => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2TagsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedTagListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2TagsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TagRetrieveResponse => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + assets: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + parent: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsListMockHandler = ( + overrideResponse?: + | PaginatedAssetList + | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), +) => { + return http.get('*/api/v2/assets/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsCreateMockHandler = ( + overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), +) => { + return http.post('*/api/v2/assets/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsRetrieveMockHandler = ( + overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), +) => { + return http.get('*/api/v2/assets/:uidAsset/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPartialUpdateMockHandler = ( + overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), +) => { + return http.patch('*/api/v2/assets/:uidAsset/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsCountsListMockHandler = ( + overrideResponse?: + | PaginatedAssetCountResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetCountResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/counts/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsCountsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDeploymentRetrieveMockHandler = ( + overrideResponse?: + | DeploymentResponse + | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/deployment/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDeploymentRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDeploymentCreateMockHandler = ( + overrideResponse?: + | DeploymentResponse + | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/deployment/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDeploymentCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDeploymentPartialUpdateMockHandler = ( + overrideResponse?: + | DeploymentResponse + | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/deployment/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDeploymentPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsVersionsListMockHandler = ( + overrideResponse?: + | PaginatedVersionListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedVersionListResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/versions/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsVersionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsVersionsRetrieveMockHandler = ( + overrideResponse?: + | VersionRetrieveResponse + | (( + info: Parameters[1]>[0], + ) => Promise | VersionRetrieveResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsVersionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsXformRetrieveMockHandler = ( + overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), +) => { + return http.get('*/api/v2/assets/:uidAsset/xform/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsXformRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsBulkCreateMockHandler = ( + overrideResponse?: + | AssetBulkResponse + | ((info: Parameters[1]>[0]) => Promise | AssetBulkResponse), +) => { + return http.post('*/api/v2/assets/bulk/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsBulkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsCountsRetrieveMockHandler = ( + overrideResponse?: + | AssetListCount + | ((info: Parameters[1]>[0]) => Promise | AssetListCount), +) => { + return http.get('*/api/v2/assets/counts/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsCountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHashRetrieveMockHandler = ( + overrideResponse?: + | HashResponse + | ((info: Parameters[1]>[0]) => Promise | HashResponse), +) => { + return http.get('*/api/v2/assets/hash/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHashRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsMetadataRetrieveMockHandler = ( + overrideResponse?: + | AssetMetadataResponse + | ((info: Parameters[1]>[0]) => Promise | AssetMetadataResponse), +) => { + return http.get('*/api/v2/assets/metadata/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsMetadataRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsMinimalListRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetMinimalListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetMinimalListList), +) => { + return http.get('*/api/v2/assets/minimal-list/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsMinimalListRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ImportsListMockHandler = ( + overrideResponse?: + | PaginatedImportResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedImportResponseList), +) => { + return http.get('*/api/v2/imports/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ImportsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ImportsCreateMockHandler = ( + overrideResponse?: + | ImportCreateResponse + | ((info: Parameters[1]>[0]) => Promise | ImportCreateResponse), +) => { + return http.post('*/api/v2/imports/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ImportsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ImportsRetrieveMockHandler = ( + overrideResponse?: + | ImportResponse + | ((info: Parameters[1]>[0]) => Promise | ImportResponse), +) => { + return http.get('*/api/v2/imports/:uidImport/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ImportsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectOwnershipInvitesListMockHandler = ( + overrideResponse?: + | PaginatedProjectInviteResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectInviteResponseList), +) => { + return http.get('*/api/v2/project-ownership/invites/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectOwnershipInvitesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectOwnershipInvitesCreateMockHandler = ( + overrideResponse?: + | ProjectInviteResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectInviteResponse), +) => { + return http.post('*/api/v2/project-ownership/invites/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectOwnershipInvitesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectOwnershipInvitesRetrieveMockHandler = ( + overrideResponse?: + | ProjectInviteResponse + | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse), +) => { + return http.get('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectOwnershipInvitesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = ( + overrideResponse?: + | ProjectInviteResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectInviteResponse), +) => { + return http.patch('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectOwnershipInvitesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectOwnershipInvitesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler = ( + overrideResponse?: + | TransferListResponse + | ((info: Parameters[1]>[0]) => Promise | TransferListResponse), +) => { + return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectOwnershipInvitesTransfersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TagsListMockHandler = ( + overrideResponse?: + | PaginatedTagListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedTagListResponseList), +) => { + return http.get('*/api/v2/tags/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TagsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TagsRetrieveMockHandler = ( + overrideResponse?: + | TagRetrieveResponse + | ((info: Parameters[1]>[0]) => Promise | TagRetrieveResponse), +) => { + return http.get('*/api/v2/tags/:taguidUid/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TagsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getManageProjectsAndLibraryContentMock = () => [ + getApiV2AssetsListMockHandler(), + getApiV2AssetsCreateMockHandler(), + getApiV2AssetsRetrieveMockHandler(), + getApiV2AssetsPartialUpdateMockHandler(), + getApiV2AssetsDestroyMockHandler(), + getApiV2AssetsCountsListMockHandler(), + getApiV2AssetsDeploymentRetrieveMockHandler(), + getApiV2AssetsDeploymentCreateMockHandler(), + getApiV2AssetsDeploymentPartialUpdateMockHandler(), + getApiV2AssetsVersionsListMockHandler(), + getApiV2AssetsVersionsRetrieveMockHandler(), + getApiV2AssetsXformRetrieveMockHandler(), + getApiV2AssetsBulkCreateMockHandler(), + getApiV2AssetsCountsRetrieveMockHandler(), + getApiV2AssetsHashRetrieveMockHandler(), + getApiV2AssetsMetadataRetrieveMockHandler(), + getApiV2AssetsMinimalListRetrieveMockHandler(), + getApiV2ImportsListMockHandler(), + getApiV2ImportsCreateMockHandler(), + getApiV2ImportsRetrieveMockHandler(), + getApiV2ProjectOwnershipInvitesListMockHandler(), + getApiV2ProjectOwnershipInvitesCreateMockHandler(), + getApiV2ProjectOwnershipInvitesRetrieveMockHandler(), + getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler(), + getApiV2ProjectOwnershipInvitesDestroyMockHandler(), + getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler(), + getApiV2TagsListMockHandler(), + getApiV2TagsRetrieveMockHandler(), +] diff --git a/jsapp/js/api/react-query/other.ts b/jsapp/js/api/react-query/other.ts index ad79449a4c..e0d1c0e9db 100644 --- a/jsapp/js/api/react-query/other.ts +++ b/jsapp/js/api/react-query/other.ts @@ -19,22 +19,42 @@ import type { UseQueryResult, } from '@tanstack/react-query' +import type { CustomerPortal } from '../models/customerPortal' + +import type { ErrorDetail } from '../models/errorDetail' + +import type { ErrorObject } from '../models/errorObject' + +import type { LanguagesListParams } from '../models/languagesListParams' + +import type { PermissionsListParams } from '../models/permissionsListParams' + +import type { StripeAddonsListParams } from '../models/stripeAddonsListParams' + +import type { StripeProductsListParams } from '../models/stripeProductsListParams' + +import type { StripeSubscriptionsListParams } from '../models/stripeSubscriptionsListParams' + +import type { TranscriptionServicesListParams } from '../models/transcriptionServicesListParams' + +import type { TranslationServicesListParams } from '../models/translationServicesListParams' + +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + +import { BlankEnum } from '../models/blankEnum' + import type { ChangePlan } from '../models/changePlan' import type { CheckoutLink } from '../models/checkoutLink' -import type { CustomerPortal } from '../models/customerPortal' +import { CollectionMethodEnum } from '../models/collectionMethodEnum' import type { CustomerPortalPostResponse } from '../models/customerPortalPostResponse' -import type { ErrorDetail } from '../models/errorDetail' - -import type { ErrorObject } from '../models/errorObject' - import type { Language } from '../models/language' -import type { LanguagesListParams } from '../models/languagesListParams' - import type { OneTimeAddOn } from '../models/oneTimeAddOn' import type { PaginatedLanguageListList } from '../models/paginatedLanguageListList' @@ -53,26 +73,28 @@ import type { PaginatedTranslationServiceList } from '../models/paginatedTransla import type { PermissionResponse } from '../models/permissionResponse' -import type { PermissionsListParams } from '../models/permissionsListParams' +import { ProrationBehaviorEnum } from '../models/prorationBehaviorEnum' -import type { StripeAddonsListParams } from '../models/stripeAddonsListParams' +import { StripeIntervalEnum } from '../models/stripeIntervalEnum' -import type { StripeProductsListParams } from '../models/stripeProductsListParams' +import { StripePriceType } from '../models/stripePriceType' -import type { StripeSubscriptionsListParams } from '../models/stripeSubscriptionsListParams' +import { StripeProductType } from '../models/stripeProductType' + +import { StripeUsageType } from '../models/stripeUsageType' import type { Subscription } from '../models/subscription' +import { SubscriptionScheduleStatusEnum } from '../models/subscriptionScheduleStatusEnum' + +import { SubscriptionStatusEnum } from '../models/subscriptionStatusEnum' + import type { TermsOfServiceResponse } from '../models/termsOfServiceResponse' import type { TranscriptionService } from '../models/transcriptionService' -import type { TranscriptionServicesListParams } from '../models/transcriptionServicesListParams' - import type { TranslationService } from '../models/translationService' -import type { TranslationServicesListParams } from '../models/translationServicesListParams' - import { fetchWithAuth } from '../orval.mutator' type SecondParameter unknown> = Parameters[1] @@ -1709,3 +1731,1024 @@ export function useTranslationServicesRetrieve< return query } + +export const getApiV2LanguagesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedLanguageListList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + transcription_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + translation_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + url: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2LanguagesRetrieveResponseMock = (overrideResponse: Partial = {}): Language => ({ + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + transcription_services: { + [faker.string.alphanumeric(5)]: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + translation_services: { + [faker.string.alphanumeric(5)]: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + regions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + })), + ...overrideResponse, +}) + +export const getApiV2PermissionsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedPermissionResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + codename: faker.string.alpha({ length: { min: 10, max: 20 } }), + implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2PermissionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PermissionResponse => ({ + url: faker.internet.url(), + codename: faker.string.alpha({ length: { min: 10, max: 20 } }), + implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2StripeAddonsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedOneTimeAddOnList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 27 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_available: faker.datatype.boolean(), + usage_limits: faker.helpers.arrayElement([{}, undefined]), + total_usage_limits: { + [faker.string.alphanumeric(5)]: {}, + }, + limits_remaining: faker.helpers.arrayElement([{}, undefined]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + product: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2StripeAddonsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OneTimeAddOn => ({ + id: faker.string.alpha({ length: { min: 10, max: 27 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_available: faker.datatype.boolean(), + usage_limits: faker.helpers.arrayElement([{}, undefined]), + total_usage_limits: { + [faker.string.alphanumeric(5)]: {}, + }, + limits_remaining: faker.helpers.arrayElement([{}, undefined]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + product: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2StripeChangePlanRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ChangePlan => ({ + price_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + subscription_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: 1, max: undefined, multipleOf: undefined }), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2StripeCheckoutLinkCreateResponseMock = ( + overrideResponse: Partial = {}, +): CheckoutLink => ({ + price_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + organization_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: 1, max: undefined, multipleOf: undefined }), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2StripeCustomerPortalCreateResponseMock = ( + overrideResponse: Partial = {}, +): CustomerPortalPostResponse => ({ url: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2StripeProductsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProductList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + name: faker.string.alpha({ length: { min: 10, max: 5000 } }), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + type: faker.helpers.arrayElement(Object.values(StripeProductType)), + prices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), + currency: faker.string.alpha({ length: { min: 10, max: 3 } }), + type: faker.helpers.arrayElement(Object.values(StripePriceType)), + recurring: { + ...{ + interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), + interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + meter: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), + }, + }, + unit_amount: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), + null, + ]), + undefined, + ]), + human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.datatype.boolean(), + product: faker.string.alpha({ length: { min: 10, max: 20 } }), + transform_quantity: faker.helpers.arrayElement([{}, undefined]), + })), + metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + })), + ...overrideResponse, +}) + +export const getApiV2StripeSubscriptionsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedSubscriptionList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + price: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), + currency: faker.string.alpha({ length: { min: 10, max: 3 } }), + type: faker.helpers.arrayElement(Object.values(StripePriceType)), + recurring: { + ...{ + interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), + interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + meter: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), + }, + }, + unit_amount: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), + null, + ]), + undefined, + ]), + human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.datatype.boolean(), + product: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + name: faker.string.alpha({ length: { min: 10, max: 5000 } }), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + type: faker.helpers.arrayElement(Object.values(StripeProductType)), + metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + transform_quantity: faker.helpers.arrayElement([{}, undefined]), + }, + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + })), + schedule: { + phases: { + [faker.string.alphanumeric(5)]: {}, + }, + status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum)), + }, + application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?d{0,3}(?:.d{0,2})?$'), null]), + djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + stripe_data: faker.helpers.arrayElement([{}, undefined]), + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + created: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + metadata: faker.helpers.arrayElement([{}, undefined]), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + billing_cycle_anchor: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + billing_thresholds: faker.helpers.arrayElement([{}, undefined]), + cancel_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + canceled_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + days_until_due: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), + null, + ]), + undefined, + ]), + discount: faker.helpers.arrayElement([{}, undefined]), + ended_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + next_pending_invoice_item_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + pause_collection: faker.helpers.arrayElement([{}, undefined]), + pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), + pending_update: faker.helpers.arrayElement([{}, undefined]), + proration_behavior: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)), + faker.helpers.arrayElement(Object.values(BlankEnum)), + ]), + undefined, + ]), + proration_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), + null, + ]), + undefined, + ]), + start_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), + trial_end: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + trial_start: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + djstripe_owner_account: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + customer: faker.string.alpha({ length: { min: 10, max: 20 } }), + default_payment_method: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + default_source: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + latest_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_setup_intent: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + plan: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), null]), + undefined, + ]), + default_tax_rates: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2StripeSubscriptionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): Subscription => ({ + items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + price: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), + currency: faker.string.alpha({ length: { min: 10, max: 3 } }), + type: faker.helpers.arrayElement(Object.values(StripePriceType)), + recurring: { + ...{ + interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), + interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + meter: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), + }, + }, + unit_amount: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), + null, + ]), + undefined, + ]), + human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.datatype.boolean(), + product: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + name: faker.string.alpha({ length: { min: 10, max: 5000 } }), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + type: faker.helpers.arrayElement(Object.values(StripeProductType)), + metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + transform_quantity: faker.helpers.arrayElement([{}, undefined]), + }, + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + })), + schedule: { + phases: { + [faker.string.alphanumeric(5)]: {}, + }, + status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum)), + }, + application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?d{0,3}(?:.d{0,2})?$'), null]), + djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + stripe_data: faker.helpers.arrayElement([{}, undefined]), + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + created: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + metadata: faker.helpers.arrayElement([{}, undefined]), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + billing_cycle_anchor: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + billing_thresholds: faker.helpers.arrayElement([{}, undefined]), + cancel_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + canceled_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + days_until_due: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + discount: faker.helpers.arrayElement([{}, undefined]), + ended_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + next_pending_invoice_item_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + pause_collection: faker.helpers.arrayElement([{}, undefined]), + pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), + pending_update: faker.helpers.arrayElement([{}, undefined]), + proration_behavior: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)), + faker.helpers.arrayElement(Object.values(BlankEnum)), + ]), + undefined, + ]), + proration_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + start_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), + trial_end: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + trial_start: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + djstripe_owner_account: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + customer: faker.string.alpha({ length: { min: 10, max: 20 } }), + default_payment_method: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + default_source: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + latest_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_setup_intent: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + plan: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), null]), + undefined, + ]), + default_tax_rates: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2TermsOfServiceListResponseMock = (): TermsOfServiceResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + slug: faker.string.alpha({ length: { min: 10, max: 20 } }), + body: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2TermsOfServiceRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TermsOfServiceResponse => ({ + url: faker.internet.url(), + slug: faker.string.alpha({ length: { min: 10, max: 20 } }), + body: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2TranscriptionServicesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedTranscriptionServiceList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + })), + ...overrideResponse, +}) + +export const getApiV2TranscriptionServicesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TranscriptionService => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + ...overrideResponse, +}) + +export const getApiV2TranslationServicesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedTranslationServiceList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + })), + ...overrideResponse, +}) + +export const getApiV2TranslationServicesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TranslationService => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + ...overrideResponse, +}) + +export const getApiV2LanguagesListMockHandler = ( + overrideResponse?: + | PaginatedLanguageListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedLanguageListList), +) => { + return http.get('*/api/v2/languages/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2LanguagesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2LanguagesRetrieveMockHandler = ( + overrideResponse?: Language | ((info: Parameters[1]>[0]) => Promise | Language), +) => { + return http.get('*/api/v2/languages/:code/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2LanguagesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2PermissionsListMockHandler = ( + overrideResponse?: + | PaginatedPermissionResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedPermissionResponseList), +) => { + return http.get('*/api/v2/permissions/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2PermissionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2PermissionsRetrieveMockHandler = ( + overrideResponse?: + | PermissionResponse + | ((info: Parameters[1]>[0]) => Promise | PermissionResponse), +) => { + return http.get('*/api/v2/permissions/:codename/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2PermissionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeAddonsListMockHandler = ( + overrideResponse?: + | PaginatedOneTimeAddOnList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedOneTimeAddOnList), +) => { + return http.get('*/api/v2/stripe/addons/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeAddonsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeAddonsRetrieveMockHandler = ( + overrideResponse?: + | OneTimeAddOn + | ((info: Parameters[1]>[0]) => Promise | OneTimeAddOn), +) => { + return http.get('*/api/v2/stripe/addons/:id/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeAddonsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeChangePlanRetrieveMockHandler = ( + overrideResponse?: + | ChangePlan + | ((info: Parameters[1]>[0]) => Promise | ChangePlan), +) => { + return http.get('*/api/v2/stripe/change-plan', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeChangePlanRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeCheckoutLinkCreateMockHandler = ( + overrideResponse?: + | CheckoutLink + | ((info: Parameters[1]>[0]) => Promise | CheckoutLink), +) => { + return http.post('*/api/v2/stripe/checkout-link', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeCheckoutLinkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeCustomerPortalCreateMockHandler = ( + overrideResponse?: + | CustomerPortalPostResponse + | (( + info: Parameters[1]>[0], + ) => Promise | CustomerPortalPostResponse), +) => { + return http.post('*/api/v2/stripe/customer-portal', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeCustomerPortalCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeProductsListMockHandler = ( + overrideResponse?: + | PaginatedProductList + | ((info: Parameters[1]>[0]) => Promise | PaginatedProductList), +) => { + return http.get('*/api/v2/stripe/products/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeProductsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeSubscriptionsListMockHandler = ( + overrideResponse?: + | PaginatedSubscriptionList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedSubscriptionList), +) => { + return http.get('*/api/v2/stripe/subscriptions/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeSubscriptionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeSubscriptionsRetrieveMockHandler = ( + overrideResponse?: + | Subscription + | ((info: Parameters[1]>[0]) => Promise | Subscription), +) => { + return http.get('*/api/v2/stripe/subscriptions/:id/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeSubscriptionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TermsOfServiceListMockHandler = ( + overrideResponse?: + | TermsOfServiceResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | TermsOfServiceResponse[]), +) => { + return http.get('*/api/v2/terms-of-service/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TermsOfServiceListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TermsOfServiceRetrieveMockHandler = ( + overrideResponse?: + | TermsOfServiceResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TermsOfServiceResponse), +) => { + return http.get('*/api/v2/terms-of-service/:slug/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TermsOfServiceRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TranscriptionServicesListMockHandler = ( + overrideResponse?: + | PaginatedTranscriptionServiceList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedTranscriptionServiceList), +) => { + return http.get('*/api/v2/transcription-services/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranscriptionServicesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TranscriptionServicesRetrieveMockHandler = ( + overrideResponse?: + | TranscriptionService + | ((info: Parameters[1]>[0]) => Promise | TranscriptionService), +) => { + return http.get('*/api/v2/transcription-services/:code/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranscriptionServicesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TranslationServicesListMockHandler = ( + overrideResponse?: + | PaginatedTranslationServiceList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedTranslationServiceList), +) => { + return http.get('*/api/v2/translation-services/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranslationServicesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TranslationServicesRetrieveMockHandler = ( + overrideResponse?: + | TranslationService + | ((info: Parameters[1]>[0]) => Promise | TranslationService), +) => { + return http.get('*/api/v2/translation-services/:code/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranslationServicesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getOtherMock = () => [ + getApiV2LanguagesListMockHandler(), + getApiV2LanguagesRetrieveMockHandler(), + getApiV2PermissionsListMockHandler(), + getApiV2PermissionsRetrieveMockHandler(), + getApiV2StripeAddonsListMockHandler(), + getApiV2StripeAddonsRetrieveMockHandler(), + getApiV2StripeChangePlanRetrieveMockHandler(), + getApiV2StripeCheckoutLinkCreateMockHandler(), + getApiV2StripeCustomerPortalCreateMockHandler(), + getApiV2StripeProductsListMockHandler(), + getApiV2StripeSubscriptionsListMockHandler(), + getApiV2StripeSubscriptionsRetrieveMockHandler(), + getApiV2TermsOfServiceListMockHandler(), + getApiV2TermsOfServiceRetrieveMockHandler(), + getApiV2TranscriptionServicesListMockHandler(), + getApiV2TranscriptionServicesRetrieveMockHandler(), + getApiV2TranslationServicesListMockHandler(), + getApiV2TranslationServicesRetrieveMockHandler(), +] diff --git a/jsapp/js/api/react-query/scim.ts b/jsapp/js/api/react-query/scim.ts index 214c76c99a..c26bdcb6a1 100644 --- a/jsapp/js/api/react-query/scim.ts +++ b/jsapp/js/api/react-query/scim.ts @@ -19,28 +19,14 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { PaginatedScimGroupList } from '../models/paginatedScimGroupList' - -import type { PaginatedScimUserList } from '../models/paginatedScimUserList' - import type { PatchedScimGroup } from '../models/patchedScimGroup' import type { PatchedScimUser } from '../models/patchedScimUser' import type { ScimError } from '../models/scimError' -import type { ScimGroup } from '../models/scimGroup' - -import type { ScimUser } from '../models/scimUser' - import type { ScimV2GroupsListParams } from '../models/scimV2GroupsListParams' -import type { ScimV2ResourceTypesRetrieve200 } from '../models/scimV2ResourceTypesRetrieve200' - -import type { ScimV2SchemasRetrieve200 } from '../models/scimV2SchemasRetrieve200' - -import type { ScimV2ServiceProviderConfigRetrieve200 } from '../models/scimV2ServiceProviderConfigRetrieve200' - import type { ScimV2UsersCreate400 } from '../models/scimV2UsersCreate400' import type { ScimV2UsersCreate409 } from '../models/scimV2UsersCreate409' @@ -49,6 +35,24 @@ import type { ScimV2UsersListParams } from '../models/scimV2UsersListParams' import type { ScimV2UsersUpdate409 } from '../models/scimV2UsersUpdate409' +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + +import type { PaginatedScimGroupList } from '../models/paginatedScimGroupList' + +import type { PaginatedScimUserList } from '../models/paginatedScimUserList' + +import type { ScimGroup } from '../models/scimGroup' + +import type { ScimUser } from '../models/scimUser' + +import type { ScimV2ResourceTypesRetrieve200 } from '../models/scimV2ResourceTypesRetrieve200' + +import type { ScimV2SchemasRetrieve200 } from '../models/scimV2SchemasRetrieve200' + +import type { ScimV2ServiceProviderConfigRetrieve200 } from '../models/scimV2ServiceProviderConfigRetrieve200' + import { fetchWithAuth } from '../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 @@ -1406,3 +1410,490 @@ export const useScimV2UsersDestroy = (op return useMutation(mutationOptions) } + +export const getApiV2ScimV2GroupsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedScimGroupList => ({ + schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + totalResults: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + itemsPerPage: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + startIndex: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsCreateResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsRetrieveResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsUpdateResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2ResourceTypesRetrieveResponseMock = (): ScimV2ResourceTypesRetrieve200 => ({ + [faker.string.alphanumeric(5)]: {}, +}) + +export const getApiV2ScimV2SchemasRetrieveResponseMock = (): ScimV2SchemasRetrieve200 => ({ + [faker.string.alphanumeric(5)]: {}, +}) + +export const getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock = (): ScimV2ServiceProviderConfigRetrieve200 => ({ + [faker.string.alphanumeric(5)]: {}, +}) + +export const getApiV2ScimV2UsersListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedScimUserList => ({ + schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + totalResults: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + itemsPerPage: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + startIndex: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersCreateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersRetrieveResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersUpdateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersPartialUpdateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsListMockHandler = ( + overrideResponse?: + | PaginatedScimGroupList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedScimGroupList), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2GroupsCreateMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.post('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2GroupsRetrieveMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2GroupsUpdateMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.put('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2GroupsPartialUpdateMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.patch('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2GroupsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2ScimV2ResourceTypesRetrieveMockHandler = ( + overrideResponse?: + | ScimV2ResourceTypesRetrieve200 + | (( + info: Parameters[1]>[0], + ) => Promise | ScimV2ResourceTypesRetrieve200), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/ResourceTypes', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2ResourceTypesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2SchemasRetrieveMockHandler = ( + overrideResponse?: + | ScimV2SchemasRetrieve200 + | (( + info: Parameters[1]>[0], + ) => Promise | ScimV2SchemasRetrieve200), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Schemas', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2SchemasRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler = ( + overrideResponse?: + | ScimV2ServiceProviderConfigRetrieve200 + | (( + info: Parameters[1]>[0], + ) => Promise | ScimV2ServiceProviderConfigRetrieve200), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/ServiceProviderConfig', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersListMockHandler = ( + overrideResponse?: + | PaginatedScimUserList + | ((info: Parameters[1]>[0]) => Promise | PaginatedScimUserList), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersCreateMockHandler = ( + overrideResponse?: + | ScimUser + | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.post('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersRetrieveMockHandler = ( + overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersUpdateMockHandler = ( + overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.put('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersPartialUpdateMockHandler = ( + overrideResponse?: + | ScimUser + | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.patch('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} +export const getScimMock = () => [ + getApiV2ScimV2GroupsListMockHandler(), + getApiV2ScimV2GroupsCreateMockHandler(), + getApiV2ScimV2GroupsRetrieveMockHandler(), + getApiV2ScimV2GroupsUpdateMockHandler(), + getApiV2ScimV2GroupsPartialUpdateMockHandler(), + getApiV2ScimV2GroupsDestroyMockHandler(), + getApiV2ScimV2ResourceTypesRetrieveMockHandler(), + getApiV2ScimV2SchemasRetrieveMockHandler(), + getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler(), + getApiV2ScimV2UsersListMockHandler(), + getApiV2ScimV2UsersCreateMockHandler(), + getApiV2ScimV2UsersRetrieveMockHandler(), + getApiV2ScimV2UsersUpdateMockHandler(), + getApiV2ScimV2UsersPartialUpdateMockHandler(), + getApiV2ScimV2UsersDestroyMockHandler(), +] diff --git a/jsapp/js/api/react-query/server-logs-superusers.ts b/jsapp/js/api/react-query/server-logs-superusers.ts index dd8fbd090a..7d53da94d9 100644 --- a/jsapp/js/api/react-query/server-logs-superusers.ts +++ b/jsapp/js/api/react-query/server-logs-superusers.ts @@ -27,6 +27,14 @@ import type { ErrorDetail } from '../models/errorDetail' import type { ErrorObject } from '../models/errorObject' +import type { ProjectHistoryLogsListParams } from '../models/projectHistoryLogsListParams' + +import type { UserReportsListParams } from '../models/userReportsListParams' + +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + import type { ExportCreateResponse } from '../models/exportCreateResponse' import type { ExportHistoryResponse } from '../models/exportHistoryResponse' @@ -41,9 +49,7 @@ import type { PaginatedSuperUserAccessLogResponseList } from '../models/paginate import type { PaginatedUserReportsListResponseList } from '../models/paginatedUserReportsListResponseList' -import type { ProjectHistoryLogsListParams } from '../models/projectHistoryLogsListParams' - -import type { UserReportsListParams } from '../models/userReportsListParams' +import type { ServiceUsageBalanceData } from '../models/serviceUsageBalanceData' import { fetchWithAuth } from '../orval.mutator' @@ -1077,3 +1083,1051 @@ export function useUserReportsList< return query } + +export const getApiV2AccessLogsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedSuperUserAccessLogResponseList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + initial_user_username: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + authorized_app_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2AccessLogsExportListResponseMock = (): ExportListResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 24 } }), + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })) + +export const getApiV2AccessLogsExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportCreateResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 32 } }), ...overrideResponse }) + +export const getApiV2AuditLogsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAuditLogResponseList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + app_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + model_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.internet.url(), + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + old: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + removed: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + description: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + 'data-table': faker.helpers.arrayElement([ + { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + }, + undefined, + ]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'asset-files': faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + permissions: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + latest_deployed_version_uid: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + submission: faker.helpers.arrayElement([ + { + root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + hook: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + bulk_action: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + params: faker.helpers.arrayElement([{}, undefined]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + total_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + processed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + completed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + failed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + cancelled_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + name: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + shared_fields: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + log_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectHistoryLogsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectHistoryLogResponseList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user: faker.internet.url(), + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cloned_from: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'paired-data': faker.helpers.arrayElement([ + { + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + old: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + removed: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + description: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + 'data-table': faker.helpers.arrayElement([ + { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + }, + undefined, + ]), + 'asset-files': faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + permissions: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + submission: faker.helpers.arrayElement([ + { + root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + hook: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + bulk_action: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + params: faker.helpers.arrayElement([{}, undefined]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + total_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + processed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + completed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + failed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + cancelled_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + name: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + shared_fields: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) + +export const getApiV2ProjectHistoryLogsExportRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExportHistoryResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2ProjectHistoryLogsExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportHistoryResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2UserReportsListResponseServiceUsageBalanceDataMock = ( + overrideResponse: Partial = {}, +): ServiceUsageBalanceData => ({ + ...{ + effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + exceeded: faker.datatype.boolean(), + }, + ...overrideResponse, +}) + +export const getApiV2UserReportsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedUserReportsListResponseList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.internet.email(), + is_superuser: faker.datatype.boolean(), + is_staff: faker.datatype.boolean(), + is_active: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + validated_email: faker.datatype.boolean(), + mfa_is_active: faker.datatype.boolean(), + sso_is_active: faker.datatype.boolean(), + accepted_tos: faker.datatype.boolean(), + social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + email: faker.helpers.arrayElement([faker.internet.email(), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + organizations: { + organization_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + role: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + extra_details: { + data: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + organization_type: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + organization_website: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + newsletter_subscription: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + date_removed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + validated_password: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + password_date_changed: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + date_removal_requested: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + }, + subscriptions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + items: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + price: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + currency: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + recurring: faker.helpers.arrayElement([ + { + meter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + interval: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + usage_type: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + interval_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + aggregate_usage: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + trial_period_days: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + unit_amount: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + human_readable_price: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + product: faker.helpers.arrayElement([ + { + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([ + { + product_type: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + storage_bytes_limit: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + transform_quantity: faker.helpers.arrayElement([ + { + divide_by: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + round: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + })), + undefined, + ]), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + })), + undefined, + ]), + schedule: faker.helpers.arrayElement([ + { + phases: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + items: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + plan: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + price: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + tax_rates: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ), + undefined, + ]), + billing_thresholds: faker.helpers.arrayElement([{}, undefined]), + })), + undefined, + ]), + coupon: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + currency: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + end_date: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + metadata: faker.helpers.arrayElement([{}, undefined]), + trial_end: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + start_date: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + description: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + on_behalf_of: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + automatic_tax: faker.helpers.arrayElement([{}, undefined]), + transfer_data: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + invoice_settings: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + add_invoice_items: faker.helpers.arrayElement([{}, undefined]), + collection_method: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_tax_rates: faker.helpers.arrayElement([{}, undefined]), + billing_thresholds: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + proration_behavior: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + billing_cycle_anchor: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + default_payment_method: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + application_fee_percent: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + })), + undefined, + ]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + djstripe_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + djstripe_updated: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([ + { + request_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_id: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + kpi_owner_user_id: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + kpi_owner_username: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + application_fee_percent: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + billing_cycle_anchor: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + billing_thresholds: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancel_at: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + canceled_at: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collection_method: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + current_period_end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + current_period_start: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + days_until_due: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + discount: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ended_at: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + next_pending_invoice_item_invoice: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + pause_collection: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + pending_invoice_item_interval: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + pending_update: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + proration_behavior: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + proration_date: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + start_date: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + trial_end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + trial_start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + djstripe_owner_account: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + customer: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + default_payment_method: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_invoice: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + pending_setup_intent: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + plan: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + default_tax_rates: faker.helpers.arrayElement([{}, undefined]), + })), + service_usage: { + total_nlp_usage: { + asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_submission_count: { + retention_days: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + cumulative: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + current_period: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + balances: { + submission: faker.helpers.arrayElement([ + { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, + null, + ]), + storage_bytes: faker.helpers.arrayElement([ + { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, + null, + ]), + asr_seconds: faker.helpers.arrayElement([ + { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, + null, + ]), + mt_characters: faker.helpers.arrayElement([ + { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, + null, + ]), + llm_requests: faker.helpers.arrayElement([ + { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, + null, + ]), + }, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + }, + account_restricted: faker.datatype.boolean(), + asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + active_project_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) + +export const getApiV2AccessLogsListMockHandler = ( + overrideResponse?: + | PaginatedSuperUserAccessLogResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedSuperUserAccessLogResponseList), +) => { + return http.get('*/api/v2/access-logs/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AccessLogsExportListMockHandler = ( + overrideResponse?: + | ExportListResponse[] + | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), +) => { + return http.get('*/api/v2/access-logs/export/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsExportListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AccessLogsExportCreateMockHandler = ( + overrideResponse?: + | ExportCreateResponse + | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), +) => { + return http.post('*/api/v2/access-logs/export/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsExportCreateResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AuditLogsListMockHandler = ( + overrideResponse?: + | PaginatedAuditLogResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAuditLogResponseList), +) => { + return http.get('*/api/v2/audit-logs/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AuditLogsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectHistoryLogsListMockHandler = ( + overrideResponse?: + | PaginatedProjectHistoryLogResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectHistoryLogResponseList), +) => { + return http.get('*/api/v2/project-history-logs/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectHistoryLogsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectHistoryLogsExportRetrieveMockHandler = ( + overrideResponse?: + | ExportHistoryResponse + | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse), +) => { + return http.get('*/api/v2/project-history-logs/export/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectHistoryLogsExportRetrieveResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectHistoryLogsExportCreateMockHandler = ( + overrideResponse?: + | ExportHistoryResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ExportHistoryResponse), +) => { + return http.post('*/api/v2/project-history-logs/export/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectHistoryLogsExportCreateResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2UserReportsListMockHandler = ( + overrideResponse?: + | PaginatedUserReportsListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedUserReportsListResponseList), +) => { + return http.get('*/api/v2/user-reports/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2UserReportsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getServerLogsSuperusersMock = () => [ + getApiV2AccessLogsListMockHandler(), + getApiV2AccessLogsExportListMockHandler(), + getApiV2AccessLogsExportCreateMockHandler(), + getApiV2AuditLogsListMockHandler(), + getApiV2ProjectHistoryLogsListMockHandler(), + getApiV2ProjectHistoryLogsExportRetrieveMockHandler(), + getApiV2ProjectHistoryLogsExportCreateMockHandler(), + getApiV2UserReportsListMockHandler(), +] diff --git a/jsapp/js/api/react-query/survey-data-rest-services.ts b/jsapp/js/api/react-query/survey-data-rest-services.ts index fd075793d0..09b295f893 100644 --- a/jsapp/js/api/react-query/survey-data-rest-services.ts +++ b/jsapp/js/api/react-query/survey-data-rest-services.ts @@ -27,6 +27,18 @@ import type { ErrorDetail } from '../models/errorDetail' import type { ErrorObject } from '../models/errorObject' +import type { PatchedHook } from '../models/patchedHook' + +import type { PatchedHookLog } from '../models/patchedHookLog' + +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + +import { AuthLevelEnum } from '../models/authLevelEnum' + +import { ExportTypeEnum } from '../models/exportTypeEnum' + import type { Hook } from '../models/hook' import type { HookLog } from '../models/hookLog' @@ -39,10 +51,6 @@ import type { PaginatedHookList } from '../models/paginatedHookList' import type { PaginatedHookLogList } from '../models/paginatedHookLogList' -import type { PatchedHook } from '../models/patchedHook' - -import type { PatchedHookLog } from '../models/patchedHookLog' - import { fetchWithAuth } from '../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 @@ -962,3 +970,423 @@ export const useAssetsHooksRetryPartialUpdate = = {}, +): PaginatedHookList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksCreateResponseMock = (overrideResponse: Partial = {}): Hook => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksRetrieveResponseMock = (overrideResponse: Partial = {}): Hook => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksPartialUpdateResponseMock = (overrideResponse: Partial = {}): Hook => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksLogsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedHookLogList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + tries: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.helpers.arrayElement([0, 1, 3, 2] as const), + status_str: faker.string.alpha({ length: { min: 10, max: 20 } }), + status_code: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + message: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksLogsRetrieveResponseMock = (overrideResponse: Partial = {}): HookLog => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + tries: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.helpers.arrayElement([0, 1, 3, 2] as const), + status_str: faker.string.alpha({ length: { min: 10, max: 20 } }), + status_code: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + message: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + ...overrideResponse, +}) + +export const getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): LogsRetryResponse => ({ + detail: faker.string.alpha({ length: { min: 10, max: 20 } }), + pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksRetryPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): HookRetryResponse => ({ + detail: faker.string.alpha({ length: { min: 10, max: 20 } }), + pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksListMockHandler = ( + overrideResponse?: + | PaginatedHookList + | ((info: Parameters[1]>[0]) => Promise | PaginatedHookList), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksCreateMockHandler = ( + overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), +) => { + return http.post('*/api/v2/assets/:uidAsset/hooks/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksRetrieveMockHandler = ( + overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksPartialUpdateMockHandler = ( + overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), +) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsHooksLogsListMockHandler = ( + overrideResponse?: + | PaginatedHookLogList + | ((info: Parameters[1]>[0]) => Promise | PaginatedHookLogList), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksLogsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksLogsRetrieveMockHandler = ( + overrideResponse?: HookLog | ((info: Parameters[1]>[0]) => Promise | HookLog), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksLogsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler = ( + overrideResponse?: + | LogsRetryResponse + | ((info: Parameters[1]>[0]) => Promise | LogsRetryResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksRetryPartialUpdateMockHandler = ( + overrideResponse?: + | HookRetryResponse + | ((info: Parameters[1]>[0]) => Promise | HookRetryResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksRetryPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getSurveyDataRestServicesMock = () => [ + getApiV2AssetsHooksListMockHandler(), + getApiV2AssetsHooksCreateMockHandler(), + getApiV2AssetsHooksRetrieveMockHandler(), + getApiV2AssetsHooksPartialUpdateMockHandler(), + getApiV2AssetsHooksDestroyMockHandler(), + getApiV2AssetsHooksLogsListMockHandler(), + getApiV2AssetsHooksLogsRetrieveMockHandler(), + getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler(), + getApiV2AssetsHooksRetryPartialUpdateMockHandler(), +] diff --git a/jsapp/js/api/react-query/survey-data.ts b/jsapp/js/api/react-query/survey-data.ts index 2a79a859fd..ecd8a9b5d8 100644 --- a/jsapp/js/api/react-query/survey-data.ts +++ b/jsapp/js/api/react-query/survey-data.ts @@ -19,16 +19,10 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { AdvancedFeatureCreateResponse } from '../models/advancedFeatureCreateResponse' - import type { AdvancedFeaturePostRequest } from '../models/advancedFeaturePostRequest' -import type { AdvancedFeatureResponse } from '../models/advancedFeatureResponse' - import type { AssetAttachmentAudioDurationRequest } from '../models/assetAttachmentAudioDurationRequest' -import type { AssetAttachmentAudioDurationResponse } from '../models/assetAttachmentAudioDurationResponse' - import type { AssetsAdvancedFeaturesBulkActionsListParams } from '../models/assetsAdvancedFeaturesBulkActionsListParams' import type { AssetsDataAttachmentsListParams } from '../models/assetsDataAttachmentsListParams' @@ -51,19 +45,63 @@ import type { AttachmentRetrieveParams } from '../models/attachmentRetrieveParam import type { BulkAcceptRequest } from '../models/bulkAcceptRequest' -import type { BulkAcceptResponse } from '../models/bulkAcceptResponse' - import type { BulkActionCreateRequest } from '../models/bulkActionCreateRequest' +import type { CreateFilePayload } from '../models/createFilePayload' + +import type { DataBulkDelete } from '../models/dataBulkDelete' + +import type { ErrorDetail } from '../models/errorDetail' + +import type { ErrorObject } from '../models/errorObject' + +import type { ExportCreatePayload } from '../models/exportCreatePayload' + +import type { ExportSettingCreatePayload } from '../models/exportSettingCreatePayload' + +import type { PairedData } from '../models/pairedData' + +import type { PatchedAdvancedFeaturePatchRequest } from '../models/patchedAdvancedFeaturePatchRequest' + +import type { PatchedBulkActionPatchRequest } from '../models/patchedBulkActionPatchRequest' + +import type { PatchedDataBulkUpdate } from '../models/patchedDataBulkUpdate' + +import type { PatchedDataSupplementPayload } from '../models/patchedDataSupplementPayload' + +import type { PatchedDataValidationStatusUpdatePayload } from '../models/patchedDataValidationStatusUpdatePayload' + +import type { PatchedDataValidationStatusesUpdatePayload } from '../models/patchedDataValidationStatusesUpdatePayload' + +import type { PatchedExportSettingUpdatePayload } from '../models/patchedExportSettingUpdatePayload' + +import type { PatchedPairedDataPatchPayload } from '../models/patchedPairedDataPatchPayload' + +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + +import { ActionEnum } from '../models/actionEnum' + +import { ActionIdEnum } from '../models/actionIdEnum' + +import type { AdvancedFeatureCreateResponse } from '../models/advancedFeatureCreateResponse' + +import type { AdvancedFeatureResponse } from '../models/advancedFeatureResponse' + +import type { AssetAttachmentAudioDurationResponse } from '../models/assetAttachmentAudioDurationResponse' + +import type { BulkAcceptResponse } from '../models/bulkAcceptResponse' + import type { BulkActionCreateResponse } from '../models/bulkActionCreateResponse' import type { BulkActionListResponse } from '../models/bulkActionListResponse' import type { BulkActionResponse } from '../models/bulkActionResponse' -import type { CreateFilePayload } from '../models/createFilePayload' +import { BulkActionResponseStatusEnum } from '../models/bulkActionResponseStatusEnum' -import type { DataBulkDelete } from '../models/dataBulkDelete' +import { BulkActionSubmissionStatusResponseStatusEnum } from '../models/bulkActionSubmissionStatusResponseStatusEnum' import type { DataBulkUpdateResponse } from '../models/dataBulkUpdateResponse' @@ -71,24 +109,40 @@ import type { DataResponse } from '../models/dataResponse' import type { DataStatusesUpdate } from '../models/dataStatusesUpdate' +import type { DataSupplementAutomaticQualDataIntegerResponse } from '../models/dataSupplementAutomaticQualDataIntegerResponse' + +import type { DataSupplementAutomaticQualDataSelectMultipleResponse } from '../models/dataSupplementAutomaticQualDataSelectMultipleResponse' + +import type { DataSupplementAutomaticQualDataSelectOneResponse } from '../models/dataSupplementAutomaticQualDataSelectOneResponse' + +import type { DataSupplementAutomaticQualDataTextResponse } from '../models/dataSupplementAutomaticQualDataTextResponse' + +import type { DataSupplementManualQualDataInteger } from '../models/dataSupplementManualQualDataInteger' + +import type { DataSupplementManualQualDataSelectMultiple } from '../models/dataSupplementManualQualDataSelectMultiple' + +import type { DataSupplementManualQualDataSelectOne } from '../models/dataSupplementManualQualDataSelectOne' + +import type { DataSupplementManualQualDataTags } from '../models/dataSupplementManualQualDataTags' + +import type { DataSupplementManualQualDataText } from '../models/dataSupplementManualQualDataText' + import type { DataSupplementResponse } from '../models/dataSupplementResponse' -import type { DataValidationStatusUpdateResponse } from '../models/dataValidationStatusUpdateResponse' +import type { DataValidationStatus } from '../models/dataValidationStatus' -import type { EnketoEditResponse } from '../models/enketoEditResponse' +import { DataValidationStatusLabelEnum } from '../models/dataValidationStatusLabelEnum' -import type { EnketoViewResponse } from '../models/enketoViewResponse' +import { DataValidationStatusUidEnum } from '../models/dataValidationStatusUidEnum' -import type { ErrorDetail } from '../models/errorDetail' +import type { DataValidationStatusUpdateResponse } from '../models/dataValidationStatusUpdateResponse' -import type { ErrorObject } from '../models/errorObject' +import type { EnketoEditResponse } from '../models/enketoEditResponse' -import type { ExportCreatePayload } from '../models/exportCreatePayload' +import type { EnketoViewResponse } from '../models/enketoViewResponse' import type { ExportResponse } from '../models/exportResponse' -import type { ExportSettingCreatePayload } from '../models/exportSettingCreatePayload' - import type { ExportSettingResponse } from '../models/exportSettingResponse' import type { ExternalResponse } from '../models/externalResponse' @@ -105,27 +159,21 @@ import type { PaginatedFilesResponseList } from '../models/paginatedFilesRespons import type { PaginatedPairedDataResponseList } from '../models/paginatedPairedDataResponseList' -import type { PairedData } from '../models/pairedData' - import type { PairedDataResponse } from '../models/pairedDataResponse' -import type { PatchedAdvancedFeaturePatchRequest } from '../models/patchedAdvancedFeaturePatchRequest' +import { QualSelectQuestionParamsTypeEnum } from '../models/qualSelectQuestionParamsTypeEnum' -import type { PatchedBulkActionPatchRequest } from '../models/patchedBulkActionPatchRequest' +import { QualSimpleQuestionParamsTypeEnum } from '../models/qualSimpleQuestionParamsTypeEnum' -import type { PatchedDataBulkUpdate } from '../models/patchedDataBulkUpdate' +import type { ReportResponse } from '../models/reportResponse' -import type { PatchedDataSupplementPayload } from '../models/patchedDataSupplementPayload' +import type { SupplementalDataContentAutomaticComplete } from '../models/supplementalDataContentAutomaticComplete' -import type { PatchedDataValidationStatusUpdatePayload } from '../models/patchedDataValidationStatusUpdatePayload' +import type { SupplementalDataContentAutomaticDeleted } from '../models/supplementalDataContentAutomaticDeleted' -import type { PatchedDataValidationStatusesUpdatePayload } from '../models/patchedDataValidationStatusesUpdatePayload' +import type { SupplementalDataContentAutomaticFailed } from '../models/supplementalDataContentAutomaticFailed' -import type { PatchedExportSettingUpdatePayload } from '../models/patchedExportSettingUpdatePayload' - -import type { PatchedPairedDataPatchPayload } from '../models/patchedPairedDataPatchPayload' - -import type { ReportResponse } from '../models/reportResponse' +import type { SupplementalDataContentAutomaticInProgress } from '../models/supplementalDataContentAutomaticInProgress' import { fetchWithAuth } from '../orval.mutator' @@ -6155,3 +6203,3010 @@ export function useAssetsReportsRetrieve< return query } + +export const getApiV2AssetsAdvancedFeaturesListResponseMock = (): AdvancedFeatureResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsAdvancedFeaturesCreateResponseMock = ( + overrideResponse: Partial = {}, +): AdvancedFeatureCreateResponse => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AdvancedFeatureResponse => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): AdvancedFeatureResponse => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionListResponse => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + previous: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionCreateResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + skipped_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsAttachmentsAudioDurationCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetAttachmentAudioDurationResponse => ({ + attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + seconds: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + })), + total: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataValidationStatusMock = ( + overrideResponse: Partial = {}, +): DataValidationStatus => ({ + ...{ + timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticInProgress => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'in_progress', + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticFailed => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'failed', + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticComplete => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'complete', + value: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticDeleted => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'deleted', + value: null, + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataInteger => ({ + ...{ + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataText => ({ + ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectOne => ({ + ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectMultiple => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataTags => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataIntegerResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataTextResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataSelectOneResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedDataResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + download_url: faker.internet.url(), + download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), + media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + _status: faker.string.alpha({ length: { min: 10, max: 20 } }), + _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), + ), + _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + _validation_status: faker.helpers.arrayElement([{ ...getApiV2AssetsDataListResponseDataValidationStatusMock() }]), + _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), + _supplementalDetails: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + { + [faker.string.alphanumeric(5)]: { + manual_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + _dependency: faker.helpers.arrayElement([ + { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, + undefined, + ]), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + ]), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataValidationStatusMock = ( + overrideResponse: Partial = {}, +): DataValidationStatus => ({ + ...{ + timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticInProgress => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'in_progress', + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticFailed => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'failed', + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticComplete => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'complete', + value: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticDeleted => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'deleted', + value: null, + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataInteger => ({ + ...{ + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataText => ({ + ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectOne => ({ + ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectMultiple => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataTags => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataIntegerResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataTextResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataSelectOneResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseMock = (overrideResponse: Partial = {}): DataResponse => ({ + _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + download_url: faker.internet.url(), + download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), + media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + _status: faker.string.alpha({ length: { min: 10, max: 20 } }), + _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), + ), + _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + _validation_status: faker.helpers.arrayElement([{ ...getApiV2AssetsDataRetrieveResponseDataValidationStatusMock() }]), + _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), + _supplementalDetails: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + { + [faker.string.alphanumeric(5)]: { + manual_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + _dependency: faker.helpers.arrayElement([ + { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, + undefined, + ]), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + ]), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock = ( + overrideResponse: Partial = {}, +): DataValidationStatus => ({ + ...{ + timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticInProgress => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'in_progress', + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticFailed => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'failed', + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticComplete => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'complete', + value: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticDeleted => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'deleted', + value: null, + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataInteger => ({ + ...{ + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataText => ({ + ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectOne => ({ + ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectMultiple => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataTags => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataIntegerResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataTextResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataSelectOneResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseMock = ( + overrideResponse: Partial = {}, +): DataResponse => ({ + _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + download_url: faker.internet.url(), + download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), + media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + _status: faker.string.alpha({ length: { min: 10, max: 20 } }), + _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), + ), + _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + _validation_status: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock() }, + ]), + _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), + _supplementalDetails: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + { + [faker.string.alphanumeric(5)]: { + manual_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock() }, + { + ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock(), + }, + { + ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock(), + }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + _dependency: faker.helpers.arrayElement([ + { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, + undefined, + ]), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + ]), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEditRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoEditResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoEditRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoEditResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoEditResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoViewResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoViewRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoViewResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataValidationStatusRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): DataValidationStatusUpdateResponse => ({ + timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataValidationStatusPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataValidationStatusUpdateResponse => ({ + timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataSupplementRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AssetsDataSupplementPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AssetsDataBulkPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataBulkUpdateResponse => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + successes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + failures: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status_code: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsDataSupplementsBulkCreateResponseMock = ( + overrideResponse: Partial = {}, +): BulkAcceptResponse => ({ + accepted_count: faker.number.int({ min: 0, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataStatusesUpdate => ({ detail: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AssetsExportSettingsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedExportSettingResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsExportSettingsCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportSettingResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportSettingsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExportSettingResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportSettingsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): ExportSettingResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedExportResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + message: {}, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + result: faker.internet.url(), + data: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source: faker.helpers.arrayElement([faker.internet.url(), undefined]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + processing_time_seconds: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsExportsCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportResponse => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + message: {}, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + result: faker.internet.url(), + data: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source: faker.helpers.arrayElement([faker.internet.url(), undefined]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + processing_time_seconds: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExportResponse => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + message: {}, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + result: faker.internet.url(), + data: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source: faker.helpers.arrayElement([faker.internet.url(), undefined]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + processing_time_seconds: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsFilesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedFilesResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + asset: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + description: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: faker.internet.url(), + metadata: { + hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsFilesCreateResponseMock = ( + overrideResponse: Partial = {}, +): FilesResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + asset: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + description: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: faker.internet.url(), + metadata: { + hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsFilesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): FilesResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + asset: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + description: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: faker.internet.url(), + metadata: { + hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedPairedDataResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataCreateResponseMock = ( + overrideResponse: Partial = {}, +): PairedDataResponse => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PairedDataResponse => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): PairedDataResponse => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataExternalRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExternalResponse => ({ + root: { + data: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + field_value_1: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + field_value_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsReportsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ReportResponse => ({ + url: faker.internet.url(), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + list: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + row: faker.helpers.arrayElement([ + { type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + data: faker.helpers.arrayElement([ + { + total_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + not_provided: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + provided: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + show_graph: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([{}, undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesListMockHandler = ( + overrideResponse?: + | AdvancedFeatureResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureResponse[]), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesCreateMockHandler = ( + overrideResponse?: + | AdvancedFeatureCreateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureCreateResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesRetrieveMockHandler = ( + overrideResponse?: + | AdvancedFeatureResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler = ( + overrideResponse?: + | AdvancedFeatureResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler = ( + overrideResponse?: + | BulkActionListResponse + | (( + info: Parameters[1]>[0], + ) => Promise | BulkActionListResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler = ( + overrideResponse?: + | BulkActionCreateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | BulkActionCreateResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler = ( + overrideResponse?: + | BulkActionResponse + | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = ( + overrideResponse?: + | BulkActionResponse + | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAttachmentsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/attachments/:id/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = ( + overrideResponse?: + | AssetAttachmentAudioDurationResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetAttachmentAudioDurationResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAttachmentsAudioDurationCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAttachmentsBulkDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 202 }) + }) +} + +export const getApiV2AssetsDataListMockHandler = ( + overrideResponse?: + | PaginatedDataResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedDataResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataRetrieveMockHandler = ( + overrideResponse?: + | DataResponse + | ((info: Parameters[1]>[0]) => Promise | DataResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsDataDuplicateCreateMockHandler = ( + overrideResponse?: + | DataResponse + | ((info: Parameters[1]>[0]) => Promise | DataResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataDuplicateCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataEditRetrieveMockHandler = ( + overrideResponse?: + | EnketoEditResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/edit/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEditRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataEnketoEditRetrieveMockHandler = ( + overrideResponse?: + | EnketoEditResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoEditRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler = ( + overrideResponse?: + | EnketoEditResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler = ( + overrideResponse?: + | EnketoViewResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataEnketoViewRetrieveMockHandler = ( + overrideResponse?: + | EnketoViewResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoViewRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataValidationStatusRetrieveMockHandler = ( + overrideResponse?: + | DataValidationStatusUpdateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataValidationStatusUpdateResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataValidationStatusRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = ( + overrideResponse?: + | DataValidationStatusUpdateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataValidationStatusUpdateResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataValidationStatusPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataValidationStatusDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsDataSupplementRetrieveMockHandler = ( + overrideResponse?: + | DataSupplementResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataSupplementResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataSupplementRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = ( + overrideResponse?: + | DataSupplementResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataSupplementResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataSupplementPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataAttachmentsListMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getAttachmentRetrieveMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getAttachmentThumbnailMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AssetsDataBulkPartialUpdateMockHandler = ( + overrideResponse?: + | DataBulkUpdateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataBulkUpdateResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataBulkPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataBulkDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AssetsDataSupplementsBulkCreateMockHandler = ( + overrideResponse?: + | BulkAcceptResponse + | ((info: Parameters[1]>[0]) => Promise | BulkAcceptResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataSupplementsBulkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = ( + overrideResponse?: + | DataStatusesUpdate + | ((info: Parameters[1]>[0]) => Promise | DataStatusesUpdate), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataValidationStatusesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsExportSettingsListMockHandler = ( + overrideResponse?: + | PaginatedExportSettingResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedExportSettingResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportSettingsCreateMockHandler = ( + overrideResponse?: + | ExportSettingResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ExportSettingResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportSettingsRetrieveMockHandler = ( + overrideResponse?: + | ExportSettingResponse + | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = ( + overrideResponse?: + | ExportSettingResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ExportSettingResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportSettingsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsExportSettingsDataRetrieveMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AssetsExportsListMockHandler = ( + overrideResponse?: + | PaginatedExportResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedExportResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/exports/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportsCreateMockHandler = ( + overrideResponse?: + | ExportResponse + | ((info: Parameters[1]>[0]) => Promise | ExportResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/exports/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportsRetrieveMockHandler = ( + overrideResponse?: + | ExportResponse + | ((info: Parameters[1]>[0]) => Promise | ExportResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsFilesListMockHandler = ( + overrideResponse?: + | PaginatedFilesResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedFilesResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/files/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsFilesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsFilesCreateMockHandler = ( + overrideResponse?: + | FilesResponse + | ((info: Parameters[1]>[0]) => Promise | FilesResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/files/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsFilesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsFilesRetrieveMockHandler = ( + overrideResponse?: + | FilesResponse + | ((info: Parameters[1]>[0]) => Promise | FilesResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsFilesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsFilesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsFilesContentRetrieveMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AssetsPairedDataListMockHandler = ( + overrideResponse?: + | PaginatedPairedDataResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedPairedDataResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPairedDataCreateMockHandler = ( + overrideResponse?: + | PairedDataResponse + | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPairedDataRetrieveMockHandler = ( + overrideResponse?: + | PairedDataResponse + | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPairedDataPartialUpdateMockHandler = ( + overrideResponse?: + | PairedDataResponse + | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPairedDataDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = ( + overrideResponse?: + | ExternalResponse + | ((info: Parameters[1]>[0]) => Promise | ExternalResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataExternalRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsReportsRetrieveMockHandler = ( + overrideResponse?: + | ReportResponse + | ((info: Parameters[1]>[0]) => Promise | ReportResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/reports/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsReportsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getSurveyDataMock = () => [ + getApiV2AssetsAdvancedFeaturesListMockHandler(), + getApiV2AssetsAdvancedFeaturesCreateMockHandler(), + getApiV2AssetsAdvancedFeaturesRetrieveMockHandler(), + getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler(), + getApiV2AssetsAttachmentsDestroyMockHandler(), + getApiV2AssetsAttachmentsAudioDurationCreateMockHandler(), + getApiV2AssetsAttachmentsBulkDestroyMockHandler(), + getApiV2AssetsDataListMockHandler(), + getApiV2AssetsDataRetrieveMockHandler(), + getApiV2AssetsDataDestroyMockHandler(), + getApiV2AssetsDataDuplicateCreateMockHandler(), + getApiV2AssetsDataEditRetrieveMockHandler(), + getApiV2AssetsDataEnketoEditRetrieveMockHandler(), + getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler(), + getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler(), + getApiV2AssetsDataEnketoViewRetrieveMockHandler(), + getApiV2AssetsDataValidationStatusRetrieveMockHandler(), + getApiV2AssetsDataValidationStatusPartialUpdateMockHandler(), + getApiV2AssetsDataValidationStatusDestroyMockHandler(), + getApiV2AssetsDataSupplementRetrieveMockHandler(), + getApiV2AssetsDataSupplementPartialUpdateMockHandler(), + getApiV2AssetsDataAttachmentsListMockHandler(), + getAttachmentRetrieveMockHandler(), + getAttachmentThumbnailMockHandler(), + getApiV2AssetsDataBulkPartialUpdateMockHandler(), + getApiV2AssetsDataBulkDestroyMockHandler(), + getApiV2AssetsDataSupplementsBulkCreateMockHandler(), + getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler(), + getApiV2AssetsDataValidationStatusesDestroyMockHandler(), + getApiV2AssetsExportSettingsListMockHandler(), + getApiV2AssetsExportSettingsCreateMockHandler(), + getApiV2AssetsExportSettingsRetrieveMockHandler(), + getApiV2AssetsExportSettingsPartialUpdateMockHandler(), + getApiV2AssetsExportSettingsDestroyMockHandler(), + getApiV2AssetsExportSettingsDataRetrieveMockHandler(), + getApiV2AssetsExportsListMockHandler(), + getApiV2AssetsExportsCreateMockHandler(), + getApiV2AssetsExportsRetrieveMockHandler(), + getApiV2AssetsExportsDestroyMockHandler(), + getApiV2AssetsFilesListMockHandler(), + getApiV2AssetsFilesCreateMockHandler(), + getApiV2AssetsFilesRetrieveMockHandler(), + getApiV2AssetsFilesDestroyMockHandler(), + getApiV2AssetsFilesContentRetrieveMockHandler(), + getApiV2AssetsPairedDataListMockHandler(), + getApiV2AssetsPairedDataCreateMockHandler(), + getApiV2AssetsPairedDataRetrieveMockHandler(), + getApiV2AssetsPairedDataPartialUpdateMockHandler(), + getApiV2AssetsPairedDataDestroyMockHandler(), + getApiV2AssetsPairedDataExternalRetrieveMockHandler(), + getApiV2AssetsReportsRetrieveMockHandler(), +] diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index a7be9edf6f..7a6ed0970b 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -19,12 +19,8 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { AssetListCount } from '../models/assetListCount' - import type { AssetUsageListParams } from '../models/assetUsageListParams' -import type { EmailAddress } from '../models/emailAddress' - import type { EmailRequestPayload } from '../models/emailRequestPayload' import type { ErrorDetail } from '../models/errorDetail' @@ -33,22 +29,10 @@ import type { ErrorObject } from '../models/errorObject' import type { InviteCreatePayload } from '../models/inviteCreatePayload' -import type { InviteCreateResponse } from '../models/inviteCreateResponse' - -import type { InviteResponse } from '../models/inviteResponse' - import type { MeEmailsListParams } from '../models/meEmailsListParams' -import type { MeListResponse } from '../models/meListResponse' - import type { MeSocialAccountsListParams } from '../models/meSocialAccountsListParams' -import type { MemberListResponse } from '../models/memberListResponse' - -import type { OrganizationResponse } from '../models/organizationResponse' - -import type { OrganizationServiceUsageResponse } from '../models/organizationServiceUsageResponse' - import type { OrganizationsAssetUsageListParams } from '../models/organizationsAssetUsageListParams' import type { OrganizationsAssetsMinimalListRetrieveParams } from '../models/organizationsAssetsMinimalListRetrieveParams' @@ -59,6 +43,58 @@ import type { OrganizationsListParams } from '../models/organizationsListParams' import type { OrganizationsMembersListParams } from '../models/organizationsMembersListParams' +import type { PatchedCurrentUser } from '../models/patchedCurrentUser' + +import type { PatchedInvitePatchPayload } from '../models/patchedInvitePatchPayload' + +import type { PatchedMemberPatchRequest } from '../models/patchedMemberPatchRequest' + +import type { PatchedOrganizationPatchPayload } from '../models/patchedOrganizationPatchPayload' + +import type { ProjectViewsAssetsMinimalListRetrieveParams } from '../models/projectViewsAssetsMinimalListRetrieveParams' + +import type { ProjectViewsAssetsRetrieveParams } from '../models/projectViewsAssetsRetrieveParams' + +import type { ProjectViewsListParams } from '../models/projectViewsListParams' + +import type { ProjectViewsUsersRetrieveParams } from '../models/projectViewsUsersRetrieveParams' + +import type { UsersListParams } from '../models/usersListParams' + +import { faker } from '@faker-js/faker' + +import { http, HttpResponse, delay } from 'msw' + +import { AssetDeploymentStatusEnum } from '../models/assetDeploymentStatusEnum' + +import type { AssetListCount } from '../models/assetListCount' + +import { AssetTypeEnum } from '../models/assetTypeEnum' + +import { CustomAssetUsageDeploymentStatusEnum } from '../models/customAssetUsageDeploymentStatusEnum' + +import type { EmailAddress } from '../models/emailAddress' + +import type { InviteCreateResponse } from '../models/inviteCreateResponse' + +import type { InviteResponse } from '../models/inviteResponse' + +import { InviteStatusChoicesEnum } from '../models/inviteStatusChoicesEnum' + +import { InviteeRoleEnum } from '../models/inviteeRoleEnum' + +import type { MeListResponse } from '../models/meListResponse' + +import type { MemberListResponse } from '../models/memberListResponse' + +import { MemberRoleEnum } from '../models/memberRoleEnum' + +import type { OrganizationResponse } from '../models/organizationResponse' + +import type { OrganizationServiceUsageResponse } from '../models/organizationServiceUsageResponse' + +import { OrganizationTypeEnum } from '../models/organizationTypeEnum' + import type { PaginatedAssetList } from '../models/paginatedAssetList' import type { PaginatedAssetMinimalListList } from '../models/paginatedAssetMinimalListList' @@ -85,27 +121,13 @@ import type { PaginatedSocialAccountList } from '../models/paginatedSocialAccoun import type { PaginatedUserListResponseList } from '../models/paginatedUserListResponseList' -import type { PatchedCurrentUser } from '../models/patchedCurrentUser' - -import type { PatchedInvitePatchPayload } from '../models/patchedInvitePatchPayload' - -import type { PatchedMemberPatchRequest } from '../models/patchedMemberPatchRequest' - -import type { PatchedOrganizationPatchPayload } from '../models/patchedOrganizationPatchPayload' - import type { ProjectViewExportCreateResponse } from '../models/projectViewExportCreateResponse' import type { ProjectViewExportResponse } from '../models/projectViewExportResponse' import type { ProjectViewListResponse } from '../models/projectViewListResponse' -import type { ProjectViewsAssetsMinimalListRetrieveParams } from '../models/projectViewsAssetsMinimalListRetrieveParams' - -import type { ProjectViewsAssetsRetrieveParams } from '../models/projectViewsAssetsRetrieveParams' - -import type { ProjectViewsListParams } from '../models/projectViewsListParams' - -import type { ProjectViewsUsersRetrieveParams } from '../models/projectViewsUsersRetrieveParams' +import type { ServiceUsageBalanceData } from '../models/serviceUsageBalanceData' import type { ServiceUsageResponse } from '../models/serviceUsageResponse' @@ -113,8 +135,6 @@ import type { SocialAccount } from '../models/socialAccount' import type { UserRetrieveResponse } from '../models/userRetrieveResponse' -import type { UsersListParams } from '../models/usersListParams' - import { fetchWithAuth } from '../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 @@ -3660,3 +3680,1905 @@ export const useMeSocialAccountsDestroy = = {}, +): PaginatedAssetUsageResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + asset: faker.internet.url(), + asset__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + nlp_usage_current_period: { + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + nlp_usage_all_time: { + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedOrganizationResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + website: faker.string.alpha({ length: { min: 10, max: 255 } }), + organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_owner: faker.datatype.boolean(), + is_mmo: faker.datatype.boolean(), + request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + members: faker.internet.url(), + assets: faker.internet.url(), + service_usage: faker.internet.url(), + asset_usage: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OrganizationResponse => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + website: faker.string.alpha({ length: { min: 10, max: 255 } }), + organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_owner: faker.datatype.boolean(), + is_mmo: faker.datatype.boolean(), + request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + members: faker.internet.url(), + assets: faker.internet.url(), + service_usage: faker.internet.url(), + asset_usage: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2OrganizationsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): OrganizationResponse => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + website: faker.string.alpha({ length: { min: 10, max: 255 } }), + organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_owner: faker.datatype.boolean(), + is_mmo: faker.datatype.boolean(), + request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + members: faker.internet.url(), + assets: faker.internet.url(), + service_usage: faker.internet.url(), + asset_usage: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetUsageListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedCustomAssetUsageList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + asset: faker.internet.url(), + asset__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + nlp_usage_current_period: { + ...{ + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + nlp_usage_all_time: { + ...{ + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment_status: faker.helpers.arrayElement(Object.values(CustomAssetUsageDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([{}, undefined]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([{}, undefined]), + default_translation: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + version__content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployed_versions: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + results: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + undefined, + ]), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: {}, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([{}, undefined]), + specified: faker.helpers.arrayElement([ + { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + kuid_names: faker.helpers.arrayElement([ + { + end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([{}, undefined]), + map_styles: faker.helpers.arrayElement([{}, undefined]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + analysis_form_json: { + additional_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({}), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetsCountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetListCount => ({ + deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetMinimalListList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 22 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsInvitesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedInviteResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsInvitesCreateResponseMock = (): InviteCreateResponse => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + invited_by: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + invitee_role: faker.helpers.arrayElement(['admin', 'member'] as const), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2OrganizationsInvitesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): InviteResponse => ({ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2OrganizationsInvitesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): InviteResponse => ({ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2OrganizationsMembersListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedMemberListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + url: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__email: faker.internet.email(), + user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__has_mfa_enabled: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + user__is_active: faker.datatype.boolean(), + invite: { + ...{ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsMembersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): MemberListResponse => ({ + role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + url: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__email: faker.internet.email(), + user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__has_mfa_enabled: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + user__is_active: faker.datatype.boolean(), + invite: { + ...{ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2OrganizationsMembersPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): MemberListResponse => ({ + role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + url: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__email: faker.internet.email(), + user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__has_mfa_enabled: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + user__is_active: faker.datatype.boolean(), + invite: { + ...{ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock = ( + overrideResponse: Partial = {}, +): ServiceUsageBalanceData => ({ + ...{ + effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + exceeded: faker.datatype.boolean(), + }, + ...overrideResponse, +}) + +export const getApiV2OrganizationsServiceUsageRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OrganizationServiceUsageResponse => ({ + total_nlp_usage: { + asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_submission_count: { + all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + balances: { + submission: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + storage_bytes: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + asr_seconds: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + mt_characters: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + llm_requests: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + }, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + ...overrideResponse, +}) + +export const getApiV2ProjectViewsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectViewListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 32 } }), + name: faker.internet.url(), + url: faker.internet.url(), + assets: faker.internet.url(), + assets_export: faker.internet.url(), + users: faker.internet.url(), + users_export: faker.internet.url(), + countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ProjectViewListResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 32 } }), + name: faker.internet.url(), + url: faker.internet.url(), + assets: faker.internet.url(), + assets_export: faker.internet.url(), + users: faker.internet.url(), + users_export: faker.internet.url(), + countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsExportRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ProjectViewExportResponse => ({ + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + result: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): ProjectViewExportCreateResponse => ({ + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsAssetsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectViewAssetResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner__email: faker.internet.email(), + owner__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner__organization: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + settings: { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + has_deployment: faker.datatype.boolean(), + deployment__active: faker.datatype.boolean(), + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment_status: faker.string.alpha({ length: { min: 10, max: 20 } }), + asset_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + })), + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsAssetsCountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetListCount => ({ + deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetMinimalListList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 22 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsUsersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectViewUserResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_superuser: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_active: faker.datatype.boolean(), + email: faker.internet.email(), + asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + metadata: { + city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + project_view_settings: faker.helpers.arrayElement([ + { + my_project_view_name: faker.helpers.arrayElement([ + { + order: faker.helpers.arrayElement([{}, undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock = ( + overrideResponse: Partial = {}, +): ServiceUsageBalanceData => ({ + ...{ + effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + exceeded: faker.datatype.boolean(), + }, + ...overrideResponse, +}) + +export const getApiV2ServiceUsageListResponseMock = (): ServiceUsageResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + total_nlp_usage: { + asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_submission_count: { + all_time: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + current_period: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + balances: { + submission: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + storage_bytes: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + asr_seconds: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + mt_characters: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + llm_requests: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + }, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + })) + +export const getApiV2UsersListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedUserListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_superuser: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_active: faker.datatype.boolean(), + email: faker.internet.email(), + asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + metadata: { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + project_views_settings: faker.helpers.arrayElement([ + { + kobo_my_project: faker.helpers.arrayElement([ + { + order: faker.helpers.arrayElement([{}, undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2UsersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): UserRetrieveResponse => ({ + url: faker.internet.url(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + public_collection_subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + public_collections_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getMeRetrieveResponseMock = (overrideResponse: Partial = {}): MeListResponse => ({ + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.internet.email(), + server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + projects_url: faker.internet.url(), + gravatar: faker.internet.url(), + last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + extra_details: { + bio: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + twitter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + linkedin: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + instagram: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_views_settings: faker.helpers.arrayElement([{}, undefined]), + require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + newsletter_subscription: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + git_rev: faker.helpers.arrayElement([ + faker.datatype.boolean(), + { + short: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + long: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + branch: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + tag: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + }, + ]), + social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + email: faker.helpers.arrayElement([faker.internet.email(), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + validated_password: faker.datatype.boolean(), + accepted_tos: faker.datatype.boolean(), + organization: { + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + extra_details__uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getMePartialUpdateResponseMock = (overrideResponse: Partial = {}): MeListResponse => ({ + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.internet.email(), + server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + projects_url: faker.internet.url(), + gravatar: faker.internet.url(), + last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + extra_details: { + bio: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + twitter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + linkedin: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + instagram: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_views_settings: faker.helpers.arrayElement([{}, undefined]), + require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + newsletter_subscription: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + git_rev: faker.helpers.arrayElement([ + faker.datatype.boolean(), + { + short: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + long: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + branch: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + tag: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + }, + ]), + social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + email: faker.helpers.arrayElement([faker.internet.email(), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + validated_password: faker.datatype.boolean(), + accepted_tos: faker.datatype.boolean(), + organization: { + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + extra_details__uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getMeEmailsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedEmailAddressList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getMeEmailsCreateResponseMock = (overrideResponse: Partial = {}): EmailAddress => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + ...overrideResponse, +}) + +export const getMeSocialAccountsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedSocialAccountList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.string.alpha({ length: { min: 10, max: 200 } }), + uid: faker.string.alpha({ length: { min: 10, max: 191 } }), + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + email: faker.internet.email(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getMeSocialAccountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): SocialAccount => ({ + provider: faker.string.alpha({ length: { min: 10, max: 200 } }), + uid: faker.string.alpha({ length: { min: 10, max: 191 } }), + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + email: faker.internet.email(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetUsageListMockHandler = ( + overrideResponse?: + | PaginatedAssetUsageResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetUsageResponseList), +) => { + return http.get('*/api/v2/asset_usage/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetUsageListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsListMockHandler = ( + overrideResponse?: + | PaginatedOrganizationResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedOrganizationResponseList), +) => { + return http.get('*/api/v2/organizations/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsRetrieveMockHandler = ( + overrideResponse?: + | OrganizationResponse + | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsPartialUpdateMockHandler = ( + overrideResponse?: + | OrganizationResponse + | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), +) => { + return http.patch('*/api/v2/organizations/:uidOrganization/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsAssetUsageListMockHandler = ( + overrideResponse?: + | PaginatedCustomAssetUsageList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedCustomAssetUsageList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/asset_usage/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetUsageListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsAssetsRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetList + | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsAssetsCountsRetrieveMockHandler = ( + overrideResponse?: + | AssetListCount + | ((info: Parameters[1]>[0]) => Promise | AssetListCount), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/counts/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetsCountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetMinimalListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetMinimalListList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsInvitesListMockHandler = ( + overrideResponse?: + | PaginatedInviteResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedInviteResponseList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsInvitesCreateMockHandler = ( + overrideResponse?: + | InviteCreateResponse + | ((info: Parameters[1]>[0]) => Promise | InviteCreateResponse), +) => { + return http.post('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsInvitesRetrieveMockHandler = ( + overrideResponse?: + | InviteResponse + | ((info: Parameters[1]>[0]) => Promise | InviteResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = ( + overrideResponse?: + | InviteResponse + | ((info: Parameters[1]>[0]) => Promise | InviteResponse), +) => { + return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsInvitesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2OrganizationsMembersListMockHandler = ( + overrideResponse?: + | PaginatedMemberListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedMemberListResponseList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/members/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsMembersListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsMembersRetrieveMockHandler = ( + overrideResponse?: + | MemberListResponse + | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsMembersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsMembersPartialUpdateMockHandler = ( + overrideResponse?: + | MemberListResponse + | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), +) => { + return http.patch('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsMembersPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsMembersDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2OrganizationsServiceUsageRetrieveMockHandler = ( + overrideResponse?: + | OrganizationServiceUsageResponse + | (( + info: Parameters[1]>[0], + ) => Promise | OrganizationServiceUsageResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/service_usage/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsServiceUsageRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsListMockHandler = ( + overrideResponse?: + | PaginatedProjectViewListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectViewListResponseList), +) => { + return http.get('*/api/v2/project-views/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsRetrieveMockHandler = ( + overrideResponse?: + | ProjectViewListResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectViewListResponse), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsExportRetrieveMockHandler = ( + overrideResponse?: + | ProjectViewExportResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectViewExportResponse), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsExportRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsExportCreateMockHandler = ( + overrideResponse?: + | ProjectViewExportCreateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectViewExportCreateResponse), +) => { + return http.post('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsExportCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsAssetsRetrieveMockHandler = ( + overrideResponse?: + | PaginatedProjectViewAssetResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectViewAssetResponseList), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsAssetsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsAssetsCountsRetrieveMockHandler = ( + overrideResponse?: + | AssetListCount + | ((info: Parameters[1]>[0]) => Promise | AssetListCount), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/counts/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsAssetsCountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetMinimalListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetMinimalListList), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsUsersRetrieveMockHandler = ( + overrideResponse?: + | PaginatedProjectViewUserResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectViewUserResponseList), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/users/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsUsersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ServiceUsageListMockHandler = ( + overrideResponse?: + | ServiceUsageResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | ServiceUsageResponse[]), +) => { + return http.get('*/api/v2/service_usage/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ServiceUsageListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2UsersListMockHandler = ( + overrideResponse?: + | PaginatedUserListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedUserListResponseList), +) => { + return http.get('*/api/v2/users/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2UsersListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2UsersRetrieveMockHandler = ( + overrideResponse?: + | UserRetrieveResponse + | ((info: Parameters[1]>[0]) => Promise | UserRetrieveResponse), +) => { + return http.get('*/api/v2/users/:username/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2UsersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeRetrieveMockHandler = ( + overrideResponse?: + | MeListResponse + | ((info: Parameters[1]>[0]) => Promise | MeListResponse), +) => { + return http.get('*/me/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMePartialUpdateMockHandler = ( + overrideResponse?: + | MeListResponse + | ((info: Parameters[1]>[0]) => Promise | MeListResponse), +) => { + return http.patch('*/me/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMePartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/me/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getMeEmailsListMockHandler = ( + overrideResponse?: + | PaginatedEmailAddressList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedEmailAddressList), +) => { + return http.get('*/me/emails/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeEmailsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeEmailsCreateMockHandler = ( + overrideResponse?: + | EmailAddress + | ((info: Parameters[1]>[0]) => Promise | EmailAddress), +) => { + return http.post('*/me/emails/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeEmailsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeSocialAccountsListMockHandler = ( + overrideResponse?: + | PaginatedSocialAccountList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedSocialAccountList), +) => { + return http.get('*/me/social-accounts/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeSocialAccountsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeSocialAccountsRetrieveMockHandler = ( + overrideResponse?: + | SocialAccount + | ((info: Parameters[1]>[0]) => Promise | SocialAccount), +) => { + return http.get('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { + await delay(1000) + + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeSocialAccountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeSocialAccountsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { + await delay(1000) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} +export const getUserTeamOrganizationUsageMock = () => [ + getApiV2AssetUsageListMockHandler(), + getApiV2OrganizationsListMockHandler(), + getApiV2OrganizationsRetrieveMockHandler(), + getApiV2OrganizationsPartialUpdateMockHandler(), + getApiV2OrganizationsAssetUsageListMockHandler(), + getApiV2OrganizationsAssetsRetrieveMockHandler(), + getApiV2OrganizationsAssetsCountsRetrieveMockHandler(), + getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler(), + getApiV2OrganizationsInvitesListMockHandler(), + getApiV2OrganizationsInvitesCreateMockHandler(), + getApiV2OrganizationsInvitesRetrieveMockHandler(), + getApiV2OrganizationsInvitesPartialUpdateMockHandler(), + getApiV2OrganizationsInvitesDestroyMockHandler(), + getApiV2OrganizationsMembersListMockHandler(), + getApiV2OrganizationsMembersRetrieveMockHandler(), + getApiV2OrganizationsMembersPartialUpdateMockHandler(), + getApiV2OrganizationsMembersDestroyMockHandler(), + getApiV2OrganizationsServiceUsageRetrieveMockHandler(), + getApiV2ProjectViewsListMockHandler(), + getApiV2ProjectViewsRetrieveMockHandler(), + getApiV2ProjectViewsExportRetrieveMockHandler(), + getApiV2ProjectViewsExportCreateMockHandler(), + getApiV2ProjectViewsAssetsRetrieveMockHandler(), + getApiV2ProjectViewsAssetsCountsRetrieveMockHandler(), + getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler(), + getApiV2ProjectViewsUsersRetrieveMockHandler(), + getApiV2ServiceUsageListMockHandler(), + getApiV2UsersListMockHandler(), + getApiV2UsersRetrieveMockHandler(), + getMeRetrieveMockHandler(), + getMePartialUpdateMockHandler(), + getMeDestroyMockHandler(), + getMeEmailsListMockHandler(), + getMeEmailsCreateMockHandler(), + getMeSocialAccountsListMockHandler(), + getMeSocialAccountsRetrieveMockHandler(), + getMeSocialAccountsDestroyMockHandler(), +] diff --git a/jsapp/js/assetUtils.tests.js b/jsapp/js/assetUtils.tests.js index c98248b070..e0d516ab32 100644 --- a/jsapp/js/assetUtils.tests.js +++ b/jsapp/js/assetUtils.tests.js @@ -26,7 +26,10 @@ jest.mock('#/api/react-query/user-team-organization-usage', () => ({ import { MemberRoleEnum } from '#/api/models/memberRoleEnum' import { DeleteBlockerReason, getSurveyFlatPaths, userCanDeleteAssets } from '#/assetUtils' import { surveyWithAllPossibleGroups, surveyWithGroups } from '#/assetUtils.mocks' -import assetFactory from '#/endpoints/asset.factory' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' + +// Helper wrapper for legacy test code +const assetFactory = (overrides) => getApiV2AssetsRetrieveResponseMock(overrides) describe('getSurveyFlatPaths', () => { it('should return a list of paths for all questions', () => { diff --git a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx index dfc602efe0..de6604eb6c 100644 --- a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx +++ b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx @@ -3,17 +3,20 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { expect, fn, userEvent, waitFor, within } from 'storybook/test' import ButtonNew from '#/components/common/ButtonNew' import type { AssetResponse } from '#/dataInterface' -import assetFactory from '#/endpoints/asset.factory' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import { assetPatchMock } from '#/endpoints/asset.mocks' import { queryClientDecorator } from '#/query/queryClient.mocks' import { KOBO_MODAL_SHARED_PROPS } from '#/theme/kobo/Modal' import { openAssetTagsModal } from './openAssetTagsModal' -const mockAsset = assetFactory({ +// TODO DEV-XXXX: Improve backend OpenAPI schema for Asset +// - Make date_created and date_modified required (they're auto-populated by Django) +// This cast is safe because the types are compatible at runtime +const mockAsset = getApiV2AssetsRetrieveResponseMock({ uid: 'storyAssetTagsUid', name: 'Storybook Asset Tags', tag_string: 'alpha,beta', -}) +}) as AssetResponse const mockAssetUid = mockAsset.uid const onAssetPatched = fn() diff --git a/jsapp/js/components/activity/FormActivity.stories.tsx b/jsapp/js/components/activity/FormActivity.stories.tsx index cf2c6e6d4f..c3c6b4e3af 100644 --- a/jsapp/js/components/activity/FormActivity.stories.tsx +++ b/jsapp/js/components/activity/FormActivity.stories.tsx @@ -5,7 +5,7 @@ import assetHistoryMock, { assetHistoryMockWithOngoingBulkProcessing, mockAssetUid, } from '#/endpoints/assetHistory.mocks' -import assetHistoryActionsMock from '#/endpoints/assetHistoryActions.mocks' +import { getApiV2AssetsHistoryActionsRetrieveMockHandler } from '#/api/react-query/logging' import { bulkActionCancelMock } from '#/endpoints/bulkActions.mocks' import { queryClientDecorator } from '#/query/queryClient.mocks' import { ROUTES } from '#/router/routerConstants' @@ -17,7 +17,22 @@ const meta: Meta = { argTypes: {}, parameters: { msw: { - handlers: [assetHistoryMock, assetHistoryActionsMock], + handlers: [ + assetHistoryMock, + getApiV2AssetsHistoryActionsRetrieveMockHandler({ + actions: [ + 'bulk-processing', + 'disallow-anonymous-submissions', + 'add-media', + 'add-submission', + 'allow-anonymous-submissions', + 'modify-user-permissions', + 'update-content', + 'deploy', + 'delete-submission', + ], + }), + ], }, reactRouter: reactRouterParameters({ location: { @@ -71,7 +86,23 @@ export const TestFilteringByActivityType: Story = { export const OngoingBulkProcessing: Story = { parameters: { msw: { - handlers: [assetHistoryMockWithOngoingBulkProcessing, assetHistoryActionsMock, bulkActionCancelMock], + handlers: [ + assetHistoryMockWithOngoingBulkProcessing, + getApiV2AssetsHistoryActionsRetrieveMockHandler({ + actions: [ + 'bulk-processing', + 'disallow-anonymous-submissions', + 'add-media', + 'add-submission', + 'allow-anonymous-submissions', + 'modify-user-permissions', + 'update-content', + 'deploy', + 'delete-submission', + ], + }), + bulkActionCancelMock, + ], }, }, } diff --git a/jsapp/js/components/map/FormMapWrapper.stories.tsx b/jsapp/js/components/map/FormMapWrapper.stories.tsx index 8f0b75b4de..07deee0e58 100644 --- a/jsapp/js/components/map/FormMapWrapper.stories.tsx +++ b/jsapp/js/components/map/FormMapWrapper.stories.tsx @@ -4,8 +4,8 @@ import { reactRouterParameters, withRouter } from 'storybook-addon-remix-react-r import { expect, waitFor, within } from 'storybook/test' import { endpoints } from '#/api.endpoints' import { MetaQuestionTypeName, QuestionTypeName } from '#/constants' -import type { PaginatedResponse, SubmissionResponse } from '#/dataInterface' -import assetFactory from '#/endpoints/asset.factory' +import type { AssetResponse, PaginatedResponse, SubmissionResponse } from '#/dataInterface' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import assetDataFactory from '#/endpoints/assetData.factory' import { queryClientDecorator } from '#/query/queryClient.mocks' import { ROUTES } from '#/router/routerConstants' @@ -14,8 +14,12 @@ import FormMapWrapper from './formMapWrapper' const mockAssetUid = 'aTestMapAssetUid123' +// TODO DEV-XXXX: Improve backend OpenAPI schema for Asset +// - Make date_created and date_modified required (they're auto-populated by Django) +// These casts are safe because the types are compatible at runtime + // Asset with only start-geopoint (no regular geopoint question) -const assetWithOnlyStartGeopoint = assetFactory({ +const assetWithOnlyStartGeopoint = getApiV2AssetsRetrieveResponseMock({ uid: mockAssetUid, name: 'Test Form with Start-Geopoint Only', deployment__active: true, @@ -30,7 +34,7 @@ const assetWithOnlyStartGeopoint = assetFactory({ languages: [], row_count: 2, name_quality: { ok: 2, bad: 0, good: 0, total: 2, firsts: {} }, - default_translation: null, + default_translation: undefined, }, content: { survey: [ @@ -49,10 +53,10 @@ const assetWithOnlyStartGeopoint = assetFactory({ ], choices: [], }, -}) +}) as AssetResponse // Asset with both start-geopoint AND regular geopoint -const assetWithBothGeopointTypes = assetFactory({ +const assetWithBothGeopointTypes = getApiV2AssetsRetrieveResponseMock({ uid: mockAssetUid, name: 'Test Form with Both Geopoint Types', deployment__active: true, @@ -67,7 +71,7 @@ const assetWithBothGeopointTypes = assetFactory({ languages: [], row_count: 3, name_quality: { ok: 3, bad: 0, good: 0, total: 3, firsts: {} }, - default_translation: null, + default_translation: undefined, }, content: { survey: [ @@ -93,7 +97,7 @@ const assetWithBothGeopointTypes = assetFactory({ ], choices: [], }, -}) +}) as AssetResponse // Submission data with populated start-geopoint const submissionsWithStartGeopoint: SubmissionResponse[] = [ diff --git a/jsapp/js/components/reports/reports.utils.tests.ts b/jsapp/js/components/reports/reports.utils.tests.ts index adf0610116..1abfdfce5c 100644 --- a/jsapp/js/components/reports/reports.utils.tests.ts +++ b/jsapp/js/components/reports/reports.utils.tests.ts @@ -1,6 +1,7 @@ import chai from 'chai' import { QuestionTypeName } from '#/constants' -import assetFactory from '#/endpoints/asset.factory' +import type { AssetResponse } from '#/dataInterface' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import { reportStyleFactory, reportsResponseDataFactory } from './reports.factory' import { buildEffectiveReportStyle, getEffectiveRowReportStyle, populateSelectQuestionLabels } from './reports.utils' import type { ReportsResponse } from './reportsConstants' @@ -134,7 +135,9 @@ describe('populateSelectQuestionLabels', () => { style: reportStyleFactory(), } - const asset = assetFactory({ + // TODO DEV-XXXX: Improve backend OpenAPI schema for Asset + // - Make date_created and date_modified required (they're auto-populated by Django) + const asset = getApiV2AssetsRetrieveResponseMock({ content: { survey: [ { @@ -161,7 +164,7 @@ describe('populateSelectQuestionLabels', () => { }, ], }, - }) + }) as AssetResponse populateSelectQuestionLabels(row, asset, 1) diff --git a/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx b/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx index ffafc585de..36eb53896e 100644 --- a/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx +++ b/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx @@ -1,15 +1,39 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { withRouter } from 'storybook-addon-remix-react-router' -import bulkActionFactory from '#/endpoints/bulkAction.factory' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' import BulkProcessingBanner from './BulkProcessingBanner' import { withBulkProcessingBannerSessionReset } from './BulkProcessingBannerStoriesUtils' -const singleJobByCurrentUser = [bulkActionFactory('uuid-1', 'en', { created_by: { username: 'storybook-user' } })] -const singleJobByAnotherUser = [bulkActionFactory('uuid-1', 'en', { created_by: { username: 'other-user' } })] +const singleJobByCurrentUser = [ + getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ + submission_uuids: ['uuid-1'], + params: { language: 'en' }, + created_by: { username: 'storybook-user' }, + }), +] +const singleJobByAnotherUser = [ + getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ + submission_uuids: ['uuid-1'], + params: { language: 'en' }, + created_by: { username: 'other-user' }, + }), +] const multipleJobs = [ - bulkActionFactory('uuid-1', 'en', { created_by: { username: 'storybook-user' } }), - bulkActionFactory('uuid-2', 'fr', { created_by: { username: 'other-user' } }), - bulkActionFactory('uuid-3', 'es', { created_by: { username: 'another-user' } }), + getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ + submission_uuids: ['uuid-1'], + params: { language: 'en' }, + created_by: { username: 'storybook-user' }, + }), + getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ + submission_uuids: ['uuid-2'], + params: { language: 'fr' }, + created_by: { username: 'other-user' }, + }), + getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ + submission_uuids: ['uuid-3'], + params: { language: 'es' }, + created_by: { username: 'another-user' }, + }), ] const meta: Meta = { title: 'Components/BulkProcessingBanner', diff --git a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx index bc0ed89394..2dcf0bcbdf 100644 --- a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx +++ b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx @@ -16,11 +16,14 @@ import { actions } from '#/actions' import { ActionIdEnum } from '#/api/models/actionIdEnum' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' import { QuestionTypeName } from '#/constants' -import assetFactory from '#/endpoints/asset.factory' -import assetMock from '#/endpoints/asset.mocks' +import type { AssetResponse } from '#/dataInterface' +import { + getApiV2AssetsRetrieveResponseMock, + getApiV2AssetsRetrieveMockHandler, +} from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' import assetDataFactory from '#/endpoints/assetData.factory' import assetDataMock from '#/endpoints/assetData.mocks' -import bulkActionFactory from '#/endpoints/bulkAction.factory' import bulkActionsMock from '#/endpoints/bulkActions.mocks' import meMock from '#/endpoints/me.mocks' import organizationMock from '#/endpoints/organization.mocks' @@ -39,6 +42,11 @@ import { resetPollingUpdateStoryHandlers, } from './DataTableWrapperPollingStoriesUtils' +// TODO DEV-XXXX: Improve backend OpenAPI schema for Asset +// - Make date_created and date_modified required (they're auto-populated by Django) +// - Fix analysis_form_json.additional_fields type (should be object[], not string[]) +// These casts are safe because the types are compatible at runtime + // Storybook preview root does not have a fixed height by default, which breaks flexbox stretching for table header // cells. By adding a wrapper with a fixed height to the story, we ensure that `.rt-tr` and `.rt-th` flex children can // stretch to fill the row height — just like in the real UI. @@ -145,7 +153,7 @@ const getRouterParams = (assetUid: string) => // Minimal asset and submissions for simple stories // Default story asset and submissions -const minimalAsset = assetFactory({ +const minimalAsset = getApiV2AssetsRetrieveResponseMock({ uid: 'audio-asset-uid', name: 'Audio form', content: { @@ -165,7 +173,8 @@ const minimalAsset = assetFactory({ translations: [null], }, effective_permissions: [{ codename: 'change_submissions' }], -}) +}) as AssetResponse + const minimalSubmissions = [ assetDataFactory(1, { Record_a_sound: 'test1.mp3', @@ -198,7 +207,7 @@ const minimalSubmissions = [ ] // ProcessingColumn story asset and submissions (unique UID) -const processingAsset = assetFactory({ +const processingAsset = getApiV2AssetsRetrieveResponseMock({ uid: 'audio-asset-uid-processing', name: 'Audio form with processing', content: { @@ -243,7 +252,8 @@ const processingAsset = assetFactory({ ], }, effective_permissions: [{ codename: 'change_submissions' }], -}) +}) as AssetResponse + const processingSubmissions = [ assetDataFactory(1, { Record_a_sound: 'test1.mp3', @@ -309,18 +319,22 @@ const processingSubmissions = [ ], }), ] -const processingBulkAction = bulkActionFactory(processingSubmissions[1]['meta/rootUuid'], 'fr', { +const processingBulkAction = getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ status: BulkActionResponseStatusEnum.complete, action_id: ActionIdEnum.automatic_google_translation, question_xpath: 'Record_a_sound', + submission_uuids: [processingSubmissions[1]['meta/rootUuid']], + params: { language: 'fr' }, created_by: { username: 'zefir', }, }) -const processingBulkAction2 = bulkActionFactory(processingSubmissions[2]['meta/rootUuid'], 'es', { +const processingBulkAction2 = getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ status: BulkActionResponseStatusEnum.in_progress, action_id: ActionIdEnum.automatic_google_translation, question_xpath: 'Record_a_sound', + submission_uuids: [processingSubmissions[2]['meta/rootUuid']], + params: { language: 'es' }, created_by: { username: 'other-user', }, @@ -347,7 +361,7 @@ const meta: Meta = { msw: { handlers: [ meMock, - assetMock(minimalAsset.uid, minimalAsset), + getApiV2AssetsRetrieveMockHandler(minimalAsset), assetDataMock(minimalAsset.uid, minimalSubmissions), organizationMock(), organizationServiceUsageMock(), @@ -374,7 +388,7 @@ export const Default: Story = { msw: { handlers: [ meMock, - assetMock(minimalAsset.uid, minimalAsset), + getApiV2AssetsRetrieveMockHandler(minimalAsset), assetDataMock(minimalAsset.uid, minimalSubmissions), organizationMock(), organizationServiceUsageMock(), @@ -396,7 +410,7 @@ export const ProcessingColumnAndBanner: Story = { msw: { handlers: [ meMock, - assetMock(processingAsset.uid, processingAsset), + getApiV2AssetsRetrieveMockHandler(processingAsset), assetDataMock(processingAsset.uid, processingSubmissions), organizationMock(), organizationServiceUsageMock(), @@ -454,7 +468,7 @@ export const ProcessingAndLimitsBannersTogether: Story = { msw: { handlers: [ meMock, - assetMock(processingAsset.uid, processingAsset), + getApiV2AssetsRetrieveMockHandler(processingAsset), assetDataMock(processingAsset.uid, processingSubmissions), organizationMock(), // Shows both BulkProcessingBanner (active jobs) + OverLimitBanner (exceeded submission limit) @@ -479,7 +493,7 @@ export const StorageLimitWarningBanner: Story = { msw: { handlers: [ meMock, - assetMock(minimalAsset.uid, minimalAsset), + getApiV2AssetsRetrieveMockHandler(minimalAsset), assetDataMock(minimalAsset.uid, minimalSubmissions), organizationMock(), organizationServiceUsageMock(undefined, organizationServiceUsageFactory.storageWarning()), @@ -501,7 +515,7 @@ export const StorageExceededBanner: Story = { msw: { handlers: [ meMock, - assetMock(minimalAsset.uid, minimalAsset), + getApiV2AssetsRetrieveMockHandler(minimalAsset), assetDataMock(minimalAsset.uid, minimalSubmissions), organizationMock(), organizationServiceUsageMock(undefined, organizationServiceUsageFactory.storageExceeded()), @@ -523,7 +537,7 @@ export const SubmissionExceededBanner: Story = { msw: { handlers: [ meMock, - assetMock(minimalAsset.uid, minimalAsset), + getApiV2AssetsRetrieveMockHandler(minimalAsset), assetDataMock(minimalAsset.uid, minimalSubmissions), organizationMock(), organizationServiceUsageMock(undefined, organizationServiceUsageFactory.submissionExceeded()), @@ -545,7 +559,7 @@ export const StorageAndSubmissionExceededBanner: Story = { msw: { handlers: [ meMock, - assetMock(minimalAsset.uid, minimalAsset), + getApiV2AssetsRetrieveMockHandler(minimalAsset), assetDataMock(minimalAsset.uid, minimalSubmissions), organizationMock(), organizationServiceUsageMock(undefined, organizationServiceUsageFactory.bothExceeded()), diff --git a/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx b/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx index ad786f5ea8..0ff1af5dde 100644 --- a/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx +++ b/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx @@ -4,10 +4,13 @@ import { ActionIdEnum } from '#/api/models/actionIdEnum' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' import { BulkActionSubmissionStatusResponseStatusEnum } from '#/api/models/bulkActionSubmissionStatusResponseStatusEnum' import { QuestionTypeName } from '#/constants' -import assetFactory from '#/endpoints/asset.factory' -import assetMock from '#/endpoints/asset.mocks' +import type { AssetResponse } from '#/dataInterface' +import { + getApiV2AssetsRetrieveResponseMock, + getApiV2AssetsRetrieveMockHandler, +} from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' import assetDataFactory from '#/endpoints/assetData.factory' -import bulkActionFactory from '#/endpoints/bulkAction.factory' import meMock from '#/endpoints/me.mocks' import organizationMock from '#/endpoints/organization.mocks' import organizationServiceUsageMock from '#/endpoints/organizationServiceUsage.mocks' @@ -23,9 +26,14 @@ const POLLING_STORY_ASSERTION_GRACE_MS = 6000 // enough time to actually render the "Processing" cell before completion fires. const POLLING_COMPLETE_AFTER_MS = 2000 +// TODO DEV-XXXX: Improve backend OpenAPI schema for Asset +// - Make date_created and date_modified required (they're auto-populated by Django) +// - Fix analysis_form_json.additional_fields type (should be object[], not string[]) +// This cast is safe because the types are compatible at runtime + // Dedicated polling story data is kept in a separate file so the main stories // file remains easy to scan as more table scenarios get added. -export const pollingAsset = assetFactory({ +export const pollingAsset = getApiV2AssetsRetrieveResponseMock({ uid: 'audio-asset-uid-polling', name: 'Audio form with polling update', // The backend writes analysis_form_json when a bulk action is created, so @@ -62,7 +70,7 @@ export const pollingAsset = assetFactory({ translations: [null], }, effective_permissions: [{ codename: 'change_submissions' }], -}) +}) as AssetResponse const pollingSubmissionInitial = assetDataFactory(11, { Record_a_sound: 'test11.mp3', @@ -104,11 +112,13 @@ const pollingSubmissionUpdated = assetDataFactory(11, { ], }) -const pollingBulkActionInProgress = bulkActionFactory(pollingSubmissionInitial['meta/rootUuid'], 'es', { +const pollingBulkActionInProgress = getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ uid: 'polling-bulk-action', status: BulkActionResponseStatusEnum.in_progress, action_id: ActionIdEnum.automatic_google_translation, question_xpath: 'Record_a_sound', + submission_uuids: [pollingSubmissionInitial['meta/rootUuid']], + params: { language: 'es' }, submission_statuses: [ { uuid: pollingSubmissionInitial['meta/rootUuid'], @@ -118,11 +128,13 @@ const pollingBulkActionInProgress = bulkActionFactory(pollingSubmissionInitial[' ], }) -const pollingBulkActionComplete = bulkActionFactory(pollingSubmissionInitial['meta/rootUuid'], 'es', { +const pollingBulkActionComplete = getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ uid: 'polling-bulk-action', status: BulkActionResponseStatusEnum.complete, action_id: ActionIdEnum.automatic_google_translation, question_xpath: 'Record_a_sound', + submission_uuids: [pollingSubmissionInitial['meta/rootUuid']], + params: { language: 'es' }, submission_statuses: [ { uuid: pollingSubmissionInitial['meta/rootUuid'], @@ -160,7 +172,7 @@ export function getPollingUpdateStoryTimeoutMs() { export function getPollingUpdateStoryHandlers() { return [ meMock, - assetMock(pollingAsset.uid, pollingAsset), + getApiV2AssetsRetrieveMockHandler(pollingAsset), organizationMock(), organizationServiceUsageMock(), http.get, never>(endpoints.ASSET_ADVANCED_FEATURES_BULK_ACTIONS, ({ params }) => { diff --git a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts index eb4d8a43e4..a38a5f6942 100644 --- a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts +++ b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts @@ -2,11 +2,11 @@ import { renderHook } from '@testing-library/react' import { ActionIdEnum } from '#/api/models/actionIdEnum' import type { BulkActionResponse } from '#/api/models/bulkActionResponse' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' +import { BulkActionSubmissionStatusResponseStatusEnum } from '#/api/models/bulkActionSubmissionStatusResponseStatusEnum' import { getAssetsAdvancedFeaturesBulkActionsListQueryKey, useAssetsAdvancedFeaturesBulkActionsList, } from '#/api/react-query/survey-data' -import bulkActionFactory from '#/endpoints/bulkAction.factory' import { useFeatureFlag } from '#/featureFlags' import { useSession } from '#/stores/useSession' import { getBulkActionsPollingIntervalMs, useDataTableBulkActions } from './useDataTableBulkActions' @@ -47,18 +47,38 @@ jest.mock('#/envStore', () => { } }) +// Inline factory to avoid importing from mocked module function buildBulkAction( status: BulkActionResponseStatusEnum, createdByUsername: string, overrides: Partial = {}, ): BulkActionResponse { - // Reuse shared factory defaults, overriding only fields relevant to this hook. - return bulkActionFactory('submission-1', 'fr', { + const { progress = 0, ...restOverrides } = overrides + + return { uid: `bulk-${status}-${createdByUsername}`, status, - created_by: { username: createdByUsername }, - ...overrides, - }) + action_id: ActionIdEnum.automatic_google_transcription, + question_xpath: 'Your_name', + submission_uuids: ['submission-1'], + submission_statuses: [ + { + uuid: 'submission-1', + status: BulkActionSubmissionStatusResponseStatusEnum.in_progress, + error: null, + }, + ], + params: { + language: 'fr', + }, + progress, + created_by: { + username: createdByUsername, + }, + date_created: '2026-01-01T00:00:00Z', + date_modified: '2026-01-01T00:00:00Z', + ...restOverrides, + } } describe('useDataTableBulkActions', () => { diff --git a/jsapp/js/endpoints/asset.factory.ts b/jsapp/js/endpoints/asset.factory.ts deleted file mode 100644 index f29f9a3865..0000000000 --- a/jsapp/js/endpoints/asset.factory.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Factory for minimal AssetResponse with audio question and transcript support -import { AssetTypeName } from '#/constants' -import type { AssetResponse } from '#/dataInterface' - -/** - * Creates a minimal AssetResponse for a form with no questions - * @param overrides - For overriding any property of the asset - */ -export default function assetFactory(overrides: Partial = {}): AssetResponse { - return { - url: '', - owner: '', - owner__username: '', - owner_label: '', - last_modified_by: null, - created_by: null, - date_created: '', - summary: {}, - date_modified: '', - version_id: null, - has_deployment: false, - deployed_version_id: null, - deployment__active: false, - deployment__submission_count: 0, - deployment_status: 'deployed', - downloads: [], - uid: 'mock-asset-uid', - kind: 'form', - assignable_permissions: [], - effective_permissions: [], - data: '', - children: { count: 0 }, - content: { - survey: [], - choices: [], - }, - subscribers_count: 0, - status: '', - access_types: null, - project_ownership: null, - parent: null, - settings: {}, - asset_type: AssetTypeName.survey, - report_styles: { default: {}, specified: {}, kuid_names: {} }, - report_custom: {}, - map_styles: {}, - map_custom: {}, - tag_string: '', - name: 'Test form', - permissions: [], - export_settings: [], - data_sharing: {}, - files: [], - ...overrides, - } -} diff --git a/jsapp/js/endpoints/asset.mocks.ts b/jsapp/js/endpoints/asset.mocks.ts index ceae9e9795..9886c412a8 100644 --- a/jsapp/js/endpoints/asset.mocks.ts +++ b/jsapp/js/endpoints/asset.mocks.ts @@ -1,6 +1,5 @@ import { http, HttpResponse } from 'msw' import { endpoints } from '#/api.endpoints' -import { AssetTypeName, QuestionTypeName } from '#/constants' import type { AssetResponse } from '#/dataInterface' interface AssetPatchMockOptions { @@ -14,24 +13,11 @@ interface AssetPatchMockOptions { // not leak mutations into the next render. const cloneAsset = (asset: AssetResponse): AssetResponse => JSON.parse(JSON.stringify(asset)) as AssetResponse -/** - * Mock API for single asset detail. Use in Storybook tests in `parameters.msw.handlers.asset`. - * - * Usage: assetMock() for default, or assetMock({ name: 'override' }) for custom. - */ -const assetMock = (assetUid: string, override?: Partial) => - http.get(endpoints.ASSET_URL, ({ params }) => { - // Only respond for the correct assetUid - if (params.uid !== assetUid) return undefined - return HttpResponse.json({ - ...defaultMockResponse, - ...override, - uid: params.uid || override?.uid || defaultMockResponse.uid, - }) - }) - /** * Builds a reusable PATCH handler for single-asset stories while keeping the in-memory asset mutable. + * + * This custom handler is kept because it has stateful logic that Orval cannot generate. + * For simple GET requests, use getApiV2AssetsRetrieveMockHandler from Orval instead. */ export const assetPatchMock = ({ asset, @@ -62,187 +48,3 @@ export const assetPatchMock = ({ return HttpResponse.json(responseAsset) }) } - -/** - * Provides a realistic asset detail payload for stories that only need one asset instance. - */ -export const defaultMockResponse: AssetResponse = { - url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/', - owner: 'http://kf.kobo.local/api/v2/users/zefir/', - owner__username: 'zefir', - parent: null, - settings: { - sector: {}, - country: [], - description: '', - collects_pii: null, - organization: '', - country_codes: [], - operational_purpose: null, - }, - asset_type: AssetTypeName.survey, - files: [], - summary: { - geo: false, - labels: ['Your name'], - columns: ['type', 'label', 'required'], - lock_all: false, - lock_any: false, - languages: [], - row_count: 1, - name_quality: { - ok: 1, - bad: 0, - good: 0, - total: 1, - firsts: { ok: { name: 'Your_name', index: 1, label: ['Your name'] } }, - }, - default_translation: null, - }, - date_created: '2025-09-09T21:08:44.296979Z', - date_modified: '2025-09-09T21:09:04.827003Z', - version_id: 'vt8TMvyLRCyv26nQLcbGBi', - version__content_hash: '822573fdb551228b65ef80359b4499e62421adde', - version_count: 3, - has_deployment: false, - deployed_version_id: null, - deployed_versions: { count: 0, next: null, previous: null, results: [] }, - deployment__links: {}, - deployment__active: false, - deployment__submission_count: 0, - deployment_status: 'draft', - report_styles: { default: {}, specified: { wb1gg11: {} }, kuid_names: { wb1gg11: 'wb1gg11' } }, - report_custom: {}, - advanced_features: {}, - analysis_form_json: { additional_fields: [] }, - map_styles: {}, - map_custom: {}, - content: { - schema: '1', - survey: [ - { - type: QuestionTypeName.text, - $kuid: 'wb1gg11', - label: ['Your name'], - $xpath: 'Your_name', - required: false, - $autoname: 'Your_name', - }, - ], - settings: {}, - translated: ['label'], - translations: [null], - }, - downloads: [ - { format: 'xls', url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5.xls' }, - { format: 'xml', url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5.xml' }, - ], - embeds: [ - { format: 'xls', url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/xls/' }, - { format: 'xform', url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/xform/' }, - ], - xform_link: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/xform/', - hooks_link: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/hooks/', - tag_string: '', - uid: 'abam8JiJ3hHTW3EYp6Tpb5', - kind: 'asset', - xls_link: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/xls/', - name: 'minimal asset first', - assignable_permissions: [ - { url: 'http://kf.kobo.local/api/v2/permissions/view_asset/', label: 'View form' }, - { url: 'http://kf.kobo.local/api/v2/permissions/change_asset/', label: 'Edit form' }, - { url: 'http://kf.kobo.local/api/v2/permissions/manage_asset/', label: 'Manage project' }, - { url: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', label: 'Add submissions' }, - { url: 'http://kf.kobo.local/api/v2/permissions/view_submissions/', label: 'View submissions' }, - { - url: 'http://kf.kobo.local/api/v2/permissions/partial_submissions/', - label: { - default: 'Act on submissions only from specific users', - view_submissions: 'View submissions only from specific users', - change_submissions: 'Edit submissions only from specific users', - delete_submissions: 'Delete submissions only from specific users', - validate_submissions: 'Validate submissions only from specific users', - }, - }, - { url: 'http://kf.kobo.local/api/v2/permissions/change_submissions/', label: 'Edit submissions' }, - { url: 'http://kf.kobo.local/api/v2/permissions/delete_submissions/', label: 'Delete submissions' }, - { url: 'http://kf.kobo.local/api/v2/permissions/validate_submissions/', label: 'Validate submissions' }, - ], - permissions: [ - { - url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/permission-assignments/pvSrj5oiVFK2VrhNRXt2yr/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/permission-assignments/p9UxbrXnf9KEWfEZdKfy49/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/change_asset/', - label: 'Edit form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/permission-assignments/pmSFAQG4Zji9bxit9McKPY/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/change_submissions/', - label: 'Edit submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/permission-assignments/pZTZtbdNcV4yQ9CMAB7BKo/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/delete_submissions/', - label: 'Delete submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/permission-assignments/pSfM5nnZ4F4i32pwzQxtz9/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/manage_asset/', - label: 'Manage project', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/permission-assignments/pnZXygNRi4subXAeBTZuux/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/validate_submissions/', - label: 'Validate submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/permission-assignments/pxbya4pDjbLY7pY4QSNxMU/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/view_asset/', - label: 'View form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/permission-assignments/phL46hRUcpycdP55e7YYGF/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/view_submissions/', - label: 'View submissions', - }, - ], - effective_permissions: [ - { codename: 'change_metadata_asset' }, - { codename: 'change_asset' }, - { codename: 'validate_submissions' }, - { codename: 'manage_asset' }, - { codename: 'delete_submissions' }, - { codename: 'delete_asset' }, - { codename: 'view_asset' }, - { codename: 'view_submissions' }, - { codename: 'change_submissions' }, - { codename: 'add_submissions' }, - ], - exports: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/exports/', - export_settings: [], - data: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/data/', - children: { count: 0 }, - subscribers_count: 0, - status: 'private', - access_types: null, - data_sharing: {}, - paired_data: 'http://kf.kobo.local/api/v2/assets/abam8JiJ3hHTW3EYp6Tpb5/paired-data/', - project_ownership: null, - owner_label: "zefir's MMO organization", - last_modified_by: 'zefir', - created_by: null, -} - -export default assetMock diff --git a/jsapp/js/endpoints/assetData.factory.ts b/jsapp/js/endpoints/assetData.factory.ts index 3b1d7d34a6..a149e407b0 100644 --- a/jsapp/js/endpoints/assetData.factory.ts +++ b/jsapp/js/endpoints/assetData.factory.ts @@ -3,6 +3,12 @@ import type { SubmissionResponse } from '#/dataInterface' /** * Creates a minimal SubmissionResponse for a form with no questions. + * + * Note: NOT migrated to Orval because SubmissionResponse is a legacy type + * defined in dataInterface.ts, not in the OpenAPI schema. It represents + * dynamic form submission data with arbitrary question fields, which cannot + * be statically typed in OpenAPI/Orval. + * * @param testId - Id of the submission * @param overrides - For overriding any property of the submission */ diff --git a/jsapp/js/endpoints/assetData.mocks.ts b/jsapp/js/endpoints/assetData.mocks.ts index b7d4b98351..4b1f6eaa3b 100644 --- a/jsapp/js/endpoints/assetData.mocks.ts +++ b/jsapp/js/endpoints/assetData.mocks.ts @@ -6,6 +6,12 @@ import assetDataFactory from './assetData.factory' /** * MSW handler factory for /api/v2/assets/:uid/data/ endpoint. * Returns a paginated response with one submission, unless overriden. + * + * Note: NOT migrated to Orval because SubmissionResponse is a legacy type + * representing dynamic form submission data. This mock uses assetData.factory.ts + * which cannot be replaced with Orval since submission data has arbitrary fields + * based on form questions (not statically typed in OpenAPI). + * * @param assetUid * @param submissions - A list of `SubmissionResponse`s to be returned * @param override - Optional override for the paginated response diff --git a/jsapp/js/endpoints/assetHistory.mocks.ts b/jsapp/js/endpoints/assetHistory.mocks.ts index 1a572bd658..60ce8fb9c1 100644 --- a/jsapp/js/endpoints/assetHistory.mocks.ts +++ b/jsapp/js/endpoints/assetHistory.mocks.ts @@ -6,15 +6,53 @@ import { BULK_PROCESSING_ACTION_IDS, } from '#/components/activity/activity.constants' import type { PaginatedResponse } from '#/dataInterface' -import assetHistoryLogFactory, { defaultAssetHistoryAssetUid } from './assetHistoryLog.factory' +import { getApiV2ProjectHistoryLogsListResponseMock } from '#/api/react-query/server-logs-superusers' +import type { ProjectHistoryLogResponse } from '#/api/models/projectHistoryLogResponse' -export const mockAssetUid = defaultAssetHistoryAssetUid +export const mockAssetUid = 'a1234567890bcdEFGhijkl' + +/** + * Creates a mock history log item using Orval's generated mock. + * + * Since the API doesn't have a single-item retrieve endpoint, Orval only generates + * getApiV2ProjectHistoryLogsListResponseMock (which returns a paginated list). + * This helper extracts a single item from that list and merges overrides. + * + * Note: ActivityLogsItem extends ProjectHistoryLogResponse with typed action/metadata. + */ +type AssetHistoryLogOverrides = Partial> & { + metadata?: Partial +} + +const createHistoryLog = (overrides: AssetHistoryLogOverrides = {}): ActivityLogsItem => { + // Get a sample log from Orval's list mock + const sampleList = getApiV2ProjectHistoryLogsListResponseMock() + const baseLog = sampleList.results[0] as ProjectHistoryLogResponse + + const { metadata, ...rest } = overrides + + return { + ...baseLog, + user: '/api/v2/users/john/', + user_uid: 'umBqhq3XSkkeNEzrFpCfTZ', + username: 'john', + action: AuditActions['update-content'], + metadata: { + ...baseLog.metadata, + source: 'Firefox (Mac OS X)', + asset_uid: mockAssetUid, + ip_address: '192.168.107.1', + ...metadata, + }, + date_created: '2025-04-15T11:31:30Z', + ...rest, + } as ActivityLogsItem +} -type AssetHistoryLogOverrides = Parameters[0] type ActivityPermissions = NonNullable const johnLog = (overrides: AssetHistoryLogOverrides) => - assetHistoryLogFactory({ + createHistoryLog({ user: '/api/v2/users/john/', user_uid: 'umBqhq3XSkkeNEzrFpCfTZ', username: 'john', @@ -22,7 +60,7 @@ const johnLog = (overrides: AssetHistoryLogOverrides) => }) const karinaLog = (overrides: AssetHistoryLogOverrides) => - assetHistoryLogFactory({ + createHistoryLog({ user: '/api/v2/users/karina/', user_uid: 'umBqhq3XSkkeNEzrFpCfTx', username: 'karina', diff --git a/jsapp/js/endpoints/assetHistoryActions.mocks.ts b/jsapp/js/endpoints/assetHistoryActions.mocks.ts deleted file mode 100644 index d7f902fa68..0000000000 --- a/jsapp/js/endpoints/assetHistoryActions.mocks.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { http, HttpResponse, type PathParams } from 'msw' -import { endpoints } from '#/api.endpoints' -import type { AssetHistoryActionsResponse } from '#/components/activity/activity.constants' -import { mockAssetUid } from './assetHistory.mocks' - -/** - * Mock API for listing all available history actions. Use it in Storybook tests in `parameters.msw.handlers[]`. - * Uses same assetUid as assetHistory mock. - */ -const assetHistoryMock = http.get, never, AssetHistoryActionsResponse>( - endpoints.ASSET_HISTORY_ACTIONS.replace(':asset_uid', mockAssetUid), - () => HttpResponse.json(assetHistoryActionsResponse), -) -export default assetHistoryMock - -const assetHistoryActionsResponse: AssetHistoryActionsResponse = { - actions: [ - 'bulk-processing', - 'disallow-anonymous-submissions', - 'add-media', - 'add-submission', - 'allow-anonymous-submissions', - 'modify-user-permissions', - 'update-content', - 'deploy', - 'delete-submission', - ], -} diff --git a/jsapp/js/endpoints/assetHistoryLog.factory.ts b/jsapp/js/endpoints/assetHistoryLog.factory.ts deleted file mode 100644 index dc89c33485..0000000000 --- a/jsapp/js/endpoints/assetHistoryLog.factory.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { type ActivityLogsItem, AuditActions } from '#/components/activity/activity.constants' - -export const defaultAssetHistoryAssetUid = 'a1234567890bcdEFGhijkl' - -type AssetHistoryLogFactoryOverrides = Partial> & { - metadata?: Partial -} - -export default function assetHistoryLogFactory(overrides: AssetHistoryLogFactoryOverrides = {}): ActivityLogsItem { - const { metadata, ...rest } = overrides - - return { - user: '/api/v2/users/john/', - user_uid: 'umBqhq3XSkkeNEzrFpCfTZ', - username: 'john', - action: AuditActions['update-content'], - metadata: { - source: 'Firefox (Mac OS X)', - asset_uid: defaultAssetHistoryAssetUid, - ip_address: '192.168.107.1', - ...metadata, - }, - date_created: '2025-04-15T11:31:30Z', - ...rest, - } -} diff --git a/jsapp/js/endpoints/assets.mocks.ts b/jsapp/js/endpoints/assets.mocks.ts index 4ba0618853..1db16c29a9 100644 --- a/jsapp/js/endpoints/assets.mocks.ts +++ b/jsapp/js/endpoints/assets.mocks.ts @@ -1,12 +1,14 @@ -import { http, HttpResponse, type PathParams } from 'msw' -import { endpoints } from '#/api.endpoints' +import { + getApiV2AssetsListMockHandler, + getApiV2AssetsRetrieveResponseMock, +} from '#/api/react-query/manage-projects-and-library-content' import { AssetTypeName, QuestionTypeName } from '#/constants' import type { AssetResponse, PaginatedResponse } from '#/dataInterface' -import assetFactory from './asset.factory' import { mockTemplates } from './assets.templates' /** - * Mock API for assets list. Use it in Storybook tests in `parameters.msw.handlers.assets`. + * Mock API for assets list using Orval-generated handler. + * Use it in Storybook tests in `parameters.msw.handlers.assets`. * * Supports query parameter 'q' for filtering by asset type: * - 'asset_type:template' returns mockTemplates @@ -16,40 +18,38 @@ import { mockTemplates } from './assets.templates' * Note that default response contains only 2 results. */ const assetsMock = (override?: Partial>) => - http.get, never, PaginatedResponse>( - endpoints.ASSETS_URL, - (info) => { - const searchParams = new URL(info.request.url).searchParams - const limit = searchParams.get('limit') !== null ? Number(searchParams.get('limit')) : undefined - const query = searchParams.get('q') + getApiV2AssetsListMockHandler(async (info) => { + const searchParams = new URL(info.request.url).searchParams + const limit = searchParams.get('limit') !== null ? Number(searchParams.get('limit')) : undefined + const query = searchParams.get('q') - // Handle template queries - if (query === 'asset_type:template') { - return HttpResponse.json({ - count: mockTemplates.length, - next: null, - previous: null, - results: mockTemplates.slice(0, limit), - }) + // Handle template queries + if (query === 'asset_type:template') { + return { + count: mockTemplates.length, + next: null, + previous: null, + results: mockTemplates.slice(0, limit), } + } + + // Default behavior for other queries + return { + ...defaultMockResponse, + ...override, + results: (override?.results ?? defaultMockResponse.results).slice(0, limit ?? override?.count ?? undefined), + } + }) - // Default behavior for other queries - return HttpResponse.json({ - ...defaultMockResponse, - ...override, - results: (override?.results ?? defaultMockResponse.results).slice(0, limit ?? override?.count ?? undefined), - }) - }, - ) export default assetsMock -// Default mock assets using assetFactory for cleaner code +// Default mock assets using Orval-generated mocks const defaultMockResponse: PaginatedResponse = { count: 2, next: null, previous: null, results: [ - assetFactory({ + getApiV2AssetsRetrieveResponseMock({ uid: 'abam8JiJ3hHTW3EYp6Tpb5', name: 'minimal asset first', owner__username: 'zefir', @@ -75,7 +75,7 @@ const defaultMockResponse: PaginatedResponse = { translations: [null], }, }), - assetFactory({ + getApiV2AssetsRetrieveResponseMock({ uid: 'abam8JiJ3hHTW3EYp6Tpb4', name: 'minimal asset second', owner__username: 'zefir', diff --git a/jsapp/js/endpoints/assets.templates.ts b/jsapp/js/endpoints/assets.templates.ts index ba47cb1ec4..584a68b433 100644 --- a/jsapp/js/endpoints/assets.templates.ts +++ b/jsapp/js/endpoints/assets.templates.ts @@ -1,13 +1,13 @@ import { AssetTypeName, QuestionTypeName } from '#/constants' import type { AssetResponse } from '#/dataInterface' -import assetFactory from './asset.factory' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' /** * Template asset definitions for Storybook stories. * These are used by assets.mocks.ts when the query includes 'asset_type:template' */ -export const templateHealthSurvey: AssetResponse = assetFactory({ +export const templateHealthSurvey: AssetResponse = getApiV2AssetsRetrieveResponseMock({ uid: 'template1uid', name: 'Community Health Survey Template', asset_type: AssetTypeName.template, @@ -30,7 +30,7 @@ export const templateHealthSurvey: AssetResponse = assetFactory({ }, }) -export const templateEducationAssessment: AssetResponse = assetFactory({ +export const templateEducationAssessment: AssetResponse = getApiV2AssetsRetrieveResponseMock({ uid: 'template2uid', name: 'Education Assessment Form', asset_type: AssetTypeName.template, @@ -53,7 +53,7 @@ export const templateEducationAssessment: AssetResponse = assetFactory({ }, }) -export const templateFeedbackSurvey: AssetResponse = assetFactory({ +export const templateFeedbackSurvey: AssetResponse = getApiV2AssetsRetrieveResponseMock({ uid: 'template3uid', name: 'Quick Feedback Survey', asset_type: AssetTypeName.template, diff --git a/jsapp/js/endpoints/bulkAction.factory.ts b/jsapp/js/endpoints/bulkAction.factory.ts deleted file mode 100644 index 0625c8b87a..0000000000 --- a/jsapp/js/endpoints/bulkAction.factory.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { ActionIdEnum } from '#/api/models/actionIdEnum' -import type { BulkActionResponse } from '#/api/models/bulkActionResponse' -import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' -import { BulkActionSubmissionStatusResponseStatusEnum } from '#/api/models/bulkActionSubmissionStatusResponseStatusEnum' -import type { LanguageCode } from '#/components/languages/languagesStore' - -export default function bulkActionFactory( - submissionUuid: string, - languageCode: LanguageCode, - overrides: Partial = {}, -): BulkActionResponse { - const { progress = 0, ...restOverrides } = overrides - - return { - uid: 'bulk-action-uid', - status: BulkActionResponseStatusEnum.in_progress, - action_id: ActionIdEnum.automatic_google_transcription, - question_xpath: 'Your_name', - submission_uuids: [submissionUuid], - submission_statuses: [ - { - uuid: submissionUuid, - status: BulkActionSubmissionStatusResponseStatusEnum.in_progress, - error: null, - }, - ], - params: { - language: languageCode, - }, - progress, - created_by: { - username: 'zefir', - }, - date_created: '2026-01-01T00:00:00Z', - date_modified: '2026-01-01T00:00:00Z', - ...restOverrides, - } -} diff --git a/jsapp/js/endpoints/bulkActions.mocks.ts b/jsapp/js/endpoints/bulkActions.mocks.ts index d4698671ea..667cd514a3 100644 --- a/jsapp/js/endpoints/bulkActions.mocks.ts +++ b/jsapp/js/endpoints/bulkActions.mocks.ts @@ -3,7 +3,9 @@ import { endpoints } from '#/api.endpoints' import type { BulkActionListResponse } from '#/api/models/bulkActionListResponse' import type { BulkActionResponse } from '#/api/models/bulkActionResponse' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' -import bulkActionFactory from './bulkAction.factory' +import { ActionIdEnum } from '#/api/models/actionIdEnum' +import { BulkActionSubmissionStatusResponseStatusEnum } from '#/api/models/bulkActionSubmissionStatusResponseStatusEnum' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' /** * Mock API for bulk actions list. Use it in Storybook tests in `parameters.msw.handlers.bulkActions`. @@ -30,7 +32,31 @@ const defaultBulkActionsResponse: BulkActionListResponse = { count: 1, next: null, previous: null, - results: [bulkActionFactory('uuid:mock-uuid-1', 'fr')], + results: [ + getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ + uid: 'bulk-action-uid', + status: BulkActionResponseStatusEnum.in_progress, + action_id: ActionIdEnum.automatic_google_transcription, + question_xpath: 'Your_name', + submission_uuids: ['uuid:mock-uuid-1'], + submission_statuses: [ + { + uuid: 'uuid:mock-uuid-1', + status: BulkActionSubmissionStatusResponseStatusEnum.in_progress, + error: null, + }, + ], + params: { + language: 'fr', + }, + progress: 0, + created_by: { + username: 'zefir', + }, + date_created: '2026-01-01T00:00:00Z', + date_modified: '2026-01-01T00:00:00Z', + }), + ], } /** diff --git a/jsapp/js/endpoints/environment.mocks.ts b/jsapp/js/endpoints/environment.mocks.ts index dbb2a599d5..6c448f1133 100644 --- a/jsapp/js/endpoints/environment.mocks.ts +++ b/jsapp/js/endpoints/environment.mocks.ts @@ -1,16 +1,10 @@ -import { http, HttpResponse } from 'msw' -import { endpoints } from '#/api.endpoints' -import type { EnvironmentResponse } from '../envStore' +import { getApiV2EnvironmentRetrieveMockHandler } from '#/api/react-query/configuration' /** - * Mock API for environment config. Use it in Storybook tests in `parameters.msw.handlers[]`. + * Production-like environment configuration for testing. + * Contains complete lists of countries, languages, and sectors that the UI depends on. */ -const environmentMock = http.get(endpoints.ENVIRONMENT, () => - HttpResponse.json(environmentResponse), -) -export default environmentMock - -const environmentResponse: EnvironmentResponse = { +const environmentResponse = { terms_of_service_url: '', privacy_policy_url: '', source_code_url: 'https://github.com/kobotoolbox/', @@ -433,3 +427,10 @@ const environmentResponse: EnvironmentResponse = { open_rosa_server: 'http://kc.kobo.local', allow_self_account_deletion: true, } + +/** + * Mock API for environment config using Orval-generated handler with production-like data. + * Use it in Storybook tests in `parameters.msw.handlers[]`. + */ +const environmentMock = getApiV2EnvironmentRetrieveMockHandler(environmentResponse) +export default environmentMock diff --git a/jsapp/js/endpoints/formMedia.factory.ts b/jsapp/js/endpoints/formMedia.factory.ts deleted file mode 100644 index 21f9652a52..0000000000 --- a/jsapp/js/endpoints/formMedia.factory.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { AssetFileResponse } from '#/dataInterface' - -export interface FormMediaItem extends Omit { - metadata: AssetFileResponse['metadata'] & { - // Only present when the media item points to an external URL. - redirect_url?: string - } -} - -export default function formMediaFactory(index: number, overrides: Partial = {}): FormMediaItem { - // Keep IDs deterministic so stories and tests are easy to read and debug. - const uid = overrides.uid ?? `form-media-${index}` - const filename = overrides.metadata?.filename ?? `file-${index}.png` - - return { - uid, - url: `/api/v2/assets/mock-asset-uid/files/${uid}/`, - asset: '/api/v2/assets/mock-asset-uid/', - user: '/api/v2/users/storybook/', - user__username: 'storybook', - file_type: 'form_media', - description: 'default', - date_created: new Date(2026, 0, index).toISOString(), - content: `/media/mock/${filename}`, - ...overrides, - metadata: { - hash: `hash-${index}`, - size: 1024, - type: 'image/png', - filename, - mimetype: 'image/png', - ...overrides.metadata, - }, - } -} diff --git a/jsapp/js/endpoints/formMedia.mocks.ts b/jsapp/js/endpoints/formMedia.mocks.ts index 31bd279920..925f124155 100644 --- a/jsapp/js/endpoints/formMedia.mocks.ts +++ b/jsapp/js/endpoints/formMedia.mocks.ts @@ -1,24 +1,34 @@ -import { http, HttpResponse } from 'msw' -import { endpoints } from '#/api.endpoints' -import formMediaFactory, { type FormMediaItem } from './formMedia.factory' +import { + getApiV2AssetsFilesCreateMockHandler, + getApiV2AssetsFilesCreateResponseMock, + getApiV2AssetsFilesDestroyMockHandler, + getApiV2AssetsFilesListMockHandler, +} from '#/api/react-query/survey-data' +import type { FilesResponse } from '#/api/models/filesResponse' + +/** + * Extended FilesResponse type with redirect_url in metadata. + * Used when the media item points to an external URL. + */ +export interface FormMediaItem extends Omit { + metadata: FilesResponse['metadata'] & { + redirect_url?: string + } +} interface CreateFormMediaPayload { description?: string file_type?: string - // metadata may arrive as a JSON string (legacy URL-encoded POST) or as a - // parsed object (JSON POST from the orval-generated client). metadata?: string | Record base64Encoded?: string } interface FormMediaMockOptions { - // Optional per-filename delays for story/play-test scenarios. uploadDelayByFilenameMs?: Record } function parsePayloadFromText(textPayload: string): CreateFormMediaPayload { const params = new URLSearchParams(textPayload) - return { description: params.get('description') ?? undefined, file_type: params.get('file_type') ?? undefined, @@ -29,13 +39,9 @@ function parsePayloadFromText(textPayload: string): CreateFormMediaPayload { async function parsePayload(request: Request): Promise { const contentType = request.headers.get('content-type') || '' - - // Keep this branch for components that may switch to JSON POST later. if (contentType.includes('application/json')) { return (await request.json()) as CreateFormMediaPayload } - - // Current uploader sends URL-encoded form payloads. return parsePayloadFromText(await request.text()) } @@ -45,57 +51,87 @@ function waitMs(ms: number): Promise { }) } +/** + * Creates a form media item using Orval's generated mock with deterministic IDs. + */ +export function createFormMediaItem(index: number, overrides: Partial = {}): FormMediaItem { + const uid = overrides.uid ?? `form-media-${index}` + const filename = overrides.metadata?.filename ?? `file-${index}.png` + + return { + ...getApiV2AssetsFilesCreateResponseMock({ + uid, + url: `/api/v2/assets/mock-asset-uid/files/${uid}/`, + asset: '/api/v2/assets/mock-asset-uid/', + user: '/api/v2/users/storybook/', + user__username: 'storybook', + file_type: 'form_media', + description: 'default', + date_created: new Date(2026, 0, index).toISOString(), + content: `/media/mock/${filename}`, + metadata: { + hash: `hash-${index}`, + filename, + mimetype: 'image/png', + }, + }), + ...overrides, + metadata: { + hash: `hash-${index}`, + filename, + mimetype: 'image/png', + ...overrides.metadata, + }, + } as FormMediaItem +} + +/** + * Stateful form media handlers using Orval-generated MSW handlers. + * Maintains an in-memory list that persists across requests within a Storybook session. + */ export function formMediaHandlers( assetUid: string, - seedItems: FormMediaItem[] = [formMediaFactory(1)], + seedItems: FormMediaItem[] = [createFormMediaItem(1)], options: FormMediaMockOptions = {}, ) { - // We mutate this local array to mimic backend persistence between requests - // inside a single Storybook run. const mediaItems = [...seedItems] return [ - http.get(endpoints.ASSET_FILES_LIST, ({ params }) => { - if (params.uid !== assetUid) { - return undefined + // GET list - returns current items + getApiV2AssetsFilesListMockHandler(async ({ params }) => { + if (params.uidAsset !== assetUid) { + return undefined as any } - - return HttpResponse.json({ + return { count: mediaItems.length, next: null, previous: null, results: mediaItems, - }) + } }), - http.post(endpoints.ASSET_FILES_LIST, async ({ params, request }) => { - if (params.uid !== assetUid) { - return undefined + // POST create - adds item to list + getApiV2AssetsFilesCreateMockHandler(async ({ params, request }) => { + if (params.uidAsset !== assetUid) { + return undefined as any } const payload = await parsePayload(request) - // metadata may be a JSON string (legacy form-encoded POST) or a plain - // object (JSON POST from the orval-generated client). const parsedMetadata = - typeof payload.metadata === 'string' - ? (JSON.parse(payload.metadata) as Record) - : (payload.metadata ?? {}) + typeof payload.metadata === 'string' ? (JSON.parse(payload.metadata) as Record) : (payload.metadata ?? {}) + const fileName = parsedMetadata.filename as string | undefined - // Unknown filenames (or missing delay map) upload immediately. const delayMs = (fileName && options.uploadDelayByFilenameMs?.[fileName]) || 0 if (delayMs > 0) { await waitMs(delayMs) } const index = mediaItems.length + 1 - - const newItem = formMediaFactory(index, { + const newItem = createFormMediaItem(index, { uid: `form-media-${index}`, - url: endpoints.ASSET_FILE_DETAIL.replace(':uid', assetUid).replace(':fileUid', `form-media-${index}`), + url: `/api/v2/assets/${assetUid}/files/form-media-${index}/`, metadata: { hash: `hash-${index}`, - size: 2048, - type: 'application/octet-stream', filename: (parsedMetadata.filename as string | undefined) || `uploaded-${index}.dat`, mimetype: 'application/octet-stream', redirect_url: parsedMetadata.redirect_url as string | undefined, @@ -104,22 +140,18 @@ export function formMediaHandlers( }) mediaItems.push(newItem) - - // Return created item so UI can behave like real API responses. - return HttpResponse.json(newItem, { status: 201 }) + return newItem }), - http.delete(endpoints.ASSET_FILE_DETAIL, ({ params }) => { - if (params.uid !== assetUid) { - return undefined + // DELETE - removes item from list + getApiV2AssetsFilesDestroyMockHandler(async ({ params }) => { + if (params.uidAsset !== assetUid) { + return } - - const itemIndex = mediaItems.findIndex((item) => item.uid === params.fileUid) + const itemIndex = mediaItems.findIndex((item) => item.uid === params.uidFile) if (itemIndex > -1) { mediaItems.splice(itemIndex, 1) } - - return new HttpResponse(null, { status: 204 }) }), ] } diff --git a/jsapp/js/endpoints/languageDetail.mocks.ts b/jsapp/js/endpoints/languageDetail.mocks.ts index 297d594370..796e9cd1c4 100644 --- a/jsapp/js/endpoints/languageDetail.mocks.ts +++ b/jsapp/js/endpoints/languageDetail.mocks.ts @@ -1,29 +1,29 @@ -import { http, HttpResponse } from 'msw' -import { endpoints } from '#/api.endpoints' -import type { Language } from '#/api/models/language' +import { getApiV2LanguagesRetrieveMockHandler } from '#/api/react-query/other' -const languageDetailMock = http.get(endpoints.LANGUAGE_DETAIL_URL, () => - HttpResponse.json({ - name: 'English', - code: 'en', - featured: true, - regions: [ - { code: 'en-US', name: 'United States' }, - { code: 'en-GB', name: 'United Kingdom' }, - ], - transcription_services: { - goog: { - 'en-US': 'en-US', - 'en-GB': 'en-GB', - }, +/** + * Mock API for language detail endpoint using Orval-generated handler. + * Uses specific English language data for testing. + */ +const languageDetailMock = getApiV2LanguagesRetrieveMockHandler({ + name: 'English', + code: 'en', + featured: true, + regions: [ + { code: 'en-US', name: 'United States' }, + { code: 'en-GB', name: 'United Kingdom' }, + ], + transcription_services: { + goog: { + 'en-US': 'en-US', + 'en-GB': 'en-GB', }, - translation_services: { - goog: { - 'en-US': 'en-US', - 'en-GB': 'en-GB', - }, + }, + translation_services: { + goog: { + 'en-US': 'en-US', + 'en-GB': 'en-GB', }, - }), -) + }, +}) export default languageDetailMock diff --git a/jsapp/js/endpoints/me.mocks.ts b/jsapp/js/endpoints/me.mocks.ts index 35ee71853d..009f5ee23c 100644 --- a/jsapp/js/endpoints/me.mocks.ts +++ b/jsapp/js/endpoints/me.mocks.ts @@ -1,14 +1,11 @@ -import { http, HttpResponse } from 'msw' -import { endpoints } from '#/api.endpoints' -import type { AccountResponse } from '#/dataInterface' +import { getMeRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage' +import type { MeListResponse } from '#/api/models/meListResponse' /** - * Mock API for session endpoint. Use it in Storybook tests in `parameters.msw.handlers[]`. + * Mock response data for /me/ endpoint. + * Note: AccountResponse (legacy) is compatible with MeListResponse (Orval). */ -const meMock = http.get(endpoints.ME, () => HttpResponse.json(meMockResponse)) -export default meMock - -export const meMockResponse: AccountResponse = { +export const meMockResponse: MeListResponse = { username: 'zefir', first_name: '', last_name: '', @@ -39,3 +36,10 @@ export const meMockResponse: AccountResponse = { }, extra_details__uid: 'uTcCX9wL5royoPb4mHWcBz', } + +/** + * Mock API for session endpoint using Orval-generated handler. + * Use it in Storybook tests in `parameters.msw.handlers[]`. + */ +const meMock = getMeRetrieveMockHandler(meMockResponse) +export default meMock diff --git a/jsapp/js/endpoints/organization.mocks.ts b/jsapp/js/endpoints/organization.mocks.ts index 66b3155205..e7c0758000 100644 --- a/jsapp/js/endpoints/organization.mocks.ts +++ b/jsapp/js/endpoints/organization.mocks.ts @@ -1,28 +1,18 @@ -import { http, HttpResponse } from 'msw' +import { getApiV2OrganizationsRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage' import type { OrganizationResponse } from '#/api/models/organizationResponse' -import { getOrganizationsRetrieveUrl } from '#/api/react-query/user-team-organization-usage' import { meMockResponse } from './me.mocks' /** - - * Mock API handler for the main organization endpoint. - * Use in Storybook tests in `parameters.msw.handlers.organization`. - * + * Mock API handler for organization endpoint using Orval-generated handler. * Property `id` is used to generate the URL and populate other response fields that depend on it. * Default value is `meMockResponse.organization!.uid`. */ const organizationMock = (override?: Partial) => { - const id = override?.id ?? meMockResponse.organization!.uid - return http.get(getOrganizationsRetrieveUrl(id), () => - HttpResponse.json({ ...organizationReponse(id), ...override }), - ) -} -export default organizationMock + const id = override?.id ?? meMockResponse.organization?.uid ?? 'default-org-id' -const organizationReponse = (organizationId: string): OrganizationResponse => { - return { - id: organizationId, - url: `http://kf.kobo.local/api/v2/organizations/${organizationId}/`, + return getApiV2OrganizationsRetrieveMockHandler({ + id, + url: `http://kf.kobo.local/api/v2/organizations/${id}/`, name: 'mocked organization', website: '', organization_type: 'none', @@ -31,9 +21,12 @@ const organizationReponse = (organizationId: string): OrganizationResponse => { is_owner: true, is_mmo: false, request_user_role: 'owner', - members: `http://kf.kobo.local/api/v2/organizations/${organizationId}/members/`, - assets: `http://kf.kobo.local/api/v2/organizations/${organizationId}/assets/`, - service_usage: `http://kf.kobo.local/api/v2/organizations/${organizationId}/service_usage/`, - asset_usage: `http://kf.kobo.local/api/v2/organizations/${organizationId}/asset_usage/`, - } + members: `http://kf.kobo.local/api/v2/organizations/${id}/members/`, + assets: `http://kf.kobo.local/api/v2/organizations/${id}/assets/`, + service_usage: `http://kf.kobo.local/api/v2/organizations/${id}/service_usage/`, + asset_usage: `http://kf.kobo.local/api/v2/organizations/${id}/asset_usage/`, + ...override, + }) } + +export default organizationMock diff --git a/jsapp/js/endpoints/organizationServiceUsage.factory.ts b/jsapp/js/endpoints/organizationServiceUsage.factory.ts index b80ef3675e..b6cb31e026 100644 --- a/jsapp/js/endpoints/organizationServiceUsage.factory.ts +++ b/jsapp/js/endpoints/organizationServiceUsage.factory.ts @@ -4,6 +4,12 @@ import type { UserReportsServiceUsageResponse } from '#/api/models/userReportsSe * Factory functions for creating mock usage data with different limit scenarios. * Useful in Storybook to test how the UI responds to warnings and exceeded limits. * + * Note: NOT migrated to Orval because this file provides valuable domain-specific + * presets (storageWarning, storageExceeded, etc.) that calculate percentage-based + * limits. These presets are more useful than raw Orval mocks because they encode + * business logic about when warnings/errors should trigger (80%, 100%, etc.). + * The helper functions make tests more readable than passing raw percentage values. + * * Instead of writing out full balance objects with calculated values, just call * the preset that matches your scenario: * - storageWarning() for 95% storage used (triggers warning banner) diff --git a/jsapp/js/endpoints/organizationServiceUsage.mocks.ts b/jsapp/js/endpoints/organizationServiceUsage.mocks.ts index 52c7b297bf..430e4d74a7 100644 --- a/jsapp/js/endpoints/organizationServiceUsage.mocks.ts +++ b/jsapp/js/endpoints/organizationServiceUsage.mocks.ts @@ -7,6 +7,11 @@ import { meMockResponse } from './me.mocks' * Mock API handler for the /service_usage/ endpoint of an organization. * Use in Storybook tests in `parameters.msw.handlers.organizationServiceUsage`. * + * Note: NOT fully migrated to Orval because it uses organizationServiceUsage.factory.ts + * which provides domain-specific presets (storageWarning, storageExceeded, etc.). + * While we could use Orval's handler, the factory presets are more valuable for tests + * than raw Orval mocks as they encode business logic about when warnings/errors trigger. + * * Property `id` is used to generate the URL and populate other response fields that depend on it. * Default value is coming from `meMockResponse`. * @@ -14,7 +19,7 @@ import { meMockResponse } from './me.mocks' * @param overrideData - Partial override for the service usage response */ const organizationServiceUsageMock = (overrideId?: string, overrideData?: Partial) => { - const id = overrideId ?? meMockResponse.organization!.uid + const id = overrideId ?? meMockResponse.organization?.uid ?? 'default-org-id' const baseResponse = mockServiceUsageResponse() // Deep merge balances if provided diff --git a/jsapp/js/endpoints/serviceUsage.factory.ts b/jsapp/js/endpoints/serviceUsage.factory.ts index 1664e1e7f6..903b0c8f40 100644 --- a/jsapp/js/endpoints/serviceUsage.factory.ts +++ b/jsapp/js/endpoints/serviceUsage.factory.ts @@ -4,6 +4,11 @@ import type { ServiceUsageResponse } from '#/api/models/serviceUsageResponse' * Factory functions for creating mock service usage data with different limit scenarios. * Useful for testing bulk processing alerts for ASR (transcription) and MT (translation). * + * Note: NOT migrated to Orval because this file provides valuable domain-specific + * presets (asrExceeded, mtExceeded, asrNearLimit, etc.) that calculate percentage-based + * quotas. These presets encode business logic about ASR (transcription) and MT (translation) + * service limits and make tests more readable than passing raw quota values to Orval mocks. + * * Instead of writing out full balance objects with calculated values, just call * the preset that matches your scenario: * - asrExceeded() for transcription quota exceeded diff --git a/jsapp/js/endpoints/subscription.mocks.ts b/jsapp/js/endpoints/subscription.mocks.ts index c4c05695fc..f9348cf83c 100644 --- a/jsapp/js/endpoints/subscription.mocks.ts +++ b/jsapp/js/endpoints/subscription.mocks.ts @@ -7,6 +7,11 @@ import type { PaginatedResponse } from '#/dataInterface' * Mock API for stripe subscriptions endpoint. * Use it in Storybook tests in `parameters.msw.handlers[]`. * + * Note: NOT migrated to Orval because the detailed Stripe types (SubscriptionInfo) + * contain more fields than Orval's generated Subscription type. The Stripe SDK types + * have nested structures for items, prices, products, etc. that would require + * significant type mapping to work with Orval's simpler schema. + * * @param overrideData - Partial override for the subscription response */ const subscriptionMock = (overrideData?: Partial>) => { diff --git a/jsapp/js/project/FormMedia/FormMedia.stories.tsx b/jsapp/js/project/FormMedia/FormMedia.stories.tsx index 9c350a1320..1f144fe02a 100644 --- a/jsapp/js/project/FormMedia/FormMedia.stories.tsx +++ b/jsapp/js/project/FormMedia/FormMedia.stories.tsx @@ -1,12 +1,11 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { expect, userEvent, waitFor, within } from 'storybook/test' -import assetFactory from '#/endpoints/asset.factory' -import formMediaFactory from '#/endpoints/formMedia.factory' -import { formMediaHandlers } from '#/endpoints/formMedia.mocks' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { createFormMediaItem, formMediaHandlers } from '#/endpoints/formMedia.mocks' import { queryClientDecorator } from '#/query/queryClient.mocks' import FormMedia from './index' -const mockAsset = assetFactory({ +const mockAsset = getApiV2AssetsRetrieveResponseMock({ uid: 'form-media-story-uid', deployment__active: false, }) @@ -22,13 +21,11 @@ const meta: Meta = { msw: { // Seed with one existing file so the first test step can verify loading. handlers: formMediaHandlers(mockAsset.uid, [ - formMediaFactory(1, { + createFormMediaItem(1, { uid: 'form-media-1', url: `/api/v2/assets/${mockAsset.uid}/files/form-media-1/`, metadata: { hash: 'hash-1', - size: 1024, - type: 'image/png', filename: 'intro-image.png', mimetype: 'image/png', }, diff --git a/kpi/schema_extensions/v2/data/extensions.py b/kpi/schema_extensions/v2/data/extensions.py index 3dd8a79063..120fcb3f6e 100644 --- a/kpi/schema_extensions/v2/data/extensions.py +++ b/kpi/schema_extensions/v2/data/extensions.py @@ -329,95 +329,74 @@ def map_serializer_field(self, auto_schema, direction): auto_schema, qual_references=references ) + # Note: These schemas are inlined (not registered as components) to avoid + # Orval generating problematic MSW mocks for types with index signatures. + # The oneOf discriminator is sufficient for the API schema. return { 'oneOf': [ - self._register_schema_component( - auto_schema, - 'SupplementalDetailsManualTranscription', - build_object_type( - additionalProperties=build_object_type( - properties={ - 'manual_transcription': supp_references[ - 'action_object_manual' - ], - }, - required=['manual_transcription'], - ), - description='Manual transcription supplemental details', + build_object_type( + additionalProperties=build_object_type( + properties={ + 'manual_transcription': supp_references[ + 'action_object_manual' + ], + }, + required=['manual_transcription'], ), + description='Manual transcription supplemental details', ), - self._register_schema_component( - auto_schema, - 'SupplementalDetailsManualTranslation', - build_object_type( - additionalProperties=build_object_type( - properties={ - 'manual_translation': supp_references[ - 'translation_map_manual' - ], - }, - required=['manual_translation'], - ), - description='Manual translation supplemental details', + build_object_type( + additionalProperties=build_object_type( + properties={ + 'manual_translation': supp_references[ + 'translation_map_manual' + ], + }, + required=['manual_translation'], ), + description='Manual translation supplemental details', ), - self._register_schema_component( - auto_schema, - 'SupplementalDetailsAutomaticTranscription', - build_object_type( - additionalProperties=build_object_type( - properties={ - 'automatic_google_transcription': supp_references[ - 'action_object_automatic' - ], - }, - required=['automatic_google_transcription'], - ), - description='Automatic transcription supplemental details', + build_object_type( + additionalProperties=build_object_type( + properties={ + 'automatic_google_transcription': supp_references[ + 'action_object_automatic' + ], + }, + required=['automatic_google_transcription'], ), + description='Automatic transcription supplemental details', ), - self._register_schema_component( - auto_schema, - 'SupplementalDetailsAutomaticTranslation', - build_object_type( - additionalProperties=build_object_type( - properties={ - 'automatic_google_translation': supp_references[ - 'translation_map_automatic' - ], - }, - required=['automatic_google_translation'], - ), - description='Automatic translation supplemental details', + build_object_type( + additionalProperties=build_object_type( + properties={ + 'automatic_google_translation': supp_references[ + 'translation_map_automatic' + ], + }, + required=['automatic_google_translation'], ), + description='Automatic translation supplemental details', ), - self._register_schema_component( - auto_schema, - 'SupplementalDetailsManualQual', - build_object_type( - additionalProperties=build_object_type( - properties={ - 'manual_qual': supp_references['qual_map'], - }, - required=['manual_qual'], - ), - description='Manual qualitative supplemental details', + build_object_type( + additionalProperties=build_object_type( + properties={ + 'manual_qual': supp_references['qual_map'], + }, + required=['manual_qual'], ), + description='Manual qualitative supplemental details', ), - self._register_schema_component( - auto_schema, - 'SupplementalDetailsAutomaticQual', - build_object_type( - additionalProperties=build_object_type( - properties={ - 'automatic_bedrock_qual': supp_references[ - 'qual_map_automatic' - ], - }, - required=['automatic_bedrock_qual'], - ), - description='Automatic qualitative supplemental details', + build_object_type( + additionalProperties=build_object_type( + properties={ + 'automatic_bedrock_qual': supp_references[ + 'qual_map_automatic' + ], + }, + required=['automatic_bedrock_qual'], ), + description='Automatic qualitative supplemental details', ), ], 'nullable': True, # Field is required=False diff --git a/kpi/schema_extensions/v2/me/extensions.py b/kpi/schema_extensions/v2/me/extensions.py index cf695ff7f2..c6ae0fd1f1 100644 --- a/kpi/schema_extensions/v2/me/extensions.py +++ b/kpi/schema_extensions/v2/me/extensions.py @@ -42,14 +42,22 @@ class GitRevFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.me.fields.GitRevField' def map_serializer_field(self, auto_schema, direction): - return build_object_type( - properties={ - 'short': GENERIC_STRING_SCHEMA, - 'long': GENERIC_STRING_SCHEMA, - 'branch': GENERIC_STRING_SCHEMA, - 'tag': GENERIC_STRING_SCHEMA, - } - ) + # git_rev can be either: + # - False (when EXPOSE_GIT_REV=False and user is not superuser) + # - An object with string/boolean properties (actual git revision info) + return { + 'oneOf': [ + build_basic_type(OpenApiTypes.BOOL), + build_object_type( + properties={ + 'short': {'oneOf': [GENERIC_STRING_SCHEMA, build_basic_type(OpenApiTypes.BOOL)]}, + 'long': {'oneOf': [GENERIC_STRING_SCHEMA, build_basic_type(OpenApiTypes.BOOL)]}, + 'branch': {'oneOf': [GENERIC_STRING_SCHEMA, build_basic_type(OpenApiTypes.BOOL)]}, + 'tag': {'oneOf': [GENERIC_STRING_SCHEMA, build_basic_type(OpenApiTypes.BOOL)]}, + } + ), + ] + } class GravatarFieldExtension(OpenApiSerializerFieldExtension): diff --git a/kpi/schema_extensions/v2/me/serializers.py b/kpi/schema_extensions/v2/me/serializers.py index 8f9d05aece..5fe6bc7814 100644 --- a/kpi/schema_extensions/v2/me/serializers.py +++ b/kpi/schema_extensions/v2/me/serializers.py @@ -28,7 +28,7 @@ 'date_joined': serializers.DateTimeField(), 'projects_url': ProjectUrlField(), 'gravatar': GravatarField(), - 'last_login': serializers.DateTimeField(), + 'last_login': serializers.DateTimeField(allow_null=True), 'extra_details': ExtraDetailField(), 'git_rev': GitRevField(), 'social_accounts': SocialAccountField(), diff --git a/orval.config.js b/orval.config.js index bd09e6047b..fb20059f35 100644 --- a/orval.config.js +++ b/orval.config.js @@ -1,4 +1,4 @@ -import { operationName } from './jsapp/js/api/orval.operationName' +const { operationName } = require('./jsapp/js/api/orval.operationName.js') module.exports = { 'kpi-v2': { @@ -15,7 +15,9 @@ module.exports = { return generatorClients['react-query'] }, httpClient: 'fetch', - mock: false, // TODO: enable in later PRs separately. + mock: { + type: 'msw', + }, indexFiles: false, biome: true, diff --git a/scripts/generate_api.sh b/scripts/generate_api.sh index ea89a8d6fb..273937166d 100755 --- a/scripts/generate_api.sh +++ b/scripts/generate_api.sh @@ -28,6 +28,14 @@ fi echo "Enabling Stripe for schema generation…" export STRIPE_ENABLED=true echo "Stripe enabled: $STRIPE_ENABLED" + +# Override KOBOFORM_URL with canonical value for schema examples +# This ensures generated schema examples use production-like URLs regardless of environment +# To use a different URL, set SCHEMA_URL environment variable before running this script +echo "Setting KOBOFORM_URL for schema generation…" +export KOBOFORM_URL="${SCHEMA_URL:-https://kf.kobotoolbox.org}" +echo "KOBOFORM_URL: $KOBOFORM_URL" + echo "Generating v2 OpenAPI JSON schema with drf-spectacular…" run python manage.py generate_openapi_schema --file "$DESTINATION_FOLDER/schema_v2.json" --schema="api_v2" --format openapi-json echo "Generating v2 OpenAPI YAML schema with drf-spectacular…" diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index cd7584ab71..047759a9bb 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -23691,22 +23691,94 @@ "_supplementalDetails": { "oneOf": [ { - "$ref": "#/components/schemas/SupplementalDetailsManualTranscription" + "type": "object", + "description": "Manual transcription supplemental details", + "additionalProperties": { + "type": "object", + "properties": { + "manual_transcription": { + "$ref": "#/components/schemas/SupplementalDataManualTranscription" + } + }, + "required": [ + "manual_transcription" + ] + } }, { - "$ref": "#/components/schemas/SupplementalDetailsManualTranslation" + "type": "object", + "description": "Manual translation supplemental details", + "additionalProperties": { + "type": "object", + "properties": { + "manual_translation": { + "$ref": "#/components/schemas/SupplementalDataManualTranslation" + } + }, + "required": [ + "manual_translation" + ] + } }, { - "$ref": "#/components/schemas/SupplementalDetailsAutomaticTranscription" + "type": "object", + "description": "Automatic transcription supplemental details", + "additionalProperties": { + "type": "object", + "properties": { + "automatic_google_transcription": { + "$ref": "#/components/schemas/SupplementalDataAutomaticTranscription" + } + }, + "required": [ + "automatic_google_transcription" + ] + } }, { - "$ref": "#/components/schemas/SupplementalDetailsAutomaticTranslation" + "type": "object", + "description": "Automatic translation supplemental details", + "additionalProperties": { + "type": "object", + "properties": { + "automatic_google_translation": { + "$ref": "#/components/schemas/SupplementalDataAutomaticTranslation" + } + }, + "required": [ + "automatic_google_translation" + ] + } }, { - "$ref": "#/components/schemas/SupplementalDetailsManualQual" + "type": "object", + "description": "Manual qualitative supplemental details", + "additionalProperties": { + "type": "object", + "properties": { + "manual_qual": { + "$ref": "#/components/schemas/SupplementalDataManualQual" + } + }, + "required": [ + "manual_qual" + ] + } }, { - "$ref": "#/components/schemas/SupplementalDetailsAutomaticQual" + "type": "object", + "description": "Automatic qualitative supplemental details", + "additionalProperties": { + "type": "object", + "properties": { + "automatic_bedrock_qual": { + "$ref": "#/components/schemas/SupplementalDataAutomaticQual" + } + }, + "required": [ + "automatic_bedrock_qual" + ] + } } ], "nullable": true, @@ -25992,7 +26064,8 @@ }, "last_login": { "type": "string", - "format": "date-time" + "format": "date-time", + "nullable": true }, "extra_details": { "type": "object", @@ -26045,21 +26118,56 @@ } }, "git_rev": { - "type": "object", - "properties": { - "short": { - "type": "string" - }, - "long": { - "type": "string" - }, - "branch": { - "type": "string" + "oneOf": [ + { + "type": "boolean" }, - "tag": { - "type": "string" + { + "type": "object", + "properties": { + "short": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "boolean" + } + ] + }, + "long": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "boolean" + } + ] + }, + "branch": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "boolean" + } + ] + }, + "tag": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "boolean" + } + ] + } + } } - } + ] }, "social_accounts": { "type": "array", @@ -31996,96 +32104,6 @@ "_uuid" ] }, - "SupplementalDetailsAutomaticQual": { - "type": "object", - "description": "Automatic qualitative supplemental details", - "additionalProperties": { - "type": "object", - "properties": { - "automatic_bedrock_qual": { - "$ref": "#/components/schemas/SupplementalDataAutomaticQual" - } - }, - "required": [ - "automatic_bedrock_qual" - ] - } - }, - "SupplementalDetailsAutomaticTranscription": { - "type": "object", - "description": "Automatic transcription supplemental details", - "additionalProperties": { - "type": "object", - "properties": { - "automatic_google_transcription": { - "$ref": "#/components/schemas/SupplementalDataAutomaticTranscription" - } - }, - "required": [ - "automatic_google_transcription" - ] - } - }, - "SupplementalDetailsAutomaticTranslation": { - "type": "object", - "description": "Automatic translation supplemental details", - "additionalProperties": { - "type": "object", - "properties": { - "automatic_google_translation": { - "$ref": "#/components/schemas/SupplementalDataAutomaticTranslation" - } - }, - "required": [ - "automatic_google_translation" - ] - } - }, - "SupplementalDetailsManualQual": { - "type": "object", - "description": "Manual qualitative supplemental details", - "additionalProperties": { - "type": "object", - "properties": { - "manual_qual": { - "$ref": "#/components/schemas/SupplementalDataManualQual" - } - }, - "required": [ - "manual_qual" - ] - } - }, - "SupplementalDetailsManualTranscription": { - "type": "object", - "description": "Manual transcription supplemental details", - "additionalProperties": { - "type": "object", - "properties": { - "manual_transcription": { - "$ref": "#/components/schemas/SupplementalDataManualTranscription" - } - }, - "required": [ - "manual_transcription" - ] - } - }, - "SupplementalDetailsManualTranslation": { - "type": "object", - "description": "Manual translation supplemental details", - "additionalProperties": { - "type": "object", - "properties": { - "manual_translation": { - "$ref": "#/components/schemas/SupplementalDataManualTranslation" - } - }, - "required": [ - "manual_translation" - ] - } - }, "TagListResponse": { "type": "object", "properties": { diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index f3b9a7aa36..cc133ca36f 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -16952,12 +16952,60 @@ components: title: ' submitted by' _supplementalDetails: oneOf: - - $ref: '#/components/schemas/SupplementalDetailsManualTranscription' - - $ref: '#/components/schemas/SupplementalDetailsManualTranslation' - - $ref: '#/components/schemas/SupplementalDetailsAutomaticTranscription' - - $ref: '#/components/schemas/SupplementalDetailsAutomaticTranslation' - - $ref: '#/components/schemas/SupplementalDetailsManualQual' - - $ref: '#/components/schemas/SupplementalDetailsAutomaticQual' + - type: object + description: Manual transcription supplemental details + additionalProperties: + type: object + properties: + manual_transcription: + $ref: '#/components/schemas/SupplementalDataManualTranscription' + required: + - manual_transcription + - type: object + description: Manual translation supplemental details + additionalProperties: + type: object + properties: + manual_translation: + $ref: '#/components/schemas/SupplementalDataManualTranslation' + required: + - manual_translation + - type: object + description: Automatic transcription supplemental details + additionalProperties: + type: object + properties: + automatic_google_transcription: + $ref: '#/components/schemas/SupplementalDataAutomaticTranscription' + required: + - automatic_google_transcription + - type: object + description: Automatic translation supplemental details + additionalProperties: + type: object + properties: + automatic_google_translation: + $ref: '#/components/schemas/SupplementalDataAutomaticTranslation' + required: + - automatic_google_translation + - type: object + description: Manual qualitative supplemental details + additionalProperties: + type: object + properties: + manual_qual: + $ref: '#/components/schemas/SupplementalDataManualQual' + required: + - manual_qual + - type: object + description: Automatic qualitative supplemental details + additionalProperties: + type: object + properties: + automatic_bedrock_qual: + $ref: '#/components/schemas/SupplementalDataAutomaticQual' + required: + - automatic_bedrock_qual nullable: true description: Action-specific supplemental data attached to this submission. Structure varies by action type (transcription, translation, qual). Top-level @@ -18582,6 +18630,7 @@ components: last_login: type: string format: date-time + nullable: true extra_details: type: object properties: @@ -18616,16 +18665,26 @@ components: newsletter_subscription: type: string git_rev: - type: object - properties: - short: - type: string - long: - type: string - branch: - type: string - tag: - type: string + oneOf: + - type: boolean + - type: object + properties: + short: + oneOf: + - type: string + - type: boolean + long: + oneOf: + - type: string + - type: boolean + branch: + oneOf: + - type: string + - type: boolean + tag: + oneOf: + - type: string + - type: boolean social_accounts: type: array items: @@ -22923,66 +22982,6 @@ components: - _data - _dateCreated - _uuid - SupplementalDetailsAutomaticQual: - type: object - description: Automatic qualitative supplemental details - additionalProperties: - type: object - properties: - automatic_bedrock_qual: - $ref: '#/components/schemas/SupplementalDataAutomaticQual' - required: - - automatic_bedrock_qual - SupplementalDetailsAutomaticTranscription: - type: object - description: Automatic transcription supplemental details - additionalProperties: - type: object - properties: - automatic_google_transcription: - $ref: '#/components/schemas/SupplementalDataAutomaticTranscription' - required: - - automatic_google_transcription - SupplementalDetailsAutomaticTranslation: - type: object - description: Automatic translation supplemental details - additionalProperties: - type: object - properties: - automatic_google_translation: - $ref: '#/components/schemas/SupplementalDataAutomaticTranslation' - required: - - automatic_google_translation - SupplementalDetailsManualQual: - type: object - description: Manual qualitative supplemental details - additionalProperties: - type: object - properties: - manual_qual: - $ref: '#/components/schemas/SupplementalDataManualQual' - required: - - manual_qual - SupplementalDetailsManualTranscription: - type: object - description: Manual transcription supplemental details - additionalProperties: - type: object - properties: - manual_transcription: - $ref: '#/components/schemas/SupplementalDataManualTranscription' - required: - - manual_transcription - SupplementalDetailsManualTranslation: - type: object - description: Manual translation supplemental details - additionalProperties: - type: object - properties: - manual_translation: - $ref: '#/components/schemas/SupplementalDataManualTranslation' - required: - - manual_translation TagListResponse: type: object properties: From 6c5b738576cc06952a9743c33533a6233d6b41f7 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 12:16:11 +0200 Subject: [PATCH 02/86] fix date_created and date_modified mismatch --- jsapp/js/dataInterface.ts | 8 ++++++-- jsapp/js/projects/projectsTable/projectsTableRow.tsx | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index e971ba8e58..f33c61aee4 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -685,11 +685,15 @@ export interface AssetResponse extends AssetRequestObject { owner: string owner__username: string owner_label: string - date_created: string + // TODO DEV-XXXX: date_created is always present at runtime but OpenAPI schema + // marks it optional (because it has a default for write operations) + date_created?: string last_modified_by: string | null created_by: string | null summary: AssetSummary - date_modified: string + // TODO DEV-XXXX: date_modified is always present at runtime but OpenAPI schema + // marks it optional (because it has a default for write operations) + date_modified?: string date_deployed?: string version_id: string | null version__content_hash?: string | null diff --git a/jsapp/js/projects/projectsTable/projectsTableRow.tsx b/jsapp/js/projects/projectsTable/projectsTableRow.tsx index c14c719b61..8f615eeea3 100644 --- a/jsapp/js/projects/projectsTable/projectsTableRow.tsx +++ b/jsapp/js/projects/projectsTable/projectsTableRow.tsx @@ -64,7 +64,7 @@ export default function ProjectsTableRow(props: ProjectsTableRowProps) { return } case 'dateModified': - return formatTime(props.asset.date_modified) + return props.asset.date_modified ? formatTime(props.asset.date_modified) : 'n/a' case 'dateDeployed': if ('date_deployed' in props.asset && props.asset.date_deployed) { return formatTime(props.asset.date_deployed) From c16f35741017493736a24e5ef2fe04cc521b016b Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 12:21:45 +0200 Subject: [PATCH 03/86] fix asset content choices and summary name quality schemas missing --- jsapp/js/api/models/assetContent.ts | 2 + .../js/api/models/assetContentChoicesItem.ts | 13 + .../js/api/models/assetSummaryNameQuality.ts | 9 +- .../models/assetSummaryNameQualityFirsts.ts | 18 + .../assetSummaryNameQualityFirstsBad.ts | 17 + .../models/assetSummaryNameQualityFirstsOk.ts | 17 + .../manage-projects-and-library-content.ts | 441 +++++++++++++++++- .../user-team-organization-usage.ts | 63 ++- jsapp/js/endpoints/assets.templates.ts | 9 +- kpi/schema_extensions/v2/assets/extensions.py | 24 +- static/openapi/schema_v2.json | 61 ++- static/openapi/schema_v2.yaml | 38 ++ 12 files changed, 696 insertions(+), 16 deletions(-) create mode 100644 jsapp/js/api/models/assetContentChoicesItem.ts create mode 100644 jsapp/js/api/models/assetSummaryNameQualityFirsts.ts create mode 100644 jsapp/js/api/models/assetSummaryNameQualityFirstsBad.ts create mode 100644 jsapp/js/api/models/assetSummaryNameQualityFirstsOk.ts diff --git a/jsapp/js/api/models/assetContent.ts b/jsapp/js/api/models/assetContent.ts index aa0cb8c0a3..da53956f89 100644 --- a/jsapp/js/api/models/assetContent.ts +++ b/jsapp/js/api/models/assetContent.ts @@ -1,3 +1,4 @@ +import type { AssetContentChoicesItem } from './assetContentChoicesItem' import type { AssetContentSettings } from './assetContentSettings' /** * Generated by orval v7.10.0 🍺 @@ -15,6 +16,7 @@ import type { AssetContentSurveyItem } from './assetContentSurveyItem' export type AssetContent = { schema?: string survey?: AssetContentSurveyItem[] + choices?: AssetContentChoicesItem[] settings?: AssetContentSettings translated?: string[] translations?: string[] diff --git a/jsapp/js/api/models/assetContentChoicesItem.ts b/jsapp/js/api/models/assetContentChoicesItem.ts new file mode 100644 index 0000000000..aac858ba75 --- /dev/null +++ b/jsapp/js/api/models/assetContentChoicesItem.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetContentChoicesItem = { [key: string]: unknown } diff --git a/jsapp/js/api/models/assetSummaryNameQuality.ts b/jsapp/js/api/models/assetSummaryNameQuality.ts index a0c8d6a869..65456cb8de 100644 --- a/jsapp/js/api/models/assetSummaryNameQuality.ts +++ b/jsapp/js/api/models/assetSummaryNameQuality.ts @@ -9,5 +9,12 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetSummaryNameQualityFirsts } from './assetSummaryNameQualityFirsts' -export type AssetSummaryNameQuality = { [key: string]: unknown } +export type AssetSummaryNameQuality = { + ok?: number + bad?: number + good?: number + total?: number + firsts?: AssetSummaryNameQualityFirsts +} diff --git a/jsapp/js/api/models/assetSummaryNameQualityFirsts.ts b/jsapp/js/api/models/assetSummaryNameQualityFirsts.ts new file mode 100644 index 0000000000..7c15273f57 --- /dev/null +++ b/jsapp/js/api/models/assetSummaryNameQualityFirsts.ts @@ -0,0 +1,18 @@ +import type { AssetSummaryNameQualityFirstsBad } from './assetSummaryNameQualityFirstsBad' +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetSummaryNameQualityFirstsOk } from './assetSummaryNameQualityFirstsOk' + +export type AssetSummaryNameQualityFirsts = { + ok?: AssetSummaryNameQualityFirstsOk + bad?: AssetSummaryNameQualityFirstsBad +} diff --git a/jsapp/js/api/models/assetSummaryNameQualityFirstsBad.ts b/jsapp/js/api/models/assetSummaryNameQualityFirstsBad.ts new file mode 100644 index 0000000000..8d81202383 --- /dev/null +++ b/jsapp/js/api/models/assetSummaryNameQualityFirstsBad.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetSummaryNameQualityFirstsBad = { + name?: string + index?: number + label?: string[] +} diff --git a/jsapp/js/api/models/assetSummaryNameQualityFirstsOk.ts b/jsapp/js/api/models/assetSummaryNameQualityFirstsOk.ts new file mode 100644 index 0000000000..760ffe1411 --- /dev/null +++ b/jsapp/js/api/models/assetSummaryNameQualityFirstsOk.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetSummaryNameQualityFirstsOk = { + name?: string + index?: number + label?: string[] +} diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 3317c99828..847b43cfb0 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2747,7 +2747,64 @@ export const getApiV2AssetsListResponseMock = ( faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - name_quality: faker.helpers.arrayElement([{}, undefined]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), default_translation: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20 } }), undefined, @@ -2818,6 +2875,10 @@ export const getApiV2AssetsListResponseMock = ( Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined, ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => @@ -2962,7 +3023,64 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), default_translation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), @@ -3030,6 +3148,10 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({})), undefined, ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => @@ -3173,7 +3295,64 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), default_translation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), @@ -3241,6 +3420,10 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({})), undefined, ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => @@ -3384,7 +3567,64 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - name_quality: faker.helpers.arrayElement([{}, undefined]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), default_translation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), @@ -3452,6 +3692,10 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined, ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => @@ -3619,7 +3863,64 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - name_quality: faker.helpers.arrayElement([{}, undefined]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), default_translation: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20 } }), undefined, @@ -3690,6 +3991,10 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined, ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => @@ -3840,7 +4145,64 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - name_quality: faker.helpers.arrayElement([{}, undefined]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), default_translation: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20 } }), undefined, @@ -3911,6 +4273,10 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined, ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => @@ -4061,7 +4427,64 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - name_quality: faker.helpers.arrayElement([{}, undefined]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), default_translation: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20 } }), undefined, @@ -4132,6 +4555,10 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined, ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 7a6ed0970b..841ed87fb5 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -3869,7 +3869,64 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - name_quality: faker.helpers.arrayElement([{}, undefined]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), default_translation: faker.helpers.arrayElement([ faker.string.alpha({ length: { min: 10, max: 20 } }), undefined, @@ -3940,6 +3997,10 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined, ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => diff --git a/jsapp/js/endpoints/assets.templates.ts b/jsapp/js/endpoints/assets.templates.ts index 584a68b433..145d9928c5 100644 --- a/jsapp/js/endpoints/assets.templates.ts +++ b/jsapp/js/endpoints/assets.templates.ts @@ -1,13 +1,12 @@ -import { AssetTypeName, QuestionTypeName } from '#/constants' -import type { AssetResponse } from '#/dataInterface' import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { AssetTypeName, QuestionTypeName } from '#/constants' /** * Template asset definitions for Storybook stories. * These are used by assets.mocks.ts when the query includes 'asset_type:template' */ -export const templateHealthSurvey: AssetResponse = getApiV2AssetsRetrieveResponseMock({ +export const templateHealthSurvey = getApiV2AssetsRetrieveResponseMock({ uid: 'template1uid', name: 'Community Health Survey Template', asset_type: AssetTypeName.template, @@ -30,7 +29,7 @@ export const templateHealthSurvey: AssetResponse = getApiV2AssetsRetrieveRespons }, }) -export const templateEducationAssessment: AssetResponse = getApiV2AssetsRetrieveResponseMock({ +export const templateEducationAssessment = getApiV2AssetsRetrieveResponseMock({ uid: 'template2uid', name: 'Education Assessment Form', asset_type: AssetTypeName.template, @@ -53,7 +52,7 @@ export const templateEducationAssessment: AssetResponse = getApiV2AssetsRetrieve }, }) -export const templateFeedbackSurvey: AssetResponse = getApiV2AssetsRetrieveResponseMock({ +export const templateFeedbackSurvey = getApiV2AssetsRetrieveResponseMock({ uid: 'template3uid', name: 'Quick Feedback Survey', asset_type: AssetTypeName.template, diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index b66ca6fb22..f1dd421fef 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -260,6 +260,7 @@ def map_serializer_field(self, auto_schema, direction): properties={ 'schema': GENERIC_STRING_SCHEMA, 'survey': build_array_type(schema=GENERIC_OBJECT_SCHEMA), + 'choices': build_array_type(schema=GENERIC_OBJECT_SCHEMA), 'settings': GENERIC_OBJECT_SCHEMA, 'translated': GENERIC_ARRAY_SCHEMA, 'translations': GENERIC_ARRAY_SCHEMA, @@ -557,6 +558,27 @@ class SummaryFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.SummaryField' def map_serializer_field(self, auto_schema, direction): + name_quality_first_item_schema = build_object_type( + properties={ + 'name': GENERIC_STRING_SCHEMA, + 'index': build_basic_type(OpenApiTypes.INT), + 'label': GENERIC_ARRAY_SCHEMA, + } + ) + name_quality_schema = build_object_type( + properties={ + 'ok': build_basic_type(OpenApiTypes.INT), + 'bad': build_basic_type(OpenApiTypes.INT), + 'good': build_basic_type(OpenApiTypes.INT), + 'total': build_basic_type(OpenApiTypes.INT), + 'firsts': build_object_type( + properties={ + 'ok': name_quality_first_item_schema, + 'bad': name_quality_first_item_schema, + } + ), + } + ) return build_object_type( properties={ 'geo': build_basic_type(OpenApiTypes.BOOL), @@ -566,7 +588,7 @@ def map_serializer_field(self, auto_schema, direction): 'lock_any': build_basic_type(OpenApiTypes.BOOL), 'languages': GENERIC_ARRAY_SCHEMA, 'row_count': build_basic_type(OpenApiTypes.INT), - 'name_quality': GENERIC_OBJECT_SCHEMA, + 'name_quality': name_quality_schema, 'default_translation': GENERIC_STRING_SCHEMA, } ) diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 047759a9bb..c1387eafa5 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21227,7 +21227,60 @@ "type": "integer" }, "name_quality": { - "type": "object" + "type": "object", + "properties": { + "ok": { + "type": "integer" + }, + "bad": { + "type": "integer" + }, + "good": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "firsts": { + "type": "object", + "properties": { + "ok": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "index": { + "type": "integer" + }, + "label": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "bad": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "index": { + "type": "integer" + }, + "label": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } }, "default_translation": { "type": "string" @@ -21401,6 +21454,12 @@ "type": "object" } }, + "choices": { + "type": "array", + "items": { + "type": "object" + } + }, "settings": { "type": "object" }, diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index cc133ca36f..fda6f65287 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15219,6 +15219,40 @@ components: type: integer name_quality: type: object + properties: + ok: + type: integer + bad: + type: integer + good: + type: integer + total: + type: integer + firsts: + type: object + properties: + ok: + type: object + properties: + name: + type: string + index: + type: integer + label: + type: array + items: + type: string + bad: + type: object + properties: + name: + type: string + index: + type: integer + label: + type: array + items: + type: string default_translation: type: string readOnly: true @@ -15338,6 +15372,10 @@ components: type: array items: type: object + choices: + type: array + items: + type: object settings: type: object translated: From 963f6a9e3045856e0e7c3466b42797ce61f81c1d Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 12:26:12 +0200 Subject: [PATCH 04/86] drop some type casting --- .../components/AssetTagsModal/AssetTagsModal.stories.tsx | 4 ++-- jsapp/js/components/map/FormMapWrapper.stories.tsx | 8 ++++---- jsapp/js/components/reports/reports.utils.tests.ts | 5 ++--- .../components/submissions/DataTableWrapper.stories.tsx | 9 ++++----- .../FormLanguagesManager.stories.tsx | 4 ++-- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx index de6604eb6c..24533000ba 100644 --- a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx +++ b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx @@ -1,9 +1,9 @@ import { ModalsProvider } from '@mantine/modals' import type { Meta, StoryObj } from '@storybook/react-webpack5' import { expect, fn, userEvent, waitFor, within } from 'storybook/test' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import ButtonNew from '#/components/common/ButtonNew' import type { AssetResponse } from '#/dataInterface' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import { assetPatchMock } from '#/endpoints/asset.mocks' import { queryClientDecorator } from '#/query/queryClient.mocks' import { KOBO_MODAL_SHARED_PROPS } from '#/theme/kobo/Modal' @@ -16,7 +16,7 @@ const mockAsset = getApiV2AssetsRetrieveResponseMock({ uid: 'storyAssetTagsUid', name: 'Storybook Asset Tags', tag_string: 'alpha,beta', -}) as AssetResponse +}) const mockAssetUid = mockAsset.uid const onAssetPatched = fn() diff --git a/jsapp/js/components/map/FormMapWrapper.stories.tsx b/jsapp/js/components/map/FormMapWrapper.stories.tsx index 07deee0e58..c057b839c3 100644 --- a/jsapp/js/components/map/FormMapWrapper.stories.tsx +++ b/jsapp/js/components/map/FormMapWrapper.stories.tsx @@ -3,9 +3,9 @@ import { http, HttpResponse } from 'msw' import { reactRouterParameters, withRouter } from 'storybook-addon-remix-react-router' import { expect, waitFor, within } from 'storybook/test' import { endpoints } from '#/api.endpoints' -import { MetaQuestionTypeName, QuestionTypeName } from '#/constants' -import type { AssetResponse, PaginatedResponse, SubmissionResponse } from '#/dataInterface' import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { MetaQuestionTypeName, QuestionTypeName } from '#/constants' +import type { PaginatedResponse, SubmissionResponse } from '#/dataInterface' import assetDataFactory from '#/endpoints/assetData.factory' import { queryClientDecorator } from '#/query/queryClient.mocks' import { ROUTES } from '#/router/routerConstants' @@ -53,7 +53,7 @@ const assetWithOnlyStartGeopoint = getApiV2AssetsRetrieveResponseMock({ ], choices: [], }, -}) as AssetResponse +}) // Asset with both start-geopoint AND regular geopoint const assetWithBothGeopointTypes = getApiV2AssetsRetrieveResponseMock({ @@ -97,7 +97,7 @@ const assetWithBothGeopointTypes = getApiV2AssetsRetrieveResponseMock({ ], choices: [], }, -}) as AssetResponse +}) // Submission data with populated start-geopoint const submissionsWithStartGeopoint: SubmissionResponse[] = [ diff --git a/jsapp/js/components/reports/reports.utils.tests.ts b/jsapp/js/components/reports/reports.utils.tests.ts index 1abfdfce5c..690ae9348c 100644 --- a/jsapp/js/components/reports/reports.utils.tests.ts +++ b/jsapp/js/components/reports/reports.utils.tests.ts @@ -1,7 +1,6 @@ import chai from 'chai' -import { QuestionTypeName } from '#/constants' -import type { AssetResponse } from '#/dataInterface' import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { QuestionTypeName } from '#/constants' import { reportStyleFactory, reportsResponseDataFactory } from './reports.factory' import { buildEffectiveReportStyle, getEffectiveRowReportStyle, populateSelectQuestionLabels } from './reports.utils' import type { ReportsResponse } from './reportsConstants' @@ -164,7 +163,7 @@ describe('populateSelectQuestionLabels', () => { }, ], }, - }) as AssetResponse + }) populateSelectQuestionLabels(row, asset, 1) diff --git a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx index 2dcf0bcbdf..b65814b1c4 100644 --- a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx +++ b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx @@ -15,13 +15,12 @@ import subscriptionStore from '#/account/subscriptionStore' import { actions } from '#/actions' import { ActionIdEnum } from '#/api/models/actionIdEnum' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' -import { QuestionTypeName } from '#/constants' -import type { AssetResponse } from '#/dataInterface' import { - getApiV2AssetsRetrieveResponseMock, getApiV2AssetsRetrieveMockHandler, + getApiV2AssetsRetrieveResponseMock, } from '#/api/react-query/manage-projects-and-library-content' import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' +import { QuestionTypeName } from '#/constants' import assetDataFactory from '#/endpoints/assetData.factory' import assetDataMock from '#/endpoints/assetData.mocks' import bulkActionsMock from '#/endpoints/bulkActions.mocks' @@ -173,7 +172,7 @@ const minimalAsset = getApiV2AssetsRetrieveResponseMock({ translations: [null], }, effective_permissions: [{ codename: 'change_submissions' }], -}) as AssetResponse +}) const minimalSubmissions = [ assetDataFactory(1, { @@ -252,7 +251,7 @@ const processingAsset = getApiV2AssetsRetrieveResponseMock({ ], }, effective_permissions: [{ codename: 'change_submissions' }], -}) as AssetResponse +}) const processingSubmissions = [ assetDataFactory(1, { diff --git a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx index 8b138d12f2..b64b91cd67 100644 --- a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx +++ b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx @@ -34,7 +34,7 @@ function buildInitialAsset(): AssetResponse { choices: [], settings: {}, }, - } as unknown as AssetResponse + } } function createAssetPatchHandler(initialAsset: AssetResponse) { @@ -254,7 +254,7 @@ export const BasicFlow: Story = { await expect(onAssetPatched).toHaveBeenCalled() const calls = (onAssetPatched as ReturnType).mock.calls - const latestPatchedAsset = calls.at(-1)?.[0] as AssetResponse | undefined + const latestPatchedAsset = calls.at(-1)?.[0] const survey = latestPatchedAsset?.content?.survey || [] const question11 = survey.find((item) => item.name === 'question_11') From 96c1b54ebbc4dda45d5e378fc27189312cd5c80e Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 12:28:56 +0200 Subject: [PATCH 05/86] fix missing kuid in mock data --- .../FormLanguagesManager/FormLanguagesManager.stories.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx index b64b91cd67..0628299fd2 100644 --- a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx +++ b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx @@ -16,6 +16,7 @@ function buildInitialAsset(): AssetResponse { const survey = Array.from({ length: 11 }, (_, idx) => { const index = idx + 1 return { + $kuid: `kuid_question_${index}`, type: 'text', name: `question_${index}`, $autoname: `question_${index}`, From 6d5cf3b589cb500fc054be8c4e713ef1f531f137 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 12:41:33 +0200 Subject: [PATCH 06/86] fix schema for translation so null is possible --- jsapp/js/api/models/assetContent.ts | 2 +- .../manage-projects-and-library-content.ts | 14 +++++++------- .../react-query/user-team-organization-usage.ts | 2 +- .../FormLanguagesManager.stories.tsx | 14 +++++++++----- kpi/schema_extensions/v2/assets/extensions.py | 4 +++- static/openapi/schema_v2.json | 3 ++- static/openapi/schema_v2.yaml | 1 + 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/jsapp/js/api/models/assetContent.ts b/jsapp/js/api/models/assetContent.ts index da53956f89..b5d89acd46 100644 --- a/jsapp/js/api/models/assetContent.ts +++ b/jsapp/js/api/models/assetContent.ts @@ -19,5 +19,5 @@ export type AssetContent = { choices?: AssetContentChoicesItem[] settings?: AssetContentSettings translated?: string[] - translations?: string[] + translations?: (string | null)[] } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 847b43cfb0..61fdf85c12 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2888,7 +2888,7 @@ export const getApiV2AssetsListResponseMock = ( ]), translations: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), ), undefined, ]), @@ -3161,7 +3161,7 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), ), undefined, ]), @@ -3433,7 +3433,7 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), ), undefined, ]), @@ -3705,7 +3705,7 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia ]), translations: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), ), undefined, ]), @@ -4004,7 +4004,7 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( ]), translations: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), ), undefined, ]), @@ -4286,7 +4286,7 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( ]), translations: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), ), undefined, ]), @@ -4568,7 +4568,7 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( ]), translations: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), ), undefined, ]), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 841ed87fb5..a7e5683daa 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4010,7 +4010,7 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( ]), translations: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), ), undefined, ]), diff --git a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx index 0628299fd2..28b397ef39 100644 --- a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx +++ b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx @@ -2,7 +2,10 @@ import { ModalsProvider } from '@mantine/modals' import type { Meta, StoryObj } from '@storybook/react-webpack5' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { expect, fn, userEvent, waitFor, within } from 'storybook/test' +import type { AssetContentSurveyItem } from '#/api/models/assetContentSurveyItem' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import ButtonNew from '#/components/common/ButtonNew' +import { QuestionTypeName } from '#/constants' import type { AssetResponse } from '#/dataInterface' import { assetPatchMock } from '#/endpoints/asset.mocks' import { withMinHeightWrapper } from '#/storybookUtils' @@ -13,18 +16,19 @@ const mockAssetUid = 'storyFormLanguagesManagerUid' const onAssetPatched = fn() function buildInitialAsset(): AssetResponse { - const survey = Array.from({ length: 11 }, (_, idx) => { + const survey: AssetContentSurveyItem[] = Array.from({ length: 11 }, (_, idx) => { const index = idx + 1 return { $kuid: `kuid_question_${index}`, - type: 'text', + type: QuestionTypeName.text, name: `question_${index}`, $autoname: `question_${index}`, label: [`Question ${index}`], } }) - return { + // TODO DEV-XXXX: Orval-generated Asset type has incompatible structure with legacy AssetResponse + return getApiV2AssetsRetrieveResponseMock({ uid: mockAssetUid, name: 'Storybook Form Languages', content: { @@ -35,7 +39,7 @@ function buildInitialAsset(): AssetResponse { choices: [], settings: {}, }, - } + }) as unknown as AssetResponse } function createAssetPatchHandler(initialAsset: AssetResponse) { @@ -255,7 +259,7 @@ export const BasicFlow: Story = { await expect(onAssetPatched).toHaveBeenCalled() const calls = (onAssetPatched as ReturnType).mock.calls - const latestPatchedAsset = calls.at(-1)?.[0] + const latestPatchedAsset = calls.at(-1)?.[0] as AssetResponse | undefined const survey = latestPatchedAsset?.content?.survey || [] const question11 = survey.find((item) => item.name === 'question_11') diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index f1dd421fef..1bbe7b8df8 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -263,7 +263,9 @@ def map_serializer_field(self, auto_schema, direction): 'choices': build_array_type(schema=GENERIC_OBJECT_SCHEMA), 'settings': GENERIC_OBJECT_SCHEMA, 'translated': GENERIC_ARRAY_SCHEMA, - 'translations': GENERIC_ARRAY_SCHEMA, + 'translations': build_array_type( + schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} + ), } ) diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index c1387eafa5..269cb8259b 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21472,7 +21472,8 @@ "translations": { "type": "array", "items": { - "type": "string" + "type": "string", + "nullable": true } } } diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index fda6f65287..b9681f013e 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15386,6 +15386,7 @@ components: type: array items: type: string + nullable: true downloads: type: array items: From 9bfc3b15cf2ca1793a4e9c47e04ab9bae0d9566c Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 12:43:45 +0200 Subject: [PATCH 07/86] fix date_deployed in legacy type --- jsapp/js/dataInterface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index f33c61aee4..af1a7f5e1e 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -694,7 +694,7 @@ export interface AssetResponse extends AssetRequestObject { // TODO DEV-XXXX: date_modified is always present at runtime but OpenAPI schema // marks it optional (because it has a default for write operations) date_modified?: string - date_deployed?: string + date_deployed?: string | null version_id: string | null version__content_hash?: string | null version_count?: number From e6d79f830caa5372a656a19d33836375758f7a43 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 12:54:20 +0200 Subject: [PATCH 08/86] make settings sector nullable in schema --- jsapp/js/api/models/assetSettings.ts | 1 + jsapp/js/api/models/assetSettingsSector.ts | 5 +- jsapp/js/endpoints/assets.mocks.ts | 60 ++++++++++--------- kpi/schema_extensions/v2/assets/extensions.py | 2 +- static/openapi/schema_v2.json | 3 +- static/openapi/schema_v2.yaml | 1 + 6 files changed, 40 insertions(+), 32 deletions(-) diff --git a/jsapp/js/api/models/assetSettings.ts b/jsapp/js/api/models/assetSettings.ts index d30a59db9d..f4aaad38f3 100644 --- a/jsapp/js/api/models/assetSettings.ts +++ b/jsapp/js/api/models/assetSettings.ts @@ -12,6 +12,7 @@ The endpoints are grouped by area of intended use. Each category contains relate import type { AssetSettingsSector } from './assetSettingsSector' export type AssetSettings = { + /** @nullable */ sector?: AssetSettingsSector country?: string[] description?: string diff --git a/jsapp/js/api/models/assetSettingsSector.ts b/jsapp/js/api/models/assetSettingsSector.ts index 367917e121..ce010fa0f2 100644 --- a/jsapp/js/api/models/assetSettingsSector.ts +++ b/jsapp/js/api/models/assetSettingsSector.ts @@ -10,4 +10,7 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type AssetSettingsSector = { [key: string]: unknown } +/** + * @nullable + */ +export type AssetSettingsSector = { [key: string]: unknown } | null diff --git a/jsapp/js/endpoints/assets.mocks.ts b/jsapp/js/endpoints/assets.mocks.ts index 1db16c29a9..41e38adc1b 100644 --- a/jsapp/js/endpoints/assets.mocks.ts +++ b/jsapp/js/endpoints/assets.mocks.ts @@ -44,6 +44,7 @@ const assetsMock = (override?: Partial>) => export default assetsMock // Default mock assets using Orval-generated mocks +// TODO DEV-XXXX: Orval-generated Asset.analysis_form_json.additional_fields is string[] but should be object[] const defaultMockResponse: PaginatedResponse = { count: 2, next: null, @@ -101,34 +102,35 @@ const defaultMockResponse: PaginatedResponse = { translations: [null], }, }), - ].map((asset) => { - return { - ...asset, - // Override factory defaults with original mock data specifics - owner_label: "zefir's MMO organization", - version__content_hash: - asset.uid === 'abam8JiJ3hHTW3EYp6Tpb5' - ? '822573fdb551228b65ef80359b4499e62421adde' - : '822573fdb551228b65ef80359b4499e62421addf', - version_count: 3, - summary: { - geo: false, - labels: ['Your name'], - columns: ['type', 'label', 'required'], - lock_all: false, - lock_any: false, - languages: [], - row_count: 1, - name_quality: { - ok: 1, - bad: 0, - good: 0, - total: 1, - firsts: { ok: { name: 'Your_name', index: 1, label: ['Your name'] } }, + ].map( + (asset) => + ({ + ...asset, + // Override factory defaults with original mock data specifics + owner_label: "zefir's MMO organization", + version__content_hash: + asset.uid === 'abam8JiJ3hHTW3EYp6Tpb5' + ? '822573fdb551228b65ef80359b4499e62421adde' + : '822573fdb551228b65ef80359b4499e62421addf', + version_count: 3, + summary: { + geo: false, + labels: ['Your name'], + columns: ['type', 'label', 'required'], + lock_all: false, + lock_any: false, + languages: [], + row_count: 1, + name_quality: { + ok: 1, + bad: 0, + good: 0, + total: 1, + firsts: { ok: { name: 'Your_name', index: 1, label: ['Your name'] } }, + }, + default_translation: null, }, - default_translation: null, - }, - report_styles: { default: {}, specified: { wb1gg11: {} }, kuid_names: { wb1gg11: 'wb1gg11' } }, - } - }), + report_styles: { default: {}, specified: { wb1gg11: {} }, kuid_names: { wb1gg11: 'wb1gg11' } }, + }) as unknown as AssetResponse, + ), } diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 1bbe7b8df8..61bfab234b 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -545,7 +545,7 @@ class SettingsFieldExtension(OpenApiSerializerFieldExtension): def map_serializer_field(self, auto_schema, direction): return build_object_type( properties={ - 'sector': GENERIC_OBJECT_SCHEMA, + 'sector': {**GENERIC_OBJECT_SCHEMA, 'nullable': True}, 'country': GENERIC_ARRAY_SCHEMA, 'description': GENERIC_STRING_SCHEMA, 'collects_pii': GENERIC_STRING_SCHEMA, diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 269cb8259b..f0b100a315 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21155,7 +21155,8 @@ "type": "object", "properties": { "sector": { - "type": "object" + "type": "object", + "nullable": true }, "country": { "type": "array", diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index b9681f013e..4a2ab703e4 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15171,6 +15171,7 @@ components: properties: sector: type: object + nullable: true country: type: array items: From 4049e3fcb2a0c56791bbd79e531fc5971f4eaee3 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 12:56:57 +0200 Subject: [PATCH 09/86] fix sector more --- jsapp/js/api/models/assetSettingsSector.ts | 5 +- .../manage-projects-and-library-content.ts | 56 ++++++++++++++++--- .../user-team-organization-usage.ts | 8 ++- kpi/schema_extensions/v2/assets/extensions.py | 13 ++++- static/openapi/schema_v2.json | 8 +++ static/openapi/schema_v2.yaml | 5 ++ 6 files changed, 85 insertions(+), 10 deletions(-) diff --git a/jsapp/js/api/models/assetSettingsSector.ts b/jsapp/js/api/models/assetSettingsSector.ts index ce010fa0f2..291272e66b 100644 --- a/jsapp/js/api/models/assetSettingsSector.ts +++ b/jsapp/js/api/models/assetSettingsSector.ts @@ -13,4 +13,7 @@ The endpoints are grouped by area of intended use. Each category contains relate /** * @nullable */ -export type AssetSettingsSector = { [key: string]: unknown } | null +export type AssetSettingsSector = { + label?: string + value?: string +} | null diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 61fdf85c12..09d7da710f 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2694,7 +2694,13 @@ export const getApiV2AssetsListResponseMock = ( parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([{}, undefined]), + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), country: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -2970,7 +2976,13 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3242,7 +3254,13 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3514,7 +3532,13 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([{}, undefined]), + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), country: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3810,7 +3834,13 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([{}, undefined]), + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), country: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -4092,7 +4122,13 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([{}, undefined]), + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), country: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -4374,7 +4410,13 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([{}, undefined]), + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), country: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index a7e5683daa..4e69de8c72 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -3816,7 +3816,13 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([{}, undefined]), + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), country: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 61bfab234b..9afb3f78aa 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -543,9 +543,20 @@ class SettingsFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.SettingsField' def map_serializer_field(self, auto_schema, direction): + # Sector can be: null (no selection), {} (empty default), or {label, value} (LabelValuePair) + sector_schema = { + **build_object_type( + properties={ + 'label': GENERIC_STRING_SCHEMA, + 'value': GENERIC_STRING_SCHEMA, + } + ), + 'nullable': True, + } + return build_object_type( properties={ - 'sector': {**GENERIC_OBJECT_SCHEMA, 'nullable': True}, + 'sector': sector_schema, 'country': GENERIC_ARRAY_SCHEMA, 'description': GENERIC_STRING_SCHEMA, 'collects_pii': GENERIC_STRING_SCHEMA, diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index f0b100a315..9a8f09a8d0 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21156,6 +21156,14 @@ "properties": { "sector": { "type": "object", + "properties": { + "label": { + "type": "string" + }, + "value": { + "type": "string" + } + }, "nullable": true }, "country": { diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 4a2ab703e4..43f9260f22 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15171,6 +15171,11 @@ components: properties: sector: type: object + properties: + label: + type: string + value: + type: string nullable: true country: type: array From 4eb52af371b47832e7fb0f74347b0d0c674a7406 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 13:00:30 +0200 Subject: [PATCH 10/86] fix asset settings country schema --- jsapp/js/api/models/assetSettings.ts | 3 +- .../js/api/models/assetSettingsCountryItem.ts | 16 ++++++ .../manage-projects-and-library-content.ts | 49 +++++++++++-------- .../user-team-organization-usage.ts | 7 +-- kpi/schema_extensions/v2/assets/extensions.py | 10 +++- static/openapi/schema_v2.json | 10 +++- static/openapi/schema_v2.yaml | 7 ++- 7 files changed, 74 insertions(+), 28 deletions(-) create mode 100644 jsapp/js/api/models/assetSettingsCountryItem.ts diff --git a/jsapp/js/api/models/assetSettings.ts b/jsapp/js/api/models/assetSettings.ts index f4aaad38f3..6acba2d327 100644 --- a/jsapp/js/api/models/assetSettings.ts +++ b/jsapp/js/api/models/assetSettings.ts @@ -1,3 +1,4 @@ +import type { AssetSettingsCountryItem } from './assetSettingsCountryItem' /** * Generated by orval v7.10.0 🍺 * Do not edit manually. @@ -14,7 +15,7 @@ import type { AssetSettingsSector } from './assetSettingsSector' export type AssetSettings = { /** @nullable */ sector?: AssetSettingsSector - country?: string[] + country?: AssetSettingsCountryItem[] description?: string collects_pii?: string organization?: string diff --git a/jsapp/js/api/models/assetSettingsCountryItem.ts b/jsapp/js/api/models/assetSettingsCountryItem.ts new file mode 100644 index 0000000000..591ef50963 --- /dev/null +++ b/jsapp/js/api/models/assetSettingsCountryItem.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetSettingsCountryItem = { + label?: string + value?: string +} diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 09d7da710f..2c03214ab3 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2702,9 +2702,10 @@ export const getApiV2AssetsListResponseMock = ( undefined, ]), country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -2984,9 +2985,10 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -3262,9 +3264,10 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -3540,9 +3543,10 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia undefined, ]), country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -3842,9 +3846,10 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( undefined, ]), country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -4130,9 +4135,10 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( undefined, ]), country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -4418,9 +4424,10 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( undefined, ]), country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 4e69de8c72..10144040a7 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -3824,9 +3824,10 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( undefined, ]), country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 9afb3f78aa..abf4dcc033 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -554,10 +554,18 @@ def map_serializer_field(self, auto_schema, direction): 'nullable': True, } + # Country is an array of {label, value} objects (LabelValuePair[]) + label_value_pair_schema = build_object_type( + properties={ + 'label': GENERIC_STRING_SCHEMA, + 'value': GENERIC_STRING_SCHEMA, + } + ) + return build_object_type( properties={ 'sector': sector_schema, - 'country': GENERIC_ARRAY_SCHEMA, + 'country': build_array_type(schema=label_value_pair_schema), 'description': GENERIC_STRING_SCHEMA, 'collects_pii': GENERIC_STRING_SCHEMA, 'organization': GENERIC_STRING_SCHEMA, diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 9a8f09a8d0..cdf17898f0 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21169,7 +21169,15 @@ "country": { "type": "array", "items": { - "type": "string" + "type": "object", + "properties": { + "label": { + "type": "string" + }, + "value": { + "type": "string" + } + } } }, "description": { diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 43f9260f22..844f799d6e 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15180,7 +15180,12 @@ components: country: type: array items: - type: string + type: object + properties: + label: + type: string + value: + type: string description: type: string collects_pii: From 290ce65e3ed1f05c95ff5f5b3a9404a4d47f3f68 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 13:03:00 +0200 Subject: [PATCH 11/86] make country nullable in schema --- jsapp/js/api/models/assetSettings.ts | 3 ++- kpi/schema_extensions/v2/assets/extensions.py | 4 ++-- static/openapi/schema_v2.json | 3 ++- static/openapi/schema_v2.yaml | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/jsapp/js/api/models/assetSettings.ts b/jsapp/js/api/models/assetSettings.ts index 6acba2d327..3c4e7b8967 100644 --- a/jsapp/js/api/models/assetSettings.ts +++ b/jsapp/js/api/models/assetSettings.ts @@ -15,7 +15,8 @@ import type { AssetSettingsSector } from './assetSettingsSector' export type AssetSettings = { /** @nullable */ sector?: AssetSettingsSector - country?: AssetSettingsCountryItem[] + /** @nullable */ + country?: AssetSettingsCountryItem[] | null description?: string collects_pii?: string organization?: string diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index abf4dcc033..c7cd58b847 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -554,7 +554,7 @@ def map_serializer_field(self, auto_schema, direction): 'nullable': True, } - # Country is an array of {label, value} objects (LabelValuePair[]) + # Country is an array of {label, value} objects (LabelValuePair[]), nullable for form state label_value_pair_schema = build_object_type( properties={ 'label': GENERIC_STRING_SCHEMA, @@ -565,7 +565,7 @@ def map_serializer_field(self, auto_schema, direction): return build_object_type( properties={ 'sector': sector_schema, - 'country': build_array_type(schema=label_value_pair_schema), + 'country': {**build_array_type(schema=label_value_pair_schema), 'nullable': True}, 'description': GENERIC_STRING_SCHEMA, 'collects_pii': GENERIC_STRING_SCHEMA, 'organization': GENERIC_STRING_SCHEMA, diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index cdf17898f0..22750d722a 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21178,7 +21178,8 @@ "type": "string" } } - } + }, + "nullable": true }, "description": { "type": "string" diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 844f799d6e..82ab14d7af 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15186,6 +15186,7 @@ components: type: string value: type: string + nullable: true description: type: string collects_pii: From 2bca9f5b6d0e33bb80d4b2da77e08c40a0f6e09a Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 13:04:54 +0200 Subject: [PATCH 12/86] fix legacy type --- jsapp/js/dataInterface.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index af1a7f5e1e..eb85386553 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -610,7 +610,8 @@ export interface AssetTableSettings extends AssetTableSettingsObject { export interface AssetSettings { sector?: LabelValuePair | null | {} - country?: LabelValuePair | LabelValuePair[] | null + // TODO DEV-XXXX: Backend always returns country as array (default []), but legacy type allowed single object + country?: LabelValuePair[] | null description?: string 'data-table'?: AssetTableSettings organization?: string From c86a4f55e9644d54e9b9522809a90521309964fb Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 13:08:20 +0200 Subject: [PATCH 13/86] fix more schema for asset settings --- jsapp/js/api/models/assetSettings.ts | 11 +- .../js/api/models/assetSettingsCollectsPii.ts | 19 +++ .../models/assetSettingsOperationalPurpose.ts | 19 +++ .../manage-projects-and-library-content.ts | 126 +++++++++++++++--- .../user-team-organization-usage.ts | 18 ++- kpi/schema_extensions/v2/assets/extensions.py | 10 +- static/openapi/schema_v2.json | 25 +++- static/openapi/schema_v2.yaml | 17 ++- 8 files changed, 210 insertions(+), 35 deletions(-) create mode 100644 jsapp/js/api/models/assetSettingsCollectsPii.ts create mode 100644 jsapp/js/api/models/assetSettingsOperationalPurpose.ts diff --git a/jsapp/js/api/models/assetSettings.ts b/jsapp/js/api/models/assetSettings.ts index 3c4e7b8967..7c7068d4c6 100644 --- a/jsapp/js/api/models/assetSettings.ts +++ b/jsapp/js/api/models/assetSettings.ts @@ -1,4 +1,6 @@ +import type { AssetSettingsCollectsPii } from './assetSettingsCollectsPii' import type { AssetSettingsCountryItem } from './assetSettingsCountryItem' +import type { AssetSettingsOperationalPurpose } from './assetSettingsOperationalPurpose' /** * Generated by orval v7.10.0 🍺 * Do not edit manually. @@ -18,8 +20,11 @@ export type AssetSettings = { /** @nullable */ country?: AssetSettingsCountryItem[] | null description?: string - collects_pii?: string - organization?: string + /** @nullable */ + collects_pii?: AssetSettingsCollectsPii + /** @nullable */ + organization?: string | null country_codes?: string[] - operational_purpose?: string + /** @nullable */ + operational_purpose?: AssetSettingsOperationalPurpose } diff --git a/jsapp/js/api/models/assetSettingsCollectsPii.ts b/jsapp/js/api/models/assetSettingsCollectsPii.ts new file mode 100644 index 0000000000..482aecfb4b --- /dev/null +++ b/jsapp/js/api/models/assetSettingsCollectsPii.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetSettingsCollectsPii = { + label?: string + value?: string +} | null diff --git a/jsapp/js/api/models/assetSettingsOperationalPurpose.ts b/jsapp/js/api/models/assetSettingsOperationalPurpose.ts new file mode 100644 index 0000000000..974f538247 --- /dev/null +++ b/jsapp/js/api/models/assetSettingsOperationalPurpose.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetSettingsOperationalPurpose = { + label?: string + value?: string +} | null diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 2c03214ab3..9cf0013504 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2709,8 +2709,17 @@ export const getApiV2AssetsListResponseMock = ( undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), country_codes: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -2718,7 +2727,10 @@ export const getApiV2AssetsListResponseMock = ( undefined, ]), operational_purpose: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, undefined, ]), }, @@ -2992,8 +3004,17 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3001,7 +3022,10 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3280,7 +3313,10 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3559,7 +3604,10 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia undefined, ]), operational_purpose: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, undefined, ]), }, @@ -3853,8 +3901,17 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), country_codes: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3862,7 +3919,10 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( undefined, ]), operational_purpose: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, undefined, ]), }, @@ -4142,8 +4202,17 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), country_codes: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -4151,7 +4220,10 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( undefined, ]), operational_purpose: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, undefined, ]), }, @@ -4431,8 +4503,17 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), country_codes: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -4440,7 +4521,10 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( undefined, ]), operational_purpose: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, undefined, ]), }, diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 10144040a7..0cf54be9dd 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -3831,8 +3831,17 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( undefined, ]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), country_codes: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3840,7 +3849,10 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( undefined, ]), operational_purpose: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, undefined, ]), }, diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index c7cd58b847..4a81e2cc6a 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -562,15 +562,19 @@ def map_serializer_field(self, auto_schema, direction): } ) + # collects_pii and operational_purpose are also LabelValuePair objects, nullable + collects_pii_schema = {**label_value_pair_schema, 'nullable': True} + operational_purpose_schema = {**label_value_pair_schema, 'nullable': True} + return build_object_type( properties={ 'sector': sector_schema, 'country': {**build_array_type(schema=label_value_pair_schema), 'nullable': True}, 'description': GENERIC_STRING_SCHEMA, - 'collects_pii': GENERIC_STRING_SCHEMA, - 'organization': GENERIC_STRING_SCHEMA, + 'collects_pii': collects_pii_schema, + 'organization': {**GENERIC_STRING_SCHEMA, 'nullable': True}, 'country_codes': GENERIC_ARRAY_SCHEMA, - 'operational_purpose': GENERIC_STRING_SCHEMA, + 'operational_purpose': operational_purpose_schema, } ) diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 22750d722a..f7a603617c 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21185,10 +21185,20 @@ "type": "string" }, "collects_pii": { - "type": "string" + "type": "object", + "properties": { + "label": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "nullable": true }, "organization": { - "type": "string" + "type": "string", + "nullable": true }, "country_codes": { "type": "array", @@ -21197,7 +21207,16 @@ } }, "operational_purpose": { - "type": "string" + "type": "object", + "properties": { + "label": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "nullable": true } } }, diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 82ab14d7af..49e1feebba 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15190,15 +15190,28 @@ components: description: type: string collects_pii: - type: string + type: object + properties: + label: + type: string + value: + type: string + nullable: true organization: type: string + nullable: true country_codes: type: array items: type: string operational_purpose: - type: string + type: object + properties: + label: + type: string + value: + type: string + nullable: true asset_type: $ref: '#/components/schemas/AssetTypeEnum' files: From 4263484c1466841237835a63e25d38adcfaeff26 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 14:48:27 +0200 Subject: [PATCH 14/86] improve asset files schema --- jsapp/js/api/models/asset.ts | 3 +- jsapp/js/api/models/assetFilesItem.ts | 25 +++++ jsapp/js/api/models/assetFilesItemMetadata.ts | 13 +++ .../manage-projects-and-library-content.ts | 105 ++++++++++++++---- .../user-team-organization-usage.ts | 15 ++- kpi/schema_extensions/v2/assets/extensions.py | 17 ++- static/openapi/schema_v2.json | 34 +++++- static/openapi/schema_v2.yaml | 23 +++- 8 files changed, 207 insertions(+), 28 deletions(-) create mode 100644 jsapp/js/api/models/assetFilesItem.ts create mode 100644 jsapp/js/api/models/assetFilesItemMetadata.ts diff --git a/jsapp/js/api/models/asset.ts b/jsapp/js/api/models/asset.ts index fc1e7ad0c1..40882f1712 100644 --- a/jsapp/js/api/models/asset.ts +++ b/jsapp/js/api/models/asset.ts @@ -12,6 +12,7 @@ import type { AssetDownloadsItem } from './assetDownloadsItem' import type { AssetEffectivePermissionsItem } from './assetEffectivePermissionsItem' import type { AssetEmbedsItem } from './assetEmbedsItem' import type { AssetExportSettings } from './assetExportSettings' +import type { AssetFilesItem } from './assetFilesItem' import type { AssetMapCustom } from './assetMapCustom' import type { AssetMapStyles } from './assetMapStyles' import type { AssetProjectOwnership } from './assetProjectOwnership' @@ -41,7 +42,7 @@ export interface Asset { parent?: string | null settings?: AssetSettings asset_type: AssetTypeEnum - readonly files: readonly string[] + readonly files: readonly AssetFilesItem[] readonly summary: AssetSummary date_created?: string date_modified?: string diff --git a/jsapp/js/api/models/assetFilesItem.ts b/jsapp/js/api/models/assetFilesItem.ts new file mode 100644 index 0000000000..e0ac38dd96 --- /dev/null +++ b/jsapp/js/api/models/assetFilesItem.ts @@ -0,0 +1,25 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetFilesItemMetadata } from './assetFilesItemMetadata' + +export type AssetFilesItem = { + uid?: string + url?: string + asset?: string + user?: string + user__username?: string + file_type?: string + description?: string + date_created?: string + content?: string + metadata?: AssetFilesItemMetadata +} diff --git a/jsapp/js/api/models/assetFilesItemMetadata.ts b/jsapp/js/api/models/assetFilesItemMetadata.ts new file mode 100644 index 0000000000..2216a8883e --- /dev/null +++ b/jsapp/js/api/models/assetFilesItemMetadata.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetFilesItemMetadata = { [key: string]: unknown } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 9cf0013504..1cea385297 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2737,9 +2737,18 @@ export const getApiV2AssetsListResponseMock = ( undefined, ]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), summary: { geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([ @@ -3032,9 +3041,18 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), summary: { geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([ @@ -3323,9 +3341,18 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), summary: { geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([ @@ -3614,9 +3641,18 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia undefined, ]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), summary: { geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([ @@ -3929,9 +3965,18 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( undefined, ]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), summary: { geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([ @@ -4230,9 +4275,18 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( undefined, ]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), summary: { geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([ @@ -4531,9 +4585,18 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( undefined, ]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), summary: { geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([ diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 0cf54be9dd..6151a5f7b1 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -3859,9 +3859,18 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( undefined, ]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), summary: { geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([ diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 4a81e2cc6a..ef0ba4f6e1 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -392,7 +392,22 @@ class FileListFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.FileListField' def map_serializer_field(self, auto_schema, direction): - return GENERIC_ARRAY_SCHEMA + # Files is an array of AssetFileSerializer objects + asset_file_schema = build_object_type( + properties={ + 'uid': GENERIC_STRING_SCHEMA, + 'url': GENERIC_STRING_SCHEMA, + 'asset': GENERIC_STRING_SCHEMA, + 'user': GENERIC_STRING_SCHEMA, + 'user__username': GENERIC_STRING_SCHEMA, + 'file_type': GENERIC_STRING_SCHEMA, + 'description': GENERIC_STRING_SCHEMA, + 'date_created': GENERIC_STRING_SCHEMA, + 'content': GENERIC_STRING_SCHEMA, + 'metadata': GENERIC_OBJECT_SCHEMA, + } + ) + return build_array_type(schema=asset_file_schema) class HasDeploymentFieldExtension(OpenApiSerializerFieldExtension): diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index f7a603617c..221aa4b703 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21226,7 +21226,39 @@ "files": { "type": "array", "items": { - "type": "string" + "type": "object", + "properties": { + "uid": { + "type": "string" + }, + "url": { + "type": "string" + }, + "asset": { + "type": "string" + }, + "user": { + "type": "string" + }, + "user__username": { + "type": "string" + }, + "file_type": { + "type": "string" + }, + "description": { + "type": "string" + }, + "date_created": { + "type": "string" + }, + "content": { + "type": "string" + }, + "metadata": { + "type": "object" + } + } }, "readOnly": true }, diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 49e1feebba..0c486f7a42 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15217,7 +15217,28 @@ components: files: type: array items: - type: string + type: object + properties: + uid: + type: string + url: + type: string + asset: + type: string + user: + type: string + user__username: + type: string + file_type: + type: string + description: + type: string + date_created: + type: string + content: + type: string + metadata: + type: object readOnly: true summary: type: object From 97b4051a39160c36207b0745de0f35a9b2dd5e02 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 14:50:49 +0200 Subject: [PATCH 15/86] fix languages --- jsapp/js/dataInterface.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index eb85386553..c37b3eaa10 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -537,7 +537,8 @@ interface AssetSummary { columns?: string[] lock_all?: boolean lock_any?: boolean - languages?: Array + // TODO DEV-XXXX: Backend returns languages as string[], legacy type incorrectly allowed null in array + languages?: LangString[] row_count?: number default_translation?: string | null /** To be used in a warning about missing or poorly written question names. */ From f52da4808e14e38904d00f6ca255d1c709fa48de Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 15:14:17 +0200 Subject: [PATCH 16/86] more schema improvements --- jsapp/js/api/models/asset.ts | 9 ++- jsapp/js/api/models/assetSummary.ts | 3 +- .../manage-projects-and-library-content.ts | 65 +++++++++++-------- .../user-team-organization-usage.ts | 8 +-- .../submissions/submissionUtils.mocks.ts | 9 ++- jsapp/js/dataInterface.ts | 2 +- kpi/schema_extensions/v2/assets/extensions.py | 2 +- kpi/serializers/v2/asset.py | 6 +- static/openapi/schema_v2.json | 10 ++- static/openapi/schema_v2.yaml | 4 ++ 10 files changed, 73 insertions(+), 45 deletions(-) diff --git a/jsapp/js/api/models/asset.ts b/jsapp/js/api/models/asset.ts index 40882f1712..0678da68ee 100644 --- a/jsapp/js/api/models/asset.ts +++ b/jsapp/js/api/models/asset.ts @@ -48,11 +48,14 @@ export interface Asset { date_modified?: string /** @nullable */ date_deployed?: string | null - readonly version_id: string - readonly version__content_hash: string + /** @nullable */ + readonly version_id: string | null + /** @nullable */ + readonly version__content_hash: string | null readonly version_count: number readonly has_deployment: boolean - readonly deployed_version_id: string + /** @nullable */ + readonly deployed_version_id: string | null readonly deployed_versions: AssetDeployedVersions readonly deployment__links: AssetDeploymentLinks readonly deployment__active: boolean diff --git a/jsapp/js/api/models/assetSummary.ts b/jsapp/js/api/models/assetSummary.ts index 4f9cca9d28..2bf2393df8 100644 --- a/jsapp/js/api/models/assetSummary.ts +++ b/jsapp/js/api/models/assetSummary.ts @@ -20,5 +20,6 @@ export type AssetSummary = { readonly languages?: string[] readonly row_count?: number readonly name_quality?: AssetSummaryNameQuality - readonly default_translation?: string + /** @nullable */ + readonly default_translation?: string | null } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 1cea385297..c34d1ac7c5 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2834,7 +2834,7 @@ export const getApiV2AssetsListResponseMock = ( undefined, ]), default_translation: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, ]), }, @@ -2844,11 +2844,11 @@ export const getApiV2AssetsListResponseMock = ( faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined, ]), - version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - version__content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), has_deployment: faker.datatype.boolean(), - deployed_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), deployed_versions: { count: faker.helpers.arrayElement([ faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), @@ -3137,7 +3137,10 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial Date: Mon, 6 Jul 2026 15:30:38 +0200 Subject: [PATCH 17/86] simplify mock data in tests --- .../submissions/DataTableWrapper.stories.tsx | 14 +- .../DataTableWrapperPollingStoriesUtils.tsx | 6 +- .../submissions/submissionUtils.mocks.ts | 323 +----------------- jsapp/js/dataInterface.ts | 4 +- 4 files changed, 28 insertions(+), 319 deletions(-) diff --git a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx index b65814b1c4..a4588383e5 100644 --- a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx +++ b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx @@ -41,10 +41,12 @@ import { resetPollingUpdateStoryHandlers, } from './DataTableWrapperPollingStoriesUtils' -// TODO DEV-XXXX: Improve backend OpenAPI schema for Asset -// - Make date_created and date_modified required (they're auto-populated by Django) -// - Fix analysis_form_json.additional_fields type (should be object[], not string[]) -// These casts are safe because the types are compatible at runtime +// TODO DEV-XXXX: Orval-generated Asset and legacy AssetResponse have structural differences +// Cast Orval mocks to legacy type for stories. Main differences: +// - analysis_form_json.additional_fields: string[] vs AnalysisFormJsonField[] +// - summary.name_quality: all properties optional vs some required +// - files: object[] vs AssetResponseFile[] with different structures +import type { AssetResponse } from '#/dataInterface' // Storybook preview root does not have a fixed height by default, which breaks flexbox stretching for table header // cells. By adding a wrapper with a fixed height to the story, we ensure that `.rt-tr` and `.rt-th` flex children can @@ -172,7 +174,7 @@ const minimalAsset = getApiV2AssetsRetrieveResponseMock({ translations: [null], }, effective_permissions: [{ codename: 'change_submissions' }], -}) +}) as unknown as AssetResponse const minimalSubmissions = [ assetDataFactory(1, { @@ -251,7 +253,7 @@ const processingAsset = getApiV2AssetsRetrieveResponseMock({ ], }, effective_permissions: [{ codename: 'change_submissions' }], -}) +}) as unknown as AssetResponse const processingSubmissions = [ assetDataFactory(1, { diff --git a/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx b/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx index 0ff1af5dde..4413b31dc7 100644 --- a/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx +++ b/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx @@ -3,13 +3,13 @@ import { endpoints } from '#/api.endpoints' import { ActionIdEnum } from '#/api/models/actionIdEnum' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' import { BulkActionSubmissionStatusResponseStatusEnum } from '#/api/models/bulkActionSubmissionStatusResponseStatusEnum' -import { QuestionTypeName } from '#/constants' -import type { AssetResponse } from '#/dataInterface' import { - getApiV2AssetsRetrieveResponseMock, getApiV2AssetsRetrieveMockHandler, + getApiV2AssetsRetrieveResponseMock, } from '#/api/react-query/manage-projects-and-library-content' import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' +import { QuestionTypeName } from '#/constants' +import type { AssetResponse } from '#/dataInterface' import assetDataFactory from '#/endpoints/assetData.factory' import meMock from '#/endpoints/me.mocks' import organizationMock from '#/endpoints/organization.mocks' diff --git a/jsapp/js/components/submissions/submissionUtils.mocks.ts b/jsapp/js/components/submissions/submissionUtils.mocks.ts index d43c6326e6..b8d5256a13 100644 --- a/jsapp/js/components/submissions/submissionUtils.mocks.ts +++ b/jsapp/js/components/submissions/submissionUtils.mocks.ts @@ -1,3 +1,4 @@ +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import { AssetTypeName, GroupTypeBeginName, @@ -74,48 +75,12 @@ export const simpleSurveyChoices = [ }, ] as const satisfies SurveyChoice[] -export const simpleSurveyAsset = { - url: '', - owner: '', - owner__username: '', - owner_label: '', - last_modified_by: null, - created_by: null, - date_created: '', - summary: {}, - date_modified: '', - version_id: null, - version__content_hash: null, - has_deployment: false, - deployed_version_id: null, - deployment__active: false, - deployment__submission_count: 0, - deployment_status: 'deployed', - downloads: [], - uid: '', - kind: '', - assignable_permissions: [], - effective_permissions: [], - data: '', - children: { - count: 0, - }, +export const simpleSurveyAsset = getApiV2AssetsRetrieveResponseMock({ content: { survey: simpleSurvey, choices: simpleSurveyChoices, }, - subscribers_count: 0, - status: '', - access_types: null, - project_ownership: null, - parent: null, - settings: {}, asset_type: AssetTypeName.survey, - report_styles: { - default: {}, - specified: {}, - kuid_names: {}, - }, report_custom: {}, map_styles: {}, map_custom: {}, @@ -125,7 +90,7 @@ export const simpleSurveyAsset = { export_settings: [], data_sharing: {}, files: [], -} as const satisfies AssetResponse +}) as unknown as AssetResponse export const simpleSurveySubmission = { __version__: 'vHNo5vFh3KoB7LWhucUkFy', @@ -295,57 +260,14 @@ export const repeatSurvey = [ }, ] as const satisfies SurveyRow[] -export const repeatSurveyAsset = { - url: '', - owner: '', - owner__username: '', - owner_label: '', - last_modified_by: null, - created_by: null, - date_created: '', - summary: {}, - date_modified: '', - version_id: null, - version__content_hash: null, - has_deployment: false, - deployed_version_id: null, - deployment__active: false, - deployment__submission_count: 0, - deployment_status: 'deployed', - downloads: [], - uid: '', - kind: '', - assignable_permissions: [], - effective_permissions: [], - data: '', - children: { - count: 0, - }, +export const repeatSurveyAsset = getApiV2AssetsRetrieveResponseMock({ content: { survey: repeatSurvey, }, - subscribers_count: 0, - status: '', - access_types: null, - project_ownership: null, - parent: null, - settings: {}, asset_type: AssetTypeName.survey, - report_styles: { - default: {}, - specified: {}, - kuid_names: {}, - }, - report_custom: {}, - map_styles: {}, - map_custom: {}, - tag_string: '', - name: '', - permissions: [], - export_settings: [], data_sharing: {}, files: [], -} as const satisfies AssetResponse +}) as unknown as AssetResponse // NOTE: the second repeat submission has no First_name and Middle_name to test stuff better export const repeatSurveySubmission = { @@ -495,57 +417,14 @@ export const nestedRepeatSurvey = [ }, ] as const satisfies SurveyRow[] -export const nestedRepeatSurveyAsset = { - url: '', - owner: '', - owner__username: '', - owner_label: '', - last_modified_by: null, - created_by: null, - date_created: '', - summary: {}, - date_modified: '', - version_id: null, - version__content_hash: null, - has_deployment: false, - deployed_version_id: null, - deployment__active: false, - deployment__submission_count: 0, - deployment_status: 'deployed', - downloads: [], - uid: '', - kind: '', - assignable_permissions: [], - effective_permissions: [], - data: '', - children: { - count: 0, - }, +export const nestedRepeatSurveyAsset = getApiV2AssetsRetrieveResponseMock({ content: { survey: nestedRepeatSurvey, }, - subscribers_count: 0, - status: '', - access_types: null, - project_ownership: null, - parent: null, - settings: {}, asset_type: AssetTypeName.survey, - report_styles: { - default: {}, - specified: {}, - kuid_names: {}, - }, - report_custom: {}, - map_styles: {}, - map_custom: {}, - tag_string: '', - name: '', - permissions: [], - export_settings: [], data_sharing: {}, files: [], -} as const satisfies AssetResponse +}) as unknown as AssetResponse export const nestedRepeatSurveySubmission = { __version__: 'v7sPQZCGQoW8JKYL5Kq79m', @@ -790,58 +669,15 @@ export const matrixSurveyChoices = [ }, ] as const satisfies SurveyChoice[] -export const matrixSurveyAsset = { - url: '', - owner: '', - owner__username: '', - owner_label: '', - last_modified_by: null, - created_by: null, - date_created: '', - summary: {}, - date_modified: '', - version_id: null, - version__content_hash: null, - has_deployment: false, - deployed_version_id: null, - deployment__active: false, - deployment__submission_count: 0, - deployment_status: 'deployed', - downloads: [], - uid: '', - kind: '', - assignable_permissions: [], - effective_permissions: [], - data: '', - children: { - count: 0, - }, +export const matrixSurveyAsset = getApiV2AssetsRetrieveResponseMock({ content: { survey: matrixSurvey, choices: matrixSurveyChoices, }, - subscribers_count: 0, - status: '', - access_types: null, - project_ownership: null, - parent: null, - settings: {}, asset_type: AssetTypeName.survey, - report_styles: { - default: {}, - specified: {}, - kuid_names: {}, - }, - report_custom: {}, - map_styles: {}, - map_custom: {}, - tag_string: '', - name: '', - permissions: [], - export_settings: [], data_sharing: {}, files: [], -} as const satisfies AssetResponse +}) as unknown as AssetResponse export const matrixSurveySubmission = { _id: 22, @@ -1093,58 +929,15 @@ export const groupsSurveyChoices = [ }, ] as const satisfies SurveyChoice[] -export const groupsSurveyAsset = { - url: '', - owner: '', - owner__username: '', - owner_label: '', - last_modified_by: null, - created_by: null, - date_created: '', - summary: {}, - date_modified: '', - version_id: null, - version__content_hash: null, - has_deployment: false, - deployed_version_id: null, - deployment__active: false, - deployment__submission_count: 0, - deployment_status: 'deployed', - downloads: [], - uid: '', - kind: '', - assignable_permissions: [], - effective_permissions: [], - data: '', - children: { - count: 0, - }, +export const groupsSurveyAsset = getApiV2AssetsRetrieveResponseMock({ content: { survey: groupsSurvey, choices: groupsSurveyChoices, }, - subscribers_count: 0, - status: '', - access_types: null, - project_ownership: null, - parent: null, - settings: {}, asset_type: AssetTypeName.survey, - report_styles: { - default: {}, - specified: {}, - kuid_names: {}, - }, - report_custom: {}, - map_styles: {}, - map_custom: {}, - tag_string: '', - name: '', - permissions: [], - export_settings: [], data_sharing: {}, files: [], -} as const satisfies AssetResponse +}) as unknown as AssetResponse export const groupsSurveySubmission = { _id: 23, @@ -1675,58 +1468,15 @@ export const everythingSurveyChoices = [ }, ] as const satisfies SurveyChoice[] -export const everythingSurveyAsset = { - url: '', - owner: '', - owner__username: '', - owner_label: '', - last_modified_by: null, - created_by: null, - date_created: '', - summary: {}, - date_modified: '', - version_id: null, - version__content_hash: null, - has_deployment: false, - deployed_version_id: null, - deployment__active: false, - deployment__submission_count: 0, - deployment_status: 'deployed', - downloads: [], - uid: '', - kind: '', - assignable_permissions: [], - effective_permissions: [], - data: '', - children: { - count: 0, - }, +export const everythingSurveyAsset = getApiV2AssetsRetrieveResponseMock({ content: { survey: everythingSurvey, choices: everythingSurveyChoices, }, - subscribers_count: 0, - status: '', - access_types: null, - project_ownership: null, - parent: null, - settings: {}, asset_type: AssetTypeName.survey, - report_styles: { - default: {}, - specified: {}, - kuid_names: {}, - }, - report_custom: {}, - map_styles: {}, - map_custom: {}, - tag_string: '', - name: '', - permissions: [], - export_settings: [], data_sharing: {}, files: [], -} as const satisfies AssetResponse +}) as unknown as AssetResponse export const everythingSurveySubmission = { _id: 25, @@ -2129,58 +1879,15 @@ export const matrixRepeatSurveyChoices = [ }, ] as const satisfies SurveyChoice[] -export const matrixRepeatSurveyAsset = { - url: '', - owner: '', - owner__username: '', - owner_label: '', - last_modified_by: null, - created_by: null, - date_created: '', - summary: {}, - date_modified: '', - version_id: null, - version__content_hash: null, - has_deployment: false, - deployed_version_id: null, - deployment__active: false, - deployment__submission_count: 0, - deployment_status: 'deployed', - downloads: [], - uid: '', - kind: '', - assignable_permissions: [], - effective_permissions: [], - data: '', - children: { - count: 0, - }, +export const matrixRepeatSurveyAsset = getApiV2AssetsRetrieveResponseMock({ content: { survey: matrixRepeatSurvey, choices: matrixRepeatSurveyChoices, }, - subscribers_count: 0, - status: '', - access_types: null, - project_ownership: null, - parent: null, - settings: {}, asset_type: AssetTypeName.survey, - report_styles: { - default: {}, - specified: {}, - kuid_names: {}, - }, - report_custom: {}, - map_styles: {}, - map_custom: {}, - tag_string: '', - name: '', - permissions: [], - export_settings: [], data_sharing: {}, files: [], -} as const satisfies AssetResponse +}) as unknown as AssetResponse export const matrixRepeatSurveySubmission = { _id: 16, diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index 2861d27e3c..57242810b5 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -699,13 +699,13 @@ export interface AssetResponse extends AssetRequestObject { date_deployed?: string | null version_id: string | null version__content_hash: string | null - version_count?: number + version_count: number has_deployment: boolean deployed_version_id: string | null analysis_form_json?: { additional_fields: AnalysisFormJsonField[] } - deployed_versions?: { + deployed_versions: { count: number next: string | null previous: string | null From f1214563f886d06a7767c40514a4ca2bdb42dbce Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 16:45:37 +0200 Subject: [PATCH 18/86] make previous and next nullable --- jsapp/js/api/models/assetDeployedVersions.ts | 6 +- .../manage-projects-and-library-content.ts | 70 +++++++++++++++---- .../user-team-organization-usage.ts | 10 ++- kpi/schema_extensions/v2/assets/extensions.py | 4 +- static/openapi/schema_v2.json | 6 +- static/openapi/schema_v2.yaml | 2 + 6 files changed, 76 insertions(+), 22 deletions(-) diff --git a/jsapp/js/api/models/assetDeployedVersions.ts b/jsapp/js/api/models/assetDeployedVersions.ts index 5d1c916e0c..bd1fb8ded8 100644 --- a/jsapp/js/api/models/assetDeployedVersions.ts +++ b/jsapp/js/api/models/assetDeployedVersions.ts @@ -13,7 +13,9 @@ import type { AssetDeployedVersionsResultsItem } from './assetDeployedVersionsRe export type AssetDeployedVersions = { readonly count?: number - readonly next?: string - readonly previous?: string + /** @nullable */ + readonly next?: string | null + /** @nullable */ + readonly previous?: string | null readonly results?: AssetDeployedVersionsResultsItem[] } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index c34d1ac7c5..d1504fa029 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2854,8 +2854,14 @@ export const getApiV2AssetsListResponseMock = ( faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + next: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + previous: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), results: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -3158,8 +3164,14 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({ uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -3461,8 +3473,14 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({ uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -3764,8 +3782,14 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + next: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + previous: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), results: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -4091,8 +4115,14 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + next: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + previous: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), results: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -4401,8 +4431,14 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + next: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + previous: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), results: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), @@ -4711,8 +4747,14 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + next: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + previous: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), results: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index e3d75ea693..884ec1e3cb 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -3976,8 +3976,14 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), undefined, ]), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + next: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + previous: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), results: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 1864dce736..e61d3d1bfc 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -330,8 +330,8 @@ def map_serializer_field(self, auto_schema, direction): return build_object_type( properties={ 'count': build_basic_type(OpenApiTypes.INT), - 'next': GENERIC_STRING_SCHEMA, - 'previous': GENERIC_STRING_SCHEMA, + 'next': {**GENERIC_STRING_SCHEMA, 'nullable': True}, + 'previous': {**GENERIC_STRING_SCHEMA, 'nullable': True}, 'results': build_array_type( schema=build_object_type( properties={ diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 86ecec70ce..c542cf48be 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21401,10 +21401,12 @@ "type": "integer" }, "next": { - "type": "string" + "type": "string", + "nullable": true }, "previous": { - "type": "string" + "type": "string", + "nullable": true }, "results": { "type": "array", diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index cda217c7bc..60d940aebc 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15338,8 +15338,10 @@ components: type: integer next: type: string + nullable: true previous: type: string + nullable: true results: type: array items: From e8d380543a891ce9617842a4ef3649c3e5c79832 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 17:01:12 +0200 Subject: [PATCH 19/86] few more improvements --- .../submissions/DataTableWrapper.stories.tsx | 2 +- .../DataTableWrapperPollingStoriesUtils.tsx | 8 +------ jsapp/js/dataInterface.ts | 24 +++++++++---------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx index a4588383e5..aff44cbad4 100644 --- a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx +++ b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx @@ -426,7 +426,7 @@ export const ProcessingColumnAndBanner: Story = { export const ProcessingPollingRefreshesTranslatedCell: Story = { args: { - asset: pollingAsset, + asset: pollingAsset as unknown as AssetResponse, }, parameters: { docs: { diff --git a/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx b/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx index 4413b31dc7..ae191a0173 100644 --- a/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx +++ b/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx @@ -9,7 +9,6 @@ import { } from '#/api/react-query/manage-projects-and-library-content' import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' import { QuestionTypeName } from '#/constants' -import type { AssetResponse } from '#/dataInterface' import assetDataFactory from '#/endpoints/assetData.factory' import meMock from '#/endpoints/me.mocks' import organizationMock from '#/endpoints/organization.mocks' @@ -26,11 +25,6 @@ const POLLING_STORY_ASSERTION_GRACE_MS = 6000 // enough time to actually render the "Processing" cell before completion fires. const POLLING_COMPLETE_AFTER_MS = 2000 -// TODO DEV-XXXX: Improve backend OpenAPI schema for Asset -// - Make date_created and date_modified required (they're auto-populated by Django) -// - Fix analysis_form_json.additional_fields type (should be object[], not string[]) -// This cast is safe because the types are compatible at runtime - // Dedicated polling story data is kept in a separate file so the main stories // file remains easy to scan as more table scenarios get added. export const pollingAsset = getApiV2AssetsRetrieveResponseMock({ @@ -70,7 +64,7 @@ export const pollingAsset = getApiV2AssetsRetrieveResponseMock({ translations: [null], }, effective_permissions: [{ codename: 'change_submissions' }], -}) as AssetResponse +}) const pollingSubmissionInitial = assetDataFactory(11, { Record_a_sound: 'test11.mp3', diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index 57242810b5..d24c2aa8e9 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -543,20 +543,20 @@ interface AssetSummary { default_translation?: string | null /** To be used in a warning about missing or poorly written question names. */ name_quality?: { - ok: number - bad: number - good: number - total: number - firsts: { + ok?: number + bad?: number + good?: number + total?: number + firsts?: { ok?: { - name: string - index: number - label: string[] + name?: string + index?: number + label?: string[] } bad?: { - name: string - index: number - label: string[] + name?: string + index?: number + label?: string[] } } } @@ -717,7 +717,7 @@ export interface AssetResponse extends AssetRequestObject { date_modified: string }> } - deployment__links?: { + deployment__links: { url?: string single_url?: string single_once_url?: string From 560c360748a72338ab9f6f4d1d7287d3ef7e9286 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 17:01:25 +0200 Subject: [PATCH 20/86] improve additional_fields schema --- jsapp/js/api/models/assetAnalysisFormJson.ts | 3 +- ...setAnalysisFormJsonAdditionalFieldsItem.ts | 22 +++ ...FormJsonAdditionalFieldsItemChoicesItem.ts | 17 +++ ...onAdditionalFieldsItemChoicesItemLabels.ts | 13 ++ .../manage-projects-and-library-content.ts | 126 +++++++++++++++--- .../user-team-organization-usage.ts | 18 ++- kpi/schema_extensions/v2/assets/extensions.py | 24 +++- static/openapi/schema_v2.json | 46 ++++++- static/openapi/schema_v2.yaml | 32 ++++- 9 files changed, 273 insertions(+), 28 deletions(-) create mode 100644 jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItem.ts create mode 100644 jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItem.ts create mode 100644 jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels.ts diff --git a/jsapp/js/api/models/assetAnalysisFormJson.ts b/jsapp/js/api/models/assetAnalysisFormJson.ts index 76a43bcf66..f27d03e88d 100644 --- a/jsapp/js/api/models/assetAnalysisFormJson.ts +++ b/jsapp/js/api/models/assetAnalysisFormJson.ts @@ -9,7 +9,8 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetAnalysisFormJsonAdditionalFieldsItem } from './assetAnalysisFormJsonAdditionalFieldsItem' export type AssetAnalysisFormJson = { - readonly additional_fields?: string[] + readonly additional_fields?: AssetAnalysisFormJsonAdditionalFieldsItem[] } diff --git a/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItem.ts b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItem.ts new file mode 100644 index 0000000000..f32546037a --- /dev/null +++ b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItem.ts @@ -0,0 +1,22 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetAnalysisFormJsonAdditionalFieldsItemChoicesItem } from './assetAnalysisFormJsonAdditionalFieldsItemChoicesItem' + +export type AssetAnalysisFormJsonAdditionalFieldsItem = { + language?: string + source: string + type: string + name: string + dtpath: string + label?: string + choices?: AssetAnalysisFormJsonAdditionalFieldsItemChoicesItem[] +} diff --git a/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItem.ts b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItem.ts new file mode 100644 index 0000000000..923c1f4756 --- /dev/null +++ b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItem.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels } from './assetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels' + +export type AssetAnalysisFormJsonAdditionalFieldsItemChoicesItem = { + uuid: string + labels: AssetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels +} diff --git a/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels.ts b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels.ts new file mode 100644 index 0000000000..20bf62b523 --- /dev/null +++ b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels = { [key: string]: unknown } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index d1504fa029..3d631854a6 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2939,9 +2939,21 @@ export const getApiV2AssetsListResponseMock = ( })), analysis_form_json: { additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), undefined, ]), }, @@ -3249,9 +3261,21 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), undefined, ]), }, @@ -3558,9 +3582,21 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), undefined, ]), }, @@ -3867,9 +3903,21 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia })), analysis_form_json: { additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), undefined, ]), }, @@ -4200,9 +4248,21 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( })), analysis_form_json: { additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), undefined, ]), }, @@ -4516,9 +4576,21 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( })), analysis_form_json: { additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), undefined, ]), }, @@ -4832,9 +4904,21 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( })), analysis_form_json: { additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), undefined, ]), }, diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 884ec1e3cb..7589179356 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4061,9 +4061,21 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( })), analysis_form_json: { additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), undefined, ]), }, diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index e61d3d1bfc..d9aa2388a7 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -64,9 +64,31 @@ class AnalysisFormJsonExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.AnalysisFormJsonField' def map_serializer_field(self, auto_schema, direction): + # Define the structure for each additional_fields item + additional_field_item = build_object_type( + required=['source', 'type', 'name', 'dtpath'], + properties={ + 'language': GENERIC_STRING_SCHEMA, # optional: two letter language code + 'source': GENERIC_STRING_SCHEMA, # required: path to form question + 'type': GENERIC_STRING_SCHEMA, # required: e.g. 'transcript', 'translation', 'qual*' + 'name': GENERIC_STRING_SCHEMA, # required + 'dtpath': GENERIC_STRING_SCHEMA, # required: data table path + 'label': GENERIC_STRING_SCHEMA, # optional: question label or 'source'/'verified' + 'choices': build_array_type( + build_object_type( + required=['uuid', 'labels'], + properties={ + 'uuid': GENERIC_STRING_SCHEMA, + 'labels': GENERIC_OBJECT_SCHEMA, # {_default: string, ...} + } + ) + ), # optional: for single/multi choice qual questions + } + ) + return build_object_type( properties={ - 'additional_fields': GENERIC_ARRAY_SCHEMA, + 'additional_fields': build_array_type(additional_field_item), } ) diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index c542cf48be..ab2ddc2093 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21589,7 +21589,51 @@ "additional_fields": { "type": "array", "items": { - "type": "string" + "type": "object", + "properties": { + "language": { + "type": "string" + }, + "source": { + "type": "string" + }, + "type": { + "type": "string" + }, + "name": { + "type": "string" + }, + "dtpath": { + "type": "string" + }, + "label": { + "type": "string" + }, + "choices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "uuid": { + "type": "string" + }, + "labels": { + "type": "object" + } + }, + "required": [ + "labels", + "uuid" + ] + } + } + }, + "required": [ + "dtpath", + "name", + "source", + "type" + ] } } }, diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 60d940aebc..61b250a313 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15465,7 +15465,37 @@ components: additional_fields: type: array items: - type: string + type: object + properties: + language: + type: string + source: + type: string + type: + type: string + name: + type: string + dtpath: + type: string + label: + type: string + choices: + type: array + items: + type: object + properties: + uuid: + type: string + labels: + type: object + required: + - labels + - uuid + required: + - dtpath + - name + - source + - type readOnly: true xform_link: type: string From a90d18b4e42b15fe16d1f5d92fe525674d1405c8 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 17:06:11 +0200 Subject: [PATCH 21/86] fix deployment__data_download_links type --- jsapp/js/dataInterface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index d24c2aa8e9..4750efc6de 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -728,7 +728,7 @@ export interface AssetResponse extends AssetRequestObject { single_once_iframe_url?: string } deployment__active: boolean - deployment__data_download_links?: { + deployment__data_download_links: { csv_legacy: string csv: string geojson?: string From 8e5638e21ea5afae0e43586a0fb6602a06ef6b16 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 17:18:59 +0200 Subject: [PATCH 22/86] improve types further --- jsapp/js/components/library/assetInfoBox.tsx | 4 +- .../submissions/tableUtils.mocks.ts | 547 +----------------- jsapp/js/dataInterface.ts | 2 +- 3 files changed, 21 insertions(+), 532 deletions(-) diff --git a/jsapp/js/components/library/assetInfoBox.tsx b/jsapp/js/components/library/assetInfoBox.tsx index 72948669a0..4d93207539 100644 --- a/jsapp/js/components/library/assetInfoBox.tsx +++ b/jsapp/js/components/library/assetInfoBox.tsx @@ -74,13 +74,13 @@ export default class AssetInfoBox extends React.Component - {formatTime(this.props.asset.date_created)} + {this.props.asset.date_created ? formatTime(this.props.asset.date_created) : 'n/a'} {this.state.areDetailsVisible && ( - {formatTime(this.props.asset.date_modified)} + {this.props.asset.date_modified ? formatTime(this.props.asset.date_modified) : 'n/a'} )} diff --git a/jsapp/js/components/submissions/tableUtils.mocks.ts b/jsapp/js/components/submissions/tableUtils.mocks.ts index dc02510d29..53aa8084e2 100644 --- a/jsapp/js/components/submissions/tableUtils.mocks.ts +++ b/jsapp/js/components/submissions/tableUtils.mocks.ts @@ -1,23 +1,14 @@ +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import { ANY_ROW_TYPE_NAMES, AssetTypeName } from '#/constants' import type { AssetResponse } from '#/dataInterface' -export const assetWithBgAudioAndNLP: AssetResponse = { - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt', - owner: 'http://kf.kobo.local/api/v2/users/kobo.json', - owner__username: 'kobo', - owner_label: 'kobo', - last_modified_by: null, - created_by: null, - parent: null, - settings: { - sector: {}, - country: [], - description: '', - organization: '', - country_codes: [], - }, +export const assetWithBgAudioAndNLP = getApiV2AssetsRetrieveResponseMock({ + uid: 'am5q2MmVckuLBXPKsbHjEt', + name: 'text and media projekt', asset_type: AssetTypeName.survey, - files: [], + deployment__active: true, + deployment__submission_count: 1, + has_deployment: true, summary: { geo: false, labels: ['Your name here', 'Your selfie goes here', 'A video? WTF', 'Secret password as an audio file'], @@ -26,96 +17,9 @@ export const assetWithBgAudioAndNLP: AssetResponse = { lock_any: false, languages: [], row_count: 5, - name_quality: { - ok: 0, - bad: 0, - good: 5, - total: 5, - firsts: {}, - }, + name_quality: { ok: 0, bad: 0, good: 5, total: 5, firsts: {} }, default_translation: null, }, - date_created: '2024-10-21T10:20:46.811112Z', - date_modified: '2024-10-23T13:54:50.828315Z', - date_deployed: '2024-10-21T10:21:16.157454Z', - version_id: 'vM3yepjgRLxbQfTy4V7JQ9', - version__content_hash: '8362f2d2c4100490fae4f811bad5296188421855', - version_count: 6, - has_deployment: true, - deployed_version_id: 'vsuXfYXtZpRaXdWcDQe8cS', - deployed_versions: { - count: 1, - next: null, - previous: null, - results: [ - { - uid: 'vsuXfYXtZpRaXdWcDQe8cS', - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/versions/vsuXfYXtZpRaXdWcDQe8cS/', - content_hash: '8362f2d2c4100490fae4f811bad5296188421855', - date_deployed: '2024-10-21T10:21:16.154074Z', - date_modified: '2024-10-21T10:21:16.154074Z', - }, - ], - }, - deployment__links: { - url: 'http://ee.kobo.local/YnqSWtB3', - single_url: 'http://ee.kobo.local/single/YnqSWtB3', - single_once_url: 'http://ee.kobo.local/single/9778636aa5d24eb2f0806bab320e7bc6', - offline_url: 'http://ee.kobo.local/x/YnqSWtB3', - preview_url: 'http://ee.kobo.local/preview/YnqSWtB3', - iframe_url: 'http://ee.kobo.local/i/YnqSWtB3', - single_iframe_url: 'http://ee.kobo.local/single/i/YnqSWtB3', - single_once_iframe_url: 'http://ee.kobo.local/single/i/9778636aa5d24eb2f0806bab320e7bc6', - }, - deployment__active: true, - deployment__data_download_links: { - xls_legacy: 'http://kc.kobo.local/kobo/exports/am5q2MmVckuLBXPKsbHjEt/xls/', - csv_legacy: 'http://kc.kobo.local/kobo/exports/am5q2MmVckuLBXPKsbHjEt/csv/', - zip_legacy: 'http://kc.kobo.local/kobo/exports/am5q2MmVckuLBXPKsbHjEt/zip/', - kml_legacy: 'http://kc.kobo.local/kobo/exports/am5q2MmVckuLBXPKsbHjEt/kml/', - geojson: 'http://kc.kobo.local/kobo/exports/am5q2MmVckuLBXPKsbHjEt/geojson/', - spss_labels: 'http://kc.kobo.local/kobo/exports/am5q2MmVckuLBXPKsbHjEt/spss/', - xls: 'http://kc.kobo.local/kobo/reports/am5q2MmVckuLBXPKsbHjEt/export.xlsx', - csv: 'http://kc.kobo.local/kobo/reports/am5q2MmVckuLBXPKsbHjEt/export.csv', - }, - deployment__submission_count: 1, - deployment_status: 'deployed', - report_styles: { - default: {}, - specified: { - end: {}, - audit: {}, - start: {}, - today: {}, - deviceid: {}, - username: {}, - simserial: {}, - A_video_WTF: {}, - phonenumber: {}, - subscriberid: {}, - Your_name_here: {}, - 'background-audio': {}, - Your_selfie_goes_here: {}, - Secret_password_as_an_audio_file: {}, - }, - kuid_names: { - end: 'MlyFnjOHJ', - audit: 'QG4SJ5LYb', - start: 'M3AXQZPzW', - today: 'aBemgUnm5', - deviceid: 'SzW7bWk8N', - username: 'mQjEGodmD', - simserial: 'QsCIjT134', - A_video_WTF: 'alGpvxEVv', - phonenumber: 'UfrYC0nkS', - subscriberid: '6iTYT9Hk1', - Your_name_here: '25l27nQ3a', - 'background-audio': 'dE9sDyVtS', - Your_selfie_goes_here: 'd0JxfaSC9', - Secret_password_as_an_audio_file: '2sN8g5yJ2', - }, - }, - report_custom: {}, advanced_features: { qual: { qual_survey: [ @@ -193,8 +97,6 @@ export const assetWithBgAudioAndNLP: AssetResponse = { }, ], }, - map_styles: {}, - map_custom: {}, content: { schema: '1', survey: [ @@ -299,195 +201,16 @@ export const assetWithBgAudioAndNLP: AssetResponse = { translated: ['label'], translations: [null], }, - downloads: [ - { - format: 'xls', - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt.xls', - }, - { - format: 'xml', - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt.xml', - }, - ], - embeds: [ - { - format: 'xls', - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/xls/', - }, - { - format: 'xform', - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/xform/', - }, - ], - xform_link: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/xform/', - hooks_link: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/hooks/', - tag_string: '', - uid: 'am5q2MmVckuLBXPKsbHjEt', - kind: 'asset', - xls_link: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/xls/', - name: 'text and media projekt', - assignable_permissions: [ - { - url: 'http://kf.kobo.local/api/v2/permissions/view_asset/', - label: 'View form', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/change_asset/', - label: 'Edit form', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/manage_asset/', - label: 'Manage project', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/view_submissions/', - label: 'View submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/partial_submissions/', - label: { - default: 'Act on submissions only from specific users', - view_submissions: 'View submissions only from specific users', - change_submissions: 'Edit submissions only from specific users', - delete_submissions: 'Delete submissions only from specific users', - validate_submissions: 'Validate submissions only from specific users', - }, - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/change_submissions/', - label: 'Edit submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/delete_submissions/', - label: 'Delete submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/validate_submissions/', - label: 'Validate submissions', - }, - ], - permissions: [ - { - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/permission-assignments/pUmPzC6pFgDdcB2cxLn9QD/', - user: 'http://kf.kobo.local/api/v2/users/AnonymousUser.json', - permission: 'http://kf.kobo.local/api/v2/permissions/add_submissions.json', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/permission-assignments/p6nyXrHUs5BpNJLZPaunvJ/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/add_submissions.json', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/permission-assignments/pz7RvRMsYHuJL9TRyQyoDP/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/change_asset.json', - label: 'Edit form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/permission-assignments/pM7p797FK3qQjCYADpxojX/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/change_submissions.json', - label: 'Edit submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/permission-assignments/p8aL4ifctta3AxvRWeUwsz/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/delete_submissions.json', - label: 'Delete submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/permission-assignments/paBd2H3gyWhZQBkGzGvfjE/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/manage_asset.json', - label: 'Manage project', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/permission-assignments/pAdfYDhVHTWXNMv8CTZxFz/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/validate_submissions.json', - label: 'Validate submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/permission-assignments/p782nm85UEcMy56EvxiNMz/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/view_asset.json', - label: 'View form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/permission-assignments/pPAFrcPkXTuQFWywccDzr7/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/view_submissions.json', - label: 'View submissions', - }, - ], - effective_permissions: [ - { - codename: 'delete_submissions', - }, - { - codename: 'view_asset', - }, - { - codename: 'change_asset', - }, - { - codename: 'view_submissions', - }, - { - codename: 'delete_asset', - }, - { - codename: 'manage_asset', - }, - { - codename: 'change_submissions', - }, - { - codename: 'validate_submissions', - }, - { - codename: 'add_submissions', - }, - ], - exports: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/exports/', - export_settings: [], - data: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/data.json', - children: { - count: 0, - }, - subscribers_count: 0, - status: 'shared', - access_types: null, - data_sharing: {}, - paired_data: 'http://kf.kobo.local/api/v2/assets/am5q2MmVckuLBXPKsbHjEt/paired-data/', - project_ownership: null, -} + effective_permissions: [{ codename: 'change_submissions' }], +}) as unknown as AssetResponse -export const assetWithNestedGroupsAndNLP: AssetResponse = { - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC.json', - owner: 'http://kf.kobo.local/api/v2/users/kobo.json', - owner__username: 'kobo', - owner_label: 'kobo', - last_modified_by: null, - created_by: null, - parent: null, - settings: { - sector: {}, - country: [], - description: '', - collects_pii: null, - organization: '', - country_codes: [], - operational_purpose: null, - }, +export const assetWithNestedGroupsAndNLP = getApiV2AssetsRetrieveResponseMock({ + uid: 'aRai4qmXVG4eukrzpHXAQC', + name: 'Project with audio inside nested group', asset_type: AssetTypeName.survey, - files: [], + deployment__active: true, + deployment__submission_count: 1, + has_deployment: true, summary: { geo: false, labels: ['What did you hear?'], @@ -511,77 +234,6 @@ export const assetWithNestedGroupsAndNLP: AssetResponse = { }, default_translation: null, }, - date_created: '2024-10-24T21:50:14.547659Z', - date_modified: '2024-10-24T22:10:01.271453Z', - date_deployed: '2024-10-24T21:52:53.487365Z', - version_id: 'veWGMzgZCdiNnDvBdxtrQj', - version__content_hash: '778df104b69459fe67b8431bb500433b82e2ee33', - version_count: 7, - has_deployment: true, - deployed_version_id: 'v4MNF9dNVo682gg2KZc5P7', - deployed_versions: { - count: 1, - next: null, - previous: null, - results: [ - { - uid: 'v4MNF9dNVo682gg2KZc5P7', - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/versions/v4MNF9dNVo682gg2KZc5P7/', - content_hash: '778df104b69459fe67b8431bb500433b82e2ee33', - date_deployed: '2024-10-24T21:52:53.478265Z', - date_modified: '2024-10-24T21:52:53.478265Z', - }, - ], - }, - deployment__links: { - url: 'http://ee.kobo.local/iQdYiTID', - single_url: 'http://ee.kobo.local/single/iQdYiTID', - single_once_url: 'http://ee.kobo.local/single/7edea25f7e36766e7558a8a9d2e015f0', - offline_url: 'http://ee.kobo.local/x/iQdYiTID', - preview_url: 'http://ee.kobo.local/preview/iQdYiTID', - iframe_url: 'http://ee.kobo.local/i/iQdYiTID', - single_iframe_url: 'http://ee.kobo.local/single/i/iQdYiTID', - single_once_iframe_url: 'http://ee.kobo.local/single/i/7edea25f7e36766e7558a8a9d2e015f0', - }, - deployment__active: true, - deployment__data_download_links: { - xls_legacy: 'http://kc.kobo.local/kobo/exports/aRai4qmXVG4eukrzpHXAQC/xls/', - csv_legacy: 'http://kc.kobo.local/kobo/exports/aRai4qmXVG4eukrzpHXAQC/csv/', - zip_legacy: 'http://kc.kobo.local/kobo/exports/aRai4qmXVG4eukrzpHXAQC/zip/', - kml_legacy: 'http://kc.kobo.local/kobo/exports/aRai4qmXVG4eukrzpHXAQC/kml/', - geojson: 'http://kc.kobo.local/kobo/exports/aRai4qmXVG4eukrzpHXAQC/geojson/', - spss_labels: 'http://kc.kobo.local/kobo/exports/aRai4qmXVG4eukrzpHXAQC/spss/', - xls: 'http://kc.kobo.local/kobo/reports/aRai4qmXVG4eukrzpHXAQC/export.xlsx', - csv: 'http://kc.kobo.local/kobo/reports/aRai4qmXVG4eukrzpHXAQC/export.csv', - }, - deployment__submission_count: 1, - deployment_status: 'deployed', - report_styles: { - default: {}, - specified: { - end: {}, - start: {}, - sm28q44: {}, - '/kx8rw55': {}, - '/oh5pd61': {}, - '/py8fl89': {}, - inner_group: {}, - outer_group: {}, - middle_group: {}, - }, - kuid_names: { - end: 'wnxtTQ2B1', - start: 'D8zvSJsd3', - sm28q44: 'sm28q44', - '/kx8rw55': '/kx8rw55', - '/oh5pd61': '/oh5pd61', - '/py8fl89': '/py8fl89', - inner_group: 'oh5pd61', - outer_group: 'kx8rw55', - middle_group: 'py8fl89', - }, - }, - report_custom: {}, advanced_features: { transcript: { languages: ['pl'], @@ -610,8 +262,6 @@ export const assetWithNestedGroupsAndNLP: AssetResponse = { }, ], }, - map_styles: {}, - map_custom: {}, content: { schema: '1', survey: [ @@ -664,166 +314,5 @@ export const assetWithNestedGroupsAndNLP: AssetResponse = { translated: ['label'], translations: [null], }, - downloads: [ - { - format: 'xls', - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC.xls', - }, - { - format: 'xml', - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC.xml', - }, - ], - embeds: [ - { - format: 'xls', - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/xls/', - }, - { - format: 'xform', - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/xform/', - }, - ], - xform_link: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/xform/', - hooks_link: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/hooks/', - tag_string: '', - uid: 'aRai4qmXVG4eukrzpHXAQC', - kind: 'asset', - xls_link: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/xls/', - name: 'Project with audio inside nested group', - assignable_permissions: [ - { - url: 'http://kf.kobo.local/api/v2/permissions/view_asset/', - label: 'View form', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/change_asset/', - label: 'Edit form', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/manage_asset/', - label: 'Manage project', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/view_submissions/', - label: 'View submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/partial_submissions/', - label: { - default: 'Act on submissions only from specific users', - view_submissions: 'View submissions only from specific users', - change_submissions: 'Edit submissions only from specific users', - delete_submissions: 'Delete submissions only from specific users', - validate_submissions: 'Validate submissions only from specific users', - }, - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/change_submissions/', - label: 'Edit submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/delete_submissions/', - label: 'Delete submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/validate_submissions/', - label: 'Validate submissions', - }, - ], - permissions: [ - { - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/permission-assignments/pCYMKNGknBkN5vMpsFeBrL/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/add_submissions.json', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/permission-assignments/pWH6k8kQyjT4z3WAheWhTH/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/change_asset.json', - label: 'Edit form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/permission-assignments/pF4feraPmjmGwbs4XGGjMd/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/change_submissions.json', - label: 'Edit submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/permission-assignments/pWXMaN6dAiwWv9kE5s2Mvn/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/delete_submissions.json', - label: 'Delete submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/permission-assignments/peFnddaDPNehS3H95ZuVEe/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/manage_asset.json', - label: 'Manage project', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/permission-assignments/pAqCW3fjVQLQNtBX4rxZjg/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/validate_submissions.json', - label: 'Validate submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/permission-assignments/puB4cwPhyJFprC5zXcdD8K/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/view_asset.json', - label: 'View form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/permission-assignments/poNyR5qmXJ7Wjq99qMuncR/', - user: 'http://kf.kobo.local/api/v2/users/kobo.json', - permission: 'http://kf.kobo.local/api/v2/permissions/view_submissions.json', - label: 'View submissions', - }, - ], - effective_permissions: [ - { - codename: 'view_submissions', - }, - { - codename: 'validate_submissions', - }, - { - codename: 'add_submissions', - }, - { - codename: 'manage_asset', - }, - { - codename: 'delete_submissions', - }, - { - codename: 'delete_asset', - }, - { - codename: 'view_asset', - }, - { - codename: 'change_asset', - }, - { - codename: 'change_submissions', - }, - ], - exports: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/exports/', - export_settings: [], - data: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/data.json', - children: { - count: 0, - }, - subscribers_count: 0, - status: 'private', - access_types: null, - data_sharing: {}, - paired_data: 'http://kf.kobo.local/api/v2/assets/aRai4qmXVG4eukrzpHXAQC/paired-data/', - project_ownership: null, -} + effective_permissions: [{ codename: 'change_submissions' }], +}) as unknown as AssetResponse diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index 4750efc6de..f35d579027 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -741,7 +741,7 @@ export interface AssetResponse extends AssetRequestObject { deployment__uuid?: string deployment__encrypted?: boolean deployment__submission_count: number - deployment__last_submission_time?: string + deployment__last_submission_time: string deployment_status: 'archived' | 'deployed' | 'draft' downloads: AssetDownloads embeds?: Array<{ From 380fce6d0d7270c4e456b401b309e44bff7a540c Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 17:21:40 +0200 Subject: [PATCH 23/86] schema improvement --- jsapp/js/api/models/asset.ts | 3 +- .../manage-projects-and-library-content.ts | 35 +++++++++++++++---- .../user-team-organization-usage.ts | 5 ++- kpi/serializers/v2/asset.py | 2 +- static/openapi/schema_v2.json | 1 + static/openapi/schema_v2.yaml | 1 + 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/jsapp/js/api/models/asset.ts b/jsapp/js/api/models/asset.ts index 0678da68ee..38c8f27212 100644 --- a/jsapp/js/api/models/asset.ts +++ b/jsapp/js/api/models/asset.ts @@ -61,7 +61,8 @@ export interface Asset { readonly deployment__active: boolean readonly deployment__data_download_links: AssetDeploymentDataDownloadLinks readonly deployment__submission_count: number - readonly deployment__last_submission_time: string + /** @nullable */ + readonly deployment__last_submission_time: string | null readonly deployment__encrypted: boolean readonly deployment__uuid: string readonly deployment_status: AssetDeploymentStatusEnum diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 3d631854a6..600f8a2ea3 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2877,7 +2877,10 @@ export const getApiV2AssetsListResponseMock = ( deployment__active: faker.datatype.boolean(), deployment__data_download_links: {}, deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment__last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + deployment__last_submission_time: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + null, + ]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), @@ -3199,7 +3202,10 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial Date: Mon, 6 Jul 2026 17:38:09 +0200 Subject: [PATCH 24/86] improve additional_fields schema --- jsapp/js/api/models/assetAnalysisFormJson.ts | 2 +- .../manage-projects-and-library-content.ts | 231 +++++++-------- .../user-team-organization-usage.ts | 33 +-- .../submissions/submissionUtils.mocks.ts | 271 +----------------- jsapp/js/dataInterface.ts | 2 +- kpi/schema_extensions/v2/assets/extensions.py | 1 + static/openapi/schema_v2.json | 3 + static/openapi/schema_v2.yaml | 2 + 8 files changed, 137 insertions(+), 408 deletions(-) diff --git a/jsapp/js/api/models/assetAnalysisFormJson.ts b/jsapp/js/api/models/assetAnalysisFormJson.ts index f27d03e88d..fbd4ed0b42 100644 --- a/jsapp/js/api/models/assetAnalysisFormJson.ts +++ b/jsapp/js/api/models/assetAnalysisFormJson.ts @@ -12,5 +12,5 @@ The endpoints are grouped by area of intended use. Each category contains relate import type { AssetAnalysisFormJsonAdditionalFieldsItem } from './assetAnalysisFormJsonAdditionalFieldsItem' export type AssetAnalysisFormJson = { - readonly additional_fields?: AssetAnalysisFormJsonAdditionalFieldsItem[] + readonly additional_fields: AssetAnalysisFormJsonAdditionalFieldsItem[] } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 600f8a2ea3..72247cefb7 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2941,24 +2941,21 @@ export const getApiV2AssetsListResponseMock = ( url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), analysis_form_json: { - additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, - })), - undefined, - ]), - })), - undefined, - ]), + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), }, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), @@ -3266,24 +3263,21 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, - })), - undefined, - ]), - })), - undefined, - ]), + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), }, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), @@ -3590,24 +3584,21 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, - })), - undefined, - ]), - })), - undefined, - ]), + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), }, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), @@ -3914,24 +3905,21 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), analysis_form_json: { - additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, - })), - undefined, - ]), - })), - undefined, - ]), + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), }, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), @@ -4262,24 +4250,21 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), analysis_form_json: { - additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, - })), - undefined, - ]), - })), - undefined, - ]), + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), }, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), @@ -4593,24 +4578,21 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), analysis_form_json: { - additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, - })), - undefined, - ]), - })), - undefined, - ]), + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), }, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), @@ -4924,24 +4906,21 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), analysis_form_json: { - additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, - })), - undefined, - ]), - })), - undefined, - ]), + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), }, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index bc0fe12bce..6c5a07bd5f 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4063,24 +4063,21 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), analysis_form_json: { - additional_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, - })), - undefined, - ]), - })), - undefined, - ]), + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: {}, + })), + undefined, + ]), + })), }, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), diff --git a/jsapp/js/components/submissions/submissionUtils.mocks.ts b/jsapp/js/components/submissions/submissionUtils.mocks.ts index b8d5256a13..24754acdf6 100644 --- a/jsapp/js/components/submissions/submissionUtils.mocks.ts +++ b/jsapp/js/components/submissions/submissionUtils.mocks.ts @@ -2086,48 +2086,13 @@ export const submissionWithAttachmentsWithUnicode = { _validation_status: {}, } as const satisfies SubmissionResponse -export const assetWithSupplementalDetails = { - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/', - owner: 'http://kf.kobo.local/api/v2/users/kobo/', - owner__username: 'kobo', - owner_label: 'kobo', - last_modified_by: null, - created_by: null, - deployment_status: 'deployed', - effective_permissions: [ - { - codename: 'manage_asset', - }, - { - codename: 'validate_submissions', - }, - { - codename: 'change_asset', - }, - { - codename: 'add_submissions', - }, - { - codename: 'delete_asset', - }, - { - codename: 'view_asset', - }, - { - codename: 'change_submissions', - }, - { - codename: 'delete_submissions', - }, - { - codename: 'view_submissions', - }, - ], - project_ownership: null, - parent: null, - settings: {}, +export const assetWithSupplementalDetails = getApiV2AssetsRetrieveResponseMock({ + uid: 'aDDywpeYGnvuDLTeiveyxZ', + name: 'text and media projekt', asset_type: AssetTypeName.survey, - date_created: '2022-05-12T10:40:02.952931Z', + deployment__active: true, + deployment__submission_count: 3, + has_deployment: true, summary: { geo: false, labels: ['Your name here', 'Your selfie goes here', 'A video? WTF', 'Secret password as an audio file'], @@ -2136,94 +2101,10 @@ export const assetWithSupplementalDetails = { lock_any: false, languages: [], row_count: 6, - name_quality: { - ok: 0, - bad: 0, - good: 6, - total: 6, - firsts: {}, - }, + name_quality: { ok: 0, bad: 0, good: 6, total: 6, firsts: {} }, naming_conflicts: ['__version__'], default_translation: null, }, - date_modified: '2022-05-12T20:46:11.778140Z', - version_id: 'vMQQP3qgzfmC9XFUkaogSu', - version__content_hash: '85c5bee02e5c2061afb598870e0308e3e0f818b5', - version_count: 6, - has_deployment: true, - deployed_version_id: 'vFFTm5vKJURadwXxntZda6', - deployed_versions: { - count: 1, - next: null, - previous: null, - results: [ - { - uid: 'vFFTm5vKJURadwXxntZda6', - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/versions/vFFTm5vKJURadwXxntZda6/', - content_hash: '85c5bee02e5c2061afb598870e0308e3e0f818b5', - date_deployed: '2022-05-12T10:40:05.215293Z', - date_modified: '2022-05-12 10:40:05.215293+00:00', - }, - ], - }, - deployment__links: { - url: 'http://ee.kobo.local/6PTli7y9', - single_url: 'http://ee.kobo.local/single/6PTli7y9', - single_once_url: 'http://ee.kobo.local/single/fc64e066ac2314795f6f6afe049420dd', - offline_url: 'http://ee.kobo.local/x/6PTli7y9', - preview_url: 'http://ee.kobo.local/preview/6PTli7y9', - iframe_url: 'http://ee.kobo.local/i/6PTli7y9', - single_iframe_url: 'http://ee.kobo.local/single/i/6PTli7y9', - single_once_iframe_url: 'http://ee.kobo.local/single/i/fc64e066ac2314795f6f6afe049420dd', - }, - deployment__active: true, - deployment__data_download_links: { - xls_legacy: 'http://kc.kobo.local/kobo/exports/aDDywpeYGnvuDLTeiveyxZ/xls/', - csv_legacy: 'http://kc.kobo.local/kobo/exports/aDDywpeYGnvuDLTeiveyxZ/csv/', - zip_legacy: 'http://kc.kobo.local/kobo/exports/aDDywpeYGnvuDLTeiveyxZ/zip/', - kml_legacy: 'http://kc.kobo.local/kobo/exports/aDDywpeYGnvuDLTeiveyxZ/kml/', - xls: 'http://kc.kobo.local/kobo/reports/aDDywpeYGnvuDLTeiveyxZ/export.xlsx', - csv: 'http://kc.kobo.local/kobo/reports/aDDywpeYGnvuDLTeiveyxZ/export.csv', - }, - deployment__submission_count: 3, - report_styles: { - default: {}, - specified: { - end: {}, - audit: {}, - start: {}, - today: {}, - deviceid: {}, - username: {}, - _version_: {}, - simserial: {}, - A_video_WTF: {}, - __version__: {}, - phonenumber: {}, - subscriberid: {}, - Your_name_here: {}, - Your_selfie_goes_here: {}, - Secret_password_as_an_audio_file: {}, - }, - kuid_names: { - end: 'VpPsXe5aq', - audit: '4Fbwq3mxP', - start: '8sHgNqqM9', - today: 'HuEzX4mel', - deviceid: 'q8Rvs1sqk', - username: '4dINVeRnR', - _version_: 'kU3D6JQPQ', - simserial: 'WrxreUkAJ', - A_video_WTF: 'bMGj1HZfu', - __version__: 'Hd5Iz0aWv', - phonenumber: 'Oqbll19yc', - subscriberid: '8ojkWhAXU', - Your_name_here: 'RAeXenoDr', - Your_selfie_goes_here: 'MWflesBzX', - Secret_password_as_an_audio_file: '3VHKj8Kt4', - }, - }, - report_custom: {}, advanced_features: { transcript: { values: ['A_video_WTF', 'Secret_password_as_an_audio_file'], @@ -2380,8 +2261,6 @@ export const assetWithSupplementalDetails = { }, ], }, - map_styles: {}, - map_custom: {}, content: { schema: '1', survey: [ @@ -2425,140 +2304,8 @@ export const assetWithSupplementalDetails = { translated: ['label'], translations: [null], }, - downloads: [ - { - format: 'xls', - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ.xls', - }, - { - format: 'xml', - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ.xml', - }, - ], - embeds: [ - { - format: 'xls', - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/xls/', - }, - { - format: 'xform', - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/xform/', - }, - ], - xform_link: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/xform/', - hooks_link: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/hooks/', - tag_string: '', - uid: 'aDDywpeYGnvuDLTeiveyxZ', - kind: 'asset', - xls_link: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/xls/', - name: 'text and media projekt', - assignable_permissions: [ - { - url: 'http://kf.kobo.local/api/v2/permissions/view_asset/', - label: 'View form', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/change_asset/', - label: 'Edit form', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/manage_asset/', - label: 'Manage project', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/view_submissions/', - label: 'View submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/partial_submissions/', - label: { - default: 'Act on submissions only from specific users', - view_submissions: 'View submissions only from specific users', - change_submissions: 'Edit submissions only from specific users', - delete_submissions: 'Delete submissions only from specific users', - validate_submissions: 'Validate submissions only from specific users', - }, - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/change_submissions/', - label: 'Edit submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/delete_submissions/', - label: 'Delete submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/validate_submissions/', - label: 'Validate submissions', - }, - ], - permissions: [ - { - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/permission-assignments/pDbXju7qDP7f4TiPnhvN2V/', - user: 'http://kf.kobo.local/api/v2/users/kobo/', - permission: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/permission-assignments/pRbazEkwqBFAT4K775yWK5/', - user: 'http://kf.kobo.local/api/v2/users/kobo/', - permission: 'http://kf.kobo.local/api/v2/permissions/change_asset/', - label: 'Edit form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/permission-assignments/pAVAdfoKu2zHjgw2ZaPvKk/', - user: 'http://kf.kobo.local/api/v2/users/kobo/', - permission: 'http://kf.kobo.local/api/v2/permissions/change_submissions/', - label: 'Edit submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/permission-assignments/pETWb6s6ezB9gs7vpMpHhZ/', - user: 'http://kf.kobo.local/api/v2/users/kobo/', - permission: 'http://kf.kobo.local/api/v2/permissions/delete_submissions/', - label: 'Delete submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/permission-assignments/pQoaazdrQ2pBRjqiMpcyc2/', - user: 'http://kf.kobo.local/api/v2/users/kobo/', - permission: 'http://kf.kobo.local/api/v2/permissions/manage_asset/', - label: 'Manage project', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/permission-assignments/pEqtSwGsEJzot98Ms3JJpL/', - user: 'http://kf.kobo.local/api/v2/users/kobo/', - permission: 'http://kf.kobo.local/api/v2/permissions/validate_submissions/', - label: 'Validate submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/permission-assignments/p62cADJonW8XuVPkaMSQcj/', - user: 'http://kf.kobo.local/api/v2/users/kobo/', - permission: 'http://kf.kobo.local/api/v2/permissions/view_asset/', - label: 'View form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/permission-assignments/p6FKWfL4SuxUqXhsJWdkkB/', - user: 'http://kf.kobo.local/api/v2/users/kobo/', - permission: 'http://kf.kobo.local/api/v2/permissions/view_submissions/', - label: 'View submissions', - }, - ], - exports: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/exports/', - export_settings: [], - data: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/data/', - children: { - count: 0, - }, - subscribers_count: 0, - status: 'private', - access_types: null, - data_sharing: {}, - paired_data: 'http://kf.kobo.local/api/v2/assets/aDDywpeYGnvuDLTeiveyxZ/paired-data/', - files: [], -} as const satisfies AssetResponse + effective_permissions: [{ codename: 'change_submissions' }], +}) as const satisfies AssetResponse export const submissionWithSupplementalDetails = { _id: 3, diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index f35d579027..03b5f16c8f 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -741,7 +741,7 @@ export interface AssetResponse extends AssetRequestObject { deployment__uuid?: string deployment__encrypted?: boolean deployment__submission_count: number - deployment__last_submission_time: string + deployment__last_submission_time: string | null deployment_status: 'archived' | 'deployed' | 'draft' downloads: AssetDownloads embeds?: Array<{ diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index d9aa2388a7..7f93951814 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -87,6 +87,7 @@ def map_serializer_field(self, auto_schema, direction): ) return build_object_type( + required=['additional_fields'], properties={ 'additional_fields': build_array_type(additional_field_item), } diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 78c54026a1..160b869345 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21638,6 +21638,9 @@ } } }, + "required": [ + "additional_fields" + ], "readOnly": true }, "xform_link": { diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 763c905bbc..4b0a2f1e93 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15497,6 +15497,8 @@ components: - name - source - type + required: + - additional_fields readOnly: true xform_link: type: string From 747af78d514fd4189962c38bfc38c67e512716cd Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 17:43:37 +0200 Subject: [PATCH 25/86] fix naming_conflicts schema --- jsapp/js/api/models/assetSummary.ts | 1 + .../manage-projects-and-library-content.ts | 42 +++++++++++++++++++ .../user-team-organization-usage.ts | 6 +++ jsapp/js/dataInterface.ts | 2 +- kpi/schema_extensions/v2/assets/extensions.py | 1 + static/openapi/schema_v2.json | 6 +++ static/openapi/schema_v2.yaml | 4 ++ 7 files changed, 61 insertions(+), 1 deletion(-) diff --git a/jsapp/js/api/models/assetSummary.ts b/jsapp/js/api/models/assetSummary.ts index 2bf2393df8..7ce5d8b03d 100644 --- a/jsapp/js/api/models/assetSummary.ts +++ b/jsapp/js/api/models/assetSummary.ts @@ -22,4 +22,5 @@ export type AssetSummary = { readonly name_quality?: AssetSummaryNameQuality /** @nullable */ readonly default_translation?: string | null + readonly naming_conflicts?: string[] } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 72247cefb7..d956901daf 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2837,6 +2837,12 @@ export const getApiV2AssetsListResponseMock = ( faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), @@ -3159,6 +3165,12 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), @@ -3480,6 +3492,12 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), @@ -3801,6 +3819,12 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), @@ -4146,6 +4170,12 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), @@ -4474,6 +4504,12 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), @@ -4802,6 +4838,12 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 6c5a07bd5f..57037858f3 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -3959,6 +3959,12 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), }, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index 03b5f16c8f..800d4b706a 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -739,7 +739,7 @@ export interface AssetResponse extends AssetRequestObject { zip_legacy: string } deployment__uuid?: string - deployment__encrypted?: boolean + deployment__encrypted: boolean deployment__submission_count: number deployment__last_submission_time: string | null deployment_status: 'archived' | 'deployed' | 'draft' diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 7f93951814..8b02b33f3f 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -653,6 +653,7 @@ def map_serializer_field(self, auto_schema, direction): 'row_count': build_basic_type(OpenApiTypes.INT), 'name_quality': name_quality_schema, 'default_translation': {**GENERIC_STRING_SCHEMA, 'nullable': True}, + 'naming_conflicts': build_array_type(GENERIC_STRING_SCHEMA), } ) diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 160b869345..6774772347 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21354,6 +21354,12 @@ "default_translation": { "type": "string", "nullable": true + }, + "naming_conflicts": { + "type": "array", + "items": { + "type": "string" + } } }, "readOnly": true diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 4b0a2f1e93..242ebf7617 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15302,6 +15302,10 @@ components: default_translation: type: string nullable: true + naming_conflicts: + type: array + items: + type: string readOnly: true date_created: type: string From 636753682ccb2e3ca640d7da83ed433604f16e42 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 17:48:24 +0200 Subject: [PATCH 26/86] improve additional fields schem --- ...setAnalysisFormJsonAdditionalFieldsItem.ts | 5 +- ...onAdditionalFieldsItemChoicesItemLabels.ts | 5 +- ...nalysisFormJsonAdditionalFieldsItemType.ts | 29 +++++ .../manage-projects-and-library-content.ts | 112 +++++++++++++++--- .../user-team-organization-usage.ts | 16 ++- kpi/schema_extensions/v2/assets/extensions.py | 25 +++- static/openapi/schema_v2.json | 28 ++++- static/openapi/schema_v2.yaml | 19 +++ 8 files changed, 216 insertions(+), 23 deletions(-) create mode 100644 jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemType.ts diff --git a/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItem.ts b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItem.ts index f32546037a..6f4bc4544f 100644 --- a/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItem.ts +++ b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItem.ts @@ -1,3 +1,4 @@ +import type { AssetAnalysisFormJsonAdditionalFieldsItemChoicesItem } from './assetAnalysisFormJsonAdditionalFieldsItemChoicesItem' /** * Generated by orval v7.10.0 🍺 * Do not edit manually. @@ -9,12 +10,12 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import type { AssetAnalysisFormJsonAdditionalFieldsItemChoicesItem } from './assetAnalysisFormJsonAdditionalFieldsItemChoicesItem' +import type { AssetAnalysisFormJsonAdditionalFieldsItemType } from './assetAnalysisFormJsonAdditionalFieldsItemType' export type AssetAnalysisFormJsonAdditionalFieldsItem = { language?: string source: string - type: string + type: AssetAnalysisFormJsonAdditionalFieldsItemType name: string dtpath: string label?: string diff --git a/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels.ts b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels.ts index 20bf62b523..8ff13f9b63 100644 --- a/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels.ts +++ b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels.ts @@ -10,4 +10,7 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type AssetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels = { [key: string]: unknown } +export type AssetAnalysisFormJsonAdditionalFieldsItemChoicesItemLabels = { + _default: string + [key: string]: string +} diff --git a/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemType.ts b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemType.ts new file mode 100644 index 0000000000..35870b522a --- /dev/null +++ b/jsapp/js/api/models/assetAnalysisFormJsonAdditionalFieldsItemType.ts @@ -0,0 +1,29 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetAnalysisFormJsonAdditionalFieldsItemType = + (typeof AssetAnalysisFormJsonAdditionalFieldsItemType)[keyof typeof AssetAnalysisFormJsonAdditionalFieldsItemType] + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const AssetAnalysisFormJsonAdditionalFieldsItemType = { + transcript: 'transcript', + translation: 'translation', + qualVerification: 'qualVerification', + qualSource: 'qualSource', + qualInteger: 'qualInteger', + qualTags: 'qualTags', + qualText: 'qualText', + qualNote: 'qualNote', + qualAutoKeywordCount: 'qualAutoKeywordCount', + qualSelectMultiple: 'qualSelectMultiple', + qualSelectOne: 'qualSelectOne', +} as const diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index d956901daf..d97ffdadee 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2950,14 +2950,26 @@ export const getApiV2AssetsListResponseMock = ( additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), name: faker.string.alpha({ length: { min: 10, max: 20 } }), dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), choices: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, })), undefined, ]), @@ -3278,14 +3290,26 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({ language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), name: faker.string.alpha({ length: { min: 10, max: 20 } }), dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), choices: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, })), undefined, ]), @@ -3605,14 +3629,26 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({ language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), name: faker.string.alpha({ length: { min: 10, max: 20 } }), dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), choices: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, })), undefined, ]), @@ -3932,14 +3968,26 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), name: faker.string.alpha({ length: { min: 10, max: 20 } }), dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), choices: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, })), undefined, ]), @@ -4283,14 +4331,26 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), name: faker.string.alpha({ length: { min: 10, max: 20 } }), dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), choices: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, })), undefined, ]), @@ -4617,14 +4677,26 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), name: faker.string.alpha({ length: { min: 10, max: 20 } }), dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), choices: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, })), undefined, ]), @@ -4951,14 +5023,26 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), name: faker.string.alpha({ length: { min: 10, max: 20 } }), dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), choices: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, })), undefined, ]), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 57037858f3..fc79408ab1 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4072,14 +4072,26 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), name: faker.string.alpha({ length: { min: 10, max: 20 } }), dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), choices: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: {}, + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, })), undefined, ]), diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 8b02b33f3f..6f53fb74e7 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -70,7 +70,22 @@ def map_serializer_field(self, auto_schema, direction): properties={ 'language': GENERIC_STRING_SCHEMA, # optional: two letter language code 'source': GENERIC_STRING_SCHEMA, # required: path to form question - 'type': GENERIC_STRING_SCHEMA, # required: e.g. 'transcript', 'translation', 'qual*' + 'type': { + 'type': 'string', + 'enum': [ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] + }, # required: type of additional field 'name': GENERIC_STRING_SCHEMA, # required 'dtpath': GENERIC_STRING_SCHEMA, # required: data table path 'label': GENERIC_STRING_SCHEMA, # optional: question label or 'source'/'verified' @@ -79,7 +94,13 @@ def map_serializer_field(self, auto_schema, direction): required=['uuid', 'labels'], properties={ 'uuid': GENERIC_STRING_SCHEMA, - 'labels': GENERIC_OBJECT_SCHEMA, # {_default: string, ...} + 'labels': build_object_type( + required=['_default'], + properties={ + '_default': GENERIC_STRING_SCHEMA, + }, + additionalProperties=GENERIC_STRING_SCHEMA, + ), # {_default: string, [key: string]: string} } ) ), # optional: for single/multi choice qual questions diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 6774772347..be1e44ad4c 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21605,7 +21605,20 @@ "type": "string" }, "type": { - "type": "string" + "type": "string", + "enum": [ + "transcript", + "translation", + "qualVerification", + "qualSource", + "qualInteger", + "qualTags", + "qualText", + "qualNote", + "qualAutoKeywordCount", + "qualSelectMultiple", + "qualSelectOne" + ] }, "name": { "type": "string" @@ -21625,7 +21638,18 @@ "type": "string" }, "labels": { - "type": "object" + "type": "object", + "properties": { + "_default": { + "type": "string" + } + }, + "additionalProperties": { + "type": "string" + }, + "required": [ + "_default" + ] } }, "required": [ diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 242ebf7617..e49b8af308 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15478,6 +15478,18 @@ components: type: string type: type: string + enum: + - transcript + - translation + - qualVerification + - qualSource + - qualInteger + - qualTags + - qualText + - qualNote + - qualAutoKeywordCount + - qualSelectMultiple + - qualSelectOne name: type: string dtpath: @@ -15493,6 +15505,13 @@ components: type: string labels: type: object + properties: + _default: + type: string + additionalProperties: + type: string + required: + - _default required: - labels - uuid From 6eadb73c91c01ae329c41fafcf38633a9b55a611 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 17:50:40 +0200 Subject: [PATCH 27/86] improve schema --- jsapp/js/api/models/assetDeployedVersions.ts | 8 +- .../manage-projects-and-library-content.ts | 224 ++++++------------ .../user-team-organization-usage.ts | 32 +-- kpi/schema_extensions/v2/assets/extensions.py | 1 + static/openapi/schema_v2.json | 6 + static/openapi/schema_v2.yaml | 5 + 6 files changed, 96 insertions(+), 180 deletions(-) diff --git a/jsapp/js/api/models/assetDeployedVersions.ts b/jsapp/js/api/models/assetDeployedVersions.ts index bd1fb8ded8..dc04b9e2be 100644 --- a/jsapp/js/api/models/assetDeployedVersions.ts +++ b/jsapp/js/api/models/assetDeployedVersions.ts @@ -12,10 +12,10 @@ The endpoints are grouped by area of intended use. Each category contains relate import type { AssetDeployedVersionsResultsItem } from './assetDeployedVersionsResultsItem' export type AssetDeployedVersions = { - readonly count?: number + readonly count: number /** @nullable */ - readonly next?: string | null + readonly next: string | null /** @nullable */ - readonly previous?: string | null - readonly results?: AssetDeployedVersionsResultsItem[] + readonly previous: string | null + readonly results: AssetDeployedVersionsResultsItem[] } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index d97ffdadee..8b01594bca 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2856,28 +2856,16 @@ export const getApiV2AssetsListResponseMock = ( has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), deployed_versions: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - next: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - previous: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - results: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - undefined, - ]), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), }, deployment__links: {}, deployment__active: faker.datatype.boolean(), @@ -3196,28 +3184,16 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - undefined, - ]), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), }, deployment__links: {}, deployment__active: faker.datatype.boolean(), @@ -3535,28 +3511,16 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - undefined, - ]), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), }, deployment__links: {}, deployment__active: faker.datatype.boolean(), @@ -3874,28 +3838,16 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), deployed_versions: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - next: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - previous: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - results: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - undefined, - ]), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), }, deployment__links: {}, deployment__active: faker.datatype.boolean(), @@ -4237,28 +4189,16 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), deployed_versions: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - next: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - previous: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - results: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - undefined, - ]), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), }, deployment__links: {}, deployment__active: faker.datatype.boolean(), @@ -4583,28 +4523,16 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), deployed_versions: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - next: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - previous: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - results: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - undefined, - ]), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), }, deployment__links: {}, deployment__active: faker.datatype.boolean(), @@ -4929,28 +4857,16 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), deployed_versions: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - next: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - previous: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - results: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - undefined, - ]), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), }, deployment__links: {}, deployment__active: faker.datatype.boolean(), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index fc79408ab1..26b891a173 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -3978,28 +3978,16 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), deployed_versions: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - next: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - previous: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - results: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - undefined, - ]), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), }, deployment__links: {}, deployment__active: faker.datatype.boolean(), diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 6f53fb74e7..ec9a9697f9 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -372,6 +372,7 @@ class DeployedVersionsFieldExtension(OpenApiSerializerFieldExtension): def map_serializer_field(self, auto_schema, direction): return build_object_type( + required=['count', 'next', 'previous', 'results'], properties={ 'count': build_basic_type(OpenApiTypes.INT), 'next': {**GENERIC_STRING_SCHEMA, 'nullable': True}, diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index be1e44ad4c..af4c7d9cdd 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21442,6 +21442,12 @@ } } }, + "required": [ + "count", + "next", + "previous", + "results" + ], "readOnly": true }, "deployment__links": { diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index e49b8af308..c39243ffe9 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15365,6 +15365,11 @@ components: date_modified: type: string format: date-time + required: + - count + - next + - previous + - results readOnly: true deployment__links: type: object From 052d825f3952e817b2106a71b84af768fea8728d Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 17:55:31 +0200 Subject: [PATCH 28/86] improve schema for deployment__uuid --- jsapp/js/api/models/asset.ts | 3 ++- .../manage-projects-and-library-content.ts | 14 +++++++------- .../react-query/user-team-organization-usage.ts | 2 +- kpi/serializers/v2/asset.py | 2 +- static/openapi/schema_v2.json | 1 + static/openapi/schema_v2.yaml | 1 + 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/jsapp/js/api/models/asset.ts b/jsapp/js/api/models/asset.ts index 38c8f27212..7e0e4fefb8 100644 --- a/jsapp/js/api/models/asset.ts +++ b/jsapp/js/api/models/asset.ts @@ -64,7 +64,8 @@ export interface Asset { /** @nullable */ readonly deployment__last_submission_time: string | null readonly deployment__encrypted: boolean - readonly deployment__uuid: string + /** @nullable */ + readonly deployment__uuid: string | null readonly deployment_status: AssetDeploymentStatusEnum report_styles?: AssetReportStyles report_custom?: AssetReportCustom diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 8b01594bca..547fb546ee 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2876,7 +2876,7 @@ export const getApiV2AssetsListResponseMock = ( null, ]), deployment__encrypted: faker.datatype.boolean(), - deployment__uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([ { @@ -3204,7 +3204,7 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial Date: Mon, 6 Jul 2026 17:58:48 +0200 Subject: [PATCH 29/86] fix schema for asset deployed version results item --- .../assetDeployedVersionsResultsItem.ts | 10 +-- .../manage-projects-and-library-content.ts | 70 +++++++++---------- .../user-team-organization-usage.ts | 10 +-- kpi/schema_extensions/v2/assets/extensions.py | 1 + static/openapi/schema_v2.json | 9 ++- static/openapi/schema_v2.yaml | 6 ++ 6 files changed, 60 insertions(+), 46 deletions(-) diff --git a/jsapp/js/api/models/assetDeployedVersionsResultsItem.ts b/jsapp/js/api/models/assetDeployedVersionsResultsItem.ts index 45b00a1dcc..b163ad4928 100644 --- a/jsapp/js/api/models/assetDeployedVersionsResultsItem.ts +++ b/jsapp/js/api/models/assetDeployedVersionsResultsItem.ts @@ -11,9 +11,9 @@ The endpoints are grouped by area of intended use. Each category contains relate */ export type AssetDeployedVersionsResultsItem = { - uid?: string - url?: string - content_hash?: string - date_deployed?: string - date_modified?: string + uid: string + url: string + content_hash: string + date_deployed: string + date_modified: string } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 547fb546ee..81e3ee0c72 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2860,11 +2860,11 @@ export const getApiV2AssetsListResponseMock = ( next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, })), }, deployment__links: {}, @@ -3188,11 +3188,11 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, })), }, deployment__links: {}, @@ -3515,11 +3515,11 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, })), }, deployment__links: {}, @@ -3842,11 +3842,11 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, })), }, deployment__links: {}, @@ -4193,11 +4193,11 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, })), }, deployment__links: {}, @@ -4527,11 +4527,11 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, })), }, deployment__links: {}, @@ -4861,11 +4861,11 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, })), }, deployment__links: {}, diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 59798491da..e474f3452a 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -3982,11 +3982,11 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_deployed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, })), }, deployment__links: {}, diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index ec9a9697f9..da95724522 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -379,6 +379,7 @@ def map_serializer_field(self, auto_schema, direction): 'previous': {**GENERIC_STRING_SCHEMA, 'nullable': True}, 'results': build_array_type( schema=build_object_type( + required=['uid', 'url', 'content_hash', 'date_deployed', 'date_modified'], properties={ 'uid': GENERIC_STRING_SCHEMA, 'url': build_url_type( diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 3d4ecce9b6..ea36c5390f 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21438,7 +21438,14 @@ "type": "string", "format": "date-time" } - } + }, + "required": [ + "content_hash", + "date_deployed", + "date_modified", + "uid", + "url" + ] } } }, diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index d968773045..8414e75574 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15365,6 +15365,12 @@ components: date_modified: type: string format: date-time + required: + - content_hash + - date_deployed + - date_modified + - uid + - url required: - count - next From ed700e13a84f671bb611b208f93417d1daa648c5 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 18:03:51 +0200 Subject: [PATCH 30/86] fix legacy deployment__uuid type --- jsapp/js/dataInterface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index 800d4b706a..530b8fb7fc 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -738,7 +738,7 @@ export interface AssetResponse extends AssetRequestObject { xls: string zip_legacy: string } - deployment__uuid?: string + deployment__uuid: string | null deployment__encrypted: boolean deployment__submission_count: number deployment__last_submission_time: string | null From f1462c5bdf0263f57c1133bf4d56dd0f4fa35966 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 18:07:38 +0200 Subject: [PATCH 31/86] fix deployment__data_download_links schema --- .../assetDeploymentDataDownloadLinks.ts | 11 ++- .../manage-projects-and-library-content.ts | 77 +++++++++++++++++-- .../user-team-organization-usage.ts | 11 ++- kpi/schema_extensions/v2/assets/extensions.py | 14 +++- static/openapi/schema_v2.json | 34 ++++++++ static/openapi/schema_v2.yaml | 24 ++++++ 6 files changed, 161 insertions(+), 10 deletions(-) diff --git a/jsapp/js/api/models/assetDeploymentDataDownloadLinks.ts b/jsapp/js/api/models/assetDeploymentDataDownloadLinks.ts index 0fe0eab133..acda90fe4e 100644 --- a/jsapp/js/api/models/assetDeploymentDataDownloadLinks.ts +++ b/jsapp/js/api/models/assetDeploymentDataDownloadLinks.ts @@ -10,4 +10,13 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type AssetDeploymentDataDownloadLinks = { [key: string]: unknown } +export type AssetDeploymentDataDownloadLinks = { + readonly csv_legacy: string + readonly csv: string + readonly geojson?: string + readonly kml_legacy: string + readonly spss_labels?: string + readonly xls_legacy: string + readonly xls: string + readonly zip_legacy: string +} diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 81e3ee0c72..f997c0456b 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2869,7 +2869,16 @@ export const getApiV2AssetsListResponseMock = ( }, deployment__links: {}, deployment__active: faker.datatype.boolean(), - deployment__data_download_links: {}, + deployment__data_download_links: { + csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls: faker.string.alpha({ length: { min: 10, max: 20 } }), + zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), deployment__last_submission_time: faker.helpers.arrayElement([ `${faker.date.past().toISOString().split('.')[0]}Z`, @@ -3197,7 +3206,16 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial Date: Mon, 6 Jul 2026 18:10:30 +0200 Subject: [PATCH 32/86] improve legacy deployment_status types --- jsapp/js/dataInterface.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index 530b8fb7fc..63938c2f86 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -742,7 +742,7 @@ export interface AssetResponse extends AssetRequestObject { deployment__encrypted: boolean deployment__submission_count: number deployment__last_submission_time: string | null - deployment_status: 'archived' | 'deployed' | 'draft' + deployment_status: 'archived' | 'deployed' | 'draft' | '-' downloads: AssetDownloads embeds?: Array<{ format: string @@ -835,7 +835,7 @@ export interface ProjectViewAsset { has_deployment: boolean deployment__active: boolean deployment__submission_count: number - deployment_status: 'archived' | 'deployed' | 'draft' + deployment_status: 'archived' | 'deployed' | 'draft' | '-' } export interface AssetsResponse extends PaginatedResponse { From d564284ea514e6115bdf4db9405f9c54063825d9 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 18:19:32 +0200 Subject: [PATCH 33/86] improve downloads schema --- jsapp/js/api/models/assetDownloadsItem.ts | 4 +- jsapp/js/api/models/assetEmbedsItem.ts | 4 +- .../manage-projects-and-library-content.ts | 56 +++++++++---------- .../user-team-organization-usage.ts | 8 +-- .../submissions/submissionUtils.mocks.ts | 6 +- kpi/schema_extensions/v2/assets/extensions.py | 1 + static/openapi/schema_v2.json | 12 +++- static/openapi/schema_v2.yaml | 6 ++ 8 files changed, 56 insertions(+), 41 deletions(-) diff --git a/jsapp/js/api/models/assetDownloadsItem.ts b/jsapp/js/api/models/assetDownloadsItem.ts index 77100ae7b7..39c13c364c 100644 --- a/jsapp/js/api/models/assetDownloadsItem.ts +++ b/jsapp/js/api/models/assetDownloadsItem.ts @@ -11,6 +11,6 @@ The endpoints are grouped by area of intended use. Each category contains relate */ export type AssetDownloadsItem = { - format?: string - url?: string + format: string + url: string } diff --git a/jsapp/js/api/models/assetEmbedsItem.ts b/jsapp/js/api/models/assetEmbedsItem.ts index 5d484d31f3..a5ecd96225 100644 --- a/jsapp/js/api/models/assetEmbedsItem.ts +++ b/jsapp/js/api/models/assetEmbedsItem.ts @@ -11,6 +11,6 @@ The endpoints are grouped by area of intended use. Each category contains relate */ export type AssetEmbedsItem = { - format?: string - url?: string + format: string + url: string } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index f997c0456b..4fae027129 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2936,12 +2936,12 @@ export const getApiV2AssetsListResponseMock = ( undefined, ]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), analysis_form_json: { additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ @@ -3273,12 +3273,12 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), analysis_form_json: { additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ @@ -3609,12 +3609,12 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), analysis_form_json: { additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ @@ -3945,12 +3945,12 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia undefined, ]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), analysis_form_json: { additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ @@ -4305,12 +4305,12 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( undefined, ]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), analysis_form_json: { additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ @@ -4648,12 +4648,12 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( undefined, ]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), analysis_form_json: { additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ @@ -4991,12 +4991,12 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( undefined, ]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), analysis_form_json: { additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index c4f43e3a80..e75c27ac04 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4058,12 +4058,12 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( undefined, ]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), })), analysis_form_json: { additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ diff --git a/jsapp/js/components/submissions/submissionUtils.mocks.ts b/jsapp/js/components/submissions/submissionUtils.mocks.ts index 24754acdf6..c68f77062f 100644 --- a/jsapp/js/components/submissions/submissionUtils.mocks.ts +++ b/jsapp/js/components/submissions/submissionUtils.mocks.ts @@ -2305,7 +2305,7 @@ export const assetWithSupplementalDetails = getApiV2AssetsRetrieveResponseMock({ translations: [null], }, effective_permissions: [{ codename: 'change_submissions' }], -}) as const satisfies AssetResponse +}) as unknown as AssetResponse export const submissionWithSupplementalDetails = { _id: 3, @@ -2921,7 +2921,7 @@ export const assetWithNestedSupplementalDetails = { owner_label: "uu's organization", last_modified_by: 'uu', created_by: null, -} as const satisfies AssetResponse +} as unknown as AssetResponse export const submissionWithNestedSupplementalDetails = { _id: 84, @@ -3494,7 +3494,7 @@ export const assetWithAllQual = { owner_label: "uu's organization", last_modified_by: 'uu', created_by: null, -} as const satisfies AssetResponse +} as unknown as AssetResponse export const submissionWithAllQual = { _id: 81, diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 236194256a..27fa51fc1c 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -415,6 +415,7 @@ class DownloadsFieldExtension(OpenApiSerializerFieldExtension): def map_serializer_field(self, auto_schema, direction): return build_array_type( schema=build_object_type( + required=['format', 'url'], properties={ 'format': GENERIC_STRING_SCHEMA, 'url': GENERIC_STRING_SCHEMA, diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 4c5d640941..4923f0d711 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21619,7 +21619,11 @@ "url": { "type": "string" } - } + }, + "required": [ + "format", + "url" + ] }, "readOnly": true }, @@ -21634,7 +21638,11 @@ "url": { "type": "string" } - } + }, + "required": [ + "format", + "url" + ] }, "readOnly": true }, diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 3656350639..4287af2f44 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15489,6 +15489,9 @@ components: type: string url: type: string + required: + - format + - url readOnly: true embeds: type: array @@ -15499,6 +15502,9 @@ components: type: string url: type: string + required: + - format + - url readOnly: true analysis_form_json: type: object From 69d7279b508cff5e2e80c1ceb41336856afe008e Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 18:23:47 +0200 Subject: [PATCH 34/86] improve report styles schema --- .../js/api/models/assetReportStylesDefault.ts | 8 +- .../api/models/assetReportStylesKuidNames.ts | 5 +- .../api/models/assetReportStylesSpecified.ts | 7 +- .../models/assetReportStylesSpecifiedEnd.ts | 13 -- .../models/assetReportStylesSpecifiedStart.ts | 13 -- .../manage-projects-and-library-content.ts | 189 ++++++++++++------ .../user-team-organization-usage.ts | 27 ++- kpi/schema_extensions/v2/assets/extensions.py | 17 +- kpi/schema_extensions/v2/assets/schema.py | 10 + static/openapi/schema_v2.json | 36 ++-- static/openapi/schema_v2.yaml | 23 ++- 11 files changed, 208 insertions(+), 140 deletions(-) delete mode 100644 jsapp/js/api/models/assetReportStylesSpecifiedEnd.ts delete mode 100644 jsapp/js/api/models/assetReportStylesSpecifiedStart.ts diff --git a/jsapp/js/api/models/assetReportStylesDefault.ts b/jsapp/js/api/models/assetReportStylesDefault.ts index 16ae5e258b..e8c71e69ab 100644 --- a/jsapp/js/api/models/assetReportStylesDefault.ts +++ b/jsapp/js/api/models/assetReportStylesDefault.ts @@ -10,4 +10,10 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type AssetReportStylesDefault = { [key: string]: unknown } +export type AssetReportStylesDefault = { + groupDataBy?: string + report_type?: string + report_colors?: string[] + translationIndex?: number + graphWidth?: number +} diff --git a/jsapp/js/api/models/assetReportStylesKuidNames.ts b/jsapp/js/api/models/assetReportStylesKuidNames.ts index f62fcc3569..4f68fad558 100644 --- a/jsapp/js/api/models/assetReportStylesKuidNames.ts +++ b/jsapp/js/api/models/assetReportStylesKuidNames.ts @@ -10,7 +10,4 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type AssetReportStylesKuidNames = { - end?: string - start?: string -} +export type AssetReportStylesKuidNames = { [key: string]: unknown } diff --git a/jsapp/js/api/models/assetReportStylesSpecified.ts b/jsapp/js/api/models/assetReportStylesSpecified.ts index 2cd19025fd..e42b98e877 100644 --- a/jsapp/js/api/models/assetReportStylesSpecified.ts +++ b/jsapp/js/api/models/assetReportStylesSpecified.ts @@ -9,10 +9,5 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import type { AssetReportStylesSpecifiedEnd } from './assetReportStylesSpecifiedEnd' -import type { AssetReportStylesSpecifiedStart } from './assetReportStylesSpecifiedStart' -export type AssetReportStylesSpecified = { - end?: AssetReportStylesSpecifiedEnd - start?: AssetReportStylesSpecifiedStart -} +export type AssetReportStylesSpecified = { [key: string]: unknown } diff --git a/jsapp/js/api/models/assetReportStylesSpecifiedEnd.ts b/jsapp/js/api/models/assetReportStylesSpecifiedEnd.ts deleted file mode 100644 index d1e6f400f7..0000000000 --- a/jsapp/js/api/models/assetReportStylesSpecifiedEnd.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ - -export type AssetReportStylesSpecifiedEnd = { [key: string]: unknown } diff --git a/jsapp/js/api/models/assetReportStylesSpecifiedStart.ts b/jsapp/js/api/models/assetReportStylesSpecifiedStart.ts deleted file mode 100644 index 26c660f883..0000000000 --- a/jsapp/js/api/models/assetReportStylesSpecifiedStart.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ - -export type AssetReportStylesSpecifiedStart = { [key: string]: unknown } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 4fae027129..32c150f45d 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2889,18 +2889,29 @@ export const getApiV2AssetsListResponseMock = ( deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([ { - default: faker.helpers.arrayElement([{}, undefined]), - specified: faker.helpers.arrayElement([ - { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, - undefined, - ]), - kuid_names: faker.helpers.arrayElement([ + default: faker.helpers.arrayElement([ { - end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), }, undefined, ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), }, undefined, ]), @@ -3226,18 +3237,29 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), }, undefined, ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), }, undefined, ]), @@ -3562,18 +3584,29 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), }, undefined, ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), }, undefined, ]), @@ -3898,18 +3931,29 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([ { - default: faker.helpers.arrayElement([{}, undefined]), - specified: faker.helpers.arrayElement([ - { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, - undefined, - ]), - kuid_names: faker.helpers.arrayElement([ + default: faker.helpers.arrayElement([ { - end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), }, undefined, ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), }, undefined, ]), @@ -4258,18 +4302,29 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([ { - default: faker.helpers.arrayElement([{}, undefined]), - specified: faker.helpers.arrayElement([ - { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, - undefined, - ]), - kuid_names: faker.helpers.arrayElement([ + default: faker.helpers.arrayElement([ { - end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), }, undefined, ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), }, undefined, ]), @@ -4601,18 +4656,29 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([ { - default: faker.helpers.arrayElement([{}, undefined]), - specified: faker.helpers.arrayElement([ - { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, - undefined, - ]), - kuid_names: faker.helpers.arrayElement([ + default: faker.helpers.arrayElement([ { - end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), }, undefined, ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), }, undefined, ]), @@ -4944,18 +5010,29 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([ { - default: faker.helpers.arrayElement([{}, undefined]), - specified: faker.helpers.arrayElement([ - { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, - undefined, - ]), - kuid_names: faker.helpers.arrayElement([ + default: faker.helpers.arrayElement([ { - end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), }, undefined, ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), }, undefined, ]), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index e75c27ac04..48e1bf4d92 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4011,18 +4011,29 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([ { - default: faker.helpers.arrayElement([{}, undefined]), - specified: faker.helpers.arrayElement([ - { end: faker.helpers.arrayElement([{}, undefined]), start: faker.helpers.arrayElement([{}, undefined]) }, - undefined, - ]), - kuid_names: faker.helpers.arrayElement([ + default: faker.helpers.arrayElement([ { - end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), }, undefined, ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), }, undefined, ]), diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 27fa51fc1c..d8a91325a5 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -29,6 +29,7 @@ BULK_ACTION_SCHEMA, BULK_ASSET_UIDS_SCHEMA, BULK_CONFIRM_SCHEMA, + REPORT_STYLE_SCHEMA, ) @@ -559,19 +560,9 @@ class ReportStyleFieldExtension(OpenApiSerializerFieldExtension): def map_serializer_field(self, auto_schema, direction): return build_object_type( properties={ - 'default': GENERIC_OBJECT_SCHEMA, - 'specified': build_object_type( - properties={ - 'end': GENERIC_OBJECT_SCHEMA, - 'start': GENERIC_OBJECT_SCHEMA, - } - ), - 'kuid_names': build_object_type( - properties={ - 'end': GENERIC_STRING_SCHEMA, - 'start': GENERIC_STRING_SCHEMA, - } - ), + 'default': REPORT_STYLE_SCHEMA, + 'specified': GENERIC_OBJECT_SCHEMA, # additionalProperties pattern for dynamic row names + 'kuid_names': GENERIC_OBJECT_SCHEMA, # additionalProperties pattern for dynamic row names } ) diff --git a/kpi/schema_extensions/v2/assets/schema.py b/kpi/schema_extensions/v2/assets/schema.py index c32e6869f4..c5a095a62e 100644 --- a/kpi/schema_extensions/v2/assets/schema.py +++ b/kpi/schema_extensions/v2/assets/schema.py @@ -45,3 +45,13 @@ ) BULK_CONFIRM_SCHEMA = build_basic_type(OpenApiTypes.BOOL) + +REPORT_STYLE_SCHEMA = build_object_type( + properties={ + 'groupDataBy': build_basic_type(OpenApiTypes.STR), + 'report_type': build_basic_type(OpenApiTypes.STR), + 'report_colors': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + 'translationIndex': build_basic_type(OpenApiTypes.INT), + 'graphWidth': build_basic_type(OpenApiTypes.INT), + } +) diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 4923f0d711..9b7c7b0caa 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21534,29 +21534,33 @@ "type": "object", "properties": { "default": { - "type": "object" - }, - "specified": { - "type": "object", - "properties": { - "end": { - "type": "object" - }, - "start": { - "type": "object" - } - } - }, - "kuid_names": { "type": "object", "properties": { - "end": { + "groupDataBy": { "type": "string" }, - "start": { + "report_type": { "type": "string" + }, + "report_colors": { + "type": "array", + "items": { + "type": "string" + } + }, + "translationIndex": { + "type": "integer" + }, + "graphWidth": { + "type": "integer" } } + }, + "specified": { + "type": "object" + }, + "kuid_names": { + "type": "object" } } }, diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 4287af2f44..cd4e0ec415 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15434,20 +15434,23 @@ components: properties: default: type: object + properties: + groupDataBy: + type: string + report_type: + type: string + report_colors: + type: array + items: + type: string + translationIndex: + type: integer + graphWidth: + type: integer specified: type: object - properties: - end: - type: object - start: - type: object kuid_names: type: object - properties: - end: - type: string - start: - type: string report_custom: type: object advanced_features: From cbe5e1835b866ff499f1c655c0e7ff114c6ae417 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 18:27:28 +0200 Subject: [PATCH 35/86] improved advanced features schema --- jsapp/js/api/models/assetAdvancedFeatures.ts | 10 +- .../api/models/assetAdvancedFeaturesQual.ts | 16 + ...assetAdvancedFeaturesQualQualSurveyItem.ts | 13 + .../models/assetAdvancedFeaturesTranscript.ts | 16 + .../assetAdvancedFeaturesTranslation.ts | 16 + .../manage-projects-and-library-content.ts | 364 +++++++++++++++++- .../user-team-organization-usage.ts | 52 ++- kpi/schema_extensions/v2/assets/extensions.py | 3 +- kpi/schema_extensions/v2/assets/schema.py | 23 ++ static/openapi/schema_v2.json | 53 ++- static/openapi/schema_v2.yaml | 33 ++ 11 files changed, 588 insertions(+), 11 deletions(-) create mode 100644 jsapp/js/api/models/assetAdvancedFeaturesQual.ts create mode 100644 jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItem.ts create mode 100644 jsapp/js/api/models/assetAdvancedFeaturesTranscript.ts create mode 100644 jsapp/js/api/models/assetAdvancedFeaturesTranslation.ts diff --git a/jsapp/js/api/models/assetAdvancedFeatures.ts b/jsapp/js/api/models/assetAdvancedFeatures.ts index 406729372c..4273cbf894 100644 --- a/jsapp/js/api/models/assetAdvancedFeatures.ts +++ b/jsapp/js/api/models/assetAdvancedFeatures.ts @@ -1,3 +1,4 @@ +import type { AssetAdvancedFeaturesQual } from './assetAdvancedFeaturesQual' /** * Generated by orval v7.10.0 🍺 * Do not edit manually. @@ -9,5 +10,12 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetAdvancedFeaturesTranscript } from './assetAdvancedFeaturesTranscript' +import type { AssetAdvancedFeaturesTranslation } from './assetAdvancedFeaturesTranslation' -export type AssetAdvancedFeatures = { [key: string]: unknown } +export type AssetAdvancedFeatures = { + transcript?: AssetAdvancedFeaturesTranscript + translation?: AssetAdvancedFeaturesTranslation + qual?: AssetAdvancedFeaturesQual + _version?: string +} diff --git a/jsapp/js/api/models/assetAdvancedFeaturesQual.ts b/jsapp/js/api/models/assetAdvancedFeaturesQual.ts new file mode 100644 index 0000000000..3df982412c --- /dev/null +++ b/jsapp/js/api/models/assetAdvancedFeaturesQual.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetAdvancedFeaturesQualQualSurveyItem } from './assetAdvancedFeaturesQualQualSurveyItem' + +export type AssetAdvancedFeaturesQual = { + qual_survey?: AssetAdvancedFeaturesQualQualSurveyItem[] +} diff --git a/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItem.ts b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItem.ts new file mode 100644 index 0000000000..25b4857bdc --- /dev/null +++ b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItem.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetAdvancedFeaturesQualQualSurveyItem = { [key: string]: unknown } diff --git a/jsapp/js/api/models/assetAdvancedFeaturesTranscript.ts b/jsapp/js/api/models/assetAdvancedFeaturesTranscript.ts new file mode 100644 index 0000000000..f2a64c6de4 --- /dev/null +++ b/jsapp/js/api/models/assetAdvancedFeaturesTranscript.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetAdvancedFeaturesTranscript = { + values?: string[] + languages?: string[] +} diff --git a/jsapp/js/api/models/assetAdvancedFeaturesTranslation.ts b/jsapp/js/api/models/assetAdvancedFeaturesTranslation.ts new file mode 100644 index 0000000000..36e4a1a7b9 --- /dev/null +++ b/jsapp/js/api/models/assetAdvancedFeaturesTranslation.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetAdvancedFeaturesTranslation = { + values?: string[] + languages?: string[] +} diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 32c150f45d..eb1063f9dd 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2916,7 +2916,57 @@ export const getApiV2AssetsListResponseMock = ( undefined, ]), report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), map_styles: faker.helpers.arrayElement([{}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([ @@ -3264,7 +3314,57 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), map_styles: faker.helpers.arrayElement([{}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([ @@ -3611,7 +3711,57 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), map_styles: faker.helpers.arrayElement([{}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([ @@ -3958,7 +4108,57 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia undefined, ]), report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), map_styles: faker.helpers.arrayElement([{}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([ @@ -4329,7 +4529,57 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( undefined, ]), report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), map_styles: faker.helpers.arrayElement([{}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([ @@ -4683,7 +4933,57 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( undefined, ]), report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), map_styles: faker.helpers.arrayElement([{}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([ @@ -5037,7 +5337,57 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( undefined, ]), report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), map_styles: faker.helpers.arrayElement([{}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([ diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 48e1bf4d92..9bd3967276 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4038,7 +4038,57 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( undefined, ]), report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), map_styles: faker.helpers.arrayElement([{}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([ diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index d8a91325a5..5ba66672db 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -18,6 +18,7 @@ ) from kpi.utils.schema_extensions.url_builder import build_url_type from .schema import ( + ADVANCED_FEATURES_SCHEMA, ASSET_CLONE_FROM_SCHEMA, ASSET_CONTENT_SCHEMA, ASSET_ENABLED_SCHEMA, @@ -44,7 +45,7 @@ class AdvancedFeatureFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.AdvancedFeatureField' def map_serializer_field(self, auto_schema, direction): - return GENERIC_OBJECT_SCHEMA + return ADVANCED_FEATURES_SCHEMA class AdvancedSubmissionSchemaFieldExtension(OpenApiSerializerFieldExtension): diff --git a/kpi/schema_extensions/v2/assets/schema.py b/kpi/schema_extensions/v2/assets/schema.py index c5a095a62e..6718360bfe 100644 --- a/kpi/schema_extensions/v2/assets/schema.py +++ b/kpi/schema_extensions/v2/assets/schema.py @@ -55,3 +55,26 @@ 'graphWidth': build_basic_type(OpenApiTypes.INT), } ) + +ADVANCED_FEATURES_SCHEMA = build_object_type( + properties={ + 'transcript': build_object_type( + properties={ + 'values': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + 'languages': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + } + ), + 'translation': build_object_type( + properties={ + 'values': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + 'languages': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + } + ), + 'qual': build_object_type( + properties={ + 'qual_survey': build_array_type(schema=build_basic_type(OpenApiTypes.OBJECT)), + } + ), + '_version': build_basic_type(OpenApiTypes.STR), + } +) diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 9b7c7b0caa..2dd3f99941 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21568,7 +21568,58 @@ "type": "object" }, "advanced_features": { - "type": "object" + "type": "object", + "properties": { + "transcript": { + "type": "object", + "properties": { + "values": { + "type": "array", + "items": { + "type": "string" + } + }, + "languages": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "translation": { + "type": "object", + "properties": { + "values": { + "type": "array", + "items": { + "type": "string" + } + }, + "languages": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "qual": { + "type": "object", + "properties": { + "qual_survey": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": {} + } + } + } + }, + "_version": { + "type": "string" + } + } }, "map_styles": { "type": "object" diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index cd4e0ec415..cc2b92c995 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15455,6 +15455,39 @@ components: type: object advanced_features: type: object + properties: + transcript: + type: object + properties: + values: + type: array + items: + type: string + languages: + type: array + items: + type: string + translation: + type: object + properties: + values: + type: array + items: + type: string + languages: + type: array + items: + type: string + qual: + type: object + properties: + qual_survey: + type: array + items: + type: object + additionalProperties: {} + _version: + type: string map_styles: type: object map_custom: From a5ef70f2891ce317df8ee3141565f008eedad68d Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 18:30:55 +0200 Subject: [PATCH 36/86] qual schema improvement --- ...assetAdvancedFeaturesQualQualSurveyItem.ts | 13 +- ...edFeaturesQualQualSurveyItemChoicesItem.ts | 19 +++ ...uresQualQualSurveyItemChoicesItemLabels.ts | 16 ++ ...resQualQualSurveyItemChoicesItemOptions.ts | 15 ++ ...dvancedFeaturesQualQualSurveyItemLabels.ts | 16 ++ ...vancedFeaturesQualQualSurveyItemOptions.ts | 15 ++ .../manage-projects-and-library-content.ts | 147 +++++++++++++++++- .../user-team-organization-usage.ts | 21 ++- kpi/schema_extensions/v2/assets/schema.py | 40 ++++- static/openapi/schema_v2.json | 80 +++++++++- static/openapi/schema_v2.yaml | 53 ++++++- 11 files changed, 423 insertions(+), 12 deletions(-) create mode 100644 jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItem.ts create mode 100644 jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItemLabels.ts create mode 100644 jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItemOptions.ts create mode 100644 jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemLabels.ts create mode 100644 jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemOptions.ts diff --git a/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItem.ts b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItem.ts index 25b4857bdc..9b7d6e55b0 100644 --- a/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItem.ts +++ b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItem.ts @@ -1,3 +1,4 @@ +import type { AssetAdvancedFeaturesQualQualSurveyItemChoicesItem } from './assetAdvancedFeaturesQualQualSurveyItemChoicesItem' /** * Generated by orval v7.10.0 🍺 * Do not edit manually. @@ -9,5 +10,15 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetAdvancedFeaturesQualQualSurveyItemLabels } from './assetAdvancedFeaturesQualQualSurveyItemLabels' +import type { AssetAdvancedFeaturesQualQualSurveyItemOptions } from './assetAdvancedFeaturesQualQualSurveyItemOptions' -export type AssetAdvancedFeaturesQualQualSurveyItem = { [key: string]: unknown } +export type AssetAdvancedFeaturesQualQualSurveyItem = { + type: string + labels: AssetAdvancedFeaturesQualQualSurveyItemLabels + uuid?: string + options?: AssetAdvancedFeaturesQualQualSurveyItemOptions + xpath: string + scope: string + choices?: AssetAdvancedFeaturesQualQualSurveyItemChoicesItem[] +} diff --git a/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItem.ts b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItem.ts new file mode 100644 index 0000000000..bd3de84f77 --- /dev/null +++ b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItem.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetAdvancedFeaturesQualQualSurveyItemChoicesItemLabels } from './assetAdvancedFeaturesQualQualSurveyItemChoicesItemLabels' +import type { AssetAdvancedFeaturesQualQualSurveyItemChoicesItemOptions } from './assetAdvancedFeaturesQualQualSurveyItemChoicesItemOptions' + +export type AssetAdvancedFeaturesQualQualSurveyItemChoicesItem = { + labels: AssetAdvancedFeaturesQualQualSurveyItemChoicesItemLabels + uuid: string + options?: AssetAdvancedFeaturesQualQualSurveyItemChoicesItemOptions +} diff --git a/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItemLabels.ts b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItemLabels.ts new file mode 100644 index 0000000000..e55ca56c53 --- /dev/null +++ b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItemLabels.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetAdvancedFeaturesQualQualSurveyItemChoicesItemLabels = { + _default: string + [key: string]: string +} diff --git a/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItemOptions.ts b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItemOptions.ts new file mode 100644 index 0000000000..34a7c8272b --- /dev/null +++ b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemChoicesItemOptions.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetAdvancedFeaturesQualQualSurveyItemChoicesItemOptions = { + deleted?: boolean +} diff --git a/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemLabels.ts b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemLabels.ts new file mode 100644 index 0000000000..73fc2ba640 --- /dev/null +++ b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemLabels.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetAdvancedFeaturesQualQualSurveyItemLabels = { + _default: string + [key: string]: string +} diff --git a/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemOptions.ts b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemOptions.ts new file mode 100644 index 0000000000..3652ddf58c --- /dev/null +++ b/jsapp/js/api/models/assetAdvancedFeaturesQualQualSurveyItemOptions.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetAdvancedFeaturesQualQualSurveyItemOptions = { + deleted?: boolean +} diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index eb1063f9dd..eb62cc0f9f 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2956,7 +2956,26 @@ export const getApiV2AssetsListResponseMock = ( { qual_survey: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), })), undefined, ]), @@ -3354,7 +3373,26 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), })), undefined, ]), @@ -3751,7 +3789,26 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), })), undefined, ]), @@ -4148,7 +4205,26 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia { qual_survey: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), })), undefined, ]), @@ -4569,7 +4645,26 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( { qual_survey: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), })), undefined, ]), @@ -4973,7 +5068,26 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( { qual_survey: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), })), undefined, ]), @@ -5377,7 +5491,26 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( { qual_survey: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), })), undefined, ]), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 9bd3967276..5826078724 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4078,7 +4078,26 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( { qual_survey: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), })), undefined, ]), diff --git a/kpi/schema_extensions/v2/assets/schema.py b/kpi/schema_extensions/v2/assets/schema.py index 6718360bfe..a53fda3817 100644 --- a/kpi/schema_extensions/v2/assets/schema.py +++ b/kpi/schema_extensions/v2/assets/schema.py @@ -56,6 +56,44 @@ } ) +ANALYSIS_QUESTION_LABELS_SCHEMA = build_object_type( + required=['_default'], + properties={ + '_default': build_basic_type(OpenApiTypes.STR), + }, + additionalProperties=build_basic_type(OpenApiTypes.STR), +) + +ANALYSIS_QUESTION_CHOICE_SCHEMA = build_object_type( + required=['labels', 'uuid'], + properties={ + 'labels': ANALYSIS_QUESTION_LABELS_SCHEMA, + 'uuid': build_basic_type(OpenApiTypes.STR), + 'options': build_object_type( + properties={ + 'deleted': build_basic_type(OpenApiTypes.BOOL), + } + ), + } +) + +ANALYSIS_QUESTION_SCHEMA = build_object_type( + required=['type', 'labels', 'xpath', 'scope'], + properties={ + 'type': build_basic_type(OpenApiTypes.STR), + 'labels': ANALYSIS_QUESTION_LABELS_SCHEMA, + 'uuid': build_basic_type(OpenApiTypes.STR), + 'options': build_object_type( + properties={ + 'deleted': build_basic_type(OpenApiTypes.BOOL), + } + ), + 'xpath': build_basic_type(OpenApiTypes.STR), + 'scope': build_basic_type(OpenApiTypes.STR), + 'choices': build_array_type(schema=ANALYSIS_QUESTION_CHOICE_SCHEMA), + } +) + ADVANCED_FEATURES_SCHEMA = build_object_type( properties={ 'transcript': build_object_type( @@ -72,7 +110,7 @@ ), 'qual': build_object_type( properties={ - 'qual_survey': build_array_type(schema=build_basic_type(OpenApiTypes.OBJECT)), + 'qual_survey': build_array_type(schema=ANALYSIS_QUESTION_SCHEMA), } ), '_version': build_basic_type(OpenApiTypes.STR), diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 2dd3f99941..04eddee0b0 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21611,7 +21611,85 @@ "type": "array", "items": { "type": "object", - "additionalProperties": {} + "properties": { + "type": { + "type": "string" + }, + "labels": { + "type": "object", + "properties": { + "_default": { + "type": "string" + } + }, + "additionalProperties": { + "type": "string" + }, + "required": [ + "_default" + ] + }, + "uuid": { + "type": "string" + }, + "options": { + "type": "object", + "properties": { + "deleted": { + "type": "boolean" + } + } + }, + "xpath": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "choices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "labels": { + "type": "object", + "properties": { + "_default": { + "type": "string" + } + }, + "additionalProperties": { + "type": "string" + }, + "required": [ + "_default" + ] + }, + "uuid": { + "type": "string" + }, + "options": { + "type": "object", + "properties": { + "deleted": { + "type": "boolean" + } + } + } + }, + "required": [ + "labels", + "uuid" + ] + } + } + }, + "required": [ + "labels", + "scope", + "type", + "xpath" + ] } } } diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index cc2b92c995..34ad583406 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15485,7 +15485,58 @@ components: type: array items: type: object - additionalProperties: {} + properties: + type: + type: string + labels: + type: object + properties: + _default: + type: string + additionalProperties: + type: string + required: + - _default + uuid: + type: string + options: + type: object + properties: + deleted: + type: boolean + xpath: + type: string + scope: + type: string + choices: + type: array + items: + type: object + properties: + labels: + type: object + properties: + _default: + type: string + additionalProperties: + type: string + required: + - _default + uuid: + type: string + options: + type: object + properties: + deleted: + type: boolean + required: + - labels + - uuid + required: + - labels + - scope + - type + - xpath _version: type: string map_styles: From be4985d64077958a9ae615c6684b3ea12937f4fc Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 18:35:10 +0200 Subject: [PATCH 37/86] map styles schema --- jsapp/js/api/models/assetMapStyles.ts | 6 +- .../manage-projects-and-library-content.ts | 63 ++++++++++++++++--- .../user-team-organization-usage.ts | 9 ++- kpi/schema_extensions/v2/assets/extensions.py | 3 +- kpi/schema_extensions/v2/assets/schema.py | 8 +++ static/openapi/schema_v2.json | 13 +++- static/openapi/schema_v2.yaml | 7 +++ 7 files changed, 98 insertions(+), 11 deletions(-) diff --git a/jsapp/js/api/models/assetMapStyles.ts b/jsapp/js/api/models/assetMapStyles.ts index 54acd7be83..19bf203fd0 100644 --- a/jsapp/js/api/models/assetMapStyles.ts +++ b/jsapp/js/api/models/assetMapStyles.ts @@ -10,4 +10,8 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type AssetMapStyles = { [key: string]: unknown } +export type AssetMapStyles = { + colorSet?: string + querylimit?: string + selectedQuestion?: string +} diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index eb62cc0f9f..f8ce4a8050 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2986,7 +2986,14 @@ export const getApiV2AssetsListResponseMock = ( }, undefined, ]), - map_styles: faker.helpers.arrayElement([{}, undefined]), + map_styles: faker.helpers.arrayElement([ + { + colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([ { @@ -3403,7 +3410,14 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial Date: Mon, 6 Jul 2026 18:39:39 +0200 Subject: [PATCH 38/86] survey row and choice schema --- jsapp/js/api/models/assetContent.ts | 4 + .../js/api/models/assetContentChoicesItem.ts | 11 +- .../assetContentKoboLockingProfilesItem.ts | 13 + jsapp/js/api/models/assetContentSettings.ts | 13 +- jsapp/js/api/models/assetContentSurveyItem.ts | 23 +- .../js/api/models/patchedAssetPatchRequest.ts | 8 +- .../models/patchedAssetPatchRequestOneOf.ts | 3 +- .../patchedAssetPatchRequestOneOfContent.ts | 27 + ...ssetPatchRequestOneOfContentChoicesItem.ts | 22 + ...uestOneOfContentKoboLockingProfilesItem.ts | 13 + ...edAssetPatchRequestOneOfContentSettings.ts | 24 + ...AssetPatchRequestOneOfContentSurveyItem.ts | 34 + ... => patchedAssetPatchRequestOneOfEight.ts} | 2 +- ... => patchedAssetPatchRequestOneOfSeven.ts} | 2 +- .../manage-projects-and-library-content.ts | 754 +++++++++++++++++- .../user-team-organization-usage.ts | 109 ++- kpi/schema_extensions/v2/assets/extensions.py | 15 +- kpi/schema_extensions/v2/assets/schema.py | 75 ++ static/openapi/schema_v2.json | 416 +++++++++- static/openapi/schema_v2.yaml | 287 ++++++- 20 files changed, 1802 insertions(+), 53 deletions(-) create mode 100644 jsapp/js/api/models/assetContentKoboLockingProfilesItem.ts create mode 100644 jsapp/js/api/models/patchedAssetPatchRequestOneOfContent.ts create mode 100644 jsapp/js/api/models/patchedAssetPatchRequestOneOfContentChoicesItem.ts create mode 100644 jsapp/js/api/models/patchedAssetPatchRequestOneOfContentKoboLockingProfilesItem.ts create mode 100644 jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSettings.ts create mode 100644 jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSurveyItem.ts rename jsapp/js/api/models/{patchedAssetPatchRequestOneOfThree.ts => patchedAssetPatchRequestOneOfEight.ts} (94%) rename jsapp/js/api/models/{patchedAssetPatchRequestOneOfTwo.ts => patchedAssetPatchRequestOneOfSeven.ts} (94%) diff --git a/jsapp/js/api/models/assetContent.ts b/jsapp/js/api/models/assetContent.ts index b5d89acd46..38c5ab31a0 100644 --- a/jsapp/js/api/models/assetContent.ts +++ b/jsapp/js/api/models/assetContent.ts @@ -1,4 +1,5 @@ import type { AssetContentChoicesItem } from './assetContentChoicesItem' +import type { AssetContentKoboLockingProfilesItem } from './assetContentKoboLockingProfilesItem' import type { AssetContentSettings } from './assetContentSettings' /** * Generated by orval v7.10.0 🍺 @@ -20,4 +21,7 @@ export type AssetContent = { settings?: AssetContentSettings translated?: string[] translations?: (string | null)[] + /** @nullable */ + translations_0?: string | null + 'kobo--locking-profiles'?: AssetContentKoboLockingProfilesItem[] } diff --git a/jsapp/js/api/models/assetContentChoicesItem.ts b/jsapp/js/api/models/assetContentChoicesItem.ts index aac858ba75..3b4391daed 100644 --- a/jsapp/js/api/models/assetContentChoicesItem.ts +++ b/jsapp/js/api/models/assetContentChoicesItem.ts @@ -10,4 +10,13 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type AssetContentChoicesItem = { [key: string]: unknown } +export type AssetContentChoicesItem = { + $autovalue: string + $kuid: string + label?: (string | null)[] + list_name: string + name: string + 'media::image'?: string[] + $autoname?: string + [key: string]: unknown +} diff --git a/jsapp/js/api/models/assetContentKoboLockingProfilesItem.ts b/jsapp/js/api/models/assetContentKoboLockingProfilesItem.ts new file mode 100644 index 0000000000..8aa4fe26f5 --- /dev/null +++ b/jsapp/js/api/models/assetContentKoboLockingProfilesItem.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetContentKoboLockingProfilesItem = { [key: string]: unknown } diff --git a/jsapp/js/api/models/assetContentSettings.ts b/jsapp/js/api/models/assetContentSettings.ts index f20d3cc94a..e74f82c285 100644 --- a/jsapp/js/api/models/assetContentSettings.ts +++ b/jsapp/js/api/models/assetContentSettings.ts @@ -10,4 +10,15 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type AssetContentSettings = { [key: string]: unknown } +export type AssetContentSettings = { + name?: string + version?: string + id_string?: string + style?: string + form_id?: string + title?: string + 'kobo--lock_all'?: boolean + 'kobo--locking-profile'?: string + /** @nullable */ + default_language?: string | null +} diff --git a/jsapp/js/api/models/assetContentSurveyItem.ts b/jsapp/js/api/models/assetContentSurveyItem.ts index be3661fe12..5088771223 100644 --- a/jsapp/js/api/models/assetContentSurveyItem.ts +++ b/jsapp/js/api/models/assetContentSurveyItem.ts @@ -10,4 +10,25 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type AssetContentSurveyItem = { [key: string]: unknown } +export type AssetContentSurveyItem = { + $kuid: string + type: string + $xpath?: string + $autoname?: string + calculation?: string + label?: (string | null)[] + hint?: (string | null)[] + name?: string + required?: boolean + appearance?: string + parameters?: string + 'kobo--matrix_list'?: string + 'kobo--rank-constraint-message'?: string + 'kobo--rank-items'?: string + 'kobo--score-choices'?: string + 'kobo--locking-profile'?: string + tags?: string[] + select_from_list_name?: string + 'body::accept'?: string + [key: string]: unknown +} diff --git a/jsapp/js/api/models/patchedAssetPatchRequest.ts b/jsapp/js/api/models/patchedAssetPatchRequest.ts index 68c92a8ff5..93830c2049 100644 --- a/jsapp/js/api/models/patchedAssetPatchRequest.ts +++ b/jsapp/js/api/models/patchedAssetPatchRequest.ts @@ -10,10 +10,10 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ import type { PatchedAssetPatchRequestOneOf } from './patchedAssetPatchRequestOneOf' -import type { PatchedAssetPatchRequestOneOfThree } from './patchedAssetPatchRequestOneOfThree' -import type { PatchedAssetPatchRequestOneOfTwo } from './patchedAssetPatchRequestOneOfTwo' +import type { PatchedAssetPatchRequestOneOfEight } from './patchedAssetPatchRequestOneOfEight' +import type { PatchedAssetPatchRequestOneOfSeven } from './patchedAssetPatchRequestOneOfSeven' export type PatchedAssetPatchRequest = | PatchedAssetPatchRequestOneOf - | PatchedAssetPatchRequestOneOfTwo - | PatchedAssetPatchRequestOneOfThree + | PatchedAssetPatchRequestOneOfSeven + | PatchedAssetPatchRequestOneOfEight diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOf.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOf.ts index 7bf39145e4..3122358e88 100644 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOf.ts +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOf.ts @@ -9,8 +9,9 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { PatchedAssetPatchRequestOneOfContent } from './patchedAssetPatchRequestOneOfContent' export type PatchedAssetPatchRequestOneOf = { - content: string + content: PatchedAssetPatchRequestOneOfContent name: string } diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContent.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContent.ts new file mode 100644 index 0000000000..5c9465b13e --- /dev/null +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContent.ts @@ -0,0 +1,27 @@ +import type { PatchedAssetPatchRequestOneOfContentChoicesItem } from './patchedAssetPatchRequestOneOfContentChoicesItem' +import type { PatchedAssetPatchRequestOneOfContentKoboLockingProfilesItem } from './patchedAssetPatchRequestOneOfContentKoboLockingProfilesItem' +import type { PatchedAssetPatchRequestOneOfContentSettings } from './patchedAssetPatchRequestOneOfContentSettings' +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { PatchedAssetPatchRequestOneOfContentSurveyItem } from './patchedAssetPatchRequestOneOfContentSurveyItem' + +export type PatchedAssetPatchRequestOneOfContent = { + schema?: string + survey?: PatchedAssetPatchRequestOneOfContentSurveyItem[] + choices?: PatchedAssetPatchRequestOneOfContentChoicesItem[] + settings?: PatchedAssetPatchRequestOneOfContentSettings + translated?: string[] + translations?: (string | null)[] + /** @nullable */ + translations_0?: string | null + 'kobo--locking-profiles'?: PatchedAssetPatchRequestOneOfContentKoboLockingProfilesItem[] +} diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentChoicesItem.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentChoicesItem.ts new file mode 100644 index 0000000000..d2e1832eba --- /dev/null +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentChoicesItem.ts @@ -0,0 +1,22 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type PatchedAssetPatchRequestOneOfContentChoicesItem = { + $autovalue: string + $kuid: string + label?: (string | null)[] + list_name: string + name: string + 'media::image'?: string[] + $autoname?: string + [key: string]: unknown +} diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentKoboLockingProfilesItem.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentKoboLockingProfilesItem.ts new file mode 100644 index 0000000000..d65adb760f --- /dev/null +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentKoboLockingProfilesItem.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type PatchedAssetPatchRequestOneOfContentKoboLockingProfilesItem = { [key: string]: unknown } diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSettings.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSettings.ts new file mode 100644 index 0000000000..a14e798112 --- /dev/null +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSettings.ts @@ -0,0 +1,24 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type PatchedAssetPatchRequestOneOfContentSettings = { + name?: string + version?: string + id_string?: string + style?: string + form_id?: string + title?: string + 'kobo--lock_all'?: boolean + 'kobo--locking-profile'?: string + /** @nullable */ + default_language?: string | null +} diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSurveyItem.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSurveyItem.ts new file mode 100644 index 0000000000..00f2919082 --- /dev/null +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSurveyItem.ts @@ -0,0 +1,34 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type PatchedAssetPatchRequestOneOfContentSurveyItem = { + $kuid: string + type: string + $xpath?: string + $autoname?: string + calculation?: string + label?: (string | null)[] + hint?: (string | null)[] + name?: string + required?: boolean + appearance?: string + parameters?: string + 'kobo--matrix_list'?: string + 'kobo--rank-constraint-message'?: string + 'kobo--rank-items'?: string + 'kobo--score-choices'?: string + 'kobo--locking-profile'?: string + tags?: string[] + select_from_list_name?: string + 'body::accept'?: string + [key: string]: unknown +} diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfThree.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfEight.ts similarity index 94% rename from jsapp/js/api/models/patchedAssetPatchRequestOneOfThree.ts rename to jsapp/js/api/models/patchedAssetPatchRequestOneOfEight.ts index 129b68c63e..18e9dcdbcb 100644 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOfThree.ts +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOfEight.ts @@ -10,6 +10,6 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type PatchedAssetPatchRequestOneOfThree = { +export type PatchedAssetPatchRequestOneOfEight = { tag_string: string } diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfTwo.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfSeven.ts similarity index 94% rename from jsapp/js/api/models/patchedAssetPatchRequestOneOfTwo.ts rename to jsapp/js/api/models/patchedAssetPatchRequestOneOfSeven.ts index c74fef6246..f073b8c38d 100644 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOfTwo.ts +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOfSeven.ts @@ -10,7 +10,7 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type PatchedAssetPatchRequestOneOfTwo = { +export type PatchedAssetPatchRequestOneOfSeven = { enabled: boolean fields: string[] } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index f8ce4a8050..013f29d85f 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -2999,14 +2999,107 @@ export const getApiV2AssetsListResponseMock = ( { schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), undefined, ]), choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, undefined, ]), - settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3019,6 +3112,16 @@ export const getApiV2AssetsListResponseMock = ( ), undefined, ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), }, undefined, ]), @@ -3423,14 +3526,104 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, undefined, ]), - settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3443,6 +3636,16 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), }, undefined, ]), @@ -3846,14 +4049,104 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, undefined, ]), - settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -3866,6 +4159,16 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), }, undefined, ]), @@ -4269,14 +4572,104 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia { schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), undefined, ]), choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, undefined, ]), - settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -4289,6 +4682,16 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia ), undefined, ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), }, undefined, ]), @@ -4716,14 +5119,107 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( { schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), undefined, ]), choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, undefined, ]), - settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -4736,6 +5232,16 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( ), undefined, ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), }, undefined, ]), @@ -5146,14 +5652,107 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( { schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), undefined, ]), choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, undefined, ]), - settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -5166,6 +5765,16 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( ), undefined, ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), }, undefined, ]), @@ -5576,14 +6185,107 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( { schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), undefined, ]), choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, undefined, ]), - settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -5596,6 +6298,16 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( ), undefined, ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), }, undefined, ]), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 291fee265e..36d1a123f8 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4121,14 +4121,107 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( { schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), undefined, ]), choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, undefined, ]), - settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), @@ -4141,6 +4234,16 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( ), undefined, ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), }, undefined, ]), diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 6b9b7d454b..f9f5bfd52b 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -32,6 +32,8 @@ BULK_CONFIRM_SCHEMA, MAP_STYLES_SCHEMA, REPORT_STYLE_SCHEMA, + SURVEY_CHOICE_SCHEMA, + SURVEY_ROW_SCHEMA, ) @@ -303,18 +305,7 @@ class ContentFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.ContentField' def map_serializer_field(self, auto_schema, direction): - return build_object_type( - properties={ - 'schema': GENERIC_STRING_SCHEMA, - 'survey': build_array_type(schema=GENERIC_OBJECT_SCHEMA), - 'choices': build_array_type(schema=GENERIC_OBJECT_SCHEMA), - 'settings': GENERIC_OBJECT_SCHEMA, - 'translated': GENERIC_ARRAY_SCHEMA, - 'translations': build_array_type( - schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} - ), - } - ) + return ASSET_CONTENT_SCHEMA class CountDailySubmissionResponseFieldExtension(OpenApiSerializerFieldExtension): diff --git a/kpi/schema_extensions/v2/assets/schema.py b/kpi/schema_extensions/v2/assets/schema.py index 8f3d412673..08495fd6c7 100644 --- a/kpi/schema_extensions/v2/assets/schema.py +++ b/kpi/schema_extensions/v2/assets/schema.py @@ -124,3 +124,78 @@ 'selectedQuestion': build_basic_type(OpenApiTypes.STR), } ) + +SURVEY_ROW_SCHEMA = build_object_type( + required=['$kuid', 'type'], + properties={ + '$kuid': build_basic_type(OpenApiTypes.STR), + 'type': build_basic_type(OpenApiTypes.STR), + '$xpath': build_basic_type(OpenApiTypes.STR), + '$autoname': build_basic_type(OpenApiTypes.STR), + 'calculation': build_basic_type(OpenApiTypes.STR), + 'label': build_array_type( + schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} + ), + 'hint': build_array_type( + schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} + ), + 'name': build_basic_type(OpenApiTypes.STR), + 'required': build_basic_type(OpenApiTypes.BOOL), + 'appearance': build_basic_type(OpenApiTypes.STR), + 'parameters': build_basic_type(OpenApiTypes.STR), + 'kobo--matrix_list': build_basic_type(OpenApiTypes.STR), + 'kobo--rank-constraint-message': build_basic_type(OpenApiTypes.STR), + 'kobo--rank-items': build_basic_type(OpenApiTypes.STR), + 'kobo--score-choices': build_basic_type(OpenApiTypes.STR), + 'kobo--locking-profile': build_basic_type(OpenApiTypes.STR), + 'tags': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + 'select_from_list_name': build_basic_type(OpenApiTypes.STR), + 'body::accept': build_basic_type(OpenApiTypes.STR), + }, + additionalProperties=True, +) + +SURVEY_CHOICE_SCHEMA = build_object_type( + required=['$autovalue', '$kuid', 'list_name', 'name'], + properties={ + '$autovalue': build_basic_type(OpenApiTypes.STR), + '$kuid': build_basic_type(OpenApiTypes.STR), + 'label': build_array_type( + schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} + ), + 'list_name': build_basic_type(OpenApiTypes.STR), + 'name': build_basic_type(OpenApiTypes.STR), + 'media::image': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + '$autoname': build_basic_type(OpenApiTypes.STR), + }, + additionalProperties=True, +) + +ASSET_CONTENT_SETTINGS_SCHEMA = build_object_type( + properties={ + 'name': build_basic_type(OpenApiTypes.STR), + 'version': build_basic_type(OpenApiTypes.STR), + 'id_string': build_basic_type(OpenApiTypes.STR), + 'style': build_basic_type(OpenApiTypes.STR), + 'form_id': build_basic_type(OpenApiTypes.STR), + 'title': build_basic_type(OpenApiTypes.STR), + 'kobo--lock_all': build_basic_type(OpenApiTypes.BOOL), + 'kobo--locking-profile': build_basic_type(OpenApiTypes.STR), + 'default_language': {**build_basic_type(OpenApiTypes.STR), 'nullable': True}, + } +) + +ASSET_CONTENT_SCHEMA = build_object_type( + properties={ + 'schema': build_basic_type(OpenApiTypes.STR), + 'survey': build_array_type(schema=SURVEY_ROW_SCHEMA), + 'choices': build_array_type(schema=SURVEY_CHOICE_SCHEMA), + 'settings': ASSET_CONTENT_SETTINGS_SCHEMA, + 'translated': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + 'translations': build_array_type( + schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} + ), + 'translations_0': {**build_basic_type(OpenApiTypes.STR), 'nullable': True}, + 'kobo--locking-profiles': build_array_type(schema=build_basic_type(OpenApiTypes.OBJECT)), + } +) diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index c755307a3a..21860a4f64 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -1479,7 +1479,74 @@ "examples": { "UpdatingAnAsset": { "value": { - "content": "string", + "content": { + "schema": "string", + "survey": [ + { + "$kuid": "string", + "type": "string", + "$xpath": "string", + "$autoname": "string", + "calculation": "string", + "label": [ + "string" + ], + "hint": [ + "string" + ], + "name": "string", + "required": true, + "appearance": "string", + "parameters": "string", + "kobo--matrix_list": "string", + "kobo--rank-constraint-message": "string", + "kobo--rank-items": "string", + "kobo--score-choices": "string", + "kobo--locking-profile": "string", + "tags": [ + "string" + ], + "select_from_list_name": "string", + "body::accept": "string" + } + ], + "choices": [ + { + "$autovalue": "string", + "$kuid": "string", + "label": [ + "string" + ], + "list_name": "string", + "name": "string", + "media::image": [ + "string" + ], + "$autoname": "string" + } + ], + "settings": { + "name": "string", + "version": "string", + "id_string": "string", + "style": "string", + "form_id": "string", + "title": "string", + "kobo--lock_all": true, + "kobo--locking-profile": "string", + "default_language": "string" + }, + "translated": [ + "string" + ], + "translations": [ + "string" + ], + "translations_0": "string", + "kobo--locking-profiles": [ + {} + ] + }, "name": "string" }, "summary": "Updating an asset" @@ -21725,17 +21792,159 @@ "survey": { "type": "array", "items": { - "type": "object" + "type": "object", + "properties": { + "$kuid": { + "type": "string" + }, + "type": { + "type": "string" + }, + "$xpath": { + "type": "string" + }, + "$autoname": { + "type": "string" + }, + "calculation": { + "type": "string" + }, + "label": { + "type": "array", + "items": { + "type": "string", + "nullable": true + } + }, + "hint": { + "type": "array", + "items": { + "type": "string", + "nullable": true + } + }, + "name": { + "type": "string" + }, + "required": { + "type": "boolean" + }, + "appearance": { + "type": "string" + }, + "parameters": { + "type": "string" + }, + "kobo--matrix_list": { + "type": "string" + }, + "kobo--rank-constraint-message": { + "type": "string" + }, + "kobo--rank-items": { + "type": "string" + }, + "kobo--score-choices": { + "type": "string" + }, + "kobo--locking-profile": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "select_from_list_name": { + "type": "string" + }, + "body::accept": { + "type": "string" + } + }, + "additionalProperties": true, + "required": [ + "$kuid", + "type" + ] } }, "choices": { "type": "array", "items": { - "type": "object" + "type": "object", + "properties": { + "$autovalue": { + "type": "string" + }, + "$kuid": { + "type": "string" + }, + "label": { + "type": "array", + "items": { + "type": "string", + "nullable": true + } + }, + "list_name": { + "type": "string" + }, + "name": { + "type": "string" + }, + "media::image": { + "type": "array", + "items": { + "type": "string" + } + }, + "$autoname": { + "type": "string" + } + }, + "additionalProperties": true, + "required": [ + "$autovalue", + "$kuid", + "list_name", + "name" + ] } }, "settings": { - "type": "object" + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "id_string": { + "type": "string" + }, + "style": { + "type": "string" + }, + "form_id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "kobo--lock_all": { + "type": "boolean" + }, + "kobo--locking-profile": { + "type": "string" + }, + "default_language": { + "type": "string", + "nullable": true + } + } }, "translated": { "type": "array", @@ -21749,6 +21958,17 @@ "type": "string", "nullable": true } + }, + "translations_0": { + "type": "string", + "nullable": true + }, + "kobo--locking-profiles": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": {} + } } } }, @@ -28818,7 +29038,193 @@ "type": "object", "properties": { "content": { - "type": "string" + "type": "object", + "properties": { + "schema": { + "type": "string" + }, + "survey": { + "type": "array", + "items": { + "type": "object", + "properties": { + "$kuid": { + "type": "string" + }, + "type": { + "type": "string" + }, + "$xpath": { + "type": "string" + }, + "$autoname": { + "type": "string" + }, + "calculation": { + "type": "string" + }, + "label": { + "type": "array", + "items": { + "type": "string", + "nullable": true + } + }, + "hint": { + "type": "array", + "items": { + "type": "string", + "nullable": true + } + }, + "name": { + "type": "string" + }, + "required": { + "type": "boolean" + }, + "appearance": { + "type": "string" + }, + "parameters": { + "type": "string" + }, + "kobo--matrix_list": { + "type": "string" + }, + "kobo--rank-constraint-message": { + "type": "string" + }, + "kobo--rank-items": { + "type": "string" + }, + "kobo--score-choices": { + "type": "string" + }, + "kobo--locking-profile": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "select_from_list_name": { + "type": "string" + }, + "body::accept": { + "type": "string" + } + }, + "additionalProperties": true, + "required": [ + "$kuid", + "type" + ] + } + }, + "choices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "$autovalue": { + "type": "string" + }, + "$kuid": { + "type": "string" + }, + "label": { + "type": "array", + "items": { + "type": "string", + "nullable": true + } + }, + "list_name": { + "type": "string" + }, + "name": { + "type": "string" + }, + "media::image": { + "type": "array", + "items": { + "type": "string" + } + }, + "$autoname": { + "type": "string" + } + }, + "additionalProperties": true, + "required": [ + "$autovalue", + "$kuid", + "list_name", + "name" + ] + } + }, + "settings": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "id_string": { + "type": "string" + }, + "style": { + "type": "string" + }, + "form_id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "kobo--lock_all": { + "type": "boolean" + }, + "kobo--locking-profile": { + "type": "string" + }, + "default_language": { + "type": "string", + "nullable": true + } + } + }, + "translated": { + "type": "array", + "items": { + "type": "string" + } + }, + "translations": { + "type": "array", + "items": { + "type": "string", + "nullable": true + } + }, + "translations_0": { + "type": "string", + "nullable": true + }, + "kobo--locking-profiles": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": {} + } + } + } }, "name": { "type": "string" diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index c3dca9f8c3..8035ca358d 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -1056,7 +1056,58 @@ paths: examples: UpdatingAnAsset: value: - content: string + content: + schema: string + survey: + - $kuid: string + type: string + $xpath: string + $autoname: string + calculation: string + label: + - string + hint: + - string + name: string + required: true + appearance: string + parameters: string + kobo--matrix_list: string + kobo--rank-constraint-message: string + kobo--rank-items: string + kobo--score-choices: string + kobo--locking-profile: string + tags: + - string + select_from_list_name: string + body::accept: string + choices: + - $autovalue: string + $kuid: string + label: + - string + list_name: string + name: string + media::image: + - string + $autoname: string + settings: + name: string + version: string + id_string: string + style: string + form_id: string + title: string + kobo--lock_all: true + kobo--locking-profile: string + default_language: string + translated: + - string + translations: + - string + translations_0: string + kobo--locking-profiles: + - {} name: string summary: Updating an asset DataSharingOfTheProject: @@ -15559,12 +15610,109 @@ components: type: array items: type: object + properties: + $kuid: + type: string + type: + type: string + $xpath: + type: string + $autoname: + type: string + calculation: + type: string + label: + type: array + items: + type: string + nullable: true + hint: + type: array + items: + type: string + nullable: true + name: + type: string + required: + type: boolean + appearance: + type: string + parameters: + type: string + kobo--matrix_list: + type: string + kobo--rank-constraint-message: + type: string + kobo--rank-items: + type: string + kobo--score-choices: + type: string + kobo--locking-profile: + type: string + tags: + type: array + items: + type: string + select_from_list_name: + type: string + body::accept: + type: string + additionalProperties: true + required: + - $kuid + - type choices: type: array items: type: object + properties: + $autovalue: + type: string + $kuid: + type: string + label: + type: array + items: + type: string + nullable: true + list_name: + type: string + name: + type: string + media::image: + type: array + items: + type: string + $autoname: + type: string + additionalProperties: true + required: + - $autovalue + - $kuid + - list_name + - name settings: type: object + properties: + name: + type: string + version: + type: string + id_string: + type: string + style: + type: string + form_id: + type: string + title: + type: string + kobo--lock_all: + type: boolean + kobo--locking-profile: + type: string + default_language: + type: string + nullable: true translated: type: array items: @@ -15574,6 +15722,14 @@ components: items: type: string nullable: true + translations_0: + type: string + nullable: true + kobo--locking-profiles: + type: array + items: + type: object + additionalProperties: {} downloads: type: array items: @@ -20591,7 +20747,134 @@ components: - type: object properties: content: - type: string + type: object + properties: + schema: + type: string + survey: + type: array + items: + type: object + properties: + $kuid: + type: string + type: + type: string + $xpath: + type: string + $autoname: + type: string + calculation: + type: string + label: + type: array + items: + type: string + nullable: true + hint: + type: array + items: + type: string + nullable: true + name: + type: string + required: + type: boolean + appearance: + type: string + parameters: + type: string + kobo--matrix_list: + type: string + kobo--rank-constraint-message: + type: string + kobo--rank-items: + type: string + kobo--score-choices: + type: string + kobo--locking-profile: + type: string + tags: + type: array + items: + type: string + select_from_list_name: + type: string + body::accept: + type: string + additionalProperties: true + required: + - $kuid + - type + choices: + type: array + items: + type: object + properties: + $autovalue: + type: string + $kuid: + type: string + label: + type: array + items: + type: string + nullable: true + list_name: + type: string + name: + type: string + media::image: + type: array + items: + type: string + $autoname: + type: string + additionalProperties: true + required: + - $autovalue + - $kuid + - list_name + - name + settings: + type: object + properties: + name: + type: string + version: + type: string + id_string: + type: string + style: + type: string + form_id: + type: string + title: + type: string + kobo--lock_all: + type: boolean + kobo--locking-profile: + type: string + default_language: + type: string + nullable: true + translated: + type: array + items: + type: string + translations: + type: array + items: + type: string + nullable: true + translations_0: + type: string + nullable: true + kobo--locking-profiles: + type: array + items: + type: object + additionalProperties: {} name: type: string required: From 1c73d49913967222dd4927c4d62260e02a4751ae Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 18:46:31 +0200 Subject: [PATCH 39/86] post schema fixes --- jsapp/js/components/formSummary/formSummaryProjectInfo.tsx | 2 +- jsapp/js/dataInterface.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jsapp/js/components/formSummary/formSummaryProjectInfo.tsx b/jsapp/js/components/formSummary/formSummaryProjectInfo.tsx index 5021d63c99..8dd4e2bc60 100644 --- a/jsapp/js/components/formSummary/formSummaryProjectInfo.tsx +++ b/jsapp/js/components/formSummary/formSummaryProjectInfo.tsx @@ -122,7 +122,7 @@ export default function FormSummaryProjectInfo(props: FormSummaryProjectInfoProp {/* date modified */} {t('Last modified')} - {formatTime(props.asset.date_modified)} + {props.asset.date_modified ? formatTime(props.asset.date_modified) : 'n/a'} {/* date deployed */} diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index 63938c2f86..e08d5dd29a 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -485,6 +485,8 @@ export interface SurveyRow { select_from_list_name?: string /** Used by `file` type to list accepted extensions */ 'body::accept'?: string + /** Allow additional properties for XLSForm custom fields */ + [key: string]: unknown } export interface SurveyChoice { @@ -497,6 +499,8 @@ export interface SurveyChoice { // Possibly deprecated? Most code doesn't use it at all, old reports code was // using it as fallback. $autoname?: string + /** Allow additional properties for XLSForm custom fields */ + [key: string]: unknown } export interface AssetContentSettings { From d9e66a3362b939fd2523c3df97c83a13c62184d3 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 19:01:46 +0200 Subject: [PATCH 40/86] assignable permissions schema --- .../models/assetAssignablePermissionsItem.ts | 6 +- .../assetAssignablePermissionsItemLabel.ts | 14 ++ ...ssetAssignablePermissionsItemLabelOneOf.ts | 19 ++ .../manage-projects-and-library-content.ts | 187 ++++++++++++++++-- .../user-team-organization-usage.ts | 28 ++- .../js/components/locking/lockingConstants.ts | 2 + jsapp/js/dataInterface.ts | 10 +- kpi/schema_extensions/v2/assets/extensions.py | 3 +- kpi/schema_extensions/v2/assets/schema.py | 25 +++ static/openapi/schema_v2.json | 41 +++- static/openapi/schema_v2.yaml | 23 +++ 11 files changed, 326 insertions(+), 32 deletions(-) create mode 100644 jsapp/js/api/models/assetAssignablePermissionsItemLabel.ts create mode 100644 jsapp/js/api/models/assetAssignablePermissionsItemLabelOneOf.ts diff --git a/jsapp/js/api/models/assetAssignablePermissionsItem.ts b/jsapp/js/api/models/assetAssignablePermissionsItem.ts index 01a6b52e0f..9ccff97525 100644 --- a/jsapp/js/api/models/assetAssignablePermissionsItem.ts +++ b/jsapp/js/api/models/assetAssignablePermissionsItem.ts @@ -9,5 +9,9 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetAssignablePermissionsItemLabel } from './assetAssignablePermissionsItemLabel' -export type AssetAssignablePermissionsItem = { [key: string]: unknown } +export type AssetAssignablePermissionsItem = { + url: string + label: AssetAssignablePermissionsItemLabel +} diff --git a/jsapp/js/api/models/assetAssignablePermissionsItemLabel.ts b/jsapp/js/api/models/assetAssignablePermissionsItemLabel.ts new file mode 100644 index 0000000000..f843695f62 --- /dev/null +++ b/jsapp/js/api/models/assetAssignablePermissionsItemLabel.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetAssignablePermissionsItemLabelOneOf } from './assetAssignablePermissionsItemLabelOneOf' + +export type AssetAssignablePermissionsItemLabel = string | AssetAssignablePermissionsItemLabelOneOf diff --git a/jsapp/js/api/models/assetAssignablePermissionsItemLabelOneOf.ts b/jsapp/js/api/models/assetAssignablePermissionsItemLabelOneOf.ts new file mode 100644 index 0000000000..00822c2d6c --- /dev/null +++ b/jsapp/js/api/models/assetAssignablePermissionsItemLabelOneOf.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetAssignablePermissionsItemLabelOneOf = { + default: string + view_submissions?: string + change_submissions?: string + delete_submissions?: string + validate_submissions?: string +} diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 013f29d85f..a9486cb862 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -3169,9 +3169,31 @@ export const getApiV2AssetsListResponseMock = ( kind: faker.string.alpha({ length: { min: 10, max: 20 } }), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( - () => ({}), - ), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), ), @@ -3693,9 +3715,28 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map( - () => ({}), - ), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), ), @@ -4216,9 +4257,28 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map( - () => ({}), - ), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), ), @@ -4739,9 +4799,28 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia kind: faker.string.alpha({ length: { min: 10, max: 20 } }), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( - () => ({}), - ), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), ), @@ -5289,9 +5368,31 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( kind: faker.string.alpha({ length: { min: 10, max: 20 } }), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( - () => ({}), - ), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), ), @@ -5822,9 +5923,31 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( kind: faker.string.alpha({ length: { min: 10, max: 20 } }), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( - () => ({}), - ), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), ), @@ -6355,9 +6478,31 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( kind: faker.string.alpha({ length: { min: 10, max: 20 } }), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( - () => ({}), - ), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), ), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 36d1a123f8..56de939155 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4291,9 +4291,31 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( kind: faker.string.alpha({ length: { min: 10, max: 20 } }), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( - () => ({}), - ), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => faker.string.alpha({ length: { min: 10, max: 20 } }), ), diff --git a/jsapp/js/components/locking/lockingConstants.ts b/jsapp/js/components/locking/lockingConstants.ts index 95b191e062..de5c4b5ecc 100644 --- a/jsapp/js/components/locking/lockingConstants.ts +++ b/jsapp/js/components/locking/lockingConstants.ts @@ -1,6 +1,8 @@ export interface AssetLockingProfileDefinition { name: string restrictions: LockingRestrictionName[] + /** Allow additional properties for backend extensions */ + [key: string]: unknown } export interface IndexedAssetLockingProfileDefinition extends AssetLockingProfileDefinition { diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index e08d5dd29a..978cceff26 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -706,7 +706,7 @@ export interface AssetResponse extends AssetRequestObject { version_count: number has_deployment: boolean deployed_version_id: string | null - analysis_form_json?: { + analysis_form_json: { additional_fields: AnalysisFormJsonField[] } deployed_versions: { @@ -748,15 +748,15 @@ export interface AssetResponse extends AssetRequestObject { deployment__last_submission_time: string | null deployment_status: 'archived' | 'deployed' | 'draft' | '-' downloads: AssetDownloads - embeds?: Array<{ + embeds: Array<{ format: string url: string }> - xform_link?: string - hooks_link?: string + xform_link: string + hooks_link: string uid: string kind: string - xls_link?: string + xls_link: string assignable_permissions: AssignablePermission[] /** * A list of all permissions (their codenames) that current user has in diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index f9f5bfd52b..46d85d57e3 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -19,6 +19,7 @@ from kpi.utils.schema_extensions.url_builder import build_url_type from .schema import ( ADVANCED_FEATURES_SCHEMA, + ASSIGNABLE_PERMISSION_SCHEMA, ASSET_CLONE_FROM_SCHEMA, ASSET_CONTENT_SCHEMA, ASSET_ENABLED_SCHEMA, @@ -213,7 +214,7 @@ class AssignablePermissionFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.AssignablePermissionField' def map_serializer_field(self, auto_schema, direction): - return build_array_type(schema=GENERIC_OBJECT_SCHEMA) + return build_array_type(schema=ASSIGNABLE_PERMISSION_SCHEMA) class AssetSettingsFieldExtension(OpenApiSerializerFieldExtension): diff --git a/kpi/schema_extensions/v2/assets/schema.py b/kpi/schema_extensions/v2/assets/schema.py index 08495fd6c7..1d2b9840b8 100644 --- a/kpi/schema_extensions/v2/assets/schema.py +++ b/kpi/schema_extensions/v2/assets/schema.py @@ -46,6 +46,31 @@ BULK_CONFIRM_SCHEMA = build_basic_type(OpenApiTypes.BOOL) +# Assignable permissions can have label as string (regular) or object (partial) +ASSIGNABLE_PERMISSION_PARTIAL_LABEL_SCHEMA = build_object_type( + required=['default'], + properties={ + 'default': build_basic_type(OpenApiTypes.STR), + 'view_submissions': build_basic_type(OpenApiTypes.STR), + 'change_submissions': build_basic_type(OpenApiTypes.STR), + 'delete_submissions': build_basic_type(OpenApiTypes.STR), + 'validate_submissions': build_basic_type(OpenApiTypes.STR), + } +) + +ASSIGNABLE_PERMISSION_SCHEMA = build_object_type( + required=['url', 'label'], + properties={ + 'url': build_basic_type(OpenApiTypes.STR), + 'label': { + 'oneOf': [ + build_basic_type(OpenApiTypes.STR), + ASSIGNABLE_PERMISSION_PARTIAL_LABEL_SCHEMA, + ] + }, + } +) + REPORT_STYLE_SCHEMA = build_object_type( properties={ 'groupDataBy': build_basic_type(OpenApiTypes.STR), diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 21860a4f64..d094f08d97 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -22129,7 +22129,46 @@ "assignable_permissions": { "type": "array", "items": { - "type": "object" + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "label": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "default": { + "type": "string" + }, + "view_submissions": { + "type": "string" + }, + "change_submissions": { + "type": "string" + }, + "delete_submissions": { + "type": "string" + }, + "validate_submissions": { + "type": "string" + } + }, + "required": [ + "default" + ] + } + ] + } + }, + "required": [ + "label", + "url" + ] }, "readOnly": true }, diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 8035ca358d..705f50115e 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15845,6 +15845,29 @@ components: type: array items: type: object + properties: + url: + type: string + label: + oneOf: + - type: string + - type: object + properties: + default: + type: string + view_submissions: + type: string + change_submissions: + type: string + delete_submissions: + type: string + validate_submissions: + type: string + required: + - default + required: + - label + - url readOnly: true permissions: type: array From 9424c42b223840440fd90668e09617eb193d155c Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 19:05:49 +0200 Subject: [PATCH 41/86] asset permissions schema --- jsapp/js/api/models/asset.ts | 3 +- jsapp/js/api/models/assetPermissionsItem.ts | 21 ++ .../api/models/assetPermissionsItemLabel.ts | 14 + .../models/assetPermissionsItemLabelOneOf.ts | 19 ++ ...etPermissionsItemPartialPermissionsItem.ts | 17 + ...nsItemPartialPermissionsItemFiltersItem.ts | 13 + .../manage-projects-and-library-content.ts | 301 ++++++++++++++++-- .../user-team-organization-usage.ts | 43 ++- kpi/schema_extensions/v2/assets/extensions.py | 3 +- kpi/schema_extensions/v2/assets/schema.py | 24 ++ static/openapi/schema_v2.json | 65 +++- static/openapi/schema_v2.yaml | 41 ++- 12 files changed, 536 insertions(+), 28 deletions(-) create mode 100644 jsapp/js/api/models/assetPermissionsItem.ts create mode 100644 jsapp/js/api/models/assetPermissionsItemLabel.ts create mode 100644 jsapp/js/api/models/assetPermissionsItemLabelOneOf.ts create mode 100644 jsapp/js/api/models/assetPermissionsItemPartialPermissionsItem.ts create mode 100644 jsapp/js/api/models/assetPermissionsItemPartialPermissionsItemFiltersItem.ts diff --git a/jsapp/js/api/models/asset.ts b/jsapp/js/api/models/asset.ts index 7e0e4fefb8..1dc22f2954 100644 --- a/jsapp/js/api/models/asset.ts +++ b/jsapp/js/api/models/asset.ts @@ -15,6 +15,7 @@ import type { AssetExportSettings } from './assetExportSettings' import type { AssetFilesItem } from './assetFilesItem' import type { AssetMapCustom } from './assetMapCustom' import type { AssetMapStyles } from './assetMapStyles' +import type { AssetPermissionsItem } from './assetPermissionsItem' import type { AssetProjectOwnership } from './assetProjectOwnership' import type { AssetReportCustom } from './assetReportCustom' import type { AssetReportStyles } from './assetReportStyles' @@ -85,7 +86,7 @@ export interface Asset { /** @maxLength 255 */ name?: string readonly assignable_permissions: readonly AssetAssignablePermissionsItem[] - readonly permissions: readonly string[] + readonly permissions: readonly AssetPermissionsItem[] readonly effective_permissions: readonly AssetEffectivePermissionsItem[] readonly exports: string readonly export_settings: readonly AssetExportSettings[] diff --git a/jsapp/js/api/models/assetPermissionsItem.ts b/jsapp/js/api/models/assetPermissionsItem.ts new file mode 100644 index 0000000000..4a0fceb38a --- /dev/null +++ b/jsapp/js/api/models/assetPermissionsItem.ts @@ -0,0 +1,21 @@ +import type { AssetPermissionsItemLabel } from './assetPermissionsItemLabel' +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetPermissionsItemPartialPermissionsItem } from './assetPermissionsItemPartialPermissionsItem' + +export type AssetPermissionsItem = { + url: string + user: string + permission: string + partial_permissions?: AssetPermissionsItemPartialPermissionsItem[] + label?: AssetPermissionsItemLabel +} diff --git a/jsapp/js/api/models/assetPermissionsItemLabel.ts b/jsapp/js/api/models/assetPermissionsItemLabel.ts new file mode 100644 index 0000000000..b234b3475d --- /dev/null +++ b/jsapp/js/api/models/assetPermissionsItemLabel.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetPermissionsItemLabelOneOf } from './assetPermissionsItemLabelOneOf' + +export type AssetPermissionsItemLabel = string | AssetPermissionsItemLabelOneOf diff --git a/jsapp/js/api/models/assetPermissionsItemLabelOneOf.ts b/jsapp/js/api/models/assetPermissionsItemLabelOneOf.ts new file mode 100644 index 0000000000..ac6acb2df6 --- /dev/null +++ b/jsapp/js/api/models/assetPermissionsItemLabelOneOf.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetPermissionsItemLabelOneOf = { + default: string + view_submissions?: string + change_submissions?: string + delete_submissions?: string + validate_submissions?: string +} diff --git a/jsapp/js/api/models/assetPermissionsItemPartialPermissionsItem.ts b/jsapp/js/api/models/assetPermissionsItemPartialPermissionsItem.ts new file mode 100644 index 0000000000..3450be6b61 --- /dev/null +++ b/jsapp/js/api/models/assetPermissionsItemPartialPermissionsItem.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetPermissionsItemPartialPermissionsItemFiltersItem } from './assetPermissionsItemPartialPermissionsItemFiltersItem' + +export type AssetPermissionsItemPartialPermissionsItem = { + url?: string + filters?: AssetPermissionsItemPartialPermissionsItemFiltersItem[] +} diff --git a/jsapp/js/api/models/assetPermissionsItemPartialPermissionsItemFiltersItem.ts b/jsapp/js/api/models/assetPermissionsItemPartialPermissionsItemFiltersItem.ts new file mode 100644 index 0000000000..9de455bf45 --- /dev/null +++ b/jsapp/js/api/models/assetPermissionsItemPartialPermissionsItemFiltersItem.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +export type AssetPermissionsItemPartialPermissionsItemFiltersItem = { [key: string]: unknown } diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index a9486cb862..d97be47055 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -3194,9 +3194,46 @@ export const getApiV2AssetsListResponseMock = ( }, ]), })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), @@ -3737,9 +3774,46 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), @@ -4279,9 +4353,46 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), @@ -4821,9 +4932,46 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia }, ]), })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), @@ -5393,9 +5541,46 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( }, ]), })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), @@ -5948,9 +6133,46 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( }, ]), })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), @@ -6503,9 +6725,46 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( }, ]), })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 56de939155..eb74492b21 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -4316,9 +4316,46 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( }, ]), })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), })), diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 46d85d57e3..4753d187df 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -32,6 +32,7 @@ BULK_ASSET_UIDS_SCHEMA, BULK_CONFIRM_SCHEMA, MAP_STYLES_SCHEMA, + PERMISSION_ASSIGNMENT_SCHEMA, REPORT_STYLE_SCHEMA, SURVEY_CHOICE_SCHEMA, SURVEY_ROW_SCHEMA, @@ -538,7 +539,7 @@ class PermissionsFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.PermissionsField' def map_serializer_field(self, auto_schema, direction): - return GENERIC_ARRAY_SCHEMA + return build_array_type(schema=PERMISSION_ASSIGNMENT_SCHEMA) class ReportCustomFieldExtension(OpenApiSerializerFieldExtension): diff --git a/kpi/schema_extensions/v2/assets/schema.py b/kpi/schema_extensions/v2/assets/schema.py index 1d2b9840b8..a6d8de115c 100644 --- a/kpi/schema_extensions/v2/assets/schema.py +++ b/kpi/schema_extensions/v2/assets/schema.py @@ -71,6 +71,30 @@ } ) +# Permission assignment response (actual permission grants) +PARTIAL_PERMISSION_FILTER_SCHEMA = build_object_type( + properties={ + 'url': build_basic_type(OpenApiTypes.STR), + 'filters': build_array_type(schema=build_object_type(properties={})), + } +) + +PERMISSION_ASSIGNMENT_SCHEMA = build_object_type( + required=['url', 'user', 'permission'], + properties={ + 'url': build_basic_type(OpenApiTypes.STR), + 'user': build_basic_type(OpenApiTypes.STR), + 'permission': build_basic_type(OpenApiTypes.STR), + 'partial_permissions': build_array_type(schema=PARTIAL_PERMISSION_FILTER_SCHEMA), + 'label': { + 'oneOf': [ + build_basic_type(OpenApiTypes.STR), + ASSIGNABLE_PERMISSION_PARTIAL_LABEL_SCHEMA, + ] + }, + } +) + REPORT_STYLE_SCHEMA = build_object_type( properties={ 'groupDataBy': build_basic_type(OpenApiTypes.STR), diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index d094f08d97..51efba501c 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -22175,7 +22175,70 @@ "permissions": { "type": "array", "items": { - "type": "string" + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "user": { + "type": "string" + }, + "permission": { + "type": "string" + }, + "partial_permissions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "filters": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "label": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "default": { + "type": "string" + }, + "view_submissions": { + "type": "string" + }, + "change_submissions": { + "type": "string" + }, + "delete_submissions": { + "type": "string" + }, + "validate_submissions": { + "type": "string" + } + }, + "required": [ + "default" + ] + } + ] + } + }, + "required": [ + "permission", + "url", + "user" + ] }, "readOnly": true }, diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 705f50115e..6ec9913814 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15872,7 +15872,46 @@ components: permissions: type: array items: - type: string + type: object + properties: + url: + type: string + user: + type: string + permission: + type: string + partial_permissions: + type: array + items: + type: object + properties: + url: + type: string + filters: + type: array + items: + type: object + label: + oneOf: + - type: string + - type: object + properties: + default: + type: string + view_submissions: + type: string + change_submissions: + type: string + delete_submissions: + type: string + validate_submissions: + type: string + required: + - default + required: + - permission + - url + - user readOnly: true effective_permissions: type: array From 7e37f1391d876ac6b1710e2d44a39ce7d7ae8838 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 19:29:39 +0200 Subject: [PATCH 42/86] make access type nullable in schema --- jsapp/js/api/models/asset.ts | 3 ++- jsapp/js/dataInterface.ts | 6 +++++- kpi/schema_extensions/v2/assets/extensions.py | 2 +- static/openapi/schema_v2.json | 1 + static/openapi/schema_v2.yaml | 1 + 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/jsapp/js/api/models/asset.ts b/jsapp/js/api/models/asset.ts index 1dc22f2954..ac63c864ca 100644 --- a/jsapp/js/api/models/asset.ts +++ b/jsapp/js/api/models/asset.ts @@ -94,7 +94,8 @@ export interface Asset { readonly children: AssetChildren readonly subscribers_count: number readonly status: string - readonly access_types: readonly string[] + /** @nullable */ + readonly access_types: readonly string[] | null data_sharing?: AssetDataSharing readonly paired_data: string /** @nullable */ diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index 978cceff26..3b1efacc12 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -336,6 +336,8 @@ export interface LabelValuePair { export interface PartialPermissionFilterByUsers { _submitted_by?: string | { $in: string[] } + /** Allow additional question response filters */ + [key: string]: unknown } export type PartialPermissionFilterByResponses = Record @@ -427,6 +429,8 @@ export interface ExportSettingSettings { query?: MongoQuery /** Only for GeoJSON */ flatten?: boolean + /** Allow additional export setting properties */ + [key: string]: unknown } /** @@ -764,7 +768,7 @@ export interface AssetResponse extends AssetRequestObject { * that user and ones coming from the Project View definition. */ effective_permissions: Array<{ codename: PermissionCodename }> - exports?: string + exports: string data: string children: { count: number diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 4753d187df..6b2b5ad909 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -43,7 +43,7 @@ class AccessTypeFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.AccessTypeField' def map_serializer_field(self, auto_schema, direction): - return GENERIC_ARRAY_SCHEMA + return {**GENERIC_ARRAY_SCHEMA, 'nullable': True} class AdvancedFeatureFieldExtension(OpenApiSerializerFieldExtension): diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 51efba501c..367dc20f00 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -22295,6 +22295,7 @@ "items": { "type": "string" }, + "nullable": true, "readOnly": true }, "data_sharing": { diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index 6ec9913814..e06850adf2 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15952,6 +15952,7 @@ components: type: array items: type: string + nullable: true readOnly: true data_sharing: type: object From d89a7a78904a9be9dc7acb0ad54dad81fc643e8e Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 19:30:33 +0200 Subject: [PATCH 43/86] fix legacy paired_data type --- jsapp/js/dataInterface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index 3b1efacc12..475abbea92 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -651,7 +651,7 @@ export interface AssetRequestObject { enabled?: boolean fields?: string[] } - paired_data?: string + paired_data: string advanced_features?: AssetAdvancedFeatures } From e84ac8b21b775f87bbdeed03054f4b80f55d3a33 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 19:32:42 +0200 Subject: [PATCH 44/86] fix project transfer asset detail type --- .../permissions/transferProjects/transferProjects.api.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jsapp/js/components/permissions/transferProjects/transferProjects.api.ts b/jsapp/js/components/permissions/transferProjects/transferProjects.api.ts index 51496ff8a8..741206af23 100644 --- a/jsapp/js/components/permissions/transferProjects/transferProjects.api.ts +++ b/jsapp/js/components/permissions/transferProjects/transferProjects.api.ts @@ -42,6 +42,8 @@ export interface ProjectTransferAssetDetail { sender: string recipient: string status: TransferStatuses + /** Allow additional properties for backend extensions */ + [key: string]: unknown } export interface InvitesResponse { From c52d0b90e01b38942924e34aa2724134308cf69a Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 21:16:13 +0200 Subject: [PATCH 45/86] safecheck date --- jsapp/js/components/assetsTable/assetsTableRow.tsx | 2 +- jsapp/js/components/formSummary/formSummaryProjectInfo.tsx | 2 +- jsapp/js/components/library/assetInfoBox.tsx | 4 ++-- jsapp/js/components/map/FormMapWrapper.stories.tsx | 6 +++--- jsapp/js/projects/projectsTable/projectsTableRow.tsx | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jsapp/js/components/assetsTable/assetsTableRow.tsx b/jsapp/js/components/assetsTable/assetsTableRow.tsx index ba00b5ed54..7b5a4b1adf 100644 --- a/jsapp/js/components/assetsTable/assetsTableRow.tsx +++ b/jsapp/js/components/assetsTable/assetsTableRow.tsx @@ -74,7 +74,7 @@ class AssetsTableRow extends React.Component { )} - {formatTime(this.props.asset.date_modified)} + {this.props.asset.date_modified ? formatTime(this.props.asset.date_modified) : '-'} ) diff --git a/jsapp/js/components/formSummary/formSummaryProjectInfo.tsx b/jsapp/js/components/formSummary/formSummaryProjectInfo.tsx index 8dd4e2bc60..20206d5cb9 100644 --- a/jsapp/js/components/formSummary/formSummaryProjectInfo.tsx +++ b/jsapp/js/components/formSummary/formSummaryProjectInfo.tsx @@ -122,7 +122,7 @@ export default function FormSummaryProjectInfo(props: FormSummaryProjectInfoProp {/* date modified */} {t('Last modified')} - {props.asset.date_modified ? formatTime(props.asset.date_modified) : 'n/a'} + {props.asset.date_modified ? formatTime(props.asset.date_modified) : '-'} {/* date deployed */} diff --git a/jsapp/js/components/library/assetInfoBox.tsx b/jsapp/js/components/library/assetInfoBox.tsx index 4d93207539..a52a2e76b7 100644 --- a/jsapp/js/components/library/assetInfoBox.tsx +++ b/jsapp/js/components/library/assetInfoBox.tsx @@ -74,13 +74,13 @@ export default class AssetInfoBox extends React.Component - {this.props.asset.date_created ? formatTime(this.props.asset.date_created) : 'n/a'} + {this.props.asset.date_created ? formatTime(this.props.asset.date_created) : '-'} {this.state.areDetailsVisible && ( - {this.props.asset.date_modified ? formatTime(this.props.asset.date_modified) : 'n/a'} + {this.props.asset.date_modified ? formatTime(this.props.asset.date_modified) : '-'} )} diff --git a/jsapp/js/components/map/FormMapWrapper.stories.tsx b/jsapp/js/components/map/FormMapWrapper.stories.tsx index c057b839c3..f7f3f64c0c 100644 --- a/jsapp/js/components/map/FormMapWrapper.stories.tsx +++ b/jsapp/js/components/map/FormMapWrapper.stories.tsx @@ -5,7 +5,7 @@ import { expect, waitFor, within } from 'storybook/test' import { endpoints } from '#/api.endpoints' import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import { MetaQuestionTypeName, QuestionTypeName } from '#/constants' -import type { PaginatedResponse, SubmissionResponse } from '#/dataInterface' +import type { AssetResponse, PaginatedResponse, SubmissionResponse } from '#/dataInterface' import assetDataFactory from '#/endpoints/assetData.factory' import { queryClientDecorator } from '#/query/queryClient.mocks' import { ROUTES } from '#/router/routerConstants' @@ -53,7 +53,7 @@ const assetWithOnlyStartGeopoint = getApiV2AssetsRetrieveResponseMock({ ], choices: [], }, -}) +}) as unknown as AssetResponse // Asset with both start-geopoint AND regular geopoint const assetWithBothGeopointTypes = getApiV2AssetsRetrieveResponseMock({ @@ -97,7 +97,7 @@ const assetWithBothGeopointTypes = getApiV2AssetsRetrieveResponseMock({ ], choices: [], }, -}) +}) as unknown as AssetResponse // Submission data with populated start-geopoint const submissionsWithStartGeopoint: SubmissionResponse[] = [ diff --git a/jsapp/js/projects/projectsTable/projectsTableRow.tsx b/jsapp/js/projects/projectsTable/projectsTableRow.tsx index 8f615eeea3..aa5afc3af3 100644 --- a/jsapp/js/projects/projectsTable/projectsTableRow.tsx +++ b/jsapp/js/projects/projectsTable/projectsTableRow.tsx @@ -64,7 +64,7 @@ export default function ProjectsTableRow(props: ProjectsTableRowProps) { return } case 'dateModified': - return props.asset.date_modified ? formatTime(props.asset.date_modified) : 'n/a' + return props.asset.date_modified ? formatTime(props.asset.date_modified) : '-' case 'dateDeployed': if ('date_deployed' in props.asset && props.asset.date_deployed) { return formatTime(props.asset.date_deployed) From 1457bd5b4f0b29a6c38fb741a54116e100da1ea2 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 21:17:09 +0200 Subject: [PATCH 46/86] simplify and orvalify lockingUtils mock data --- .../components/locking/lockingUtils.mocks.ts | 590 ++++++------------ 1 file changed, 208 insertions(+), 382 deletions(-) diff --git a/jsapp/js/components/locking/lockingUtils.mocks.ts b/jsapp/js/components/locking/lockingUtils.mocks.ts index 494a4847ef..b3e2a2f009 100644 --- a/jsapp/js/components/locking/lockingUtils.mocks.ts +++ b/jsapp/js/components/locking/lockingUtils.mocks.ts @@ -1,5 +1,6 @@ import cloneDeep from 'lodash.clonedeep' import merge from 'lodash.merge' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import { AssetTypeName, GroupTypeBeginName, @@ -11,28 +12,18 @@ import type { AssetResponse } from '#/dataInterface' import { LOCKING_PROFILE_PROP_NAME, LOCK_ALL_PROP_NAME, LockingRestrictionName } from './lockingConstants' /** - * This is a minimal response from asset endpoin. The idea is to make it up - * to date and extend in other test objects (rather than having those huge - * lengthy JSONs). + * This is a minimal response from asset endpoint. Uses Orval-generated factory + * for type safety and to ensure all required fields are present. */ -const minimalAssetResponse = { - url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/', - owner: 'http://kf.kobo.local/api/v2/users/zefir/', +const minimalAssetResponse = getApiV2AssetsRetrieveResponseMock({ + uid: 'aBcDe12345', + name: 'Test form', owner__username: 'zefir', - last_modified_by: null, - created_by: null, - parent: null, - settings: { - sector: { label: 'Other', value: 'Other' }, - country: [{ label: 'Sweden', value: 'SWE' }], - description: '', - collects_pii: null, - organization: '', - country_codes: ['SWE'], - operational_purpose: null, - }, asset_type: AssetTypeName.survey, - files: [], + deployment_status: 'deployed', + has_deployment: true, + deployment__active: true, + deployment__submission_count: 0, summary: { geo: false, labels: ['Your name'], @@ -56,69 +47,6 @@ const minimalAssetResponse = { }, default_translation: null, }, - date_created: '2024-12-27T13:34:55.637503Z', - date_modified: '2024-12-27T13:35:40.543334Z', - date_deployed: '2024-12-27T13:35:38.897089Z', - version_id: 'veUGfHFYgnfkX9uxo3FoJ6', - version__content_hash: '1685a50ec9695c20eafb17a1b5a0e8ce5946e33c', - version_count: 2, - has_deployment: true, - deployed_version_id: 'veUGfHFYgnfkX9uxo3FoJ6', - deployed_versions: { - count: 1, - next: null, - previous: null, - results: [ - { - uid: 'veUGfHFYgnfkX9uxo3FoJ6', - url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/versions/veUGfHFYgnfkX9uxo3FoJ6/', - content_hash: '1685a50ec9695c20eafb17a1b5a0e8ce5946e33c', - date_deployed: '2024-12-27T13:35:38.894580Z', - date_modified: '2024-12-27T13:35:38.894580Z', - }, - ], - }, - deployment__links: { - url: 'http://ee.kobo.local/bNOwZTAI', - single_url: 'http://ee.kobo.local/single/bNOwZTAI', - single_once_url: 'http://ee.kobo.local/single/451523a0f57ad42817198c8b2ae93dc3', - offline_url: 'http://ee.kobo.local/x/bNOwZTAI', - preview_url: 'http://ee.kobo.local/preview/bNOwZTAI', - iframe_url: 'http://ee.kobo.local/i/bNOwZTAI', - single_iframe_url: 'http://ee.kobo.local/single/i/bNOwZTAI', - single_once_iframe_url: 'http://ee.kobo.local/single/i/451523a0f57ad42817198c8b2ae93dc3', - }, - deployment__active: true, - deployment__data_download_links: { - xls_legacy: 'http://kc.kobo.local/zefir/exports/aBcDe12345/xls/', - csv_legacy: 'http://kc.kobo.local/zefir/exports/aBcDe12345/csv/', - zip_legacy: 'http://kc.kobo.local/zefir/exports/aBcDe12345/zip/', - kml_legacy: 'http://kc.kobo.local/zefir/exports/aBcDe12345/kml/', - geojson: 'http://kc.kobo.local/zefir/exports/aBcDe12345/geojson/', - spss_labels: 'http://kc.kobo.local/zefir/exports/aBcDe12345/spss/', - xls: 'http://kc.kobo.local/zefir/reports/aBcDe12345/export.xlsx', - csv: 'http://kc.kobo.local/zefir/reports/aBcDe12345/export.csv', - }, - deployment__submission_count: 0, - deployment_status: 'deployed', - report_styles: { - default: {}, - specified: { - end: {}, - px18z33: {}, - }, - kuid_names: { - end: '4s7wEq869', - px18z33: 'px18z33', - }, - }, - report_custom: {}, - advanced_features: {}, - analysis_form_json: { - additional_fields: [], - }, - map_styles: {}, - map_custom: {}, content: { schema: '1', survey: [ @@ -142,114 +70,7 @@ const minimalAssetResponse = { translated: ['label'], translations: [null], }, - downloads: [ - { format: 'xls', url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345.xls' }, - { format: 'xml', url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345.xml' }, - ], - embeds: [ - { format: 'xls', url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/xls/' }, - { format: 'xform', url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/xform/' }, - ], - xform_link: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/xform/', - hooks_link: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/hooks/', - tag_string: '', - uid: 'aBcDe12345', - kind: 'asset', - xls_link: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/xls/', - name: 'Test form', - assignable_permissions: [ - { url: 'http://kf.kobo.local/api/v2/permissions/view_asset/', label: 'View form' }, - { url: 'http://kf.kobo.local/api/v2/permissions/change_asset/', label: 'Edit form' }, - { url: 'http://kf.kobo.local/api/v2/permissions/manage_asset/', label: 'Manage project' }, - { url: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', label: 'Add submissions' }, - { url: 'http://kf.kobo.local/api/v2/permissions/view_submissions/', label: 'View submissions' }, - { - url: 'http://kf.kobo.local/api/v2/permissions/partial_submissions/', - label: { - default: 'Act on submissions only from specific users', - view_submissions: 'View submissions only from specific users', - change_submissions: 'Edit submissions only from specific users', - delete_submissions: 'Delete submissions only from specific users', - validate_submissions: 'Validate submissions only from specific users', - }, - }, - { url: 'http://kf.kobo.local/api/v2/permissions/change_submissions/', label: 'Edit submissions' }, - { url: 'http://kf.kobo.local/api/v2/permissions/delete_submissions/', label: 'Delete submissions' }, - { url: 'http://kf.kobo.local/api/v2/permissions/validate_submissions/', label: 'Validate submissions' }, - ], - permissions: [ - { - url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/permission-assignments/pVQvikEvyQYmQazbNxobN6/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/permission-assignments/pFuSpuH2DYWCpqXL6vQ94x/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/change_asset/', - label: 'Edit form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/permission-assignments/p48wUoqUifRyj8bJssDKJi/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/change_submissions/', - label: 'Edit submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/permission-assignments/ptUCvQdK5ghnoHT5WHF8AA/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/delete_submissions/', - label: 'Delete submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/permission-assignments/pUKmhnLN2UXpxsipebgieS/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/manage_asset/', - label: 'Manage project', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/permission-assignments/poeQAKvMyjWsQYxejuPKpM/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/validate_submissions/', - label: 'Validate submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/permission-assignments/pBBjGJRLfMAqdtFvZeNj52/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/view_asset/', - label: 'View form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/permission-assignments/p4koRMKP65jdVQuacNPuke/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/view_submissions/', - label: 'View submissions', - }, - ], - effective_permissions: [ - { codename: 'change_asset' }, - { codename: 'manage_asset' }, - { codename: 'view_submissions' }, - { codename: 'validate_submissions' }, - { codename: 'change_submissions' }, - { codename: 'delete_asset' }, - { codename: 'view_asset' }, - { codename: 'delete_submissions' }, - { codename: 'add_submissions' }, - ], - exports: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/exports/', - export_settings: [], - data: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/data/', - children: { count: 0 }, - subscribers_count: 0, - status: 'private', - access_types: null, - data_sharing: {}, - paired_data: 'http://kf.kobo.local/api/v2/assets/aBcDe12345/paired-data/', - project_ownership: null, - owner_label: 'Test Korp Inc', -} satisfies AssetResponse +}) as unknown as AssetResponse // need an asset with locking profiles included and used for rows @@ -258,97 +79,104 @@ const minimalAssetResponse = { */ export const simpleTemplate = { ...cloneDeep(minimalAssetResponse), - ...{ - asset_type: AssetTypeName.template, - name: 'Test template', - summary: { - geo: false, - labels: ['Best thing in the world?', 'Person', 'Your name', 'Your age'], - columns: ['type', 'label', 'required', 'select_from_list_name', 'name'], - languages: ['English (en)', 'Polski (pl)'], - row_count: 4, - default_translation: 'English (en)', + asset_type: AssetTypeName.template, + name: 'Test template', + summary: { + geo: false, + labels: ['Best thing in the world?', 'Person', 'Your name', 'Your age'], + columns: ['type', 'label', 'required', 'select_from_list_name', 'name'], + languages: ['English (en)', 'Polski (pl)'], + row_count: 4, + default_translation: 'English (en)', + lock_all: false, + lock_any: false, + name_quality: { + ok: 4, + bad: 0, + good: 0, + total: 4, + firsts: {}, }, - content: { - schema: '1', - survey: [ - { - name: 'start', - type: MetaQuestionTypeName.start, - $kuid: 'ZJRmskGCC', - $autoname: 'start', - }, - { - name: 'end', - type: MetaQuestionTypeName.end, - $kuid: 'JuoCtJWO5', - $autoname: 'end', - }, - { - type: QuestionTypeName.select_one, - $kuid: 'ri0lk77', - label: ['Best thing in the world?', 'Najlepsze na świecie?'], - required: false, - $autoname: 'Best_thing_in_the_world', - select_from_list_name: 'dp8iw04', - }, - { - name: 'person', - type: GroupTypeBeginName.begin_group, - $kuid: 'xl7sb31', - label: ['Person', 'Osoba'], - $autoname: 'person', - }, - { - type: QuestionTypeName.text, - $kuid: 'xw6go48', - label: ['Your name', 'Twoje imię'], - required: false, - $autoname: 'Your_name', - }, - { - type: QuestionTypeName.integer, - $kuid: 'wd3rh84', - label: ['Your age', 'Twój wiek'], - required: false, - $autoname: 'Your_age', - }, - { - type: GroupTypeEndName.end_group, - $kuid: '/xl7sb31', - }, - ], - choices: [ - { - name: 'peace', - $kuid: '7grWIZ8bE', - label: ['Peace', 'Pokój'], - list_name: 'dp8iw04', - $autovalue: 'peace', - }, - { - name: 'love', - $kuid: 'I4x3DFdQl', - label: ['Love', 'Miłość'], - list_name: 'dp8iw04', - $autovalue: 'love', - }, - { - name: 'understanding', - $kuid: 'klWY60huh', - label: ['Understanding', 'Zrozumienie'], - list_name: 'dp8iw04', - $autovalue: 'understanding', - }, - ], - settings: { - default_language: 'English (en)', + }, + content: { + schema: '1', + survey: [ + { + name: 'start', + type: MetaQuestionTypeName.start, + $kuid: 'ZJRmskGCC', + $autoname: 'start', + }, + { + name: 'end', + type: MetaQuestionTypeName.end, + $kuid: 'JuoCtJWO5', + $autoname: 'end', + }, + { + type: QuestionTypeName.select_one, + $kuid: 'ri0lk77', + label: ['Best thing in the world?', 'Najlepsze na świecie?'], + required: false, + $autoname: 'Best_thing_in_the_world', + select_from_list_name: 'dp8iw04', + }, + { + name: 'person', + type: GroupTypeBeginName.begin_group, + $kuid: 'xl7sb31', + label: ['Person', 'Osoba'], + $autoname: 'person', + }, + { + type: QuestionTypeName.text, + $kuid: 'xw6go48', + label: ['Your name', 'Twoje imię'], + required: false, + $autoname: 'Your_name', }, - translated: ['label'], - translations: ['English (en)', 'Polski (pl)'], + { + type: QuestionTypeName.integer, + $kuid: 'wd3rh84', + label: ['Your age', 'Twój wiek'], + required: false, + $autoname: 'Your_age', + }, + { + type: GroupTypeEndName.end_group, + $kuid: '/xl7sb31', + }, + ], + choices: [ + { + name: 'peace', + $kuid: '7grWIZ8bE', + label: ['Peace', 'Pokój'], + list_name: 'dp8iw04', + $autovalue: 'peace', + }, + { + name: 'love', + $kuid: 'I4x3DFdQl', + label: ['Love', 'Miłość'], + list_name: 'dp8iw04', + $autovalue: 'love', + }, + { + name: 'understanding', + $kuid: 'klWY60huh', + label: ['Understanding', 'Zrozumienie'], + list_name: 'dp8iw04', + $autovalue: 'understanding', + }, + ], + settings: { + default_language: 'English (en)', }, + translated: ['label'], + translations: ['English (en)', 'Polski (pl)'], }, -} satisfies AssetResponse +} /** * A template with few questions, a group and additional Polish labels. Some of @@ -357,115 +185,113 @@ export const simpleTemplate = { */ export const simpleTemplateLocked = { ...cloneDeep(simpleTemplate), - ...{ - name: 'Test locked template', - content: { - schema: '1', - survey: [ - { - name: 'start', - type: MetaQuestionTypeName.start, - $kuid: 'ZJRmskGCC', - $autoname: 'start', - }, - { - name: 'end', - type: MetaQuestionTypeName.end, - $kuid: 'JuoCtJWO5', - $autoname: 'end', - }, - { - type: QuestionTypeName.select_one, - $kuid: 'ri0lk77', - label: ['Best thing in the world?', 'Najlepsze na świecie?'], - required: false, - $autoname: 'Best_thing_in_the_world', - select_from_list_name: 'dp8iw04', - 'kobo--locking-profile': 'lock2', - }, - { - name: 'person', - type: GroupTypeBeginName.begin_group, - $kuid: 'xl7sb31', - label: ['Person', 'Osoba'], - $autoname: 'person', - 'kobo--locking-profile': 'lock2', - }, - { - type: QuestionTypeName.text, - $kuid: 'xw6go48', - label: ['Your name', 'Twoje imię'], - required: false, - $autoname: 'Your_name', - }, - { - type: QuestionTypeName.integer, - $kuid: 'wd3rh84', - label: ['Your age', 'Twój wiek'], - required: false, - $autoname: 'Your_age', - 'kobo--locking-profile': 'mycustomlock1', - }, - { - type: GroupTypeEndName.end_group, - $kuid: '/xl7sb31', - }, - ], - choices: [ - { - name: 'peace', - $kuid: '7grWIZ8bE', - label: ['Peace', 'Pokój'], - list_name: 'dp8iw04', - $autovalue: 'peace', - }, - { - name: 'love', - $kuid: 'I4x3DFdQl', - label: ['Love', 'Miłość'], - list_name: 'dp8iw04', - $autovalue: 'love', - }, - { - name: 'understanding', - $kuid: 'klWY60huh', - label: ['Understanding', 'Zrozumienie'], - list_name: 'dp8iw04', - $autovalue: 'understanding', - }, - ], - 'kobo--locking-profiles': [ - { - name: 'mycustomlock1', - restrictions: [ - LockingRestrictionName.choice_add, - LockingRestrictionName.choice_delete, - LockingRestrictionName.choice_label_edit, - LockingRestrictionName.question_settings_edit, - LockingRestrictionName.group_label_edit, - LockingRestrictionName.group_question_order_edit, - LockingRestrictionName.group_add, - LockingRestrictionName.question_order_edit, - ], - }, - { - name: 'lock2', - restrictions: [ - LockingRestrictionName.question_delete, - LockingRestrictionName.group_delete, - LockingRestrictionName.language_edit, - ], - }, - ], - settings: { - default_language: 'English (en)', + name: 'Test locked template', + content: { + schema: '1', + survey: [ + { + name: 'start', + type: MetaQuestionTypeName.start, + $kuid: 'ZJRmskGCC', + $autoname: 'start', + }, + { + name: 'end', + type: MetaQuestionTypeName.end, + $kuid: 'JuoCtJWO5', + $autoname: 'end', + }, + { + type: QuestionTypeName.select_one, + $kuid: 'ri0lk77', + label: ['Best thing in the world?', 'Najlepsze na świecie?'], + required: false, + $autoname: 'Best_thing_in_the_world', + select_from_list_name: 'dp8iw04', + 'kobo--locking-profile': 'lock2', + }, + { + name: 'person', + type: GroupTypeBeginName.begin_group, + $kuid: 'xl7sb31', + label: ['Person', 'Osoba'], + $autoname: 'person', + 'kobo--locking-profile': 'lock2', + }, + { + type: QuestionTypeName.text, + $kuid: 'xw6go48', + label: ['Your name', 'Twoje imię'], + required: false, + $autoname: 'Your_name', + }, + { + type: QuestionTypeName.integer, + $kuid: 'wd3rh84', + label: ['Your age', 'Twój wiek'], + required: false, + $autoname: 'Your_age', 'kobo--locking-profile': 'mycustomlock1', }, - translated: ['label'], - translations: ['English (en)', 'Polski (pl)'], + { + type: GroupTypeEndName.end_group, + $kuid: '/xl7sb31', + }, + ], + choices: [ + { + name: 'peace', + $kuid: '7grWIZ8bE', + label: ['Peace', 'Pokój'], + list_name: 'dp8iw04', + $autovalue: 'peace', + }, + { + name: 'love', + $kuid: 'I4x3DFdQl', + label: ['Love', 'Miłość'], + list_name: 'dp8iw04', + $autovalue: 'love', + }, + { + name: 'understanding', + $kuid: 'klWY60huh', + label: ['Understanding', 'Zrozumienie'], + list_name: 'dp8iw04', + $autovalue: 'understanding', + }, + ], + 'kobo--locking-profiles': [ + { + name: 'mycustomlock1', + restrictions: [ + LockingRestrictionName.choice_add, + LockingRestrictionName.choice_delete, + LockingRestrictionName.choice_label_edit, + LockingRestrictionName.question_settings_edit, + LockingRestrictionName.group_label_edit, + LockingRestrictionName.group_question_order_edit, + LockingRestrictionName.group_add, + LockingRestrictionName.question_order_edit, + ], + }, + { + name: 'lock2', + restrictions: [ + LockingRestrictionName.question_delete, + LockingRestrictionName.group_delete, + LockingRestrictionName.language_edit, + ], + }, + ], + settings: { + default_language: 'English (en)', + 'kobo--locking-profile': 'mycustomlock1', }, + translated: ['label'], + translations: ['English (en)', 'Polski (pl)'], }, -} satisfies AssetResponse +} /** A template with some locking profiles on rows, and a lock all property. */ export const simpleTemplateLockedWithAll = merge(cloneDeep(simpleTemplateLocked), { From e8bfc7503a96c1fd73b5730064fd053a50c82c1b Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 21:19:42 +0200 Subject: [PATCH 47/86] orvalify AttachmentActionsDropdown mocks --- .../AttachmentActionsDropdown.mocks.ts | 254 +----------------- 1 file changed, 9 insertions(+), 245 deletions(-) diff --git a/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts b/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts index e2ea1fc1c4..1b661cf4da 100644 --- a/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts +++ b/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts @@ -1,24 +1,16 @@ +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import { ANY_ROW_TYPE_NAMES, AssetTypeName } from '#/constants' import type { AssetResponse, SubmissionResponse } from '#/dataInterface' -export const assetWithImage: AssetResponse = { - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/', - owner: 'http://kf.kobo.local/api/v2/users/zefir/', +export const assetWithImage = getApiV2AssetsRetrieveResponseMock({ + uid: 'aALUCUEKcgKk28owQo3LrA', + name: 'Small image project', owner__username: 'zefir', - last_modified_by: null, - created_by: null, - parent: null, - settings: { - sector: {}, - country: [], - description: '', - collects_pii: null, - organization: '', - country_codes: [], - operational_purpose: null, - }, asset_type: AssetTypeName.survey, - files: [], + deployment_status: 'deployed', + has_deployment: true, + deployment__active: true, + deployment__submission_count: 1, summary: { geo: false, labels: ['Add a picture'], @@ -42,65 +34,6 @@ export const assetWithImage: AssetResponse = { }, default_translation: null, }, - date_created: '2025-03-13T11:21:07.647839Z', - date_modified: '2025-03-13T11:21:36.038403Z', - date_deployed: '2025-03-13T11:21:36.019801Z', - version_id: 'vXCTi4YUvJ8FuwgcdDMDki', - version__content_hash: '82fcae2bf3933d231b963d6ef4dd37f853475ab5', - version_count: 2, - has_deployment: true, - deployed_version_id: 'vXCTi4YUvJ8FuwgcdDMDki', - deployed_versions: { - count: 1, - next: null, - previous: null, - results: [ - { - uid: 'vXCTi4YUvJ8FuwgcdDMDki', - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/versions/vXCTi4YUvJ8FuwgcdDMDki/', - content_hash: '82fcae2bf3933d231b963d6ef4dd37f853475ab5', - date_deployed: '2025-03-13T11:21:36.016537Z', - date_modified: '2025-03-13T11:21:36.016537Z', - }, - ], - }, - deployment__links: { - url: 'http://ee.kobo.local/X63UWDPC', - single_url: 'http://ee.kobo.local/single/X63UWDPC', - single_once_url: 'http://ee.kobo.local/single/1b7edd93e9e4c47629868c8a8163a308', - offline_url: 'http://ee.kobo.local/x/X63UWDPC', - preview_url: 'http://ee.kobo.local/preview/X63UWDPC', - iframe_url: 'http://ee.kobo.local/i/X63UWDPC', - single_iframe_url: 'http://ee.kobo.local/single/i/X63UWDPC', - single_once_iframe_url: 'http://ee.kobo.local/single/i/1b7edd93e9e4c47629868c8a8163a308', - }, - deployment__active: true, - deployment__data_download_links: { - csv_legacy: 'http://kc.kobo.local/zefir/exports/aALUCUEKcgKk28owQo3LrA/csv/', - csv: 'http://kc.kobo.local/zefir/reports/aALUCUEKcgKk28owQo3LrA/export.csv', - kml_legacy: 'http://kc.kobo.local/zefir/exports/aALUCUEKcgKk28owQo3LrA/kml/', - xls_legacy: 'http://kc.kobo.local/zefir/exports/aALUCUEKcgKk28owQo3LrA/xls/', - xls: 'http://kc.kobo.local/zefir/reports/aALUCUEKcgKk28owQo3LrA/export.xlsx', - zip_legacy: 'http://kc.kobo.local/zefir/exports/aALUCUEKcgKk28owQo3LrA/zip/', - }, - deployment__submission_count: 1, - deployment_status: 'deployed', - report_styles: { - default: {}, - specified: { - gd0wv19: {}, - }, - kuid_names: { - gd0wv19: 'gd0wv19', - }, - }, - report_custom: {}, - advanced_features: {}, - analysis_form_json: { - additional_fields: [], - }, - map_styles: {}, - map_custom: {}, content: { schema: '1', survey: [ @@ -117,176 +50,7 @@ export const assetWithImage: AssetResponse = { translated: ['label'], translations: [null], }, - downloads: [ - { - format: 'xls', - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA.xls', - }, - { - format: 'xml', - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA.xml', - }, - ], - embeds: [ - { - format: 'xls', - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/xls/', - }, - { - format: 'xform', - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/xform/', - }, - ], - xform_link: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/xform/', - hooks_link: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/hooks/', - tag_string: '', - uid: 'aALUCUEKcgKk28owQo3LrA', - kind: 'asset', - xls_link: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/xls/', - name: 'Small image project', - assignable_permissions: [ - { - url: 'http://kf.kobo.local/api/v2/permissions/view_asset/', - label: 'View form', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/change_asset/', - label: 'Edit form', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/manage_asset/', - label: 'Manage project', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/view_submissions/', - label: 'View submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/partial_submissions/', - label: { - default: 'Act on submissions only from specific users', - view_submissions: 'View submissions only from specific users', - change_submissions: 'Edit submissions only from specific users', - delete_submissions: 'Delete submissions only from specific users', - validate_submissions: 'Validate submissions only from specific users', - }, - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/change_submissions/', - label: 'Edit submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/delete_submissions/', - label: 'Delete submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/permissions/validate_submissions/', - label: 'Validate submissions', - }, - ], - permissions: [ - { - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/permission-assignments/pcAumEGxWPumiRiotggxP8/', - user: 'http://kf.kobo.local/api/v2/users/AnonymousUser/', - permission: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/permission-assignments/ppN82KMksMFmUBJiqZRpUj/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/add_submissions/', - label: 'Add submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/permission-assignments/phSpaAPcqEaTWCCXZpcVVi/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/change_asset/', - label: 'Edit form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/permission-assignments/pTGqsL9eQLgAcbQHKvBvvt/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/change_submissions/', - label: 'Edit submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/permission-assignments/p458sk4MGkRtvfSGf3yWYi/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/delete_submissions/', - label: 'Delete submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/permission-assignments/pqgKoy64qwztzVfSmg4hfV/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/manage_asset/', - label: 'Manage project', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/permission-assignments/pyKd6Zp7BAmCAmLE9FySJK/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/validate_submissions/', - label: 'Validate submissions', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/permission-assignments/pR2nuq5oJVscaUvDdm5o5c/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/view_asset/', - label: 'View form', - }, - { - url: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/permission-assignments/pqhwwj6WKLvE4Sxi8EXmxW/', - user: 'http://kf.kobo.local/api/v2/users/zefir/', - permission: 'http://kf.kobo.local/api/v2/permissions/view_submissions/', - label: 'View submissions', - }, - ], - effective_permissions: [ - { - codename: 'change_asset', - }, - { - codename: 'change_submissions', - }, - { - codename: 'delete_submissions', - }, - { - codename: 'view_submissions', - }, - { - codename: 'manage_asset', - }, - { - codename: 'view_asset', - }, - { - codename: 'delete_asset', - }, - { - codename: 'validate_submissions', - }, - { - codename: 'add_submissions', - }, - ], - exports: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/exports/', - export_settings: [], - data: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/data/', - children: { - count: 0, - }, - subscribers_count: 0, - status: 'shared', - access_types: null, - data_sharing: {}, - paired_data: 'http://kf.kobo.local/api/v2/assets/aALUCUEKcgKk28owQo3LrA/paired-data/', - project_ownership: null, - owner_label: 'Test Korp Inc', -} +}) as unknown as AssetResponse export const assetWithImageSubmission: SubmissionResponse = { _id: 67, From 23af0b5b7c714179c9e3070f9e9b97665713c488 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 21:24:20 +0200 Subject: [PATCH 48/86] fix more errors --- jsapp/js/assetUtils.ts | 4 +--- .../components/AssetTagsModal/AssetTagsModal.stories.tsx | 2 +- jsapp/js/components/modalForms/LibraryAssetForm.tsx | 7 ++----- jsapp/js/components/reports/reports.utils.tests.ts | 3 ++- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/jsapp/js/assetUtils.ts b/jsapp/js/assetUtils.ts index 7ed3b3352f..86f700b1b0 100644 --- a/jsapp/js/assetUtils.ts +++ b/jsapp/js/assetUtils.ts @@ -154,13 +154,11 @@ export function getCountryDisplayString(asset: AssetResponse | ProjectViewAsset) * and then switching to french would result in seeing spanish labels) */ const countries = [] - // https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#working-with-union-types + // Backend always returns country as an array (or null/undefined) if (Array.isArray(asset.settings.country)) { for (const country of asset.settings.country) { countries.push(envStore.getCountryLabel(country.value)) } - } else { - countries.push(envStore.getCountryLabel(asset.settings.country.value)) } if (countries.length === 0) { diff --git a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx index 24533000ba..32a5b39c52 100644 --- a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx +++ b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx @@ -16,7 +16,7 @@ const mockAsset = getApiV2AssetsRetrieveResponseMock({ uid: 'storyAssetTagsUid', name: 'Storybook Asset Tags', tag_string: 'alpha,beta', -}) +}) as unknown as AssetResponse const mockAssetUid = mockAsset.uid const onAssetPatched = fn() diff --git a/jsapp/js/components/modalForms/LibraryAssetForm.tsx b/jsapp/js/components/modalForms/LibraryAssetForm.tsx index e962c929b6..b599251437 100644 --- a/jsapp/js/components/modalForms/LibraryAssetForm.tsx +++ b/jsapp/js/components/modalForms/LibraryAssetForm.tsx @@ -162,11 +162,8 @@ export const LibraryAssetForm = ({ asset, assetType, onSetModalTitle: _onSetModa return [] } - if (Array.isArray(value)) { - return value.map((item) => item.value) - } - - return [value.value] + // Backend always returns country as an array + return value.map((item) => item.value) } const fromSingleSelectValue = (newValue: string | null, option?: LabelValuePair): LabelValuePair | null => { diff --git a/jsapp/js/components/reports/reports.utils.tests.ts b/jsapp/js/components/reports/reports.utils.tests.ts index 690ae9348c..6b7f97864b 100644 --- a/jsapp/js/components/reports/reports.utils.tests.ts +++ b/jsapp/js/components/reports/reports.utils.tests.ts @@ -1,6 +1,7 @@ import chai from 'chai' import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import { QuestionTypeName } from '#/constants' +import type { AssetResponse } from '#/dataInterface' import { reportStyleFactory, reportsResponseDataFactory } from './reports.factory' import { buildEffectiveReportStyle, getEffectiveRowReportStyle, populateSelectQuestionLabels } from './reports.utils' import type { ReportsResponse } from './reportsConstants' @@ -163,7 +164,7 @@ describe('populateSelectQuestionLabels', () => { }, ], }, - }) + }) as unknown as AssetResponse populateSelectQuestionLabels(row, asset, 1) From 5ed8cd02075cac68d06dc563419e3092137582dd Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 21:58:33 +0200 Subject: [PATCH 49/86] fix orval mock generated code --- jsapp/js/api/react-query/survey-data.ts | 4 +- orval.config.js | 5 +- .../orval-fix-mock-factory-type-assertions.js | 125 ++++++++++++++++++ 3 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 scripts/orval-fix-mock-factory-type-assertions.js diff --git a/jsapp/js/api/react-query/survey-data.ts b/jsapp/js/api/react-query/survey-data.ts index ecd8a9b5d8..c30c29a32f 100644 --- a/jsapp/js/api/react-query/survey-data.ts +++ b/jsapp/js/api/react-query/survey-data.ts @@ -7664,11 +7664,11 @@ export const getApiV2AssetsDataValidationStatusPartialUpdateResponseMock = ( export const getApiV2AssetsDataSupplementRetrieveResponseMock = ( overrideResponse: Partial = {}, -): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) +): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) as DataSupplementResponse export const getApiV2AssetsDataSupplementPartialUpdateResponseMock = ( overrideResponse: Partial = {}, -): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) +): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) as DataSupplementResponse export const getApiV2AssetsDataBulkPartialUpdateResponseMock = ( overrideResponse: Partial = {}, diff --git a/orval.config.js b/orval.config.js index fb20059f35..9e65dfdfbc 100644 --- a/orval.config.js +++ b/orval.config.js @@ -47,8 +47,9 @@ module.exports = { hooks: { // Orval has a bug that fails to generate imports for $ref in additionalProperties. // See https://github.com/orval-labs/orval/issues/1077. - // This is a workaround. Remove it once the underlying bug is fixed. - afterAllFilesWrite: 'node scripts/orval-fix-referenced-additional-properties.js', + // Also fix TypeScript errors in MSW mock factories for types with index signatures. + afterAllFilesWrite: + 'node scripts/orval-fix-referenced-additional-properties.js && node scripts/orval-fix-mock-factory-type-assertions.js', }, }, } diff --git a/scripts/orval-fix-mock-factory-type-assertions.js b/scripts/orval-fix-mock-factory-type-assertions.js new file mode 100644 index 0000000000..c9ad330e3f --- /dev/null +++ b/scripts/orval-fix-mock-factory-type-assertions.js @@ -0,0 +1,125 @@ +/* eslint-disable no-console */ +/** + * Fixes TypeScript errors in MSW mock factories. + * + * The problem: Types like { _version: string } & Record + * tell TypeScript that _version has to be both a string AND SomeOtherType. + * That doesn't work, so mock factories that return { _version: "..." } fail to compile. + * + * The fix: Cast the return value with `as TypeName`. Safe because these are test mocks + * and the structure is fine at runtime. + * + * Types we fix: + * - DataSupplementResponse (& Record) + * - PatchedDataSupplementPayload (| Record) + */ +const fs = require('fs') +const path = require('path') + +const ROOT = process.cwd() +const MODELS_DIR = path.join(ROOT, 'jsapp/js/api/models') +const REACT_QUERY_DIR = path.join(ROOT, 'jsapp/js/api/react-query') + +// Types that need fixing +const TYPE_FILES = { + 'dataSupplementResponse.ts': { + typeName: 'DataSupplementResponse', + factoryFile: 'survey-data.ts', + }, + 'patchedDataSupplementPayload.ts': { + typeName: 'PatchedDataSupplementPayload', + factoryFile: 'survey-data.ts', + }, +} + +function detectTypeWithVersionAndRecord(source) { + // Look for patterns like: + // export type SomeName = { _version: ... } & Record<...> + // These might span multiple lines + + if (!source.includes('export type')) return null + if (!source.includes('_version')) return null + if (!source.includes('Record<')) return null + + // Find the line with "export type" + const lines = source.split('\n') + for (let i = 0; i < lines.length; i++) { + const line = lines[i] + if (!line.includes('export type')) continue + + // Extract type name: "export type DataSupplementResponse = {" + const afterExport = line.split('export type')[1] + if (!afterExport) continue + + const typeName = afterExport.split('=')[0].trim() + if (typeName) return typeName + } + + return null +} + +let totalFixed = 0 + +for (const [modelFile, config] of Object.entries(TYPE_FILES)) { + const modelPath = path.join(MODELS_DIR, modelFile) + if (!fs.existsSync(modelPath)) { + console.log(`⊘ Skipped ${modelFile} (file not found)`) + continue + } + + const modelSource = fs.readFileSync(modelPath, 'utf8') + const detectedType = detectTypeWithVersionAndRecord(modelSource) + + if (!detectedType) { + console.log(`⊘ Skipped ${modelFile} (no problematic type pattern found)`) + continue + } + + if (detectedType !== config.typeName) { + console.log(`⚠ Warning: Expected type ${config.typeName} but found ${detectedType} in ${modelFile}`) + } + + // Now fix the mock factories + const factoryPath = path.join(REACT_QUERY_DIR, config.factoryFile) + if (!fs.existsSync(factoryPath)) { + console.log(`⊘ Skipped ${config.factoryFile} (file not found)`) + continue + } + + let factorySource = fs.readFileSync(factoryPath, 'utf8') + + // Find factories that return this type and add `as TypeName` if missing + // Turns: ): TypeName => ({ _version: ..., ...overrideResponse }) + // Into: ): TypeName => ({ _version: ..., ...overrideResponse }) as TypeName + const lines = factorySource.split('\n') + let fixCount = 0 + + for (let i = 0; i < lines.length; i++) { + const line = lines[i] + + // Skip lines that don't look like factory returns + if (!line.includes(`): ${config.typeName} =>`)) continue + if (!line.includes('_version:')) continue + if (!line.includes('...override')) continue + + // Skip if already has the type assertion + if (line.includes(` as ${config.typeName}`)) continue + + // Add the type assertion before the closing parenthesis at the end + lines[i] = line.replace(/\)\s*$/, `) as ${config.typeName}`) + fixCount++ + } + + if (fixCount > 0) { + const patchedFactory = lines.join('\n') + fs.writeFileSync(factoryPath, patchedFactory, 'utf8') + console.log(`✔ Fixed ${fixCount} mock factories for ${config.typeName} in ${config.factoryFile}`) + totalFixed += fixCount + } else { + console.log(`⊙ No fixes needed for ${config.typeName} in ${config.factoryFile}`) + } +} + +if (totalFixed > 0) { + console.log(`\n✨ Total: Fixed ${totalFixed} mock factory type assertions`) +} From 75538300cc16d432301bf9fb47ae0f4b353119e8 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 22:13:25 +0200 Subject: [PATCH 50/86] fix errors in msw mocks --- jsapp/js/api/react-query/survey-data.ts | 24 ++++++++++++------------ kpi/utils/schema_extensions/mixins.py | 4 ++++ static/openapi/schema_v2.json | 20 ++++++++++++++++---- static/openapi/schema_v2.yaml | 8 ++++++++ 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/jsapp/js/api/react-query/survey-data.ts b/jsapp/js/api/react-query/survey-data.ts index c30c29a32f..9bc5dd4bd8 100644 --- a/jsapp/js/api/react-query/survey-data.ts +++ b/jsapp/js/api/react-query/survey-data.ts @@ -6633,7 +6633,7 @@ export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock }) export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataIntegerResponse => ({ ...faker.helpers.arrayElement([ { @@ -6650,7 +6650,7 @@ export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntege }) export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataTextResponse => ({ ...faker.helpers.arrayElement([ { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, @@ -6660,7 +6660,7 @@ export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextRe }) export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataSelectOneResponse => ({ ...faker.helpers.arrayElement([ { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, @@ -6670,7 +6670,7 @@ export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelect }) export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ ...faker.helpers.arrayElement([ { @@ -6997,7 +6997,7 @@ export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsM }) export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataIntegerResponse => ({ ...faker.helpers.arrayElement([ { @@ -7014,7 +7014,7 @@ export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIn }) export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataTextResponse => ({ ...faker.helpers.arrayElement([ { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, @@ -7024,7 +7024,7 @@ export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTe }) export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataSelectOneResponse => ({ ...faker.helpers.arrayElement([ { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, @@ -7034,7 +7034,7 @@ export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSe }) export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ ...faker.helpers.arrayElement([ { @@ -7351,7 +7351,7 @@ export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDa }) export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataIntegerResponse => ({ ...faker.helpers.arrayElement([ { @@ -7368,7 +7368,7 @@ export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQua }) export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataTextResponse => ({ ...faker.helpers.arrayElement([ { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, @@ -7378,7 +7378,7 @@ export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQua }) export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataSelectOneResponse => ({ ...faker.helpers.arrayElement([ { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, @@ -7388,7 +7388,7 @@ export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQua }) export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( - overrideResponse: Partial = {}, + overrideResponse: Omit, 'status'> = {}, ): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ ...faker.helpers.arrayElement([ { diff --git a/kpi/utils/schema_extensions/mixins.py b/kpi/utils/schema_extensions/mixins.py index be297e58b6..ef57d21e72 100644 --- a/kpi/utils/schema_extensions/mixins.py +++ b/kpi/utils/schema_extensions/mixins.py @@ -112,6 +112,10 @@ def _register_qual_data_schema_components(self, auto_schema): required=['status', 'error', 'uuid'], ), ], + # Tell code generators that 'status' discriminates between the oneOf branches + 'discriminator': { + 'propertyName': 'status', + }, } references[f'automatic_qual_{q_type}'] = ( diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 367dc20f00..6d81284ecc 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -24667,7 +24667,10 @@ "uuid" ] } - ] + ], + "discriminator": { + "propertyName": "status" + } }, "DataSupplementAutomaticQualDataSelectMultipleResponse": { "type": "object", @@ -24721,7 +24724,10 @@ "uuid" ] } - ] + ], + "discriminator": { + "propertyName": "status" + } }, "DataSupplementAutomaticQualDataSelectOneResponse": { "type": "object", @@ -24772,7 +24778,10 @@ "uuid" ] } - ] + ], + "discriminator": { + "propertyName": "status" + } }, "DataSupplementAutomaticQualDataTextResponse": { "type": "object", @@ -24822,7 +24831,10 @@ "uuid" ] } - ] + ], + "discriminator": { + "propertyName": "status" + } }, "DataSupplementManualQualDataInteger": { "type": "object", diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index e06850adf2..f34943ed0b 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -17614,6 +17614,8 @@ components: - error - status - uuid + discriminator: + propertyName: status DataSupplementAutomaticQualDataSelectMultipleResponse: type: object additionalProperties: false @@ -17651,6 +17653,8 @@ components: - error - status - uuid + discriminator: + propertyName: status DataSupplementAutomaticQualDataSelectOneResponse: type: object additionalProperties: false @@ -17686,6 +17690,8 @@ components: - error - status - uuid + discriminator: + propertyName: status DataSupplementAutomaticQualDataTextResponse: type: object additionalProperties: false @@ -17720,6 +17726,8 @@ components: - error - status - uuid + discriminator: + propertyName: status DataSupplementManualQualDataInteger: type: object additionalProperties: false From a0259b6b38c217f35b5c5ac9d8cf49123a8b01cb Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 22:29:03 +0200 Subject: [PATCH 51/86] almost final fixes --- jsapp/js/api/react-query/survey-data.ts | 6 ++++-- kpi/schema_extensions/v2/assets/extensions.py | 3 +++ orval.config.js | 6 ++++-- scripts/orval-fix-referenced-additional-properties.js | 5 ++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/jsapp/js/api/react-query/survey-data.ts b/jsapp/js/api/react-query/survey-data.ts index 9bc5dd4bd8..7ba785e53b 100644 --- a/jsapp/js/api/react-query/survey-data.ts +++ b/jsapp/js/api/react-query/survey-data.ts @@ -7664,11 +7664,13 @@ export const getApiV2AssetsDataValidationStatusPartialUpdateResponseMock = ( export const getApiV2AssetsDataSupplementRetrieveResponseMock = ( overrideResponse: Partial = {}, -): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) as DataSupplementResponse +): DataSupplementResponse => + ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) as DataSupplementResponse export const getApiV2AssetsDataSupplementPartialUpdateResponseMock = ( overrideResponse: Partial = {}, -): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) as DataSupplementResponse +): DataSupplementResponse => + ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) as DataSupplementResponse export const getApiV2AssetsDataBulkPartialUpdateResponseMock = ( overrideResponse: Partial = {}, diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 6b2b5ad909..ca7f8f4d25 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -307,6 +307,9 @@ class ContentFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.ContentField' def map_serializer_field(self, auto_schema, direction): + # WriteableJsonWithSchemaField accepts JSON string for writes, returns object for reads + if direction == 'request': + return build_basic_type(OpenApiTypes.STR) return ASSET_CONTENT_SCHEMA diff --git a/orval.config.js b/orval.config.js index 9e65dfdfbc..21593b4c4d 100644 --- a/orval.config.js +++ b/orval.config.js @@ -48,8 +48,10 @@ module.exports = { // Orval has a bug that fails to generate imports for $ref in additionalProperties. // See https://github.com/orval-labs/orval/issues/1077. // Also fix TypeScript errors in MSW mock factories for types with index signatures. - afterAllFilesWrite: - 'node scripts/orval-fix-referenced-additional-properties.js && node scripts/orval-fix-mock-factory-type-assertions.js', + afterAllFilesWrite: [ + 'node scripts/orval-fix-referenced-additional-properties.js', + 'node scripts/orval-fix-mock-factory-type-assertions.js', + ], }, }, } diff --git a/scripts/orval-fix-referenced-additional-properties.js b/scripts/orval-fix-referenced-additional-properties.js index 93d4ab4ddd..56a1b467fc 100644 --- a/scripts/orval-fix-referenced-additional-properties.js +++ b/scripts/orval-fix-referenced-additional-properties.js @@ -64,7 +64,10 @@ for (const file of FILES) { const source = fs.readFileSync(filePath, 'utf8') const detected = detectInterfaceWithIndex(source) - if (!fs.existsSync(filePath)) throw new Error(`File ${file} doesn't have an interface within`) + if (!detected) { + // File already processed (converted from interface to type) + continue + } const { name, versionType, valueType, interfaceBlock } = detected From a4d6d12ea927a835f6a769c8ce9d27530358012b Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 6 Jul 2026 22:48:02 +0200 Subject: [PATCH 52/86] last error fix --- .../js/project/FormLanguagesManager/FormLanguagesManager.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx index c72a64c5fd..00475c3c87 100644 --- a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx +++ b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx @@ -5,6 +5,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query' import cloneDeep from 'lodash.clonedeep' import type { PaginatedListResponse } from '#/UniversalTable' import { assetsPartialUpdate } from '#/api/react-query/manage-projects-and-library-content' +import type { PatchedAssetPatchRequestOneOfContent } from '#/api/models/patchedAssetPatchRequestOneOfContent' import ButtonNew from '#/components/common/ButtonNew' import ModalNew from '#/components/common/ModalNew' import LoadingSpinner from '#/components/common/loadingSpinner' @@ -117,7 +118,8 @@ export default function FormLanguagesManager(props: FormLanguagesManagerProps) { try { const response = await assetsPartialUpdate(asset.uid, { name: asset.name, - content: JSON.stringify(content), + // Backend accepts JSON string for content field in PATCH requests + content: JSON.stringify(content) as unknown as PatchedAssetPatchRequestOneOfContent, }) if (response.status === 200) { From 7a9cc19627dafd56ba119c28ac493347684ae704 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 00:28:09 +0200 Subject: [PATCH 53/86] fix unit tests --- jsapp/jest/setupUnitTest.ts | 12 ++++++++++++ jsapp/jest/unit.config.ts | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/jsapp/jest/setupUnitTest.ts b/jsapp/jest/setupUnitTest.ts index 2eef8a8d3e..101c7c46df 100644 --- a/jsapp/jest/setupUnitTest.ts +++ b/jsapp/jest/setupUnitTest.ts @@ -9,6 +9,18 @@ import $ from 'jquery' Object.defineProperty(globalThis, 'TextEncoder', { value: TextEncoder, configurable: true }) Object.defineProperty(globalThis, 'TextDecoder', { value: TextDecoder, configurable: true }) +// MSW needs BroadcastChannel for WebSocket mocking +if (typeof globalThis.BroadcastChannel === 'undefined') { + // @ts-expect-error: Minimal polyfill for test environment + globalThis.BroadcastChannel = class BroadcastChannel { + constructor(public name: string) {} + postMessage() {} + close() {} + addEventListener() {} + removeEventListener() {} + } +} + // Add global t() mock (see /static/js/global_t.js) global.t = (str: string) => str diff --git a/jsapp/jest/unit.config.ts b/jsapp/jest/unit.config.ts index f71421fca5..e9049c5112 100644 --- a/jsapp/jest/unit.config.ts +++ b/jsapp/jest/unit.config.ts @@ -41,6 +41,11 @@ const config: Config = { ...defaults.testPathIgnorePatterns, // 📦 exclude '/node_modules/' ], + // Transform ESM modules from node_modules (MSW and its dependencies) + transformIgnorePatterns: [ + 'node_modules/(?!(msw|@mswjs|@bundled-es-modules|statuses|until-async)/)', + ], + // Set up test environment testEnvironment: 'jsdom', From 90d026219eb44d6749f3ebe5908bc4d79270e0da Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 10:47:51 +0200 Subject: [PATCH 54/86] fix tests --- .../account/DeleteAccountBanner.stories.tsx | 13 +- .../authentication-allauth-headless.ts | 80 +------ jsapp/js/api/react-query/configuration.ts | 5 +- jsapp/js/api/react-query/form-content.ts | 35 +-- .../js/api/react-query/library-collections.ts | 14 +- jsapp/js/api/react-query/logging.ts | 20 +- .../js/api/react-query/manage-permissions.ts | 23 +- .../manage-projects-and-library-content.ts | 86 +++---- jsapp/js/api/react-query/other.ts | 50 ++-- jsapp/js/api/react-query/scim.ts | 17 +- .../api/react-query/server-logs-superusers.ts | 26 +-- .../react-query/survey-data-rest-services.ts | 29 +-- jsapp/js/api/react-query/survey-data.ts | 167 +++++--------- .../user-team-organization-usage.ts | 113 +++------ .../components/map/FormMapWrapper.stories.tsx | 2 + .../submissions/DataTableWrapper.stories.tsx | 53 +---- .../DataTableWrapperPollingStoriesUtils.tsx | 217 ------------------ jsapp/js/endpoints/formMedia.mocks.ts | 8 +- .../project/FormMedia/FormMedia.stories.tsx | 1 + orval.config.js | 3 + scripts/orval-make-trailing-slash-optional.js | 50 ++++ scripts/orval-remove-mock-delays.js | 68 ++++++ 22 files changed, 334 insertions(+), 746 deletions(-) delete mode 100644 jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx create mode 100644 scripts/orval-make-trailing-slash-optional.js create mode 100644 scripts/orval-remove-mock-delays.js diff --git a/jsapp/js/account/DeleteAccountBanner.stories.tsx b/jsapp/js/account/DeleteAccountBanner.stories.tsx index f06f16847f..f3ebf7bdf7 100644 --- a/jsapp/js/account/DeleteAccountBanner.stories.tsx +++ b/jsapp/js/account/DeleteAccountBanner.stories.tsx @@ -13,10 +13,7 @@ const meta: Meta = { argTypes: {}, parameters: { msw: { - handlers: { - organization: organizationMock(), - assets: assetsMock(), - }, + handlers: [organizationMock(), assetsMock()], }, a11y: { test: 'todo' }, }, @@ -61,9 +58,7 @@ export const UserHasAssets: Story = { export const UserHasNoAssets: Story = { parameters: { msw: { - handlers: { - assets: assetsMock({ count: 0 }), - }, + handlers: [organizationMock(), assetsMock({ count: 0 })], }, }, play: async ({ canvasElement }) => { @@ -80,9 +75,7 @@ export const UserHasNoAssets: Story = { export const UserOwnsMMO: Story = { parameters: { msw: { - handlers: { - organization: organizationMock({ is_mmo: true }), - }, + handlers: [organizationMock({ is_mmo: true }), assetsMock()], }, }, play: async ({ canvasElement }) => { diff --git a/jsapp/js/api/react-query/authentication-allauth-headless.ts b/jsapp/js/api/react-query/authentication-allauth-headless.ts index dbbaef1a24..3b22dc3321 100644 --- a/jsapp/js/api/react-query/authentication-allauth-headless.ts +++ b/jsapp/js/api/react-query/authentication-allauth-headless.ts @@ -85,7 +85,7 @@ import type { VerifyPhoneBody } from '../models/verifyPhoneBody' import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import type { AuthenticatedByCodeResponse } from '../models/authenticatedByCodeResponse' @@ -10594,7 +10594,6 @@ export const getApiV2AllauthBrowserV1ConfigGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/config', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10615,7 +10614,6 @@ export const getApiV2AllauthAppV1ConfigGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), ) => { return http.get('*/api/v2/allauth/app/v1/config', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10638,7 +10636,6 @@ export const getApiV2AllauthBrowserV1AuthLoginPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/login', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10661,7 +10658,6 @@ export const getApiV2AllauthAppV1AuthLoginPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/login', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10684,7 +10680,6 @@ export const getApiV2AllauthBrowserV1AuthSignupPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/signup', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10707,7 +10702,6 @@ export const getApiV2AllauthAppV1AuthSignupPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/signup', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10730,7 +10724,6 @@ export const getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler = ( ) => Promise | EmailVerificationInfoResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10753,7 +10746,6 @@ export const getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10776,7 +10768,6 @@ export const getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler = ( ) => Promise | EmailVerificationInfoResponse), ) => { return http.get('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10799,7 +10790,6 @@ export const getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10820,7 +10810,6 @@ export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/email/verify/resend', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10841,7 +10830,6 @@ export const getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/email/verify/resend', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10864,7 +10852,6 @@ export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10887,7 +10874,6 @@ export const getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/phone/verify', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10908,7 +10894,6 @@ export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify/resend', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10929,7 +10914,6 @@ export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/phone/verify/resend', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10952,7 +10936,6 @@ export const getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/reauthenticate', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10975,7 +10958,6 @@ export const getApiV2AllauthAppV1AuthReauthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/reauthenticate', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -10996,7 +10978,6 @@ export const getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/password/request', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11017,7 +10998,6 @@ export const getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/password/request', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11040,7 +11020,6 @@ export const getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler = ( ) => Promise | PasswordResetInfoResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11063,7 +11042,6 @@ export const getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11086,7 +11064,6 @@ export const getApiV2AllauthAppV1AuthPasswordResetGetMockHandler = ( ) => Promise | PasswordResetInfoResponse), ) => { return http.get('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11109,7 +11086,6 @@ export const getApiV2AllauthAppV1AuthPasswordResetPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11128,7 +11104,6 @@ export const getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler = ( overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/provider/redirect', async (info) => { - await delay(1000) if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -11144,7 +11119,6 @@ export const getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/provider/token', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11167,7 +11141,6 @@ export const getApiV2AllauthAppV1AuthProviderTokenPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/provider/token', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11190,7 +11163,6 @@ export const getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler = ( ) => Promise | ProviderSignupResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11213,7 +11185,6 @@ export const getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11236,7 +11207,6 @@ export const getApiV2AllauthAppV1AuthProviderSignupGetMockHandler = ( ) => Promise | ProviderSignupResponse), ) => { return http.get('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11259,7 +11229,6 @@ export const getApiV2AllauthAppV1AuthProviderSignupPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11282,7 +11251,6 @@ export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordAnd2FAResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/2fa/authenticate', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11305,7 +11273,6 @@ export const getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordAnd2FAResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/2fa/authenticate', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11328,7 +11295,6 @@ export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordAnd2FAResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/2fa/reauthenticate', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11351,7 +11317,6 @@ export const getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordAnd2FAResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/2fa/reauthenticate', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11374,7 +11339,6 @@ export const getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler = ( ) => Promise | AuthenticatedByCodeResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/code/confirm', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11397,7 +11361,6 @@ export const getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler = ( ) => Promise | AuthenticatedByCodeResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/code/confirm', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11420,7 +11383,6 @@ export const getApiV2AllauthBrowserV1AccountProvidersGetMockHandler = ( ) => Promise | ProviderAccountsResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/providers', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11443,7 +11405,6 @@ export const getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler = ( ) => Promise | ProviderAccountsResponse), ) => { return http.delete('*/api/v2/allauth/browser/v1/account/providers', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11466,7 +11427,6 @@ export const getApiV2AllauthAppV1AccountProvidersGetMockHandler = ( ) => Promise | ProviderAccountsResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/providers', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11489,7 +11449,6 @@ export const getApiV2AllauthAppV1AccountProvidersDeleteMockHandler = ( ) => Promise | ProviderAccountsResponse), ) => { return http.delete('*/api/v2/allauth/app/v1/account/providers', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11512,7 +11471,6 @@ export const getApiV2AllauthBrowserV1AccountEmailGetMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/email', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11535,7 +11493,6 @@ export const getApiV2AllauthBrowserV1AccountEmailPostMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/account/email', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11556,7 +11513,6 @@ export const getApiV2AllauthBrowserV1AccountEmailPutMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.put('*/api/v2/allauth/browser/v1/account/email', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11579,7 +11535,6 @@ export const getApiV2AllauthBrowserV1AccountEmailPatchMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.patch('*/api/v2/allauth/browser/v1/account/email', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11602,7 +11557,6 @@ export const getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.delete('*/api/v2/allauth/browser/v1/account/email', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11625,7 +11579,6 @@ export const getApiV2AllauthAppV1AccountEmailGetMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/email', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11648,7 +11601,6 @@ export const getApiV2AllauthAppV1AccountEmailPostMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.post('*/api/v2/allauth/app/v1/account/email', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11669,7 +11621,6 @@ export const getApiV2AllauthAppV1AccountEmailPutMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.put('*/api/v2/allauth/app/v1/account/email', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11692,7 +11643,6 @@ export const getApiV2AllauthAppV1AccountEmailPatchMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.patch('*/api/v2/allauth/app/v1/account/email', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11715,7 +11665,6 @@ export const getApiV2AllauthAppV1AccountEmailDeleteMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.delete('*/api/v2/allauth/app/v1/account/email', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11736,7 +11685,6 @@ export const getApiV2AllauthBrowserV1AccountPhoneGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/phone', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11759,7 +11707,6 @@ export const getApiV2AllauthBrowserV1AccountPhonePostMockHandler = ( ) => Promise | PhoneNumberChangeResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/account/phone', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11780,7 +11727,6 @@ export const getApiV2AllauthAppV1AccountPhoneGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/phone', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11803,7 +11749,6 @@ export const getApiV2AllauthAppV1AccountPhonePostMockHandler = ( ) => Promise | PhoneNumberChangeResponse), ) => { return http.post('*/api/v2/allauth/app/v1/account/phone', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11826,7 +11771,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler = ( ) => Promise | AuthenticatorsResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/authenticators', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11849,7 +11793,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler = ( ) => Promise | AuthenticatorsResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/authenticators', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11872,7 +11815,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler = ( ) => Promise | TOTPAuthenticatorResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11895,7 +11837,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler = ) => Promise | TOTPAuthenticatorResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11916,7 +11857,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.delete('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11939,7 +11879,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler = ( ) => Promise | TOTPAuthenticatorResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11962,7 +11901,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler = ( ) => Promise | TOTPAuthenticatorResponse), ) => { return http.post('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -11983,7 +11921,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.delete('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -12004,7 +11941,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHa | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -12023,7 +11959,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockH overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), ) => { return http.post('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { - await delay(1000) if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -12037,7 +11972,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandle | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -12056,7 +11990,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandl overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), ) => { return http.post('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { - await delay(1000) if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -12070,7 +12003,6 @@ export const getApiV2AllauthBrowserV1AuthSessionGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/auth/session', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -12089,7 +12021,6 @@ export const getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler = ( overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), ) => { return http.delete('*/api/v2/allauth/browser/v1/auth/session', async (info) => { - await delay(1000) if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -12103,7 +12034,6 @@ export const getApiV2AllauthAppV1AuthSessionGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), ) => { return http.get('*/api/v2/allauth/app/v1/auth/session', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -12122,7 +12052,6 @@ export const getApiV2AllauthAppV1AuthSessionDeleteMockHandler = ( overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), ) => { return http.delete('*/api/v2/allauth/app/v1/auth/session', async (info) => { - await delay(1000) if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -12136,7 +12065,6 @@ export const getApiV2AllauthAppV1TokensRefreshPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | RefreshTokenResponse), ) => { return http.post('*/api/v2/allauth/app/v1/tokens/refresh', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -12155,7 +12083,6 @@ export const getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler = ( overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), ) => { return http.post('*/api/v2/allauth/browser/v1/account/password/change', async (info) => { - await delay(1000) if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -12167,7 +12094,6 @@ export const getApiV2AllauthAppV1AccountPasswordChangePostMockHandler = ( overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), ) => { return http.post('*/api/v2/allauth/app/v1/account/password/change', async (info) => { - await delay(1000) if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -12181,7 +12107,6 @@ export const getApiV2AllauthBrowserV1AuthSessionsGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -12202,7 +12127,6 @@ export const getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), ) => { return http.delete('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -12223,7 +12147,6 @@ export const getApiV2AllauthAppV1AuthSessionsGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), ) => { return http.get('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -12244,7 +12167,6 @@ export const getApiV2AllauthAppV1AuthSessionsDeleteMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), ) => { return http.delete('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( diff --git a/jsapp/js/api/react-query/configuration.ts b/jsapp/js/api/react-query/configuration.ts index 53faa4ed72..b69fca9b5c 100644 --- a/jsapp/js/api/react-query/configuration.ts +++ b/jsapp/js/api/react-query/configuration.ts @@ -14,7 +14,7 @@ import type { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult } from '@ import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import type { EnvironmentResponse } from '../models/environmentResponse' @@ -209,8 +209,7 @@ export const getApiV2EnvironmentRetrieveMockHandler = ( | EnvironmentResponse | ((info: Parameters[1]>[0]) => Promise | EnvironmentResponse), ) => { - return http.get('*/api/v2/environment/', async (info) => { - await delay(1000) + return http.get('*/api/v2/environment{/}?', async (info) => { return new HttpResponse( JSON.stringify( diff --git a/jsapp/js/api/react-query/form-content.ts b/jsapp/js/api/react-query/form-content.ts index ffa8ae17a3..63a09a85fc 100644 --- a/jsapp/js/api/react-query/form-content.ts +++ b/jsapp/js/api/react-query/form-content.ts @@ -31,7 +31,7 @@ import type { ErrorObject } from '../models/errorObject' import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import type { AssetSnapshotResponse } from '../models/assetSnapshotResponse' @@ -1361,8 +1361,7 @@ export const getApiV2AssetSnapshotsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetSnapshotResponseList), ) => { - return http.get('*/api/v2/asset_snapshots/', async (info) => { - await delay(1000) + return http.get('*/api/v2/asset_snapshots{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1384,8 +1383,7 @@ export const getApiV2AssetSnapshotsCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | AssetSnapshotResponse), ) => { - return http.post('*/api/v2/asset_snapshots/', async (info) => { - await delay(1000) + return http.post('*/api/v2/asset_snapshots{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1405,8 +1403,7 @@ export const getApiV2AssetSnapshotsRetrieveMockHandler = ( | AssetSnapshotResponse | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse), ) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { - await delay(1000) + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1424,8 +1421,7 @@ export const getApiV2AssetSnapshotsRetrieveMockHandler = ( export const getApiV2AssetSnapshotsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -1436,8 +1432,7 @@ export const getApiV2AssetSnapshotsDestroyMockHandler = ( export const getApiV2AssetSnapshotsPreviewRetrieveMockHandler = ( overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), ) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview/', async (info) => { - await delay(1000) + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -1450,8 +1445,7 @@ export const getApiV2AssetSnapshotsXformRetrieveMockHandler = ( | OpenRosaXFormResponse | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), ) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform/', async (info) => { - await delay(1000) + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1471,8 +1465,7 @@ export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler = ( | OpenRosaXFormResponse | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), ) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer/', async (info) => { - await delay(1000) + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1492,8 +1485,7 @@ export const getApiV2AssetsContentRetrieveMockHandler = ( | ContentResponse | ((info: Parameters[1]>[0]) => Promise | ContentResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/content/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/content{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1511,8 +1503,7 @@ export const getApiV2AssetsContentRetrieveMockHandler = ( export const getApiV2AssetsTableViewRetrieveMockHandler = ( overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), ) => { - return http.get('*/api/v2/assets/:uidAsset/table_view/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/table_view{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1534,8 +1525,7 @@ export const getApiV2AssetsValidContentRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | AssetValidContentResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/valid_content/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/valid_content{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1553,8 +1543,7 @@ export const getApiV2AssetsValidContentRetrieveMockHandler = ( export const getApiV2AssetsXlsRetrieveMockHandler = ( overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), ) => { - return http.get('*/api/v2/assets/:uidAsset/xls/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/xls{/}?', async (info) => { return new HttpResponse( JSON.stringify( diff --git a/jsapp/js/api/react-query/library-collections.ts b/jsapp/js/api/react-query/library-collections.ts index 332c1ff200..bb9afc4fa9 100644 --- a/jsapp/js/api/react-query/library-collections.ts +++ b/jsapp/js/api/react-query/library-collections.ts @@ -29,7 +29,7 @@ import type { ErrorObject } from '../models/errorObject' import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import type { AssetSubscriptionResponse } from '../models/assetSubscriptionResponse' @@ -431,8 +431,7 @@ export const getApiV2AssetSubscriptionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetSubscriptionResponseList), ) => { - return http.get('*/api/v2/asset_subscriptions/', async (info) => { - await delay(1000) + return http.get('*/api/v2/asset_subscriptions{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -454,8 +453,7 @@ export const getApiV2AssetSubscriptionsCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | AssetSubscriptionResponse), ) => { - return http.post('*/api/v2/asset_subscriptions/', async (info) => { - await delay(1000) + return http.post('*/api/v2/asset_subscriptions{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -477,8 +475,7 @@ export const getApiV2AssetSubscriptionsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | AssetSubscriptionResponse), ) => { - return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { - await delay(1000) + return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -496,8 +493,7 @@ export const getApiV2AssetSubscriptionsRetrieveMockHandler = ( export const getApiV2AssetSubscriptionsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } diff --git a/jsapp/js/api/react-query/logging.ts b/jsapp/js/api/react-query/logging.ts index f06b368ef5..b1403b29bf 100644 --- a/jsapp/js/api/react-query/logging.ts +++ b/jsapp/js/api/react-query/logging.ts @@ -27,7 +27,7 @@ import type { ErrorDetail } from '../models/errorDetail' import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import type { ExportCreateResponse } from '../models/exportCreateResponse' @@ -972,8 +972,7 @@ export const getApiV2AccessLogsMeListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAccessLogResponseList), ) => { - return http.get('*/api/v2/access-logs/me/', async (info) => { - await delay(1000) + return http.get('*/api/v2/access-logs/me{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -993,8 +992,7 @@ export const getApiV2AccessLogsMeExportListMockHandler = ( | ExportListResponse[] | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), ) => { - return http.get('*/api/v2/access-logs/me/export/', async (info) => { - await delay(1000) + return http.get('*/api/v2/access-logs/me/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1014,8 +1012,7 @@ export const getApiV2AccessLogsMeExportCreateMockHandler = ( | ExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), ) => { - return http.post('*/api/v2/access-logs/me/export/', async (info) => { - await delay(1000) + return http.post('*/api/v2/access-logs/me/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1037,8 +1034,7 @@ export const getApiV2AssetsHistoryListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedHistoryListResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/history/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/history{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1058,8 +1054,7 @@ export const getApiV2AssetsHistoryActionsRetrieveMockHandler = ( | HistoryActionResponse | ((info: Parameters[1]>[0]) => Promise | HistoryActionResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/history/actions/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/history/actions{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1081,8 +1076,7 @@ export const getApiV2AssetsHistoryExportCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | HistoryExportResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/history/export/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/history/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( diff --git a/jsapp/js/api/react-query/manage-permissions.ts b/jsapp/js/api/react-query/manage-permissions.ts index 2cf3749e38..bd2652fd13 100644 --- a/jsapp/js/api/react-query/manage-permissions.ts +++ b/jsapp/js/api/react-query/manage-permissions.ts @@ -31,7 +31,7 @@ import type { PermissionAssignmentCreateRequest } from '../models/permissionAssi import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import type { PermissionAssignmentResponse } from '../models/permissionAssignmentResponse' @@ -807,8 +807,7 @@ export const getApiV2AssetsPermissionAssignmentsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PermissionAssignmentResponse[]), ) => { - return http.get('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/permission-assignments{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -830,8 +829,7 @@ export const getApiV2AssetsPermissionAssignmentsCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | PermissionAssignmentResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/permission-assignments{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -853,8 +851,7 @@ export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PermissionAssignmentResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -872,8 +869,7 @@ export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = ( export const getApiV2AssetsPermissionAssignmentsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -888,8 +884,7 @@ export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | PermissionAssignmentResponse[]), ) => { - return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -907,8 +902,7 @@ export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = ( export const getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -923,8 +917,7 @@ export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler = info: Parameters[1]>[0], ) => Promise | PermissionAssignmentResponse[]), ) => { - return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone{/}?', async (info) => { return new HttpResponse( JSON.stringify( diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index d97be47055..61f1df963f 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -57,7 +57,7 @@ import type { TagsListParams } from '../models/tagsListParams' import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import type { Asset } from '../models/asset' @@ -7260,8 +7260,7 @@ export const getApiV2AssetsListMockHandler = ( | PaginatedAssetList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), ) => { - return http.get('*/api/v2/assets/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7279,8 +7278,7 @@ export const getApiV2AssetsListMockHandler = ( export const getApiV2AssetsCreateMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { - return http.post('*/api/v2/assets/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7298,8 +7296,7 @@ export const getApiV2AssetsCreateMockHandler = ( export const getApiV2AssetsRetrieveMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { - return http.get('*/api/v2/assets/:uidAsset/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7317,8 +7314,7 @@ export const getApiV2AssetsRetrieveMockHandler = ( export const getApiV2AssetsPartialUpdateMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { - return http.patch('*/api/v2/assets/:uidAsset/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7336,8 +7332,7 @@ export const getApiV2AssetsPartialUpdateMockHandler = ( export const getApiV2AssetsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -7352,8 +7347,7 @@ export const getApiV2AssetsCountsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetCountResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/counts/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/counts{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7373,8 +7367,7 @@ export const getApiV2AssetsDeploymentRetrieveMockHandler = ( | DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/deployment/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7394,8 +7387,7 @@ export const getApiV2AssetsDeploymentCreateMockHandler = ( | DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/deployment/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7415,8 +7407,7 @@ export const getApiV2AssetsDeploymentPartialUpdateMockHandler = ( | DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/deployment/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7438,8 +7429,7 @@ export const getApiV2AssetsVersionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedVersionListResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/versions/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/versions{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7461,8 +7451,7 @@ export const getApiV2AssetsVersionsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | VersionRetrieveResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7480,8 +7469,7 @@ export const getApiV2AssetsVersionsRetrieveMockHandler = ( export const getApiV2AssetsXformRetrieveMockHandler = ( overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), ) => { - return http.get('*/api/v2/assets/:uidAsset/xform/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/xform{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7501,8 +7489,7 @@ export const getApiV2AssetsBulkCreateMockHandler = ( | AssetBulkResponse | ((info: Parameters[1]>[0]) => Promise | AssetBulkResponse), ) => { - return http.post('*/api/v2/assets/bulk/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/bulk{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7522,8 +7509,7 @@ export const getApiV2AssetsCountsRetrieveMockHandler = ( | AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount), ) => { - return http.get('*/api/v2/assets/counts/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/counts{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7543,8 +7529,7 @@ export const getApiV2AssetsHashRetrieveMockHandler = ( | HashResponse | ((info: Parameters[1]>[0]) => Promise | HashResponse), ) => { - return http.get('*/api/v2/assets/hash/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/hash{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7564,8 +7549,7 @@ export const getApiV2AssetsMetadataRetrieveMockHandler = ( | AssetMetadataResponse | ((info: Parameters[1]>[0]) => Promise | AssetMetadataResponse), ) => { - return http.get('*/api/v2/assets/metadata/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/metadata{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7587,8 +7571,7 @@ export const getApiV2AssetsMinimalListRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetMinimalListList), ) => { - return http.get('*/api/v2/assets/minimal-list/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/minimal-list{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7610,8 +7593,7 @@ export const getApiV2ImportsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedImportResponseList), ) => { - return http.get('*/api/v2/imports/', async (info) => { - await delay(1000) + return http.get('*/api/v2/imports{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7631,8 +7613,7 @@ export const getApiV2ImportsCreateMockHandler = ( | ImportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ImportCreateResponse), ) => { - return http.post('*/api/v2/imports/', async (info) => { - await delay(1000) + return http.post('*/api/v2/imports{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7652,8 +7633,7 @@ export const getApiV2ImportsRetrieveMockHandler = ( | ImportResponse | ((info: Parameters[1]>[0]) => Promise | ImportResponse), ) => { - return http.get('*/api/v2/imports/:uidImport/', async (info) => { - await delay(1000) + return http.get('*/api/v2/imports/:uidImport{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7675,8 +7655,7 @@ export const getApiV2ProjectOwnershipInvitesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectInviteResponseList), ) => { - return http.get('*/api/v2/project-ownership/invites/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-ownership/invites{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7698,8 +7677,7 @@ export const getApiV2ProjectOwnershipInvitesCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectInviteResponse), ) => { - return http.post('*/api/v2/project-ownership/invites/', async (info) => { - await delay(1000) + return http.post('*/api/v2/project-ownership/invites{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7719,8 +7697,7 @@ export const getApiV2ProjectOwnershipInvitesRetrieveMockHandler = ( | ProjectInviteResponse | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse), ) => { - return http.get('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7742,8 +7719,7 @@ export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectInviteResponse), ) => { - return http.patch('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7761,8 +7737,7 @@ export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = ( export const getApiV2ProjectOwnershipInvitesDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -7775,8 +7750,7 @@ export const getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler = ( | TransferListResponse | ((info: Parameters[1]>[0]) => Promise | TransferListResponse), ) => { - return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7798,8 +7772,7 @@ export const getApiV2TagsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedTagListResponseList), ) => { - return http.get('*/api/v2/tags/', async (info) => { - await delay(1000) + return http.get('*/api/v2/tags{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -7819,8 +7792,7 @@ export const getApiV2TagsRetrieveMockHandler = ( | TagRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | TagRetrieveResponse), ) => { - return http.get('*/api/v2/tags/:taguidUid/', async (info) => { - await delay(1000) + return http.get('*/api/v2/tags/:taguidUid{/}?', async (info) => { return new HttpResponse( JSON.stringify( diff --git a/jsapp/js/api/react-query/other.ts b/jsapp/js/api/react-query/other.ts index e0d1c0e9db..f5f571b08e 100644 --- a/jsapp/js/api/react-query/other.ts +++ b/jsapp/js/api/react-query/other.ts @@ -41,7 +41,7 @@ import type { TranslationServicesListParams } from '../models/translationService import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import { BlankEnum } from '../models/blankEnum' @@ -2346,8 +2346,7 @@ export const getApiV2LanguagesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedLanguageListList), ) => { - return http.get('*/api/v2/languages/', async (info) => { - await delay(1000) + return http.get('*/api/v2/languages{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2365,8 +2364,7 @@ export const getApiV2LanguagesListMockHandler = ( export const getApiV2LanguagesRetrieveMockHandler = ( overrideResponse?: Language | ((info: Parameters[1]>[0]) => Promise | Language), ) => { - return http.get('*/api/v2/languages/:code/', async (info) => { - await delay(1000) + return http.get('*/api/v2/languages/:code{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2388,8 +2386,7 @@ export const getApiV2PermissionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedPermissionResponseList), ) => { - return http.get('*/api/v2/permissions/', async (info) => { - await delay(1000) + return http.get('*/api/v2/permissions{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2409,8 +2406,7 @@ export const getApiV2PermissionsRetrieveMockHandler = ( | PermissionResponse | ((info: Parameters[1]>[0]) => Promise | PermissionResponse), ) => { - return http.get('*/api/v2/permissions/:codename/', async (info) => { - await delay(1000) + return http.get('*/api/v2/permissions/:codename{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2432,8 +2428,7 @@ export const getApiV2StripeAddonsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedOneTimeAddOnList), ) => { - return http.get('*/api/v2/stripe/addons/', async (info) => { - await delay(1000) + return http.get('*/api/v2/stripe/addons{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2453,8 +2448,7 @@ export const getApiV2StripeAddonsRetrieveMockHandler = ( | OneTimeAddOn | ((info: Parameters[1]>[0]) => Promise | OneTimeAddOn), ) => { - return http.get('*/api/v2/stripe/addons/:id/', async (info) => { - await delay(1000) + return http.get('*/api/v2/stripe/addons/:id{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2475,7 +2469,6 @@ export const getApiV2StripeChangePlanRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ChangePlan), ) => { return http.get('*/api/v2/stripe/change-plan', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -2496,7 +2489,6 @@ export const getApiV2StripeCheckoutLinkCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | CheckoutLink), ) => { return http.post('*/api/v2/stripe/checkout-link', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -2519,7 +2511,6 @@ export const getApiV2StripeCustomerPortalCreateMockHandler = ( ) => Promise | CustomerPortalPostResponse), ) => { return http.post('*/api/v2/stripe/customer-portal', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -2539,8 +2530,7 @@ export const getApiV2StripeProductsListMockHandler = ( | PaginatedProductList | ((info: Parameters[1]>[0]) => Promise | PaginatedProductList), ) => { - return http.get('*/api/v2/stripe/products/', async (info) => { - await delay(1000) + return http.get('*/api/v2/stripe/products{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2562,8 +2552,7 @@ export const getApiV2StripeSubscriptionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedSubscriptionList), ) => { - return http.get('*/api/v2/stripe/subscriptions/', async (info) => { - await delay(1000) + return http.get('*/api/v2/stripe/subscriptions{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2583,8 +2572,7 @@ export const getApiV2StripeSubscriptionsRetrieveMockHandler = ( | Subscription | ((info: Parameters[1]>[0]) => Promise | Subscription), ) => { - return http.get('*/api/v2/stripe/subscriptions/:id/', async (info) => { - await delay(1000) + return http.get('*/api/v2/stripe/subscriptions/:id{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2606,8 +2594,7 @@ export const getApiV2TermsOfServiceListMockHandler = ( info: Parameters[1]>[0], ) => Promise | TermsOfServiceResponse[]), ) => { - return http.get('*/api/v2/terms-of-service/', async (info) => { - await delay(1000) + return http.get('*/api/v2/terms-of-service{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2629,8 +2616,7 @@ export const getApiV2TermsOfServiceRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | TermsOfServiceResponse), ) => { - return http.get('*/api/v2/terms-of-service/:slug/', async (info) => { - await delay(1000) + return http.get('*/api/v2/terms-of-service/:slug{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2652,8 +2638,7 @@ export const getApiV2TranscriptionServicesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedTranscriptionServiceList), ) => { - return http.get('*/api/v2/transcription-services/', async (info) => { - await delay(1000) + return http.get('*/api/v2/transcription-services{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2673,8 +2658,7 @@ export const getApiV2TranscriptionServicesRetrieveMockHandler = ( | TranscriptionService | ((info: Parameters[1]>[0]) => Promise | TranscriptionService), ) => { - return http.get('*/api/v2/transcription-services/:code/', async (info) => { - await delay(1000) + return http.get('*/api/v2/transcription-services/:code{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2696,8 +2680,7 @@ export const getApiV2TranslationServicesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedTranslationServiceList), ) => { - return http.get('*/api/v2/translation-services/', async (info) => { - await delay(1000) + return http.get('*/api/v2/translation-services{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2717,8 +2700,7 @@ export const getApiV2TranslationServicesRetrieveMockHandler = ( | TranslationService | ((info: Parameters[1]>[0]) => Promise | TranslationService), ) => { - return http.get('*/api/v2/translation-services/:code/', async (info) => { - await delay(1000) + return http.get('*/api/v2/translation-services/:code{/}?', async (info) => { return new HttpResponse( JSON.stringify( diff --git a/jsapp/js/api/react-query/scim.ts b/jsapp/js/api/react-query/scim.ts index c26bdcb6a1..c0426c2cc5 100644 --- a/jsapp/js/api/react-query/scim.ts +++ b/jsapp/js/api/react-query/scim.ts @@ -37,7 +37,7 @@ import type { ScimV2UsersUpdate409 } from '../models/scimV2UsersUpdate409' import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import type { PaginatedScimGroupList } from '../models/paginatedScimGroupList' @@ -1588,7 +1588,6 @@ export const getApiV2ScimV2GroupsListMockHandler = ( ) => Promise | PaginatedScimGroupList), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1609,7 +1608,6 @@ export const getApiV2ScimV2GroupsCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimGroup), ) => { return http.post('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1630,7 +1628,6 @@ export const getApiV2ScimV2GroupsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimGroup), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1651,7 +1648,6 @@ export const getApiV2ScimV2GroupsUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimGroup), ) => { return http.put('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1672,7 +1668,6 @@ export const getApiV2ScimV2GroupsPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimGroup), ) => { return http.patch('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1691,7 +1686,6 @@ export const getApiV2ScimV2GroupsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { return http.delete('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - await delay(1000) if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -1707,7 +1701,6 @@ export const getApiV2ScimV2ResourceTypesRetrieveMockHandler = ( ) => Promise | ScimV2ResourceTypesRetrieve200), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/ResourceTypes', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1730,7 +1723,6 @@ export const getApiV2ScimV2SchemasRetrieveMockHandler = ( ) => Promise | ScimV2SchemasRetrieve200), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/Schemas', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1753,7 +1745,6 @@ export const getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler = ( ) => Promise | ScimV2ServiceProviderConfigRetrieve200), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/ServiceProviderConfig', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1774,7 +1765,6 @@ export const getApiV2ScimV2UsersListMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PaginatedScimUserList), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1795,7 +1785,6 @@ export const getApiV2ScimV2UsersCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimUser), ) => { return http.post('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1814,7 +1803,6 @@ export const getApiV2ScimV2UsersRetrieveMockHandler = ( overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1833,7 +1821,6 @@ export const getApiV2ScimV2UsersUpdateMockHandler = ( overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), ) => { return http.put('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1854,7 +1841,6 @@ export const getApiV2ScimV2UsersPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimUser), ) => { return http.patch('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - await delay(1000) return new HttpResponse( JSON.stringify( @@ -1873,7 +1859,6 @@ export const getApiV2ScimV2UsersDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { return http.delete('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - await delay(1000) if (typeof overrideResponse === 'function') { await overrideResponse(info) } diff --git a/jsapp/js/api/react-query/server-logs-superusers.ts b/jsapp/js/api/react-query/server-logs-superusers.ts index 7d53da94d9..4dc5b1a3a5 100644 --- a/jsapp/js/api/react-query/server-logs-superusers.ts +++ b/jsapp/js/api/react-query/server-logs-superusers.ts @@ -33,7 +33,7 @@ import type { UserReportsListParams } from '../models/userReportsListParams' import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import type { ExportCreateResponse } from '../models/exportCreateResponse' @@ -1951,8 +1951,7 @@ export const getApiV2AccessLogsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedSuperUserAccessLogResponseList), ) => { - return http.get('*/api/v2/access-logs/', async (info) => { - await delay(1000) + return http.get('*/api/v2/access-logs{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1972,8 +1971,7 @@ export const getApiV2AccessLogsExportListMockHandler = ( | ExportListResponse[] | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), ) => { - return http.get('*/api/v2/access-logs/export/', async (info) => { - await delay(1000) + return http.get('*/api/v2/access-logs/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1993,8 +1991,7 @@ export const getApiV2AccessLogsExportCreateMockHandler = ( | ExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), ) => { - return http.post('*/api/v2/access-logs/export/', async (info) => { - await delay(1000) + return http.post('*/api/v2/access-logs/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2016,8 +2013,7 @@ export const getApiV2AuditLogsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAuditLogResponseList), ) => { - return http.get('*/api/v2/audit-logs/', async (info) => { - await delay(1000) + return http.get('*/api/v2/audit-logs{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2039,8 +2035,7 @@ export const getApiV2ProjectHistoryLogsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectHistoryLogResponseList), ) => { - return http.get('*/api/v2/project-history-logs/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-history-logs{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2060,8 +2055,7 @@ export const getApiV2ProjectHistoryLogsExportRetrieveMockHandler = ( | ExportHistoryResponse | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse), ) => { - return http.get('*/api/v2/project-history-logs/export/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-history-logs/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2083,8 +2077,7 @@ export const getApiV2ProjectHistoryLogsExportCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ExportHistoryResponse), ) => { - return http.post('*/api/v2/project-history-logs/export/', async (info) => { - await delay(1000) + return http.post('*/api/v2/project-history-logs/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -2106,8 +2099,7 @@ export const getApiV2UserReportsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedUserReportsListResponseList), ) => { - return http.get('*/api/v2/user-reports/', async (info) => { - await delay(1000) + return http.get('*/api/v2/user-reports{/}?', async (info) => { return new HttpResponse( JSON.stringify( diff --git a/jsapp/js/api/react-query/survey-data-rest-services.ts b/jsapp/js/api/react-query/survey-data-rest-services.ts index 09b295f893..f0d725eb2a 100644 --- a/jsapp/js/api/react-query/survey-data-rest-services.ts +++ b/jsapp/js/api/react-query/survey-data-rest-services.ts @@ -33,7 +33,7 @@ import type { PatchedHookLog } from '../models/patchedHookLog' import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import { AuthLevelEnum } from '../models/authLevelEnum' @@ -1213,8 +1213,7 @@ export const getApiV2AssetsHooksListMockHandler = ( | PaginatedHookList | ((info: Parameters[1]>[0]) => Promise | PaginatedHookList), ) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/hooks{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1232,8 +1231,7 @@ export const getApiV2AssetsHooksListMockHandler = ( export const getApiV2AssetsHooksCreateMockHandler = ( overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), ) => { - return http.post('*/api/v2/assets/:uidAsset/hooks/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/hooks{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1251,8 +1249,7 @@ export const getApiV2AssetsHooksCreateMockHandler = ( export const getApiV2AssetsHooksRetrieveMockHandler = ( overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), ) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1270,8 +1267,7 @@ export const getApiV2AssetsHooksRetrieveMockHandler = ( export const getApiV2AssetsHooksPartialUpdateMockHandler = ( overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), ) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1289,8 +1285,7 @@ export const getApiV2AssetsHooksPartialUpdateMockHandler = ( export const getApiV2AssetsHooksDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -1303,8 +1298,7 @@ export const getApiV2AssetsHooksLogsListMockHandler = ( | PaginatedHookLogList | ((info: Parameters[1]>[0]) => Promise | PaginatedHookLogList), ) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1322,8 +1316,7 @@ export const getApiV2AssetsHooksLogsListMockHandler = ( export const getApiV2AssetsHooksLogsRetrieveMockHandler = ( overrideResponse?: HookLog | ((info: Parameters[1]>[0]) => Promise | HookLog), ) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1343,8 +1336,7 @@ export const getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler = ( | LogsRetryResponse | ((info: Parameters[1]>[0]) => Promise | LogsRetryResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -1364,8 +1356,7 @@ export const getApiV2AssetsHooksRetryPartialUpdateMockHandler = ( | HookRetryResponse | ((info: Parameters[1]>[0]) => Promise | HookRetryResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry{/}?', async (info) => { return new HttpResponse( JSON.stringify( diff --git a/jsapp/js/api/react-query/survey-data.ts b/jsapp/js/api/react-query/survey-data.ts index 7ba785e53b..b690b1264d 100644 --- a/jsapp/js/api/react-query/survey-data.ts +++ b/jsapp/js/api/react-query/survey-data.ts @@ -79,7 +79,7 @@ import type { PatchedPairedDataPatchPayload } from '../models/patchedPairedDataP import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import { ActionEnum } from '../models/actionEnum' @@ -8105,8 +8105,7 @@ export const getApiV2AssetsAdvancedFeaturesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | AdvancedFeatureResponse[]), ) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/advanced-features{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8128,8 +8127,7 @@ export const getApiV2AssetsAdvancedFeaturesCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | AdvancedFeatureCreateResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/advanced-features{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8151,8 +8149,7 @@ export const getApiV2AssetsAdvancedFeaturesRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | AdvancedFeatureResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8174,8 +8171,7 @@ export const getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | AdvancedFeatureResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8197,8 +8193,7 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | BulkActionListResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8220,8 +8215,7 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | BulkActionCreateResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8241,8 +8235,7 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler = ( | BulkActionResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8262,8 +8255,7 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = | BulkActionResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8281,8 +8273,7 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = export const getApiV2AssetsAttachmentsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/attachments/:id/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/attachments/:id{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8297,8 +8288,7 @@ export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | AssetAttachmentAudioDurationResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8316,8 +8306,7 @@ export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = ( export const getApiV2AssetsAttachmentsBulkDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8332,8 +8321,7 @@ export const getApiV2AssetsDataListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedDataResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8353,8 +8341,7 @@ export const getApiV2AssetsDataRetrieveMockHandler = ( | DataResponse | ((info: Parameters[1]>[0]) => Promise | DataResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:id{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8372,8 +8359,7 @@ export const getApiV2AssetsDataRetrieveMockHandler = ( export const getApiV2AssetsDataDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/data/:id{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8386,8 +8372,7 @@ export const getApiV2AssetsDataDuplicateCreateMockHandler = ( | DataResponse | ((info: Parameters[1]>[0]) => Promise | DataResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8407,8 +8392,7 @@ export const getApiV2AssetsDataEditRetrieveMockHandler = ( | EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/edit/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:id/edit{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8428,8 +8412,7 @@ export const getApiV2AssetsDataEnketoEditRetrieveMockHandler = ( | EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8449,8 +8432,7 @@ export const getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler = ( | EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8470,8 +8452,7 @@ export const getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler = ( | EnketoViewResponse | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8491,8 +8472,7 @@ export const getApiV2AssetsDataEnketoViewRetrieveMockHandler = ( | EnketoViewResponse | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8514,8 +8494,7 @@ export const getApiV2AssetsDataValidationStatusRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | DataValidationStatusUpdateResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8537,8 +8516,7 @@ export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | DataValidationStatusUpdateResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8556,8 +8534,7 @@ export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = ( export const getApiV2AssetsDataValidationStatusDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8572,8 +8549,7 @@ export const getApiV2AssetsDataSupplementRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | DataSupplementResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8595,8 +8571,7 @@ export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | DataSupplementResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8614,8 +8589,7 @@ export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = ( export const getApiV2AssetsDataAttachmentsListMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8626,8 +8600,7 @@ export const getApiV2AssetsDataAttachmentsListMockHandler = ( export const getAttachmentRetrieveMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8638,8 +8611,7 @@ export const getAttachmentRetrieveMockHandler = ( export const getAttachmentThumbnailMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8654,8 +8626,7 @@ export const getApiV2AssetsDataBulkPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | DataBulkUpdateResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/data/bulk{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8673,8 +8644,7 @@ export const getApiV2AssetsDataBulkPartialUpdateMockHandler = ( export const getApiV2AssetsDataBulkDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/data/bulk{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8687,8 +8657,7 @@ export const getApiV2AssetsDataSupplementsBulkCreateMockHandler = ( | BulkAcceptResponse | ((info: Parameters[1]>[0]) => Promise | BulkAcceptResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8708,8 +8677,7 @@ export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = ( | DataStatusesUpdate | ((info: Parameters[1]>[0]) => Promise | DataStatusesUpdate), ) => { - return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8727,8 +8695,7 @@ export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = ( export const getApiV2AssetsDataValidationStatusesDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8743,8 +8710,7 @@ export const getApiV2AssetsExportSettingsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedExportSettingResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/export-settings{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8766,8 +8732,7 @@ export const getApiV2AssetsExportSettingsCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ExportSettingResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/export-settings{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8787,8 +8752,7 @@ export const getApiV2AssetsExportSettingsRetrieveMockHandler = ( | ExportSettingResponse | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8810,8 +8774,7 @@ export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ExportSettingResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8829,8 +8792,7 @@ export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = ( export const getApiV2AssetsExportSettingsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8841,8 +8803,7 @@ export const getApiV2AssetsExportSettingsDestroyMockHandler = ( export const getApiV2AssetsExportSettingsDataRetrieveMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8857,8 +8818,7 @@ export const getApiV2AssetsExportsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedExportResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/exports/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/exports{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8878,8 +8838,7 @@ export const getApiV2AssetsExportsCreateMockHandler = ( | ExportResponse | ((info: Parameters[1]>[0]) => Promise | ExportResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/exports/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/exports{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8899,8 +8858,7 @@ export const getApiV2AssetsExportsRetrieveMockHandler = ( | ExportResponse | ((info: Parameters[1]>[0]) => Promise | ExportResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8918,8 +8876,7 @@ export const getApiV2AssetsExportsRetrieveMockHandler = ( export const getApiV2AssetsExportsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -8934,8 +8891,7 @@ export const getApiV2AssetsFilesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedFilesResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/files/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/files{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8955,8 +8911,7 @@ export const getApiV2AssetsFilesCreateMockHandler = ( | FilesResponse | ((info: Parameters[1]>[0]) => Promise | FilesResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/files/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/files{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8976,8 +8931,7 @@ export const getApiV2AssetsFilesRetrieveMockHandler = ( | FilesResponse | ((info: Parameters[1]>[0]) => Promise | FilesResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -8995,8 +8949,7 @@ export const getApiV2AssetsFilesRetrieveMockHandler = ( export const getApiV2AssetsFilesDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -9007,8 +8960,7 @@ export const getApiV2AssetsFilesDestroyMockHandler = ( export const getApiV2AssetsFilesContentRetrieveMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -9023,8 +8975,7 @@ export const getApiV2AssetsPairedDataListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedPairedDataResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/paired-data{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -9044,8 +8995,7 @@ export const getApiV2AssetsPairedDataCreateMockHandler = ( | PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { - await delay(1000) + return http.post('*/api/v2/assets/:uidAsset/paired-data{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -9065,8 +9015,7 @@ export const getApiV2AssetsPairedDataRetrieveMockHandler = ( | PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -9086,8 +9035,7 @@ export const getApiV2AssetsPairedDataPartialUpdateMockHandler = ( | PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -9105,8 +9053,7 @@ export const getApiV2AssetsPairedDataPartialUpdateMockHandler = ( export const getApiV2AssetsPairedDataDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -9119,8 +9066,7 @@ export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = ( | ExternalResponse | ((info: Parameters[1]>[0]) => Promise | ExternalResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -9140,8 +9086,7 @@ export const getApiV2AssetsReportsRetrieveMockHandler = ( | ReportResponse | ((info: Parameters[1]>[0]) => Promise | ReportResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/reports/', async (info) => { - await delay(1000) + return http.get('*/api/v2/assets/:uidAsset/reports{/}?', async (info) => { return new HttpResponse( JSON.stringify( diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index eb74492b21..3f223bdb4a 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -63,7 +63,7 @@ import type { UsersListParams } from '../models/usersListParams' import { faker } from '@faker-js/faker' -import { http, HttpResponse, delay } from 'msw' +import { http, HttpResponse } from 'msw' import { AssetDeploymentStatusEnum } from '../models/assetDeploymentStatusEnum' @@ -5145,8 +5145,7 @@ export const getApiV2AssetUsageListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetUsageResponseList), ) => { - return http.get('*/api/v2/asset_usage/', async (info) => { - await delay(1000) + return http.get('*/api/v2/asset_usage{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5168,8 +5167,7 @@ export const getApiV2OrganizationsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedOrganizationResponseList), ) => { - return http.get('*/api/v2/organizations/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5189,8 +5187,7 @@ export const getApiV2OrganizationsRetrieveMockHandler = ( | OrganizationResponse | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations/:uidOrganization{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5210,8 +5207,7 @@ export const getApiV2OrganizationsPartialUpdateMockHandler = ( | OrganizationResponse | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), ) => { - return http.patch('*/api/v2/organizations/:uidOrganization/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/organizations/:uidOrganization{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5233,8 +5229,7 @@ export const getApiV2OrganizationsAssetUsageListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedCustomAssetUsageList), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/asset_usage/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations/:uidOrganization/asset_usage{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5254,8 +5249,7 @@ export const getApiV2OrganizationsAssetsRetrieveMockHandler = ( | PaginatedAssetList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations/:uidOrganization/assets{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5275,8 +5269,7 @@ export const getApiV2OrganizationsAssetsCountsRetrieveMockHandler = ( | AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/counts/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations/:uidOrganization/assets/counts{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5298,8 +5291,7 @@ export const getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetMinimalListList), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5321,8 +5313,7 @@ export const getApiV2OrganizationsInvitesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedInviteResponseList), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations/:uidOrganization/invites{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5342,8 +5333,7 @@ export const getApiV2OrganizationsInvitesCreateMockHandler = ( | InviteCreateResponse | ((info: Parameters[1]>[0]) => Promise | InviteCreateResponse), ) => { - return http.post('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { - await delay(1000) + return http.post('*/api/v2/organizations/:uidOrganization/invites{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5363,8 +5353,7 @@ export const getApiV2OrganizationsInvitesRetrieveMockHandler = ( | InviteResponse | ((info: Parameters[1]>[0]) => Promise | InviteResponse), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5384,8 +5373,7 @@ export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = ( | InviteResponse | ((info: Parameters[1]>[0]) => Promise | InviteResponse), ) => { - return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5403,8 +5391,7 @@ export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = ( export const getApiV2OrganizationsInvitesDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -5419,8 +5406,7 @@ export const getApiV2OrganizationsMembersListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedMemberListResponseList), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/members/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations/:uidOrganization/members{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5440,8 +5426,7 @@ export const getApiV2OrganizationsMembersRetrieveMockHandler = ( | MemberListResponse | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5461,8 +5446,7 @@ export const getApiV2OrganizationsMembersPartialUpdateMockHandler = ( | MemberListResponse | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), ) => { - return http.patch('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { - await delay(1000) + return http.patch('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5480,8 +5464,7 @@ export const getApiV2OrganizationsMembersPartialUpdateMockHandler = ( export const getApiV2OrganizationsMembersDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { - await delay(1000) + return http.delete('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -5496,8 +5479,7 @@ export const getApiV2OrganizationsServiceUsageRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | OrganizationServiceUsageResponse), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/service_usage/', async (info) => { - await delay(1000) + return http.get('*/api/v2/organizations/:uidOrganization/service_usage{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5519,8 +5501,7 @@ export const getApiV2ProjectViewsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectViewListResponseList), ) => { - return http.get('*/api/v2/project-views/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-views{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5542,8 +5523,7 @@ export const getApiV2ProjectViewsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectViewListResponse), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-views/:uidProjectView{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5565,8 +5545,7 @@ export const getApiV2ProjectViewsExportRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectViewExportResponse), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-views/:uidProjectView/:objType/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5588,8 +5567,7 @@ export const getApiV2ProjectViewsExportCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectViewExportCreateResponse), ) => { - return http.post('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { - await delay(1000) + return http.post('*/api/v2/project-views/:uidProjectView/:objType/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5611,8 +5589,7 @@ export const getApiV2ProjectViewsAssetsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectViewAssetResponseList), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-views/:uidProjectView/assets{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5632,8 +5609,7 @@ export const getApiV2ProjectViewsAssetsCountsRetrieveMockHandler = ( | AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/counts/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-views/:uidProjectView/assets/counts{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5655,8 +5631,7 @@ export const getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetMinimalListList), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5678,8 +5653,7 @@ export const getApiV2ProjectViewsUsersRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectViewUserResponseList), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/users/', async (info) => { - await delay(1000) + return http.get('*/api/v2/project-views/:uidProjectView/users{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5701,8 +5675,7 @@ export const getApiV2ServiceUsageListMockHandler = ( info: Parameters[1]>[0], ) => Promise | ServiceUsageResponse[]), ) => { - return http.get('*/api/v2/service_usage/', async (info) => { - await delay(1000) + return http.get('*/api/v2/service_usage{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5724,8 +5697,7 @@ export const getApiV2UsersListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedUserListResponseList), ) => { - return http.get('*/api/v2/users/', async (info) => { - await delay(1000) + return http.get('*/api/v2/users{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5745,8 +5717,7 @@ export const getApiV2UsersRetrieveMockHandler = ( | UserRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | UserRetrieveResponse), ) => { - return http.get('*/api/v2/users/:username/', async (info) => { - await delay(1000) + return http.get('*/api/v2/users/:username{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5766,8 +5737,7 @@ export const getMeRetrieveMockHandler = ( | MeListResponse | ((info: Parameters[1]>[0]) => Promise | MeListResponse), ) => { - return http.get('*/me/', async (info) => { - await delay(1000) + return http.get('*/me{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5787,8 +5757,7 @@ export const getMePartialUpdateMockHandler = ( | MeListResponse | ((info: Parameters[1]>[0]) => Promise | MeListResponse), ) => { - return http.patch('*/me/', async (info) => { - await delay(1000) + return http.patch('*/me{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5806,8 +5775,7 @@ export const getMePartialUpdateMockHandler = ( export const getMeDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/me/', async (info) => { - await delay(1000) + return http.delete('*/me{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -5822,8 +5790,7 @@ export const getMeEmailsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedEmailAddressList), ) => { - return http.get('*/me/emails/', async (info) => { - await delay(1000) + return http.get('*/me/emails{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5843,8 +5810,7 @@ export const getMeEmailsCreateMockHandler = ( | EmailAddress | ((info: Parameters[1]>[0]) => Promise | EmailAddress), ) => { - return http.post('*/me/emails/', async (info) => { - await delay(1000) + return http.post('*/me/emails{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5866,8 +5832,7 @@ export const getMeSocialAccountsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedSocialAccountList), ) => { - return http.get('*/me/social-accounts/', async (info) => { - await delay(1000) + return http.get('*/me/social-accounts{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5887,8 +5852,7 @@ export const getMeSocialAccountsRetrieveMockHandler = ( | SocialAccount | ((info: Parameters[1]>[0]) => Promise | SocialAccount), ) => { - return http.get('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { - await delay(1000) + return http.get('*/me/social-accounts/:provider/:uidSocialAccount{/}?', async (info) => { return new HttpResponse( JSON.stringify( @@ -5906,8 +5870,7 @@ export const getMeSocialAccountsRetrieveMockHandler = ( export const getMeSocialAccountsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { - await delay(1000) + return http.delete('*/me/social-accounts/:provider/:uidSocialAccount{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } diff --git a/jsapp/js/components/map/FormMapWrapper.stories.tsx b/jsapp/js/components/map/FormMapWrapper.stories.tsx index f7f3f64c0c..6c4f6b3fcc 100644 --- a/jsapp/js/components/map/FormMapWrapper.stories.tsx +++ b/jsapp/js/components/map/FormMapWrapper.stories.tsx @@ -25,6 +25,7 @@ const assetWithOnlyStartGeopoint = getApiV2AssetsRetrieveResponseMock({ deployment__active: true, deployment__submission_count: 2, has_deployment: true, + map_styles: {}, summary: { geo: true, labels: ['Your name'], @@ -62,6 +63,7 @@ const assetWithBothGeopointTypes = getApiV2AssetsRetrieveResponseMock({ deployment__active: true, deployment__submission_count: 2, has_deployment: true, + map_styles: {}, summary: { geo: true, labels: ['Your name', 'Where are you?'], diff --git a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx index aff44cbad4..7fd95bf810 100644 --- a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx +++ b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx @@ -10,7 +10,7 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import type { DecoratorFunction } from '@storybook/types' import React, { useEffect } from 'react' import { reactRouterParameters, withRouter } from 'storybook-addon-remix-react-router' -import { expect, waitFor } from 'storybook/test' +// import { expect, waitFor } from 'storybook/test' import subscriptionStore from '#/account/subscriptionStore' import { actions } from '#/actions' import { ActionIdEnum } from '#/api/models/actionIdEnum' @@ -33,13 +33,6 @@ import { queryClientDecorator } from '#/query/queryClient.mocks' import { ROUTES } from '#/router/routerConstants' import { withBulkProcessingBannerSessionReset } from './BulkProcessingBannerStoriesUtils' import DataTableWrapper from './DataTableWrapper' -import { - getPollingUpdateStoryHandlers, - getPollingUpdateStoryState, - getPollingUpdateStoryTimeoutMs, - pollingAsset, - resetPollingUpdateStoryHandlers, -} from './DataTableWrapperPollingStoriesUtils' // TODO DEV-XXXX: Orval-generated Asset and legacy AssetResponse have structural differences // Cast Orval mocks to legacy type for stories. Main differences: @@ -157,6 +150,9 @@ const getRouterParams = (assetUid: string) => const minimalAsset = getApiV2AssetsRetrieveResponseMock({ uid: 'audio-asset-uid', name: 'Audio form', + deployment__active: true, + has_deployment: true, + map_styles: {}, content: { schema: '1', survey: [ @@ -211,6 +207,9 @@ const minimalSubmissions = [ const processingAsset = getApiV2AssetsRetrieveResponseMock({ uid: 'audio-asset-uid-processing', name: 'Audio form with processing', + deployment__active: true, + has_deployment: true, + map_styles: {}, content: { schema: '1', survey: [ @@ -344,9 +343,6 @@ const processingBulkAction2 = getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveR const meta: Meta = { title: 'Components/DataTableWrapper', component: DataTableWrapper, - async beforeEach() { - resetPollingUpdateStoryHandlers() - }, args: { asset: minimalAsset, }, @@ -424,41 +420,6 @@ export const ProcessingColumnAndBanner: Story = { loaders: [loadAssetForStory], } -export const ProcessingPollingRefreshesTranslatedCell: Story = { - args: { - asset: pollingAsset as unknown as AssetResponse, - }, - parameters: { - docs: { - description: { - story: - 'Starts with a Processing placeholder and updates that row after polling (about 8 seconds) when the mocked bulk action item transitions to complete.', - }, - }, - a11y: { test: 'todo' }, - reactRouter: getRouterParams(pollingAsset.uid), - msw: { - handlers: getPollingUpdateStoryHandlers(), - }, - }, - loaders: [loadAssetForStory], - play: async ({ step }) => { - // We intentionally avoid asserting rendered translated text here. - // We tried multiple DOM-based variants (including intermediate - // "Processing" checks), but they remained flaky in CI across browsers. - // This play test focuses on stable polling/refresh behavior via mock state. - await step('Wait for polling to refresh one submission row', async () => { - await waitFor( - async () => { - const storyState = getPollingUpdateStoryState() - await expect(storyState.pollingBulkActionsCalls).toBeGreaterThanOrEqual(2) - await expect(storyState.pollingSubmissionRefreshCalls).toBeGreaterThanOrEqual(1) - }, - { timeout: getPollingUpdateStoryTimeoutMs() }, - ) - }) - }, -} export const ProcessingAndLimitsBannersTogether: Story = { args: { asset: processingAsset, diff --git a/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx b/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx deleted file mode 100644 index ae191a0173..0000000000 --- a/jsapp/js/components/submissions/DataTableWrapperPollingStoriesUtils.tsx +++ /dev/null @@ -1,217 +0,0 @@ -import { http, HttpResponse, type PathParams } from 'msw' -import { endpoints } from '#/api.endpoints' -import { ActionIdEnum } from '#/api/models/actionIdEnum' -import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' -import { BulkActionSubmissionStatusResponseStatusEnum } from '#/api/models/bulkActionSubmissionStatusResponseStatusEnum' -import { - getApiV2AssetsRetrieveMockHandler, - getApiV2AssetsRetrieveResponseMock, -} from '#/api/react-query/manage-projects-and-library-content' -import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' -import { QuestionTypeName } from '#/constants' -import assetDataFactory from '#/endpoints/assetData.factory' -import meMock from '#/endpoints/me.mocks' -import organizationMock from '#/endpoints/organization.mocks' -import organizationServiceUsageMock from '#/endpoints/organizationServiceUsage.mocks' -import { getBulkActionsPollingIntervalMs } from './useDataTableBulkActions' - -let pollingBulkActionsCalls = 0 -let pollingSubmissionRefreshCalls = 0 -let pollingFirstBulkActionsRequestTime: number | null = null -const POLLING_STORY_ASSERTION_GRACE_MS = 6000 -// How long after a story resets before the mock bulk action reports completion. -// Needs to be shorter than the polling interval (8 s for translation) so that -// the first poll always returns in_progress — giving every parallel browser -// enough time to actually render the "Processing" cell before completion fires. -const POLLING_COMPLETE_AFTER_MS = 2000 - -// Dedicated polling story data is kept in a separate file so the main stories -// file remains easy to scan as more table scenarios get added. -export const pollingAsset = getApiV2AssetsRetrieveResponseMock({ - uid: 'audio-asset-uid-polling', - name: 'Audio form with polling update', - // The backend writes analysis_form_json when a bulk action is created, so - // this entry is present from the moment the story starts — not only after - // polling finishes. Having it here is what keeps the supplemental column in - // its correct position (immediately after the source question) throughout the - // whole lifecycle. The virtual fields from active bulk actions handle the - // "Processing" cell state while the action is still running. - analysis_form_json: { - additional_fields: [ - { - language: 'es', - source: 'Record_a_sound', - type: 'translation', - name: 'translation_es', - dtpath: 'Record_a_sound/translation_es', - }, - ], - }, - content: { - schema: '1', - survey: [ - { - type: QuestionTypeName.audio, - $kuid: 'snd1', - label: ['Record a sound'], - $xpath: 'Record_a_sound', - required: false, - $autoname: 'Record_a_sound', - }, - ], - settings: {}, - translated: ['label'], - translations: [null], - }, - effective_permissions: [{ codename: 'change_submissions' }], -}) - -const pollingSubmissionInitial = assetDataFactory(11, { - Record_a_sound: 'test11.mp3', - _attachments: [ - { - download_url: './test11.mp3', - mimetype: 'audio/x-m3a', - filename: 'uu/attachments/test11.mp3', - media_file_basename: 'test11.mp3', - uid: 'tst11', - is_deleted: false, - question_xpath: 'Record_a_sound', - }, - ], -}) - -const pollingSubmissionUpdated = assetDataFactory(11, { - Record_a_sound: 'test11.mp3', - _supplementalDetails: { - Record_a_sound: { - translation: { - es: { - languageCode: 'es', - value: 'Hola, el procesamiento masivo ha finalizado correctamente.', - }, - }, - }, - }, - _attachments: [ - { - download_url: './test11.mp3', - mimetype: 'audio/x-m3a', - filename: 'uu/attachments/test11.mp3', - media_file_basename: 'test11.mp3', - uid: 'tst11', - is_deleted: false, - question_xpath: 'Record_a_sound', - }, - ], -}) - -const pollingBulkActionInProgress = getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ - uid: 'polling-bulk-action', - status: BulkActionResponseStatusEnum.in_progress, - action_id: ActionIdEnum.automatic_google_translation, - question_xpath: 'Record_a_sound', - submission_uuids: [pollingSubmissionInitial['meta/rootUuid']], - params: { language: 'es' }, - submission_statuses: [ - { - uuid: pollingSubmissionInitial['meta/rootUuid'], - status: BulkActionSubmissionStatusResponseStatusEnum.in_progress, - error: null, - }, - ], -}) - -const pollingBulkActionComplete = getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ - uid: 'polling-bulk-action', - status: BulkActionResponseStatusEnum.complete, - action_id: ActionIdEnum.automatic_google_translation, - question_xpath: 'Record_a_sound', - submission_uuids: [pollingSubmissionInitial['meta/rootUuid']], - params: { language: 'es' }, - submission_statuses: [ - { - uuid: pollingSubmissionInitial['meta/rootUuid'], - status: BulkActionSubmissionStatusResponseStatusEnum.complete, - error: null, - }, - ], -}) - -export function resetPollingUpdateStoryHandlers() { - pollingBulkActionsCalls = 0 - pollingSubmissionRefreshCalls = 0 - pollingFirstBulkActionsRequestTime = null -} - -export function getPollingUpdateStoryState() { - return { - pollingBulkActionsCalls, - pollingSubmissionRefreshCalls, - } -} - -export function getPollingUpdateStoryTimeoutMs() { - const pollingIntervalMs = getBulkActionsPollingIntervalMs([pollingBulkActionInProgress]) - - if (pollingIntervalMs === false) { - return POLLING_STORY_ASSERTION_GRACE_MS - } - - // The UI change happens after one more poll and one row refresh request, so - // the test allows one computed interval plus a small render/network cushion. - return pollingIntervalMs + POLLING_STORY_ASSERTION_GRACE_MS -} - -export function getPollingUpdateStoryHandlers() { - return [ - meMock, - getApiV2AssetsRetrieveMockHandler(pollingAsset), - organizationMock(), - organizationServiceUsageMock(), - http.get, never>(endpoints.ASSET_ADVANCED_FEATURES_BULK_ACTIONS, ({ params }) => { - if (params.uid !== pollingAsset.uid) { - return undefined - } - - // Use wall-clock time rather than call count to decide when to switch to - // complete. A call-count threshold is unreliable when multiple browsers - // run the same story in parallel — their polls all share the same counter, - // so the count can cross the threshold before any single browser has had - // a chance to render the "Processing" cell. - pollingBulkActionsCalls += 1 - if (pollingFirstBulkActionsRequestTime === null) { - pollingFirstBulkActionsRequestTime = Date.now() - } - const isComplete = Date.now() - pollingFirstBulkActionsRequestTime >= POLLING_COMPLETE_AFTER_MS - return HttpResponse.json({ - count: 1, - next: null, - previous: null, - results: [isComplete ? pollingBulkActionComplete : pollingBulkActionInProgress], - }) - }), - http.get, never>(endpoints.ASSET_DATA_URL, ({ params, request }) => { - if (params.uid !== pollingAsset.uid) { - return undefined - } - - // DataTable uses the regular list call for the page, and a query-based call - // when refreshing one submission by uuid; we return updated data only for - // that single-row refresh path. - const requestUrl = new URL(request.url) - const hasUuidQuery = Boolean(requestUrl.searchParams.get('query')) - if (hasUuidQuery) { - pollingSubmissionRefreshCalls += 1 - } - const submissions = hasUuidQuery ? [pollingSubmissionUpdated] : [pollingSubmissionInitial] - - return HttpResponse.json({ - count: submissions.length, - next: null, - previous: null, - results: submissions, - }) - }), - ] -} diff --git a/jsapp/js/endpoints/formMedia.mocks.ts b/jsapp/js/endpoints/formMedia.mocks.ts index 925f124155..2f83ecf6ca 100644 --- a/jsapp/js/endpoints/formMedia.mocks.ts +++ b/jsapp/js/endpoints/formMedia.mocks.ts @@ -53,16 +53,19 @@ function waitMs(ms: number): Promise { /** * Creates a form media item using Orval's generated mock with deterministic IDs. + * If assetUid is not provided in overrides, uses 'mock-asset-uid' as default. */ export function createFormMediaItem(index: number, overrides: Partial = {}): FormMediaItem { const uid = overrides.uid ?? `form-media-${index}` const filename = overrides.metadata?.filename ?? `file-${index}.png` + // Extract asset UID from overrides.asset URL if provided, or use overrides.uid, or default + const assetUid = overrides.asset?.match(/\/assets\/([^/]+)\//)?.[1] ?? 'mock-asset-uid' return { ...getApiV2AssetsFilesCreateResponseMock({ uid, - url: `/api/v2/assets/mock-asset-uid/files/${uid}/`, - asset: '/api/v2/assets/mock-asset-uid/', + url: `/api/v2/assets/${assetUid}/files/${uid}/`, + asset: `/api/v2/assets/${assetUid}/`, user: '/api/v2/users/storybook/', user__username: 'storybook', file_type: 'form_media', @@ -130,6 +133,7 @@ export function formMediaHandlers( const newItem = createFormMediaItem(index, { uid: `form-media-${index}`, url: `/api/v2/assets/${assetUid}/files/form-media-${index}/`, + asset: `/api/v2/assets/${assetUid}/`, metadata: { hash: `hash-${index}`, filename: (parsedMetadata.filename as string | undefined) || `uploaded-${index}.dat`, diff --git a/jsapp/js/project/FormMedia/FormMedia.stories.tsx b/jsapp/js/project/FormMedia/FormMedia.stories.tsx index 1f144fe02a..9fcb48f7c7 100644 --- a/jsapp/js/project/FormMedia/FormMedia.stories.tsx +++ b/jsapp/js/project/FormMedia/FormMedia.stories.tsx @@ -24,6 +24,7 @@ const meta: Meta = { createFormMediaItem(1, { uid: 'form-media-1', url: `/api/v2/assets/${mockAsset.uid}/files/form-media-1/`, + asset: `/api/v2/assets/${mockAsset.uid}/`, metadata: { hash: 'hash-1', filename: 'intro-image.png', diff --git a/orval.config.js b/orval.config.js index 21593b4c4d..69bf6c8c43 100644 --- a/orval.config.js +++ b/orval.config.js @@ -48,9 +48,12 @@ module.exports = { // Orval has a bug that fails to generate imports for $ref in additionalProperties. // See https://github.com/orval-labs/orval/issues/1077. // Also fix TypeScript errors in MSW mock factories for types with index signatures. + // Make trailing slashes optional in MSW handlers to match both /path and /path/ afterAllFilesWrite: [ 'node scripts/orval-fix-referenced-additional-properties.js', 'node scripts/orval-fix-mock-factory-type-assertions.js', + 'node scripts/orval-make-trailing-slash-optional.js', + 'node scripts/orval-remove-mock-delays.js', ], }, }, diff --git a/scripts/orval-make-trailing-slash-optional.js b/scripts/orval-make-trailing-slash-optional.js new file mode 100644 index 0000000000..c58e2c8cf7 --- /dev/null +++ b/scripts/orval-make-trailing-slash-optional.js @@ -0,0 +1,50 @@ +/* eslint-disable no-console */ +/** + * Django REST Framework adds trailing slashes to all URLs, so Orval-generated + * MSW handlers end with '/'. But the frontend sometimes drops the slash. + * + * We fix this by appending '?' to make the slash optional in handler patterns. + * Both /api/v2/assets/123/history/actions and /actions/ will match. + */ +const fs = require('fs') +const path = require('path') + +const ROOT = process.cwd() +const REACT_QUERY_DIR = path.join(ROOT, 'jsapp/js/api/react-query') + +let totalFixed = 0 + +function processFile(filePath) { + let source = fs.readFileSync(filePath, 'utf8') + let modified = false + + // Change http.get('path/', ...) to http.get('path{/}?', ...) + // The {/}? syntax makes the trailing slash optional in path-to-regexp + const pattern = /http\.(get|post|put|patch|delete)\('(\*\/[^']+)\/'/g + + source = source.replace(pattern, (match, method, pathWithoutSlash) => { + if (pathWithoutSlash.endsWith('{/}')) { + return match + } + modified = true + return `http.${method}('${pathWithoutSlash}{/}?'` + }) + + if (modified) { + fs.writeFileSync(filePath, source, 'utf8') + totalFixed++ + } + + return modified +} + +const files = fs.readdirSync(REACT_QUERY_DIR) +for (const file of files) { + if (!file.endsWith('.ts')) continue + const filePath = path.join(REACT_QUERY_DIR, file) + processFile(filePath) +} + +if (totalFixed > 0) { + console.log(`✔ Made trailing slashes optional in ${totalFixed} react-query files`) +} diff --git a/scripts/orval-remove-mock-delays.js b/scripts/orval-remove-mock-delays.js new file mode 100644 index 0000000000..2f6ff772ba --- /dev/null +++ b/scripts/orval-remove-mock-delays.js @@ -0,0 +1,68 @@ +#!/usr/bin/env node + +/** + * Post-process Orval-generated MSW handlers to remove delays. + * + * Orval generates mock handlers with `await delay(1000)` which is good for + * simulating realistic loading states but causes tests to be slow and potentially + * timeout when multiple requests are involved. + * + * This script removes the `await delay(1000)` lines from all generated handler files. + */ + +const fs = require('fs') +const path = require('path') + +const targetDir = path.join(__dirname, '../jsapp/js/api/react-query') + +function removeDelays(filePath) { + let source = fs.readFileSync(filePath, 'utf-8') + const originalSource = source + + // Remove the delay import from msw + source = source.replace( + /import\s+{([^}]*),\s*delay\s*([^}]*)}\s+from\s+['"]msw['"]/g, + (match, before, after) => { + // Remove trailing/leading commas + const cleaned = `${before}${after}`.replace(/,\s*,/g, ',').replace(/^,|,$/g, '').trim() + return cleaned ? `import { ${cleaned} } from 'msw'` : "import { } from 'msw'" + } + ) + + // Remove standalone delay import + source = source.replace(/import\s+{\s*delay\s*}\s+from\s+['"]msw['"][\s\r\n]*/g, '') + + // Remove await delay() calls + source = source.replace(/\s*await\s+delay\(\d+\)[\s\r\n]*/g, '\n') + + if (source !== originalSource) { + fs.writeFileSync(filePath, source, 'utf-8') + return true + } + return false +} + +function processDirectory(dir) { + let modifiedCount = 0 + const files = fs.readdirSync(dir) + + for (const file of files) { + const filePath = path.join(dir, file) + const stat = fs.statSync(filePath) + + if (stat.isDirectory()) { + modifiedCount += processDirectory(filePath) + } else if (file.endsWith('.ts') || file.endsWith('.tsx')) { + if (removeDelays(filePath)) { + modifiedCount++ + console.log(`Removed delays from: ${path.relative(process.cwd(), filePath)}`) + } + } + } + + return modifiedCount +} + +console.log('Removing delays from Orval-generated mock handlers...') +const modifiedCount = processDirectory(targetDir) +console.log(`Modified ${modifiedCount} file(s)`) From f2e21f3ae5e2674da7923301d34efab02ac0b907 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 11:04:46 +0200 Subject: [PATCH 55/86] cleanups --- jsapp/jest/unit.config.ts | 4 +--- jsapp/js/assetUtils.tests.js | 2 +- jsapp/js/endpoints/assetHistory.mocks.ts | 4 ++-- jsapp/js/endpoints/bulkActions.mocks.ts | 2 +- jsapp/js/endpoints/formMedia.mocks.ts | 6 ++++-- jsapp/js/endpoints/me.mocks.ts | 2 +- jsapp/js/endpoints/organization.mocks.ts | 2 +- .../FormLanguagesManager.tsx | 5 ++--- kpi/schema_extensions/v2/data/extensions.py | 17 +++++++++++++++++ .../orval-fix-mock-factory-type-assertions.js | 19 +++++++++++-------- ...al-fix-referenced-additional-properties.js | 11 ++++++++--- scripts/orval-remove-mock-delays.js | 12 ++++++++---- 12 files changed, 57 insertions(+), 29 deletions(-) diff --git a/jsapp/jest/unit.config.ts b/jsapp/jest/unit.config.ts index e9049c5112..5241a594c4 100644 --- a/jsapp/jest/unit.config.ts +++ b/jsapp/jest/unit.config.ts @@ -42,9 +42,7 @@ const config: Config = { ], // Transform ESM modules from node_modules (MSW and its dependencies) - transformIgnorePatterns: [ - 'node_modules/(?!(msw|@mswjs|@bundled-es-modules|statuses|until-async)/)', - ], + transformIgnorePatterns: ['node_modules/(?!(msw|@mswjs|@bundled-es-modules|statuses|until-async)/)'], // Set up test environment testEnvironment: 'jsdom', diff --git a/jsapp/js/assetUtils.tests.js b/jsapp/js/assetUtils.tests.js index e0d516ab32..8ea9e9ee8b 100644 --- a/jsapp/js/assetUtils.tests.js +++ b/jsapp/js/assetUtils.tests.js @@ -24,9 +24,9 @@ jest.mock('#/api/react-query/user-team-organization-usage', () => ({ })) import { MemberRoleEnum } from '#/api/models/memberRoleEnum' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' import { DeleteBlockerReason, getSurveyFlatPaths, userCanDeleteAssets } from '#/assetUtils' import { surveyWithAllPossibleGroups, surveyWithGroups } from '#/assetUtils.mocks' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' // Helper wrapper for legacy test code const assetFactory = (overrides) => getApiV2AssetsRetrieveResponseMock(overrides) diff --git a/jsapp/js/endpoints/assetHistory.mocks.ts b/jsapp/js/endpoints/assetHistory.mocks.ts index 60ce8fb9c1..dbb6ad883c 100644 --- a/jsapp/js/endpoints/assetHistory.mocks.ts +++ b/jsapp/js/endpoints/assetHistory.mocks.ts @@ -1,13 +1,13 @@ import { http, HttpResponse, type PathParams } from 'msw' import { endpoints } from '#/api.endpoints' +import type { ProjectHistoryLogResponse } from '#/api/models/projectHistoryLogResponse' +import { getApiV2ProjectHistoryLogsListResponseMock } from '#/api/react-query/server-logs-superusers' import { type ActivityLogsItem, AuditActions, BULK_PROCESSING_ACTION_IDS, } from '#/components/activity/activity.constants' import type { PaginatedResponse } from '#/dataInterface' -import { getApiV2ProjectHistoryLogsListResponseMock } from '#/api/react-query/server-logs-superusers' -import type { ProjectHistoryLogResponse } from '#/api/models/projectHistoryLogResponse' export const mockAssetUid = 'a1234567890bcdEFGhijkl' diff --git a/jsapp/js/endpoints/bulkActions.mocks.ts b/jsapp/js/endpoints/bulkActions.mocks.ts index 667cd514a3..c7fac1d811 100644 --- a/jsapp/js/endpoints/bulkActions.mocks.ts +++ b/jsapp/js/endpoints/bulkActions.mocks.ts @@ -1,9 +1,9 @@ import { http, HttpResponse, type PathParams } from 'msw' import { endpoints } from '#/api.endpoints' +import { ActionIdEnum } from '#/api/models/actionIdEnum' import type { BulkActionListResponse } from '#/api/models/bulkActionListResponse' import type { BulkActionResponse } from '#/api/models/bulkActionResponse' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' -import { ActionIdEnum } from '#/api/models/actionIdEnum' import { BulkActionSubmissionStatusResponseStatusEnum } from '#/api/models/bulkActionSubmissionStatusResponseStatusEnum' import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' diff --git a/jsapp/js/endpoints/formMedia.mocks.ts b/jsapp/js/endpoints/formMedia.mocks.ts index 2f83ecf6ca..ee1c4b24ae 100644 --- a/jsapp/js/endpoints/formMedia.mocks.ts +++ b/jsapp/js/endpoints/formMedia.mocks.ts @@ -1,10 +1,10 @@ +import type { FilesResponse } from '#/api/models/filesResponse' import { getApiV2AssetsFilesCreateMockHandler, getApiV2AssetsFilesCreateResponseMock, getApiV2AssetsFilesDestroyMockHandler, getApiV2AssetsFilesListMockHandler, } from '#/api/react-query/survey-data' -import type { FilesResponse } from '#/api/models/filesResponse' /** * Extended FilesResponse type with redirect_url in metadata. @@ -121,7 +121,9 @@ export function formMediaHandlers( const payload = await parsePayload(request) const parsedMetadata = - typeof payload.metadata === 'string' ? (JSON.parse(payload.metadata) as Record) : (payload.metadata ?? {}) + typeof payload.metadata === 'string' + ? (JSON.parse(payload.metadata) as Record) + : (payload.metadata ?? {}) const fileName = parsedMetadata.filename as string | undefined const delayMs = (fileName && options.uploadDelayByFilenameMs?.[fileName]) || 0 diff --git a/jsapp/js/endpoints/me.mocks.ts b/jsapp/js/endpoints/me.mocks.ts index 009f5ee23c..f45ce83f6f 100644 --- a/jsapp/js/endpoints/me.mocks.ts +++ b/jsapp/js/endpoints/me.mocks.ts @@ -1,5 +1,5 @@ -import { getMeRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage' import type { MeListResponse } from '#/api/models/meListResponse' +import { getMeRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage' /** * Mock response data for /me/ endpoint. diff --git a/jsapp/js/endpoints/organization.mocks.ts b/jsapp/js/endpoints/organization.mocks.ts index e7c0758000..472a4f931e 100644 --- a/jsapp/js/endpoints/organization.mocks.ts +++ b/jsapp/js/endpoints/organization.mocks.ts @@ -1,5 +1,5 @@ -import { getApiV2OrganizationsRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage' import type { OrganizationResponse } from '#/api/models/organizationResponse' +import { getApiV2OrganizationsRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage' import { meMockResponse } from './me.mocks' /** diff --git a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx index 00475c3c87..3690237b49 100644 --- a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx +++ b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx @@ -1,11 +1,10 @@ -import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' - import { Box, Group, Text } from '@mantine/core' import { useQuery, useQueryClient } from '@tanstack/react-query' import cloneDeep from 'lodash.clonedeep' +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import type { PaginatedListResponse } from '#/UniversalTable' -import { assetsPartialUpdate } from '#/api/react-query/manage-projects-and-library-content' import type { PatchedAssetPatchRequestOneOfContent } from '#/api/models/patchedAssetPatchRequestOneOfContent' +import { assetsPartialUpdate } from '#/api/react-query/manage-projects-and-library-content' import ButtonNew from '#/components/common/ButtonNew' import ModalNew from '#/components/common/ModalNew' import LoadingSpinner from '#/components/common/loadingSpinner' diff --git a/kpi/schema_extensions/v2/data/extensions.py b/kpi/schema_extensions/v2/data/extensions.py index 120fcb3f6e..d27e1fffe5 100644 --- a/kpi/schema_extensions/v2/data/extensions.py +++ b/kpi/schema_extensions/v2/data/extensions.py @@ -332,8 +332,20 @@ def map_serializer_field(self, auto_schema, direction): # Note: These schemas are inlined (not registered as components) to avoid # Orval generating problematic MSW mocks for types with index signatures. # The oneOf discriminator is sufficient for the API schema. + # + # Structure of each oneOf option: + # { + # [question_xpath]: { + # [action_type]: { ...action_data } + # } + # } + # + # The six oneOf options represent all possible action types that can generate + # supplemental data. Each has a unique property name that acts as a discriminator, + # allowing TypeScript to narrow the union based on which property exists. return { 'oneOf': [ + # Option 1: Human-generated audio/video transcription build_object_type( additionalProperties=build_object_type( properties={ @@ -345,6 +357,7 @@ def map_serializer_field(self, auto_schema, direction): ), description='Manual transcription supplemental details', ), + # Option 2: Human-generated text translation build_object_type( additionalProperties=build_object_type( properties={ @@ -356,6 +369,7 @@ def map_serializer_field(self, auto_schema, direction): ), description='Manual translation supplemental details', ), + # Option 3: AI-generated audio/video transcription build_object_type( additionalProperties=build_object_type( properties={ @@ -367,6 +381,7 @@ def map_serializer_field(self, auto_schema, direction): ), description='Automatic transcription supplemental details', ), + # Option 4: AI-generated text translation build_object_type( additionalProperties=build_object_type( properties={ @@ -378,6 +393,7 @@ def map_serializer_field(self, auto_schema, direction): ), description='Automatic translation supplemental details', ), + # Option 5: Human-generated qualitative analysis tags build_object_type( additionalProperties=build_object_type( properties={ @@ -387,6 +403,7 @@ def map_serializer_field(self, auto_schema, direction): ), description='Manual qualitative supplemental details', ), + # Option 6: AI-generated qualitative analysis tags build_object_type( additionalProperties=build_object_type( properties={ diff --git a/scripts/orval-fix-mock-factory-type-assertions.js b/scripts/orval-fix-mock-factory-type-assertions.js index c9ad330e3f..54392aa819 100644 --- a/scripts/orval-fix-mock-factory-type-assertions.js +++ b/scripts/orval-fix-mock-factory-type-assertions.js @@ -2,16 +2,19 @@ /** * Fixes TypeScript errors in MSW mock factories. * - * The problem: Types like { _version: string } & Record - * tell TypeScript that _version has to be both a string AND SomeOtherType. - * That doesn't work, so mock factories that return { _version: "..." } fail to compile. + * Why this is needed: When Orval generates types like + * `{ _version: string } & Record`, TypeScript's type system + * sees a conflict - _version must be both a `string` AND a `SomeOtherType`, which + * is impossible. This causes the mock factory return values to fail type checking + * even though they're structurally correct at runtime. * - * The fix: Cast the return value with `as TypeName`. Safe because these are test mocks - * and the structure is fine at runtime. + * What this does: Adds explicit type assertions (`as TypeName`) to mock factory + * return statements. This tells TypeScript "trust me, this object matches the type" + * without changing runtime behavior. Safe for test mocks where we control the data. * - * Types we fix: - * - DataSupplementResponse (& Record) - * - PatchedDataSupplementPayload (| Record) + * Types currently affected: + * - DataSupplementResponse (intersection with Record) + * - PatchedDataSupplementPayload (union with Record) */ const fs = require('fs') const path = require('path') diff --git a/scripts/orval-fix-referenced-additional-properties.js b/scripts/orval-fix-referenced-additional-properties.js index 56a1b467fc..6c75fa3d67 100644 --- a/scripts/orval-fix-referenced-additional-properties.js +++ b/scripts/orval-fix-referenced-additional-properties.js @@ -46,14 +46,17 @@ function detectInterfaceWithIndex(source) { function ensureTypeImportAfterHeader(source, typeName, importPath) { const importLine = `import type { ${typeName} } from '${importPath}'` - // Already imported? + // Check if this type is already imported const hasImport = new RegExp(`\\bimport\\s+type\\s*\\{\\s*${typeName}\\s*\\}\\s+from\\s+['"]`).test(source) if (hasImport) return source + // Split the file into Orval's header comment and the rest const { header, rest } = splitHeader(source) + + // If no header exists, add import at the top if (!header) return `${importLine}\n${source}` - // Ensure one blank line after the Orval header for readability + // Insert import right after the Orval header with one blank line for readability return `${header}\n${importLine}\n${rest}` } @@ -74,7 +77,9 @@ for (const file of FILES) { const importPath = inferImportPath(valueType) let patched = ensureTypeImportAfterHeader(source, valueType, importPath) - // Note: the workaround with index signatures is partial: `|` works only for assignment and `&` works for reading. + // TypeScript index signatures behave differently with unions vs intersections: + // - Use `|` (union) for Payload types: allows assigning objects without all Record keys + // - Use `&` (intersection) for Response types: allows reading all properties safely const operator = file.includes('Payload') ? '|' : '&' const replacement = diff --git a/scripts/orval-remove-mock-delays.js b/scripts/orval-remove-mock-delays.js index 2f6ff772ba..5f8c448dc7 100644 --- a/scripts/orval-remove-mock-delays.js +++ b/scripts/orval-remove-mock-delays.js @@ -19,20 +19,24 @@ function removeDelays(filePath) { let source = fs.readFileSync(filePath, 'utf-8') const originalSource = source - // Remove the delay import from msw + // Remove `delay` from the MSW import statement + // Example: "import { http, delay, HttpResponse } from 'msw'" becomes "import { http, HttpResponse } from 'msw'" source = source.replace( /import\s+{([^}]*),\s*delay\s*([^}]*)}\s+from\s+['"]msw['"]/g, (match, before, after) => { - // Remove trailing/leading commas + // Merge the parts before and after `delay`, then clean up any double commas const cleaned = `${before}${after}`.replace(/,\s*,/g, ',').replace(/^,|,$/g, '').trim() + // If nothing remains after removing `delay`, leave an empty import (will be cleaned up by formatter) return cleaned ? `import { ${cleaned} } from 'msw'` : "import { } from 'msw'" } ) - // Remove standalone delay import + // Remove standalone delay import if `delay` was the only import + // Example: "import { delay } from 'msw'" becomes "" source = source.replace(/import\s+{\s*delay\s*}\s+from\s+['"]msw['"][\s\r\n]*/g, '') - // Remove await delay() calls + // Remove all `await delay(...)` calls from handler bodies + // Example: "await delay(1000)" becomes a blank line source = source.replace(/\s*await\s+delay\(\d+\)[\s\r\n]*/g, '\n') if (source !== originalSource) { From e8849777c967c2935b5a9fbb41fb7ef81694c28b Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 11:11:41 +0200 Subject: [PATCH 56/86] cleanup todo comments --- .../AssetTagsModal/AssetTagsModal.stories.tsx | 7 ++++--- .../js/components/map/FormMapWrapper.stories.tsx | 5 ++--- .../submissions/DataTableWrapper.stories.tsx | 15 ++++++++++----- jsapp/js/dataInterface.ts | 14 ++++++++------ jsapp/js/endpoints/assets.mocks.ts | 2 +- .../FormLanguagesManager.stories.tsx | 2 +- 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx index 32a5b39c52..4c7141a412 100644 --- a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx +++ b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx @@ -9,9 +9,10 @@ import { queryClientDecorator } from '#/query/queryClient.mocks' import { KOBO_MODAL_SHARED_PROPS } from '#/theme/kobo/Modal' import { openAssetTagsModal } from './openAssetTagsModal' -// TODO DEV-XXXX: Improve backend OpenAPI schema for Asset -// - Make date_created and date_modified required (they're auto-populated by Django) -// This cast is safe because the types are compatible at runtime +// Cast Orval-generated Asset to legacy AssetResponse type +// The types are structurally compatible at runtime, differences are: +// - Optional fields (date_created, date_modified) that are always present in responses +// - Legacy type has looser field types for backward compatibility const mockAsset = getApiV2AssetsRetrieveResponseMock({ uid: 'storyAssetTagsUid', name: 'Storybook Asset Tags', diff --git a/jsapp/js/components/map/FormMapWrapper.stories.tsx b/jsapp/js/components/map/FormMapWrapper.stories.tsx index 6c4f6b3fcc..2eb456f6c3 100644 --- a/jsapp/js/components/map/FormMapWrapper.stories.tsx +++ b/jsapp/js/components/map/FormMapWrapper.stories.tsx @@ -14,9 +14,8 @@ import FormMapWrapper from './formMapWrapper' const mockAssetUid = 'aTestMapAssetUid123' -// TODO DEV-XXXX: Improve backend OpenAPI schema for Asset -// - Make date_created and date_modified required (they're auto-populated by Django) -// These casts are safe because the types are compatible at runtime +// Cast Orval-generated Assets to legacy AssetResponse type +// The types are structurally compatible at runtime (see DataTableWrapper.stories.tsx for details) // Asset with only start-geopoint (no regular geopoint question) const assetWithOnlyStartGeopoint = getApiV2AssetsRetrieveResponseMock({ diff --git a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx index 7fd95bf810..14ac48e91c 100644 --- a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx +++ b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx @@ -34,11 +34,16 @@ import { ROUTES } from '#/router/routerConstants' import { withBulkProcessingBannerSessionReset } from './BulkProcessingBannerStoriesUtils' import DataTableWrapper from './DataTableWrapper' -// TODO DEV-XXXX: Orval-generated Asset and legacy AssetResponse have structural differences -// Cast Orval mocks to legacy type for stories. Main differences: -// - analysis_form_json.additional_fields: string[] vs AnalysisFormJsonField[] -// - summary.name_quality: all properties optional vs some required -// - files: object[] vs AssetResponseFile[] with different structures +// Orval-generated Asset and legacy AssetResponse have minor structural differences. +// The OpenAPI schema was improved during this migration: +// ✅ analysis_form_json.additional_fields is now properly typed as object[] (was string[]) +// +// Remaining differences are intentional (backward compatibility in legacy type): +// - Optional fields (date_created, date_modified) marked optional for POST/PATCH, always present in GET +// - summary.name_quality has all optional properties for flexibility +// - files structure has minor type differences that don't affect runtime +// +// These casts are safe because both types represent the same runtime data structure import type { AssetResponse } from '#/dataInterface' // Storybook preview root does not have a fixed height by default, which breaks flexbox stretching for table header diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index 475abbea92..f48a9a9a51 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -545,7 +545,8 @@ interface AssetSummary { columns?: string[] lock_all?: boolean lock_any?: boolean - // TODO DEV-XXXX: Backend returns languages as string[], legacy type incorrectly allowed null in array + // Backend returns languages as string[] (never null elements) + // Note: OpenAPI schema correctly specifies string[], this legacy type matches it now languages?: LangString[] row_count?: number default_translation?: string | null @@ -619,7 +620,8 @@ export interface AssetTableSettings extends AssetTableSettingsObject { export interface AssetSettings { sector?: LabelValuePair | null | {} - // TODO DEV-XXXX: Backend always returns country as array (default []), but legacy type allowed single object + // Backend always returns country as array (even when empty: []) + // Legacy code might have treated it as single object in some cases, but array is correct country?: LabelValuePair[] | null description?: string 'data-table'?: AssetTableSettings @@ -695,14 +697,14 @@ export interface AssetResponse extends AssetRequestObject { owner: string owner__username: string owner_label: string - // TODO DEV-XXXX: date_created is always present at runtime but OpenAPI schema - // marks it optional (because it has a default for write operations) + // Always present in GET responses (Django auto-populates on creation) + // OpenAPI marks optional because POST/PATCH don't require it (has default value) date_created?: string last_modified_by: string | null created_by: string | null summary: AssetSummary - // TODO DEV-XXXX: date_modified is always present at runtime but OpenAPI schema - // marks it optional (because it has a default for write operations) + // Always present in GET responses (Django auto-updates on save) + // OpenAPI marks optional because POST/PATCH don't require it (has default value) date_modified?: string date_deployed?: string | null version_id: string | null diff --git a/jsapp/js/endpoints/assets.mocks.ts b/jsapp/js/endpoints/assets.mocks.ts index 41e38adc1b..063b2f0e3e 100644 --- a/jsapp/js/endpoints/assets.mocks.ts +++ b/jsapp/js/endpoints/assets.mocks.ts @@ -44,7 +44,7 @@ const assetsMock = (override?: Partial>) => export default assetsMock // Default mock assets using Orval-generated mocks -// TODO DEV-XXXX: Orval-generated Asset.analysis_form_json.additional_fields is string[] but should be object[] +// Note: Cast to AssetResponse for backward compatibility (see DataTableWrapper.stories.tsx) const defaultMockResponse: PaginatedResponse = { count: 2, next: null, diff --git a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx index 28b397ef39..e326b5f034 100644 --- a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx +++ b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx @@ -27,7 +27,7 @@ function buildInitialAsset(): AssetResponse { } }) - // TODO DEV-XXXX: Orval-generated Asset type has incompatible structure with legacy AssetResponse + // Cast Orval Asset to legacy AssetResponse (see DataTableWrapper.stories.tsx for details) return getApiV2AssetsRetrieveResponseMock({ uid: mockAssetUid, name: 'Storybook Form Languages', From e20aa1d621ef3ef9a6ea19c6e25ee8f4faf72378 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 11:25:44 +0200 Subject: [PATCH 57/86] biome fixes --- .../authentication-allauth-headless.ts | 71 ------------------- jsapp/js/api/react-query/configuration.ts | 1 - jsapp/js/api/react-query/form-content.ts | 9 --- .../js/api/react-query/library-collections.ts | 3 - jsapp/js/api/react-query/logging.ts | 6 -- .../js/api/react-query/manage-permissions.ts | 5 -- .../manage-projects-and-library-content.ts | 26 ------- jsapp/js/api/react-query/other.ts | 18 ----- jsapp/js/api/react-query/scim.ts | 13 ---- .../api/react-query/server-logs-superusers.ts | 8 --- .../react-query/survey-data-rest-services.ts | 8 --- jsapp/js/api/react-query/survey-data.ts | 40 ----------- .../user-team-organization-usage.ts | 33 --------- .../components/reports/reports.utils.tests.ts | 2 +- scripts/orval-remove-mock-delays.js | 6 +- 15 files changed, 5 insertions(+), 244 deletions(-) diff --git a/jsapp/js/api/react-query/authentication-allauth-headless.ts b/jsapp/js/api/react-query/authentication-allauth-headless.ts index 3b22dc3321..feaf4d33d8 100644 --- a/jsapp/js/api/react-query/authentication-allauth-headless.ts +++ b/jsapp/js/api/react-query/authentication-allauth-headless.ts @@ -10594,7 +10594,6 @@ export const getApiV2AllauthBrowserV1ConfigGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/config', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10614,7 +10613,6 @@ export const getApiV2AllauthAppV1ConfigGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), ) => { return http.get('*/api/v2/allauth/app/v1/config', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10636,7 +10634,6 @@ export const getApiV2AllauthBrowserV1AuthLoginPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/login', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10658,7 +10655,6 @@ export const getApiV2AllauthAppV1AuthLoginPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/login', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10680,7 +10676,6 @@ export const getApiV2AllauthBrowserV1AuthSignupPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/signup', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10702,7 +10697,6 @@ export const getApiV2AllauthAppV1AuthSignupPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/signup', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10724,7 +10718,6 @@ export const getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler = ( ) => Promise | EmailVerificationInfoResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10746,7 +10739,6 @@ export const getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10768,7 +10760,6 @@ export const getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler = ( ) => Promise | EmailVerificationInfoResponse), ) => { return http.get('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10790,7 +10781,6 @@ export const getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10810,7 +10800,6 @@ export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/email/verify/resend', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10830,7 +10819,6 @@ export const getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/email/verify/resend', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10852,7 +10840,6 @@ export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10874,7 +10861,6 @@ export const getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/phone/verify', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10894,7 +10880,6 @@ export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify/resend', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10914,7 +10899,6 @@ export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/phone/verify/resend', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10936,7 +10920,6 @@ export const getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/reauthenticate', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10958,7 +10941,6 @@ export const getApiV2AllauthAppV1AuthReauthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/reauthenticate', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10978,7 +10960,6 @@ export const getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/password/request', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -10998,7 +10979,6 @@ export const getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/password/request', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11020,7 +11000,6 @@ export const getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler = ( ) => Promise | PasswordResetInfoResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11042,7 +11021,6 @@ export const getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11064,7 +11042,6 @@ export const getApiV2AllauthAppV1AuthPasswordResetGetMockHandler = ( ) => Promise | PasswordResetInfoResponse), ) => { return http.get('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11086,7 +11063,6 @@ export const getApiV2AllauthAppV1AuthPasswordResetPostMockHandler = ( ) => Promise | AuthenticatedByPasswordResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11119,7 +11095,6 @@ export const getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/provider/token', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11141,7 +11116,6 @@ export const getApiV2AllauthAppV1AuthProviderTokenPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/provider/token', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11163,7 +11137,6 @@ export const getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler = ( ) => Promise | ProviderSignupResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11185,7 +11158,6 @@ export const getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11207,7 +11179,6 @@ export const getApiV2AllauthAppV1AuthProviderSignupGetMockHandler = ( ) => Promise | ProviderSignupResponse), ) => { return http.get('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11229,7 +11200,6 @@ export const getApiV2AllauthAppV1AuthProviderSignupPostMockHandler = ( ) => Promise | AuthenticatedResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11251,7 +11221,6 @@ export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordAnd2FAResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/2fa/authenticate', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11273,7 +11242,6 @@ export const getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordAnd2FAResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/2fa/authenticate', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11295,7 +11263,6 @@ export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordAnd2FAResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/2fa/reauthenticate', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11317,7 +11284,6 @@ export const getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler = ( ) => Promise | AuthenticatedByPasswordAnd2FAResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/2fa/reauthenticate', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11339,7 +11305,6 @@ export const getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler = ( ) => Promise | AuthenticatedByCodeResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/auth/code/confirm', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11361,7 +11326,6 @@ export const getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler = ( ) => Promise | AuthenticatedByCodeResponse), ) => { return http.post('*/api/v2/allauth/app/v1/auth/code/confirm', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11383,7 +11347,6 @@ export const getApiV2AllauthBrowserV1AccountProvidersGetMockHandler = ( ) => Promise | ProviderAccountsResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/providers', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11405,7 +11368,6 @@ export const getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler = ( ) => Promise | ProviderAccountsResponse), ) => { return http.delete('*/api/v2/allauth/browser/v1/account/providers', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11427,7 +11389,6 @@ export const getApiV2AllauthAppV1AccountProvidersGetMockHandler = ( ) => Promise | ProviderAccountsResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/providers', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11449,7 +11410,6 @@ export const getApiV2AllauthAppV1AccountProvidersDeleteMockHandler = ( ) => Promise | ProviderAccountsResponse), ) => { return http.delete('*/api/v2/allauth/app/v1/account/providers', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11471,7 +11431,6 @@ export const getApiV2AllauthBrowserV1AccountEmailGetMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11493,7 +11452,6 @@ export const getApiV2AllauthBrowserV1AccountEmailPostMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11513,7 +11471,6 @@ export const getApiV2AllauthBrowserV1AccountEmailPutMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.put('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11535,7 +11492,6 @@ export const getApiV2AllauthBrowserV1AccountEmailPatchMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.patch('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11557,7 +11513,6 @@ export const getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.delete('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11579,7 +11534,6 @@ export const getApiV2AllauthAppV1AccountEmailGetMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11601,7 +11555,6 @@ export const getApiV2AllauthAppV1AccountEmailPostMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.post('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11621,7 +11574,6 @@ export const getApiV2AllauthAppV1AccountEmailPutMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.put('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11643,7 +11595,6 @@ export const getApiV2AllauthAppV1AccountEmailPatchMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.patch('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11665,7 +11616,6 @@ export const getApiV2AllauthAppV1AccountEmailDeleteMockHandler = ( ) => Promise | EmailAddressesResponse), ) => { return http.delete('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11685,7 +11635,6 @@ export const getApiV2AllauthBrowserV1AccountPhoneGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/phone', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11707,7 +11656,6 @@ export const getApiV2AllauthBrowserV1AccountPhonePostMockHandler = ( ) => Promise | PhoneNumberChangeResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/account/phone', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11727,7 +11675,6 @@ export const getApiV2AllauthAppV1AccountPhoneGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/phone', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11749,7 +11696,6 @@ export const getApiV2AllauthAppV1AccountPhonePostMockHandler = ( ) => Promise | PhoneNumberChangeResponse), ) => { return http.post('*/api/v2/allauth/app/v1/account/phone', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11771,7 +11717,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler = ( ) => Promise | AuthenticatorsResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/authenticators', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11793,7 +11738,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler = ( ) => Promise | AuthenticatorsResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/authenticators', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11815,7 +11759,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler = ( ) => Promise | TOTPAuthenticatorResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11837,7 +11780,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler = ) => Promise | TOTPAuthenticatorResponse), ) => { return http.post('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11857,7 +11799,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.delete('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11879,7 +11820,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler = ( ) => Promise | TOTPAuthenticatorResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11901,7 +11841,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler = ( ) => Promise | TOTPAuthenticatorResponse), ) => { return http.post('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11921,7 +11860,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), ) => { return http.delete('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11941,7 +11879,6 @@ export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHa | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -11972,7 +11909,6 @@ export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandle | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), ) => { return http.get('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -12003,7 +11939,6 @@ export const getApiV2AllauthBrowserV1AuthSessionGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/auth/session', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -12034,7 +11969,6 @@ export const getApiV2AllauthAppV1AuthSessionGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), ) => { return http.get('*/api/v2/allauth/app/v1/auth/session', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -12065,7 +11999,6 @@ export const getApiV2AllauthAppV1TokensRefreshPostMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | RefreshTokenResponse), ) => { return http.post('*/api/v2/allauth/app/v1/tokens/refresh', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -12107,7 +12040,6 @@ export const getApiV2AllauthBrowserV1AuthSessionsGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), ) => { return http.get('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -12127,7 +12059,6 @@ export const getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), ) => { return http.delete('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -12147,7 +12078,6 @@ export const getApiV2AllauthAppV1AuthSessionsGetMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), ) => { return http.get('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -12167,7 +12097,6 @@ export const getApiV2AllauthAppV1AuthSessionsDeleteMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), ) => { return http.delete('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/configuration.ts b/jsapp/js/api/react-query/configuration.ts index b69fca9b5c..9ab9781e53 100644 --- a/jsapp/js/api/react-query/configuration.ts +++ b/jsapp/js/api/react-query/configuration.ts @@ -210,7 +210,6 @@ export const getApiV2EnvironmentRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | EnvironmentResponse), ) => { return http.get('*/api/v2/environment{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/form-content.ts b/jsapp/js/api/react-query/form-content.ts index 63a09a85fc..a2af1b129a 100644 --- a/jsapp/js/api/react-query/form-content.ts +++ b/jsapp/js/api/react-query/form-content.ts @@ -1362,7 +1362,6 @@ export const getApiV2AssetSnapshotsListMockHandler = ( ) => Promise | PaginatedAssetSnapshotResponseList), ) => { return http.get('*/api/v2/asset_snapshots{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1384,7 +1383,6 @@ export const getApiV2AssetSnapshotsCreateMockHandler = ( ) => Promise | AssetSnapshotResponse), ) => { return http.post('*/api/v2/asset_snapshots{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1404,7 +1402,6 @@ export const getApiV2AssetSnapshotsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse), ) => { return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1446,7 +1443,6 @@ export const getApiV2AssetSnapshotsXformRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), ) => { return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1466,7 +1462,6 @@ export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), ) => { return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1486,7 +1481,6 @@ export const getApiV2AssetsContentRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ContentResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/content{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1504,7 +1498,6 @@ export const getApiV2AssetsTableViewRetrieveMockHandler = ( overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), ) => { return http.get('*/api/v2/assets/:uidAsset/table_view{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1526,7 +1519,6 @@ export const getApiV2AssetsValidContentRetrieveMockHandler = ( ) => Promise | AssetValidContentResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/valid_content{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1544,7 +1536,6 @@ export const getApiV2AssetsXlsRetrieveMockHandler = ( overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), ) => { return http.get('*/api/v2/assets/:uidAsset/xls{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/library-collections.ts b/jsapp/js/api/react-query/library-collections.ts index bb9afc4fa9..bda068a3a3 100644 --- a/jsapp/js/api/react-query/library-collections.ts +++ b/jsapp/js/api/react-query/library-collections.ts @@ -432,7 +432,6 @@ export const getApiV2AssetSubscriptionsListMockHandler = ( ) => Promise | PaginatedAssetSubscriptionResponseList), ) => { return http.get('*/api/v2/asset_subscriptions{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -454,7 +453,6 @@ export const getApiV2AssetSubscriptionsCreateMockHandler = ( ) => Promise | AssetSubscriptionResponse), ) => { return http.post('*/api/v2/asset_subscriptions{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -476,7 +474,6 @@ export const getApiV2AssetSubscriptionsRetrieveMockHandler = ( ) => Promise | AssetSubscriptionResponse), ) => { return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/logging.ts b/jsapp/js/api/react-query/logging.ts index b1403b29bf..a3254c0be2 100644 --- a/jsapp/js/api/react-query/logging.ts +++ b/jsapp/js/api/react-query/logging.ts @@ -973,7 +973,6 @@ export const getApiV2AccessLogsMeListMockHandler = ( ) => Promise | PaginatedAccessLogResponseList), ) => { return http.get('*/api/v2/access-logs/me{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -993,7 +992,6 @@ export const getApiV2AccessLogsMeExportListMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), ) => { return http.get('*/api/v2/access-logs/me/export{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1013,7 +1011,6 @@ export const getApiV2AccessLogsMeExportCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), ) => { return http.post('*/api/v2/access-logs/me/export{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1035,7 +1032,6 @@ export const getApiV2AssetsHistoryListMockHandler = ( ) => Promise | PaginatedHistoryListResponseList), ) => { return http.get('*/api/v2/assets/:uidAsset/history{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1055,7 +1051,6 @@ export const getApiV2AssetsHistoryActionsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | HistoryActionResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/history/actions{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1077,7 +1072,6 @@ export const getApiV2AssetsHistoryExportCreateMockHandler = ( ) => Promise | HistoryExportResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/history/export{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/manage-permissions.ts b/jsapp/js/api/react-query/manage-permissions.ts index bd2652fd13..03e422e0d2 100644 --- a/jsapp/js/api/react-query/manage-permissions.ts +++ b/jsapp/js/api/react-query/manage-permissions.ts @@ -808,7 +808,6 @@ export const getApiV2AssetsPermissionAssignmentsListMockHandler = ( ) => Promise | PermissionAssignmentResponse[]), ) => { return http.get('*/api/v2/assets/:uidAsset/permission-assignments{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -830,7 +829,6 @@ export const getApiV2AssetsPermissionAssignmentsCreateMockHandler = ( ) => Promise | PermissionAssignmentResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/permission-assignments{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -852,7 +850,6 @@ export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = ( ) => Promise | PermissionAssignmentResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -885,7 +882,6 @@ export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = ( ) => Promise | PermissionAssignmentResponse[]), ) => { return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -918,7 +914,6 @@ export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler = ) => Promise | PermissionAssignmentResponse[]), ) => { return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content.ts index 61f1df963f..03e3fd6b4a 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content.ts @@ -7261,7 +7261,6 @@ export const getApiV2AssetsListMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), ) => { return http.get('*/api/v2/assets{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7279,7 +7278,6 @@ export const getApiV2AssetsCreateMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { return http.post('*/api/v2/assets{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7297,7 +7295,6 @@ export const getApiV2AssetsRetrieveMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { return http.get('*/api/v2/assets/:uidAsset{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7315,7 +7312,6 @@ export const getApiV2AssetsPartialUpdateMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { return http.patch('*/api/v2/assets/:uidAsset{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7348,7 +7344,6 @@ export const getApiV2AssetsCountsListMockHandler = ( ) => Promise | PaginatedAssetCountResponseList), ) => { return http.get('*/api/v2/assets/:uidAsset/counts{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7368,7 +7363,6 @@ export const getApiV2AssetsDeploymentRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7388,7 +7382,6 @@ export const getApiV2AssetsDeploymentCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7408,7 +7401,6 @@ export const getApiV2AssetsDeploymentPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { return http.patch('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7430,7 +7422,6 @@ export const getApiV2AssetsVersionsListMockHandler = ( ) => Promise | PaginatedVersionListResponseList), ) => { return http.get('*/api/v2/assets/:uidAsset/versions{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7452,7 +7443,6 @@ export const getApiV2AssetsVersionsRetrieveMockHandler = ( ) => Promise | VersionRetrieveResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7470,7 +7460,6 @@ export const getApiV2AssetsXformRetrieveMockHandler = ( overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), ) => { return http.get('*/api/v2/assets/:uidAsset/xform{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7490,7 +7479,6 @@ export const getApiV2AssetsBulkCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | AssetBulkResponse), ) => { return http.post('*/api/v2/assets/bulk{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7510,7 +7498,6 @@ export const getApiV2AssetsCountsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | AssetListCount), ) => { return http.get('*/api/v2/assets/counts{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7530,7 +7517,6 @@ export const getApiV2AssetsHashRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | HashResponse), ) => { return http.get('*/api/v2/assets/hash{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7550,7 +7536,6 @@ export const getApiV2AssetsMetadataRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | AssetMetadataResponse), ) => { return http.get('*/api/v2/assets/metadata{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7572,7 +7557,6 @@ export const getApiV2AssetsMinimalListRetrieveMockHandler = ( ) => Promise | PaginatedAssetMinimalListList), ) => { return http.get('*/api/v2/assets/minimal-list{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7594,7 +7578,6 @@ export const getApiV2ImportsListMockHandler = ( ) => Promise | PaginatedImportResponseList), ) => { return http.get('*/api/v2/imports{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7614,7 +7597,6 @@ export const getApiV2ImportsCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ImportCreateResponse), ) => { return http.post('*/api/v2/imports{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7634,7 +7616,6 @@ export const getApiV2ImportsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ImportResponse), ) => { return http.get('*/api/v2/imports/:uidImport{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7656,7 +7637,6 @@ export const getApiV2ProjectOwnershipInvitesListMockHandler = ( ) => Promise | PaginatedProjectInviteResponseList), ) => { return http.get('*/api/v2/project-ownership/invites{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7678,7 +7658,6 @@ export const getApiV2ProjectOwnershipInvitesCreateMockHandler = ( ) => Promise | ProjectInviteResponse), ) => { return http.post('*/api/v2/project-ownership/invites{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7698,7 +7677,6 @@ export const getApiV2ProjectOwnershipInvitesRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse), ) => { return http.get('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7720,7 +7698,6 @@ export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = ( ) => Promise | ProjectInviteResponse), ) => { return http.patch('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7751,7 +7728,6 @@ export const getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | TransferListResponse), ) => { return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7773,7 +7749,6 @@ export const getApiV2TagsListMockHandler = ( ) => Promise | PaginatedTagListResponseList), ) => { return http.get('*/api/v2/tags{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7793,7 +7768,6 @@ export const getApiV2TagsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | TagRetrieveResponse), ) => { return http.get('*/api/v2/tags/:taguidUid{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/other.ts b/jsapp/js/api/react-query/other.ts index f5f571b08e..933c2a5802 100644 --- a/jsapp/js/api/react-query/other.ts +++ b/jsapp/js/api/react-query/other.ts @@ -2347,7 +2347,6 @@ export const getApiV2LanguagesListMockHandler = ( ) => Promise | PaginatedLanguageListList), ) => { return http.get('*/api/v2/languages{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2365,7 +2364,6 @@ export const getApiV2LanguagesRetrieveMockHandler = ( overrideResponse?: Language | ((info: Parameters[1]>[0]) => Promise | Language), ) => { return http.get('*/api/v2/languages/:code{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2387,7 +2385,6 @@ export const getApiV2PermissionsListMockHandler = ( ) => Promise | PaginatedPermissionResponseList), ) => { return http.get('*/api/v2/permissions{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2407,7 +2404,6 @@ export const getApiV2PermissionsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PermissionResponse), ) => { return http.get('*/api/v2/permissions/:codename{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2429,7 +2425,6 @@ export const getApiV2StripeAddonsListMockHandler = ( ) => Promise | PaginatedOneTimeAddOnList), ) => { return http.get('*/api/v2/stripe/addons{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2449,7 +2444,6 @@ export const getApiV2StripeAddonsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | OneTimeAddOn), ) => { return http.get('*/api/v2/stripe/addons/:id{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2469,7 +2463,6 @@ export const getApiV2StripeChangePlanRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ChangePlan), ) => { return http.get('*/api/v2/stripe/change-plan', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2489,7 +2482,6 @@ export const getApiV2StripeCheckoutLinkCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | CheckoutLink), ) => { return http.post('*/api/v2/stripe/checkout-link', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2511,7 +2503,6 @@ export const getApiV2StripeCustomerPortalCreateMockHandler = ( ) => Promise | CustomerPortalPostResponse), ) => { return http.post('*/api/v2/stripe/customer-portal', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2531,7 +2522,6 @@ export const getApiV2StripeProductsListMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PaginatedProductList), ) => { return http.get('*/api/v2/stripe/products{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2553,7 +2543,6 @@ export const getApiV2StripeSubscriptionsListMockHandler = ( ) => Promise | PaginatedSubscriptionList), ) => { return http.get('*/api/v2/stripe/subscriptions{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2573,7 +2562,6 @@ export const getApiV2StripeSubscriptionsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | Subscription), ) => { return http.get('*/api/v2/stripe/subscriptions/:id{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2595,7 +2583,6 @@ export const getApiV2TermsOfServiceListMockHandler = ( ) => Promise | TermsOfServiceResponse[]), ) => { return http.get('*/api/v2/terms-of-service{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2617,7 +2604,6 @@ export const getApiV2TermsOfServiceRetrieveMockHandler = ( ) => Promise | TermsOfServiceResponse), ) => { return http.get('*/api/v2/terms-of-service/:slug{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2639,7 +2625,6 @@ export const getApiV2TranscriptionServicesListMockHandler = ( ) => Promise | PaginatedTranscriptionServiceList), ) => { return http.get('*/api/v2/transcription-services{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2659,7 +2644,6 @@ export const getApiV2TranscriptionServicesRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | TranscriptionService), ) => { return http.get('*/api/v2/transcription-services/:code{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2681,7 +2665,6 @@ export const getApiV2TranslationServicesListMockHandler = ( ) => Promise | PaginatedTranslationServiceList), ) => { return http.get('*/api/v2/translation-services{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2701,7 +2684,6 @@ export const getApiV2TranslationServicesRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | TranslationService), ) => { return http.get('*/api/v2/translation-services/:code{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/scim.ts b/jsapp/js/api/react-query/scim.ts index c0426c2cc5..9d0304dd9a 100644 --- a/jsapp/js/api/react-query/scim.ts +++ b/jsapp/js/api/react-query/scim.ts @@ -1588,7 +1588,6 @@ export const getApiV2ScimV2GroupsListMockHandler = ( ) => Promise | PaginatedScimGroupList), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1608,7 +1607,6 @@ export const getApiV2ScimV2GroupsCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimGroup), ) => { return http.post('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1628,7 +1626,6 @@ export const getApiV2ScimV2GroupsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimGroup), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1648,7 +1645,6 @@ export const getApiV2ScimV2GroupsUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimGroup), ) => { return http.put('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1668,7 +1664,6 @@ export const getApiV2ScimV2GroupsPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimGroup), ) => { return http.patch('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1701,7 +1696,6 @@ export const getApiV2ScimV2ResourceTypesRetrieveMockHandler = ( ) => Promise | ScimV2ResourceTypesRetrieve200), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/ResourceTypes', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1723,7 +1717,6 @@ export const getApiV2ScimV2SchemasRetrieveMockHandler = ( ) => Promise | ScimV2SchemasRetrieve200), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/Schemas', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1745,7 +1738,6 @@ export const getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler = ( ) => Promise | ScimV2ServiceProviderConfigRetrieve200), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/ServiceProviderConfig', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1765,7 +1757,6 @@ export const getApiV2ScimV2UsersListMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PaginatedScimUserList), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1785,7 +1776,6 @@ export const getApiV2ScimV2UsersCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimUser), ) => { return http.post('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1803,7 +1793,6 @@ export const getApiV2ScimV2UsersRetrieveMockHandler = ( overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), ) => { return http.get('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1821,7 +1810,6 @@ export const getApiV2ScimV2UsersUpdateMockHandler = ( overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), ) => { return http.put('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1841,7 +1829,6 @@ export const getApiV2ScimV2UsersPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ScimUser), ) => { return http.patch('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/server-logs-superusers.ts b/jsapp/js/api/react-query/server-logs-superusers.ts index 4dc5b1a3a5..46f6247dfb 100644 --- a/jsapp/js/api/react-query/server-logs-superusers.ts +++ b/jsapp/js/api/react-query/server-logs-superusers.ts @@ -1952,7 +1952,6 @@ export const getApiV2AccessLogsListMockHandler = ( ) => Promise | PaginatedSuperUserAccessLogResponseList), ) => { return http.get('*/api/v2/access-logs{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1972,7 +1971,6 @@ export const getApiV2AccessLogsExportListMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), ) => { return http.get('*/api/v2/access-logs/export{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1992,7 +1990,6 @@ export const getApiV2AccessLogsExportCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), ) => { return http.post('*/api/v2/access-logs/export{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2014,7 +2011,6 @@ export const getApiV2AuditLogsListMockHandler = ( ) => Promise | PaginatedAuditLogResponseList), ) => { return http.get('*/api/v2/audit-logs{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2036,7 +2032,6 @@ export const getApiV2ProjectHistoryLogsListMockHandler = ( ) => Promise | PaginatedProjectHistoryLogResponseList), ) => { return http.get('*/api/v2/project-history-logs{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2056,7 +2051,6 @@ export const getApiV2ProjectHistoryLogsExportRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse), ) => { return http.get('*/api/v2/project-history-logs/export{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2078,7 +2072,6 @@ export const getApiV2ProjectHistoryLogsExportCreateMockHandler = ( ) => Promise | ExportHistoryResponse), ) => { return http.post('*/api/v2/project-history-logs/export{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2100,7 +2093,6 @@ export const getApiV2UserReportsListMockHandler = ( ) => Promise | PaginatedUserReportsListResponseList), ) => { return http.get('*/api/v2/user-reports{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/survey-data-rest-services.ts b/jsapp/js/api/react-query/survey-data-rest-services.ts index f0d725eb2a..7a64bb0490 100644 --- a/jsapp/js/api/react-query/survey-data-rest-services.ts +++ b/jsapp/js/api/react-query/survey-data-rest-services.ts @@ -1214,7 +1214,6 @@ export const getApiV2AssetsHooksListMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PaginatedHookList), ) => { return http.get('*/api/v2/assets/:uidAsset/hooks{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1232,7 +1231,6 @@ export const getApiV2AssetsHooksCreateMockHandler = ( overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), ) => { return http.post('*/api/v2/assets/:uidAsset/hooks{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1250,7 +1248,6 @@ export const getApiV2AssetsHooksRetrieveMockHandler = ( overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), ) => { return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1268,7 +1265,6 @@ export const getApiV2AssetsHooksPartialUpdateMockHandler = ( overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), ) => { return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1299,7 +1295,6 @@ export const getApiV2AssetsHooksLogsListMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PaginatedHookLogList), ) => { return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1317,7 +1312,6 @@ export const getApiV2AssetsHooksLogsRetrieveMockHandler = ( overrideResponse?: HookLog | ((info: Parameters[1]>[0]) => Promise | HookLog), ) => { return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1337,7 +1331,6 @@ export const getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | LogsRetryResponse), ) => { return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1357,7 +1350,6 @@ export const getApiV2AssetsHooksRetryPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | HookRetryResponse), ) => { return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/survey-data.ts b/jsapp/js/api/react-query/survey-data.ts index b690b1264d..bf9bae8854 100644 --- a/jsapp/js/api/react-query/survey-data.ts +++ b/jsapp/js/api/react-query/survey-data.ts @@ -8106,7 +8106,6 @@ export const getApiV2AssetsAdvancedFeaturesListMockHandler = ( ) => Promise | AdvancedFeatureResponse[]), ) => { return http.get('*/api/v2/assets/:uidAsset/advanced-features{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8128,7 +8127,6 @@ export const getApiV2AssetsAdvancedFeaturesCreateMockHandler = ( ) => Promise | AdvancedFeatureCreateResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/advanced-features{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8150,7 +8148,6 @@ export const getApiV2AssetsAdvancedFeaturesRetrieveMockHandler = ( ) => Promise | AdvancedFeatureResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8172,7 +8169,6 @@ export const getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler = ( ) => Promise | AdvancedFeatureResponse), ) => { return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8194,7 +8190,6 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler = ( ) => Promise | BulkActionListResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8216,7 +8211,6 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler = ( ) => Promise | BulkActionCreateResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8236,7 +8230,6 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8256,7 +8249,6 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), ) => { return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8289,7 +8281,6 @@ export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = ( ) => Promise | AssetAttachmentAudioDurationResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8322,7 +8313,6 @@ export const getApiV2AssetsDataListMockHandler = ( ) => Promise | PaginatedDataResponseList), ) => { return http.get('*/api/v2/assets/:uidAsset/data{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8342,7 +8332,6 @@ export const getApiV2AssetsDataRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | DataResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/data/:id{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8373,7 +8362,6 @@ export const getApiV2AssetsDataDuplicateCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | DataResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8393,7 +8381,6 @@ export const getApiV2AssetsDataEditRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/data/:id/edit{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8413,7 +8400,6 @@ export const getApiV2AssetsDataEnketoEditRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8433,7 +8419,6 @@ export const getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8453,7 +8438,6 @@ export const getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8473,7 +8457,6 @@ export const getApiV2AssetsDataEnketoViewRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8495,7 +8478,6 @@ export const getApiV2AssetsDataValidationStatusRetrieveMockHandler = ( ) => Promise | DataValidationStatusUpdateResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8517,7 +8499,6 @@ export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = ( ) => Promise | DataValidationStatusUpdateResponse), ) => { return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8550,7 +8531,6 @@ export const getApiV2AssetsDataSupplementRetrieveMockHandler = ( ) => Promise | DataSupplementResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8572,7 +8552,6 @@ export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = ( ) => Promise | DataSupplementResponse), ) => { return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8627,7 +8606,6 @@ export const getApiV2AssetsDataBulkPartialUpdateMockHandler = ( ) => Promise | DataBulkUpdateResponse), ) => { return http.patch('*/api/v2/assets/:uidAsset/data/bulk{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8658,7 +8636,6 @@ export const getApiV2AssetsDataSupplementsBulkCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | BulkAcceptResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8678,7 +8655,6 @@ export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | DataStatusesUpdate), ) => { return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8711,7 +8687,6 @@ export const getApiV2AssetsExportSettingsListMockHandler = ( ) => Promise | PaginatedExportSettingResponseList), ) => { return http.get('*/api/v2/assets/:uidAsset/export-settings{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8733,7 +8708,6 @@ export const getApiV2AssetsExportSettingsCreateMockHandler = ( ) => Promise | ExportSettingResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/export-settings{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8753,7 +8727,6 @@ export const getApiV2AssetsExportSettingsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8775,7 +8748,6 @@ export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = ( ) => Promise | ExportSettingResponse), ) => { return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8819,7 +8791,6 @@ export const getApiV2AssetsExportsListMockHandler = ( ) => Promise | PaginatedExportResponseList), ) => { return http.get('*/api/v2/assets/:uidAsset/exports{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8839,7 +8810,6 @@ export const getApiV2AssetsExportsCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ExportResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/exports{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8859,7 +8829,6 @@ export const getApiV2AssetsExportsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ExportResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8892,7 +8861,6 @@ export const getApiV2AssetsFilesListMockHandler = ( ) => Promise | PaginatedFilesResponseList), ) => { return http.get('*/api/v2/assets/:uidAsset/files{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8912,7 +8880,6 @@ export const getApiV2AssetsFilesCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | FilesResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/files{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8932,7 +8899,6 @@ export const getApiV2AssetsFilesRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | FilesResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/files/:uidFile{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8976,7 +8942,6 @@ export const getApiV2AssetsPairedDataListMockHandler = ( ) => Promise | PaginatedPairedDataResponseList), ) => { return http.get('*/api/v2/assets/:uidAsset/paired-data{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -8996,7 +8961,6 @@ export const getApiV2AssetsPairedDataCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), ) => { return http.post('*/api/v2/assets/:uidAsset/paired-data{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -9016,7 +8980,6 @@ export const getApiV2AssetsPairedDataRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -9036,7 +8999,6 @@ export const getApiV2AssetsPairedDataPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), ) => { return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -9067,7 +9029,6 @@ export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ExternalResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -9087,7 +9048,6 @@ export const getApiV2AssetsReportsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | ReportResponse), ) => { return http.get('*/api/v2/assets/:uidAsset/reports{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage.ts index 3f223bdb4a..411f880214 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage.ts @@ -5146,7 +5146,6 @@ export const getApiV2AssetUsageListMockHandler = ( ) => Promise | PaginatedAssetUsageResponseList), ) => { return http.get('*/api/v2/asset_usage{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5168,7 +5167,6 @@ export const getApiV2OrganizationsListMockHandler = ( ) => Promise | PaginatedOrganizationResponseList), ) => { return http.get('*/api/v2/organizations{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5188,7 +5186,6 @@ export const getApiV2OrganizationsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), ) => { return http.get('*/api/v2/organizations/:uidOrganization{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5208,7 +5205,6 @@ export const getApiV2OrganizationsPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), ) => { return http.patch('*/api/v2/organizations/:uidOrganization{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5230,7 +5226,6 @@ export const getApiV2OrganizationsAssetUsageListMockHandler = ( ) => Promise | PaginatedCustomAssetUsageList), ) => { return http.get('*/api/v2/organizations/:uidOrganization/asset_usage{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5250,7 +5245,6 @@ export const getApiV2OrganizationsAssetsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), ) => { return http.get('*/api/v2/organizations/:uidOrganization/assets{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5270,7 +5264,6 @@ export const getApiV2OrganizationsAssetsCountsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | AssetListCount), ) => { return http.get('*/api/v2/organizations/:uidOrganization/assets/counts{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5292,7 +5285,6 @@ export const getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler = ( ) => Promise | PaginatedAssetMinimalListList), ) => { return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5314,7 +5306,6 @@ export const getApiV2OrganizationsInvitesListMockHandler = ( ) => Promise | PaginatedInviteResponseList), ) => { return http.get('*/api/v2/organizations/:uidOrganization/invites{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5334,7 +5325,6 @@ export const getApiV2OrganizationsInvitesCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | InviteCreateResponse), ) => { return http.post('*/api/v2/organizations/:uidOrganization/invites{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5354,7 +5344,6 @@ export const getApiV2OrganizationsInvitesRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | InviteResponse), ) => { return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5374,7 +5363,6 @@ export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | InviteResponse), ) => { return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5407,7 +5395,6 @@ export const getApiV2OrganizationsMembersListMockHandler = ( ) => Promise | PaginatedMemberListResponseList), ) => { return http.get('*/api/v2/organizations/:uidOrganization/members{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5427,7 +5414,6 @@ export const getApiV2OrganizationsMembersRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), ) => { return http.get('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5447,7 +5433,6 @@ export const getApiV2OrganizationsMembersPartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), ) => { return http.patch('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5480,7 +5465,6 @@ export const getApiV2OrganizationsServiceUsageRetrieveMockHandler = ( ) => Promise | OrganizationServiceUsageResponse), ) => { return http.get('*/api/v2/organizations/:uidOrganization/service_usage{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5502,7 +5486,6 @@ export const getApiV2ProjectViewsListMockHandler = ( ) => Promise | PaginatedProjectViewListResponseList), ) => { return http.get('*/api/v2/project-views{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5524,7 +5507,6 @@ export const getApiV2ProjectViewsRetrieveMockHandler = ( ) => Promise | ProjectViewListResponse), ) => { return http.get('*/api/v2/project-views/:uidProjectView{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5546,7 +5528,6 @@ export const getApiV2ProjectViewsExportRetrieveMockHandler = ( ) => Promise | ProjectViewExportResponse), ) => { return http.get('*/api/v2/project-views/:uidProjectView/:objType/export{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5568,7 +5549,6 @@ export const getApiV2ProjectViewsExportCreateMockHandler = ( ) => Promise | ProjectViewExportCreateResponse), ) => { return http.post('*/api/v2/project-views/:uidProjectView/:objType/export{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5590,7 +5570,6 @@ export const getApiV2ProjectViewsAssetsRetrieveMockHandler = ( ) => Promise | PaginatedProjectViewAssetResponseList), ) => { return http.get('*/api/v2/project-views/:uidProjectView/assets{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5610,7 +5589,6 @@ export const getApiV2ProjectViewsAssetsCountsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | AssetListCount), ) => { return http.get('*/api/v2/project-views/:uidProjectView/assets/counts{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5632,7 +5610,6 @@ export const getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler = ( ) => Promise | PaginatedAssetMinimalListList), ) => { return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5654,7 +5631,6 @@ export const getApiV2ProjectViewsUsersRetrieveMockHandler = ( ) => Promise | PaginatedProjectViewUserResponseList), ) => { return http.get('*/api/v2/project-views/:uidProjectView/users{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5676,7 +5652,6 @@ export const getApiV2ServiceUsageListMockHandler = ( ) => Promise | ServiceUsageResponse[]), ) => { return http.get('*/api/v2/service_usage{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5698,7 +5673,6 @@ export const getApiV2UsersListMockHandler = ( ) => Promise | PaginatedUserListResponseList), ) => { return http.get('*/api/v2/users{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5718,7 +5692,6 @@ export const getApiV2UsersRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | UserRetrieveResponse), ) => { return http.get('*/api/v2/users/:username{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5738,7 +5711,6 @@ export const getMeRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | MeListResponse), ) => { return http.get('*/me{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5758,7 +5730,6 @@ export const getMePartialUpdateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | MeListResponse), ) => { return http.patch('*/me{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5791,7 +5762,6 @@ export const getMeEmailsListMockHandler = ( ) => Promise | PaginatedEmailAddressList), ) => { return http.get('*/me/emails{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5811,7 +5781,6 @@ export const getMeEmailsCreateMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | EmailAddress), ) => { return http.post('*/me/emails{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5833,7 +5802,6 @@ export const getMeSocialAccountsListMockHandler = ( ) => Promise | PaginatedSocialAccountList), ) => { return http.get('*/me/social-accounts{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -5853,7 +5821,6 @@ export const getMeSocialAccountsRetrieveMockHandler = ( | ((info: Parameters[1]>[0]) => Promise | SocialAccount), ) => { return http.get('*/me/social-accounts/:provider/:uidSocialAccount{/}?', async (info) => { - return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/components/reports/reports.utils.tests.ts b/jsapp/js/components/reports/reports.utils.tests.ts index 6b7f97864b..7fb8d32bcf 100644 --- a/jsapp/js/components/reports/reports.utils.tests.ts +++ b/jsapp/js/components/reports/reports.utils.tests.ts @@ -135,7 +135,7 @@ describe('populateSelectQuestionLabels', () => { style: reportStyleFactory(), } - // TODO DEV-XXXX: Improve backend OpenAPI schema for Asset + // TODO: Improve backend OpenAPI schema for Asset // - Make date_created and date_modified required (they're auto-populated by Django) const asset = getApiV2AssetsRetrieveResponseMock({ content: { diff --git a/scripts/orval-remove-mock-delays.js b/scripts/orval-remove-mock-delays.js index 5f8c448dc7..c446a22bf4 100644 --- a/scripts/orval-remove-mock-delays.js +++ b/scripts/orval-remove-mock-delays.js @@ -36,8 +36,10 @@ function removeDelays(filePath) { source = source.replace(/import\s+{\s*delay\s*}\s+from\s+['"]msw['"][\s\r\n]*/g, '') // Remove all `await delay(...)` calls from handler bodies - // Example: "await delay(1000)" becomes a blank line - source = source.replace(/\s*await\s+delay\(\d+\)[\s\r\n]*/g, '\n') + // Handles both formats: + // 1. Delay on same line: "=> {await delay(1000);\n" becomes "=> {\n" + // 2. Delay on own line: " await delay(1000)\n" becomes "" + source = source.replace(/await\s+delay\(\d+\)\s*;?\s*/g, '') if (source !== originalSource) { fs.writeFileSync(filePath, source, 'utf-8') From a2c827e56fb8bcb4acc7caa337755e7c09187f32 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 11:27:22 +0200 Subject: [PATCH 58/86] biome fix --- jsapp/js/components/activity/FormActivity.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsapp/js/components/activity/FormActivity.stories.tsx b/jsapp/js/components/activity/FormActivity.stories.tsx index c3c6b4e3af..5019b1b306 100644 --- a/jsapp/js/components/activity/FormActivity.stories.tsx +++ b/jsapp/js/components/activity/FormActivity.stories.tsx @@ -1,11 +1,11 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { reactRouterParameters, withRouter } from 'storybook-addon-remix-react-router' import { expect, userEvent, waitFor, within } from 'storybook/test' +import { getApiV2AssetsHistoryActionsRetrieveMockHandler } from '#/api/react-query/logging' import assetHistoryMock, { assetHistoryMockWithOngoingBulkProcessing, mockAssetUid, } from '#/endpoints/assetHistory.mocks' -import { getApiV2AssetsHistoryActionsRetrieveMockHandler } from '#/api/react-query/logging' import { bulkActionCancelMock } from '#/endpoints/bulkActions.mocks' import { queryClientDecorator } from '#/query/queryClient.mocks' import { ROUTES } from '#/router/routerConstants' From 451b6f94c0226e689c78cabf7bc60d200fb16fd7 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 11:56:34 +0200 Subject: [PATCH 59/86] fix darker --- kpi/schema_extensions/v2/assets/extensions.py | 13 +++++---- kpi/schema_extensions/v2/assets/schema.py | 24 ++++++++++++---- kpi/schema_extensions/v2/data/extensions.py | 7 +++-- kpi/schema_extensions/v2/me/extensions.py | 28 ++++++++++++++++--- kpi/utils/schema_extensions/mixins.py | 3 +- 5 files changed, 56 insertions(+), 19 deletions(-) diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index ca7f8f4d25..43b7af4ca8 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -35,7 +35,6 @@ PERMISSION_ASSIGNMENT_SCHEMA, REPORT_STYLE_SCHEMA, SURVEY_CHOICE_SCHEMA, - SURVEY_ROW_SCHEMA, ) @@ -95,7 +94,8 @@ def map_serializer_field(self, auto_schema, direction): }, # required: type of additional field 'name': GENERIC_STRING_SCHEMA, # required 'dtpath': GENERIC_STRING_SCHEMA, # required: data table path - 'label': GENERIC_STRING_SCHEMA, # optional: question label or 'source'/'verified' + # optional: question label or 'source'/'verified' + 'label': GENERIC_STRING_SCHEMA, 'choices': build_array_type( build_object_type( required=['uuid', 'labels'], @@ -307,7 +307,8 @@ class ContentFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.ContentField' def map_serializer_field(self, auto_schema, direction): - # WriteableJsonWithSchemaField accepts JSON string for writes, returns object for reads + # WriteableJsonWithSchemaField accepts JSON string for writes, + # returns object for reads if direction == 'request': return build_basic_type(OpenApiTypes.STR) return ASSET_CONTENT_SCHEMA @@ -559,8 +560,10 @@ def map_serializer_field(self, auto_schema, direction): return build_object_type( properties={ 'default': REPORT_STYLE_SCHEMA, - 'specified': GENERIC_OBJECT_SCHEMA, # additionalProperties pattern for dynamic row names - 'kuid_names': GENERIC_OBJECT_SCHEMA, # additionalProperties pattern for dynamic row names + # additionalProperties pattern for dynamic row names + 'specified': GENERIC_OBJECT_SCHEMA, + # additionalProperties pattern for dynamic row names + 'kuid_names': GENERIC_OBJECT_SCHEMA, } ) diff --git a/kpi/schema_extensions/v2/assets/schema.py b/kpi/schema_extensions/v2/assets/schema.py index a6d8de115c..39e7c337d2 100644 --- a/kpi/schema_extensions/v2/assets/schema.py +++ b/kpi/schema_extensions/v2/assets/schema.py @@ -85,7 +85,9 @@ 'url': build_basic_type(OpenApiTypes.STR), 'user': build_basic_type(OpenApiTypes.STR), 'permission': build_basic_type(OpenApiTypes.STR), - 'partial_permissions': build_array_type(schema=PARTIAL_PERMISSION_FILTER_SCHEMA), + 'partial_permissions': build_array_type( + schema=PARTIAL_PERMISSION_FILTER_SCHEMA + ), 'label': { 'oneOf': [ build_basic_type(OpenApiTypes.STR), @@ -147,14 +149,22 @@ properties={ 'transcript': build_object_type( properties={ - 'values': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), - 'languages': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + 'values': build_array_type( + schema=build_basic_type(OpenApiTypes.STR) + ), + 'languages': build_array_type( + schema=build_basic_type(OpenApiTypes.STR) + ), } ), 'translation': build_object_type( properties={ - 'values': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), - 'languages': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + 'values': build_array_type( + schema=build_basic_type(OpenApiTypes.STR) + ), + 'languages': build_array_type( + schema=build_basic_type(OpenApiTypes.STR) + ), } ), 'qual': build_object_type( @@ -245,6 +255,8 @@ schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} ), 'translations_0': {**build_basic_type(OpenApiTypes.STR), 'nullable': True}, - 'kobo--locking-profiles': build_array_type(schema=build_basic_type(OpenApiTypes.OBJECT)), + 'kobo--locking-profiles': build_array_type( + schema=build_basic_type(OpenApiTypes.OBJECT) + ), } ) diff --git a/kpi/schema_extensions/v2/data/extensions.py b/kpi/schema_extensions/v2/data/extensions.py index d27e1fffe5..273de2a747 100644 --- a/kpi/schema_extensions/v2/data/extensions.py +++ b/kpi/schema_extensions/v2/data/extensions.py @@ -340,9 +340,10 @@ def map_serializer_field(self, auto_schema, direction): # } # } # - # The six oneOf options represent all possible action types that can generate - # supplemental data. Each has a unique property name that acts as a discriminator, - # allowing TypeScript to narrow the union based on which property exists. + # The six oneOf options represent all possible action types that can + # generate supplemental data. Each has a unique property name that acts + # as a discriminator, allowing TypeScript to narrow the union based on + # which property exists. return { 'oneOf': [ # Option 1: Human-generated audio/video transcription diff --git a/kpi/schema_extensions/v2/me/extensions.py b/kpi/schema_extensions/v2/me/extensions.py index c6ae0fd1f1..6625b8fd3a 100644 --- a/kpi/schema_extensions/v2/me/extensions.py +++ b/kpi/schema_extensions/v2/me/extensions.py @@ -50,10 +50,30 @@ def map_serializer_field(self, auto_schema, direction): build_basic_type(OpenApiTypes.BOOL), build_object_type( properties={ - 'short': {'oneOf': [GENERIC_STRING_SCHEMA, build_basic_type(OpenApiTypes.BOOL)]}, - 'long': {'oneOf': [GENERIC_STRING_SCHEMA, build_basic_type(OpenApiTypes.BOOL)]}, - 'branch': {'oneOf': [GENERIC_STRING_SCHEMA, build_basic_type(OpenApiTypes.BOOL)]}, - 'tag': {'oneOf': [GENERIC_STRING_SCHEMA, build_basic_type(OpenApiTypes.BOOL)]}, + 'short': { + 'oneOf': [ + GENERIC_STRING_SCHEMA, + build_basic_type(OpenApiTypes.BOOL), + ] + }, + 'long': { + 'oneOf': [ + GENERIC_STRING_SCHEMA, + build_basic_type(OpenApiTypes.BOOL), + ] + }, + 'branch': { + 'oneOf': [ + GENERIC_STRING_SCHEMA, + build_basic_type(OpenApiTypes.BOOL), + ] + }, + 'tag': { + 'oneOf': [ + GENERIC_STRING_SCHEMA, + build_basic_type(OpenApiTypes.BOOL), + ] + }, } ), ] diff --git a/kpi/utils/schema_extensions/mixins.py b/kpi/utils/schema_extensions/mixins.py index ef57d21e72..13aa9cf1b9 100644 --- a/kpi/utils/schema_extensions/mixins.py +++ b/kpi/utils/schema_extensions/mixins.py @@ -112,7 +112,8 @@ def _register_qual_data_schema_components(self, auto_schema): required=['status', 'error', 'uuid'], ), ], - # Tell code generators that 'status' discriminates between the oneOf branches + # Tell code generators that 'status' discriminates + # between the oneOf branches 'discriminator': { 'propertyName': 'status', }, From 30722de22707b21d54dca30f52059b5efb13d19e Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 12:55:50 +0200 Subject: [PATCH 60/86] improve tests --- .../submissions/DataTableWrapper.stories.tsx | 4 ---- .../useDataTableBulkActions.tests.ts | 23 +++++++------------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx index 14ac48e91c..73e503e07e 100644 --- a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx +++ b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx @@ -10,7 +10,6 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import type { DecoratorFunction } from '@storybook/types' import React, { useEffect } from 'react' import { reactRouterParameters, withRouter } from 'storybook-addon-remix-react-router' -// import { expect, waitFor } from 'storybook/test' import subscriptionStore from '#/account/subscriptionStore' import { actions } from '#/actions' import { ActionIdEnum } from '#/api/models/actionIdEnum' @@ -35,9 +34,6 @@ import { withBulkProcessingBannerSessionReset } from './BulkProcessingBannerStor import DataTableWrapper from './DataTableWrapper' // Orval-generated Asset and legacy AssetResponse have minor structural differences. -// The OpenAPI schema was improved during this migration: -// ✅ analysis_form_json.additional_fields is now properly typed as object[] (was string[]) -// // Remaining differences are intentional (backward compatibility in legacy type): // - Optional fields (date_created, date_modified) marked optional for POST/PATCH, always present in GET // - summary.name_quality has all optional properties for flexibility diff --git a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts index a38a5f6942..5f468c2e89 100644 --- a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts +++ b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts @@ -2,9 +2,9 @@ import { renderHook } from '@testing-library/react' import { ActionIdEnum } from '#/api/models/actionIdEnum' import type { BulkActionResponse } from '#/api/models/bulkActionResponse' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' -import { BulkActionSubmissionStatusResponseStatusEnum } from '#/api/models/bulkActionSubmissionStatusResponseStatusEnum' import { getAssetsAdvancedFeaturesBulkActionsListQueryKey, + getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock, useAssetsAdvancedFeaturesBulkActionsList, } from '#/api/react-query/survey-data' import { useFeatureFlag } from '#/featureFlags' @@ -12,7 +12,9 @@ import { useSession } from '#/stores/useSession' import { getBulkActionsPollingIntervalMs, useDataTableBulkActions } from './useDataTableBulkActions' jest.mock('#/api/react-query/survey-data', () => { + const actual = jest.requireActual('#/api/react-query/survey-data') return { + ...actual, getAssetsAdvancedFeaturesBulkActionsListQueryKey: jest.fn( (uidAsset: string, params?: unknown) => ['api', 'v2', 'assets', uidAsset, 'advanced-features', 'bulk-actions', ...(params ? [params] : [])] as const, @@ -47,38 +49,29 @@ jest.mock('#/envStore', () => { } }) -// Inline factory to avoid importing from mocked module +// Use Orval-generated mock factory for type-safe bulk action mocks function buildBulkAction( status: BulkActionResponseStatusEnum, createdByUsername: string, overrides: Partial = {}, ): BulkActionResponse { - const { progress = 0, ...restOverrides } = overrides - - return { + return getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ uid: `bulk-${status}-${createdByUsername}`, status, action_id: ActionIdEnum.automatic_google_transcription, question_xpath: 'Your_name', submission_uuids: ['submission-1'], - submission_statuses: [ - { - uuid: 'submission-1', - status: BulkActionSubmissionStatusResponseStatusEnum.in_progress, - error: null, - }, - ], params: { language: 'fr', }, - progress, + progress: 0, created_by: { username: createdByUsername, }, date_created: '2026-01-01T00:00:00Z', date_modified: '2026-01-01T00:00:00Z', - ...restOverrides, - } + ...overrides, + }) } describe('useDataTableBulkActions', () => { From a17c13d934441fc00be861ded727cbf095d5a88c Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 13:02:33 +0200 Subject: [PATCH 61/86] bring back comments, simplify tests --- jsapp/js/assetUtils.tests.js | 41 +++++++++++++-------------- jsapp/js/endpoints/formMedia.mocks.ts | 13 +++++++++ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/jsapp/js/assetUtils.tests.js b/jsapp/js/assetUtils.tests.js index 8ea9e9ee8b..3c459d2082 100644 --- a/jsapp/js/assetUtils.tests.js +++ b/jsapp/js/assetUtils.tests.js @@ -28,9 +28,6 @@ import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-pro import { DeleteBlockerReason, getSurveyFlatPaths, userCanDeleteAssets } from '#/assetUtils' import { surveyWithAllPossibleGroups, surveyWithGroups } from '#/assetUtils.mocks' -// Helper wrapper for legacy test code -const assetFactory = (overrides) => getApiV2AssetsRetrieveResponseMock(overrides) - describe('getSurveyFlatPaths', () => { it('should return a list of paths for all questions', () => { const test = getSurveyFlatPaths(surveyWithGroups) @@ -167,15 +164,15 @@ describe('userCanDeleteAssets', () => { it('can delete any asset regardless of ownership or submissions', () => { const assets = [ - assetFactory({ created_by: 'bob', deployment__submission_count: 100 }), - assetFactory({ created_by: null, deployment__submission_count: 0 }), + getApiV2AssetsRetrieveResponseMock({ created_by: 'bob', deployment__submission_count: 100 }), + getApiV2AssetsRetrieveResponseMock({ created_by: null, deployment__submission_count: 0 }), ] const results = userCanDeleteAssets(assets) expect(results.every((r) => r.canDelete)).to.be.true }) it('returns canDelete: true even when the project was created by someone else', () => { - const asset = assetFactory({ created_by: 'carol', deployment__submission_count: 999 }) + const asset = getApiV2AssetsRetrieveResponseMock({ created_by: 'carol', deployment__submission_count: 999 }) const [result] = userCanDeleteAssets([asset]) expect(result.canDelete).to.be.true }) @@ -187,13 +184,13 @@ describe('userCanDeleteAssets', () => { }) it('can delete own project with no submissions', () => { - const asset = assetFactory({ created_by: 'alice', deployment__submission_count: 0 }) + const asset = getApiV2AssetsRetrieveResponseMock({ created_by: 'alice', deployment__submission_count: 0 }) const [result] = userCanDeleteAssets([asset]) expect(result.canDelete).to.be.true }) it('is blocked from deleting own project that has submissions', () => { - const asset = assetFactory({ created_by: 'alice', deployment__submission_count: 5 }) + const asset = getApiV2AssetsRetrieveResponseMock({ created_by: 'alice', deployment__submission_count: 5 }) const [result] = userCanDeleteAssets([asset]) expect(result.canDelete).to.be.false if (!result.canDelete) { @@ -202,7 +199,7 @@ describe('userCanDeleteAssets', () => { }) it("is blocked from deleting another member's project (no submissions)", () => { - const asset = assetFactory({ created_by: 'bob', deployment__submission_count: 0 }) + const asset = getApiV2AssetsRetrieveResponseMock({ created_by: 'bob', deployment__submission_count: 0 }) const [result] = userCanDeleteAssets([asset]) expect(result.canDelete).to.be.false if (!result.canDelete) { @@ -211,7 +208,7 @@ describe('userCanDeleteAssets', () => { }) it('permissions blocker takes priority when project belongs to another member and has submissions', () => { - const asset = assetFactory({ created_by: 'bob', deployment__submission_count: 10 }) + const asset = getApiV2AssetsRetrieveResponseMock({ created_by: 'bob', deployment__submission_count: 10 }) const [result] = userCanDeleteAssets([asset]) expect(result.canDelete).to.be.false if (!result.canDelete) { @@ -220,7 +217,7 @@ describe('userCanDeleteAssets', () => { }) it('is blocked when created_by is null', () => { - const asset = assetFactory({ created_by: null, deployment__submission_count: 0 }) + const asset = getApiV2AssetsRetrieveResponseMock({ created_by: null, deployment__submission_count: 0 }) const [result] = userCanDeleteAssets([asset]) expect(result.canDelete).to.be.false if (!result.canDelete) { @@ -230,10 +227,10 @@ describe('userCanDeleteAssets', () => { it('returns per-asset results in input order for a mixed set', () => { const assets = [ - assetFactory({ uid: 'a1', created_by: 'alice', deployment__submission_count: 0 }), // ok - assetFactory({ uid: 'a2', created_by: 'alice', deployment__submission_count: 3 }), // submissions - assetFactory({ uid: 'a3', created_by: 'bob', deployment__submission_count: 0 }), // permissions - assetFactory({ uid: 'a4', created_by: 'alice', deployment__submission_count: 0 }), // ok + getApiV2AssetsRetrieveResponseMock({ uid: 'a1', created_by: 'alice', deployment__submission_count: 0 }), // ok + getApiV2AssetsRetrieveResponseMock({ uid: 'a2', created_by: 'alice', deployment__submission_count: 3 }), // submissions + getApiV2AssetsRetrieveResponseMock({ uid: 'a3', created_by: 'bob', deployment__submission_count: 0 }), // permissions + getApiV2AssetsRetrieveResponseMock({ uid: 'a4', created_by: 'alice', deployment__submission_count: 0 }), // ok ] const results = userCanDeleteAssets(assets) @@ -247,7 +244,7 @@ describe('userCanDeleteAssets', () => { }) it('preserves the original asset reference in each result', () => { - const asset = assetFactory({ uid: 'unique-uid', created_by: 'alice' }) + const asset = getApiV2AssetsRetrieveResponseMock({ uid: 'unique-uid', created_by: 'alice' }) const [result] = userCanDeleteAssets([asset]) expect(result.asset).to.equal(asset) }) @@ -256,7 +253,7 @@ describe('userCanDeleteAssets', () => { describe('MMO owner', () => { it('can delete any asset (owner is not subject to MMO member restrictions)', () => { mockedGetQueryData.mockReturnValue(makeOrgResponse({ is_mmo: true, request_user_role: MemberRoleEnum.owner })) - const asset = assetFactory({ created_by: 'bob', deployment__submission_count: 50 }) + const asset = getApiV2AssetsRetrieveResponseMock({ created_by: 'bob', deployment__submission_count: 50 }) const [result] = userCanDeleteAssets([asset]) expect(result.canDelete).to.be.true }) @@ -266,8 +263,8 @@ describe('userCanDeleteAssets', () => { it('can delete all assets regardless of ownership or submissions', () => { mockedGetQueryData.mockReturnValue(makeOrgResponse({ is_mmo: false, request_user_role: MemberRoleEnum.member })) const assets = [ - assetFactory({ created_by: 'bob', deployment__submission_count: 10 }), - assetFactory({ created_by: null }), + getApiV2AssetsRetrieveResponseMock({ created_by: 'bob', deployment__submission_count: 10 }), + getApiV2AssetsRetrieveResponseMock({ created_by: null }), ] const results = userCanDeleteAssets(assets) expect(results.every((r) => r.canDelete)).to.be.true @@ -277,21 +274,21 @@ describe('userCanDeleteAssets', () => { describe('edge cases', () => { it('treats missing org cache data as no restrictions', () => { mockedGetQueryData.mockReturnValue(undefined) - const asset = assetFactory({ created_by: 'bob', deployment__submission_count: 99 }) + const asset = getApiV2AssetsRetrieveResponseMock({ created_by: 'bob', deployment__submission_count: 99 }) const [result] = userCanDeleteAssets([asset]) expect(result.canDelete).to.be.true }) it('treats a non-200 org response as no restrictions', () => { mockedGetQueryData.mockReturnValue({ status: 404, data: { detail: 'Not found' } }) - const asset = assetFactory({ created_by: 'bob', deployment__submission_count: 5 }) + const asset = getApiV2AssetsRetrieveResponseMock({ created_by: 'bob', deployment__submission_count: 5 }) const [result] = userCanDeleteAssets([asset]) expect(result.canDelete).to.be.true }) it('treats an account with no organization property as no restrictions', () => { setAccount('alice') - const asset = assetFactory({ created_by: 'bob' }) + const asset = getApiV2AssetsRetrieveResponseMock({ created_by: 'bob' }) const [result] = userCanDeleteAssets([asset]) expect(result.canDelete).to.be.true }) diff --git a/jsapp/js/endpoints/formMedia.mocks.ts b/jsapp/js/endpoints/formMedia.mocks.ts index ee1c4b24ae..0fdda1f4da 100644 --- a/jsapp/js/endpoints/formMedia.mocks.ts +++ b/jsapp/js/endpoints/formMedia.mocks.ts @@ -19,11 +19,14 @@ export interface FormMediaItem extends Omit { interface CreateFormMediaPayload { description?: string file_type?: string + // metadata may arrive as a JSON string (legacy URL-encoded POST) or as a + // parsed object (JSON POST from the orval-generated client). metadata?: string | Record base64Encoded?: string } interface FormMediaMockOptions { + // Optional per-filename delays for story/play-test scenarios. uploadDelayByFilenameMs?: Record } @@ -39,9 +42,13 @@ function parsePayloadFromText(textPayload: string): CreateFormMediaPayload { async function parsePayload(request: Request): Promise { const contentType = request.headers.get('content-type') || '' + + // Keep this branch for components that may switch to JSON POST later. if (contentType.includes('application/json')) { return (await request.json()) as CreateFormMediaPayload } + + // Current uploader sends URL-encoded form payloads. return parsePayloadFromText(await request.text()) } @@ -97,6 +104,8 @@ export function formMediaHandlers( seedItems: FormMediaItem[] = [createFormMediaItem(1)], options: FormMediaMockOptions = {}, ) { + // We mutate this local array to mimic backend persistence between requests + // inside a single Storybook run. const mediaItems = [...seedItems] return [ @@ -120,12 +129,15 @@ export function formMediaHandlers( } const payload = await parsePayload(request) + // metadata may be a JSON string (legacy form-encoded POST) or a plain + // object (JSON POST from the orval-generated client). const parsedMetadata = typeof payload.metadata === 'string' ? (JSON.parse(payload.metadata) as Record) : (payload.metadata ?? {}) const fileName = parsedMetadata.filename as string | undefined + // Unknown filenames (or missing delay map) upload immediately. const delayMs = (fileName && options.uploadDelayByFilenameMs?.[fileName]) || 0 if (delayMs > 0) { await waitMs(delayMs) @@ -146,6 +158,7 @@ export function formMediaHandlers( }) mediaItems.push(newItem) + // Return created item so UI can behave like real API responses. return newItem }), From fba24fa39af2f6f112a8d2c8415d15cbfda39c26 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 13:38:31 +0200 Subject: [PATCH 62/86] biome fix --- .../js/components/submissions/useDataTableBulkActions.tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts index 5f468c2e89..d3964fe572 100644 --- a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts +++ b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts @@ -3,8 +3,8 @@ import { ActionIdEnum } from '#/api/models/actionIdEnum' import type { BulkActionResponse } from '#/api/models/bulkActionResponse' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' import { - getAssetsAdvancedFeaturesBulkActionsListQueryKey, getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock, + getAssetsAdvancedFeaturesBulkActionsListQueryKey, useAssetsAdvancedFeaturesBulkActionsList, } from '#/api/react-query/survey-data' import { useFeatureFlag } from '#/featureFlags' From b64ea10e4b40f579e173de08c8b682e7cdee5067 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 13:42:58 +0200 Subject: [PATCH 63/86] fix darker --- kpi/schema_extensions/v2/assets/extensions.py | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 43b7af4ca8..fe1bb04091 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -34,7 +34,6 @@ MAP_STYLES_SCHEMA, PERMISSION_ASSIGNMENT_SCHEMA, REPORT_STYLE_SCHEMA, - SURVEY_CHOICE_SCHEMA, ) @@ -358,7 +357,14 @@ class DeploymentDataDownloadLinksFieldExtension(OpenApiSerializerFieldExtension) def map_serializer_field(self, auto_schema, direction): return build_object_type( - required=['csv_legacy', 'csv', 'kml_legacy', 'xls_legacy', 'xls', 'zip_legacy'], + required=[ + 'csv_legacy', + 'csv', + 'kml_legacy', + 'xls_legacy', + 'xls', + 'zip_legacy', + ], properties={ 'csv_legacy': GENERIC_STRING_SCHEMA, 'csv': GENERIC_STRING_SCHEMA, @@ -391,7 +397,13 @@ def map_serializer_field(self, auto_schema, direction): 'previous': {**GENERIC_STRING_SCHEMA, 'nullable': True}, 'results': build_array_type( schema=build_object_type( - required=['uid', 'url', 'content_hash', 'date_deployed', 'date_modified'], + required=[ + 'uid', + 'url', + 'content_hash', + 'date_deployed', + 'date_modified', + ], properties={ 'uid': GENERIC_STRING_SCHEMA, 'url': build_url_type( @@ -609,7 +621,8 @@ class SettingsFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.SettingsField' def map_serializer_field(self, auto_schema, direction): - # Sector can be: null (no selection), {} (empty default), or {label, value} (LabelValuePair) + # Sector can be: null (no selection), {} (empty default), + # or {label, value} (LabelValuePair) sector_schema = { **build_object_type( properties={ @@ -620,7 +633,8 @@ def map_serializer_field(self, auto_schema, direction): 'nullable': True, } - # Country is an array of {label, value} objects (LabelValuePair[]), nullable for form state + # Country is an array of {label, value} objects (LabelValuePair[]), + # nullable for form state label_value_pair_schema = build_object_type( properties={ 'label': GENERIC_STRING_SCHEMA, @@ -628,14 +642,21 @@ def map_serializer_field(self, auto_schema, direction): } ) - # collects_pii and operational_purpose are also LabelValuePair objects, nullable + # collects_pii and operational_purpose are also LabelValuePair objects, + # nullable collects_pii_schema = {**label_value_pair_schema, 'nullable': True} - operational_purpose_schema = {**label_value_pair_schema, 'nullable': True} + operational_purpose_schema = { + **label_value_pair_schema, + 'nullable': True, + } return build_object_type( properties={ 'sector': sector_schema, - 'country': {**build_array_type(schema=label_value_pair_schema), 'nullable': True}, + 'country': { + **build_array_type(schema=label_value_pair_schema), + 'nullable': True, + }, 'description': GENERIC_STRING_SCHEMA, 'collects_pii': collects_pii_schema, 'organization': {**GENERIC_STRING_SCHEMA, 'nullable': True}, From a97ccb2a31276e16950714b6408f8e71882c5035 Mon Sep 17 00:00:00 2001 From: Leszek Pietrzak Date: Tue, 7 Jul 2026 13:07:45 +0100 Subject: [PATCH 64/86] Update jsapp/js/components/modalForms/LibraryAssetForm.tsx Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- jsapp/js/components/modalForms/LibraryAssetForm.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jsapp/js/components/modalForms/LibraryAssetForm.tsx b/jsapp/js/components/modalForms/LibraryAssetForm.tsx index b599251437..e962c929b6 100644 --- a/jsapp/js/components/modalForms/LibraryAssetForm.tsx +++ b/jsapp/js/components/modalForms/LibraryAssetForm.tsx @@ -162,8 +162,11 @@ export const LibraryAssetForm = ({ asset, assetType, onSetModalTitle: _onSetModa return [] } - // Backend always returns country as an array - return value.map((item) => item.value) + if (Array.isArray(value)) { + return value.map((item) => item.value) + } + + return [value.value] } const fromSingleSelectValue = (newValue: string | null, option?: LabelValuePair): LabelValuePair | null => { From ec0673d38f4fc38325a8aa7f976d5446f7e43818 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 14:09:51 +0200 Subject: [PATCH 65/86] cr fixes --- jsapp/js/assetUtils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jsapp/js/assetUtils.ts b/jsapp/js/assetUtils.ts index 86f700b1b0..0d274421e8 100644 --- a/jsapp/js/assetUtils.ts +++ b/jsapp/js/assetUtils.ts @@ -159,6 +159,9 @@ export function getCountryDisplayString(asset: AssetResponse | ProjectViewAsset) for (const country of asset.settings.country) { countries.push(envStore.getCountryLabel(country.value)) } + } else { + // We leave this for legacy reasons - there might be some very old assets with country being a single object + countries.push(envStore.getCountryLabel(asset.settings.country.value)) } if (countries.length === 0) { From c4d2eae5f5114a37c030cd12c8f670b863a1fa59 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 14:14:48 +0200 Subject: [PATCH 66/86] cr fix --- .../js/api/models/patchedAssetPatchRequest.ts | 8 +- .../models/patchedAssetPatchRequestOneOf.ts | 3 +- .../patchedAssetPatchRequestOneOfContent.ts | 27 -- ...ssetPatchRequestOneOfContentChoicesItem.ts | 22 -- ...uestOneOfContentKoboLockingProfilesItem.ts | 13 - ...edAssetPatchRequestOneOfContentSettings.ts | 24 -- ...AssetPatchRequestOneOfContentSurveyItem.ts | 34 --- ... => patchedAssetPatchRequestOneOfThree.ts} | 2 +- ...ts => patchedAssetPatchRequestOneOfTwo.ts} | 2 +- kpi/schema_extensions/v2/assets/extensions.py | 9 +- kpi/schema_extensions/v2/assets/schema.py | 5 +- kpi/views/v2/asset.py | 4 +- static/openapi/schema_v2.json | 257 +----------------- static/openapi/schema_v2.yaml | 182 +------------ 14 files changed, 21 insertions(+), 571 deletions(-) delete mode 100644 jsapp/js/api/models/patchedAssetPatchRequestOneOfContent.ts delete mode 100644 jsapp/js/api/models/patchedAssetPatchRequestOneOfContentChoicesItem.ts delete mode 100644 jsapp/js/api/models/patchedAssetPatchRequestOneOfContentKoboLockingProfilesItem.ts delete mode 100644 jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSettings.ts delete mode 100644 jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSurveyItem.ts rename jsapp/js/api/models/{patchedAssetPatchRequestOneOfEight.ts => patchedAssetPatchRequestOneOfThree.ts} (94%) rename jsapp/js/api/models/{patchedAssetPatchRequestOneOfSeven.ts => patchedAssetPatchRequestOneOfTwo.ts} (94%) diff --git a/jsapp/js/api/models/patchedAssetPatchRequest.ts b/jsapp/js/api/models/patchedAssetPatchRequest.ts index 93830c2049..68c92a8ff5 100644 --- a/jsapp/js/api/models/patchedAssetPatchRequest.ts +++ b/jsapp/js/api/models/patchedAssetPatchRequest.ts @@ -10,10 +10,10 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ import type { PatchedAssetPatchRequestOneOf } from './patchedAssetPatchRequestOneOf' -import type { PatchedAssetPatchRequestOneOfEight } from './patchedAssetPatchRequestOneOfEight' -import type { PatchedAssetPatchRequestOneOfSeven } from './patchedAssetPatchRequestOneOfSeven' +import type { PatchedAssetPatchRequestOneOfThree } from './patchedAssetPatchRequestOneOfThree' +import type { PatchedAssetPatchRequestOneOfTwo } from './patchedAssetPatchRequestOneOfTwo' export type PatchedAssetPatchRequest = | PatchedAssetPatchRequestOneOf - | PatchedAssetPatchRequestOneOfSeven - | PatchedAssetPatchRequestOneOfEight + | PatchedAssetPatchRequestOneOfTwo + | PatchedAssetPatchRequestOneOfThree diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOf.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOf.ts index 3122358e88..7bf39145e4 100644 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOf.ts +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOf.ts @@ -9,9 +9,8 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import type { PatchedAssetPatchRequestOneOfContent } from './patchedAssetPatchRequestOneOfContent' export type PatchedAssetPatchRequestOneOf = { - content: PatchedAssetPatchRequestOneOfContent + content: string name: string } diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContent.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContent.ts deleted file mode 100644 index 5c9465b13e..0000000000 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContent.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { PatchedAssetPatchRequestOneOfContentChoicesItem } from './patchedAssetPatchRequestOneOfContentChoicesItem' -import type { PatchedAssetPatchRequestOneOfContentKoboLockingProfilesItem } from './patchedAssetPatchRequestOneOfContentKoboLockingProfilesItem' -import type { PatchedAssetPatchRequestOneOfContentSettings } from './patchedAssetPatchRequestOneOfContentSettings' -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import type { PatchedAssetPatchRequestOneOfContentSurveyItem } from './patchedAssetPatchRequestOneOfContentSurveyItem' - -export type PatchedAssetPatchRequestOneOfContent = { - schema?: string - survey?: PatchedAssetPatchRequestOneOfContentSurveyItem[] - choices?: PatchedAssetPatchRequestOneOfContentChoicesItem[] - settings?: PatchedAssetPatchRequestOneOfContentSettings - translated?: string[] - translations?: (string | null)[] - /** @nullable */ - translations_0?: string | null - 'kobo--locking-profiles'?: PatchedAssetPatchRequestOneOfContentKoboLockingProfilesItem[] -} diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentChoicesItem.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentChoicesItem.ts deleted file mode 100644 index d2e1832eba..0000000000 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentChoicesItem.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ - -export type PatchedAssetPatchRequestOneOfContentChoicesItem = { - $autovalue: string - $kuid: string - label?: (string | null)[] - list_name: string - name: string - 'media::image'?: string[] - $autoname?: string - [key: string]: unknown -} diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentKoboLockingProfilesItem.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentKoboLockingProfilesItem.ts deleted file mode 100644 index d65adb760f..0000000000 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentKoboLockingProfilesItem.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ - -export type PatchedAssetPatchRequestOneOfContentKoboLockingProfilesItem = { [key: string]: unknown } diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSettings.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSettings.ts deleted file mode 100644 index a14e798112..0000000000 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSettings.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ - -export type PatchedAssetPatchRequestOneOfContentSettings = { - name?: string - version?: string - id_string?: string - style?: string - form_id?: string - title?: string - 'kobo--lock_all'?: boolean - 'kobo--locking-profile'?: string - /** @nullable */ - default_language?: string | null -} diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSurveyItem.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSurveyItem.ts deleted file mode 100644 index 00f2919082..0000000000 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOfContentSurveyItem.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ - -export type PatchedAssetPatchRequestOneOfContentSurveyItem = { - $kuid: string - type: string - $xpath?: string - $autoname?: string - calculation?: string - label?: (string | null)[] - hint?: (string | null)[] - name?: string - required?: boolean - appearance?: string - parameters?: string - 'kobo--matrix_list'?: string - 'kobo--rank-constraint-message'?: string - 'kobo--rank-items'?: string - 'kobo--score-choices'?: string - 'kobo--locking-profile'?: string - tags?: string[] - select_from_list_name?: string - 'body::accept'?: string - [key: string]: unknown -} diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfEight.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfThree.ts similarity index 94% rename from jsapp/js/api/models/patchedAssetPatchRequestOneOfEight.ts rename to jsapp/js/api/models/patchedAssetPatchRequestOneOfThree.ts index 18e9dcdbcb..129b68c63e 100644 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOfEight.ts +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOfThree.ts @@ -10,6 +10,6 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type PatchedAssetPatchRequestOneOfEight = { +export type PatchedAssetPatchRequestOneOfThree = { tag_string: string } diff --git a/jsapp/js/api/models/patchedAssetPatchRequestOneOfSeven.ts b/jsapp/js/api/models/patchedAssetPatchRequestOneOfTwo.ts similarity index 94% rename from jsapp/js/api/models/patchedAssetPatchRequestOneOfSeven.ts rename to jsapp/js/api/models/patchedAssetPatchRequestOneOfTwo.ts index f073b8c38d..c74fef6246 100644 --- a/jsapp/js/api/models/patchedAssetPatchRequestOneOfSeven.ts +++ b/jsapp/js/api/models/patchedAssetPatchRequestOneOfTwo.ts @@ -10,7 +10,7 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type PatchedAssetPatchRequestOneOfSeven = { +export type PatchedAssetPatchRequestOneOfTwo = { enabled: boolean fields: string[] } diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index fe1bb04091..19610c81ef 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -21,7 +21,8 @@ ADVANCED_FEATURES_SCHEMA, ASSIGNABLE_PERMISSION_SCHEMA, ASSET_CLONE_FROM_SCHEMA, - ASSET_CONTENT_SCHEMA, + ASSET_CONTENT_REQUEST_SCHEMA, + ASSET_CONTENT_RESPONSE_SCHEMA, ASSET_ENABLED_SCHEMA, ASSET_FIELDS_SCHEMA, ASSET_NAME_SCHEMA, @@ -175,7 +176,7 @@ def map_serializer(self, auto_schema, direction): build_object_type( required=['content', 'name'], properties={ - 'content': ASSET_CONTENT_SCHEMA, + 'content': ASSET_CONTENT_REQUEST_SCHEMA, 'name': ASSET_NAME_SCHEMA, }, ), @@ -309,8 +310,8 @@ def map_serializer_field(self, auto_schema, direction): # WriteableJsonWithSchemaField accepts JSON string for writes, # returns object for reads if direction == 'request': - return build_basic_type(OpenApiTypes.STR) - return ASSET_CONTENT_SCHEMA + return ASSET_CONTENT_REQUEST_SCHEMA + return ASSET_CONTENT_RESPONSE_SCHEMA class CountDailySubmissionResponseFieldExtension(OpenApiSerializerFieldExtension): diff --git a/kpi/schema_extensions/v2/assets/schema.py b/kpi/schema_extensions/v2/assets/schema.py index 39e7c337d2..04bbc5b1f4 100644 --- a/kpi/schema_extensions/v2/assets/schema.py +++ b/kpi/schema_extensions/v2/assets/schema.py @@ -11,7 +11,8 @@ ASSET_CLONE_FROM_SCHEMA = build_basic_type(OpenApiTypes.STR) -ASSET_CONTENT_SCHEMA = build_basic_type(OpenApiTypes.STR) +# Asset content can be sent as a JSON string (write) or received as an object (read) +ASSET_CONTENT_REQUEST_SCHEMA = build_basic_type(OpenApiTypes.STR) ASSET_ENABLED_SCHEMA = build_basic_type(OpenApiTypes.BOOL) @@ -244,7 +245,7 @@ } ) -ASSET_CONTENT_SCHEMA = build_object_type( +ASSET_CONTENT_RESPONSE_SCHEMA = build_object_type( properties={ 'schema': build_basic_type(OpenApiTypes.STR), 'survey': build_array_type(schema=SURVEY_ROW_SCHEMA), diff --git a/kpi/views/v2/asset.py b/kpi/views/v2/asset.py index c88903ac71..e4af7c89f4 100644 --- a/kpi/views/v2/asset.py +++ b/kpi/views/v2/asset.py @@ -59,7 +59,7 @@ ) from kpi.schema_extensions.v2.assets.schema import ( ASSET_CLONE_FROM_SCHEMA, - ASSET_CONTENT_SCHEMA, + ASSET_CONTENT_REQUEST_SCHEMA, ASSET_ENABLED_SCHEMA, ASSET_FIELDS_SCHEMA, ASSET_NAME_SCHEMA, @@ -299,7 +299,7 @@ OpenApiExample( name='Updating an asset', value={ - 'content': generate_example_from_schema(ASSET_CONTENT_SCHEMA), + 'content': generate_example_from_schema(ASSET_CONTENT_REQUEST_SCHEMA), 'name': generate_example_from_schema(ASSET_NAME_SCHEMA), }, request_only=True, diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index 6d81284ecc..bd51e4ea0b 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -1479,74 +1479,7 @@ "examples": { "UpdatingAnAsset": { "value": { - "content": { - "schema": "string", - "survey": [ - { - "$kuid": "string", - "type": "string", - "$xpath": "string", - "$autoname": "string", - "calculation": "string", - "label": [ - "string" - ], - "hint": [ - "string" - ], - "name": "string", - "required": true, - "appearance": "string", - "parameters": "string", - "kobo--matrix_list": "string", - "kobo--rank-constraint-message": "string", - "kobo--rank-items": "string", - "kobo--score-choices": "string", - "kobo--locking-profile": "string", - "tags": [ - "string" - ], - "select_from_list_name": "string", - "body::accept": "string" - } - ], - "choices": [ - { - "$autovalue": "string", - "$kuid": "string", - "label": [ - "string" - ], - "list_name": "string", - "name": "string", - "media::image": [ - "string" - ], - "$autoname": "string" - } - ], - "settings": { - "name": "string", - "version": "string", - "id_string": "string", - "style": "string", - "form_id": "string", - "title": "string", - "kobo--lock_all": true, - "kobo--locking-profile": "string", - "default_language": "string" - }, - "translated": [ - "string" - ], - "translations": [ - "string" - ], - "translations_0": "string", - "kobo--locking-profiles": [ - {} - ] - }, + "content": "string", "name": "string" }, "summary": "Updating an asset" @@ -29153,193 +29086,7 @@ "type": "object", "properties": { "content": { - "type": "object", - "properties": { - "schema": { - "type": "string" - }, - "survey": { - "type": "array", - "items": { - "type": "object", - "properties": { - "$kuid": { - "type": "string" - }, - "type": { - "type": "string" - }, - "$xpath": { - "type": "string" - }, - "$autoname": { - "type": "string" - }, - "calculation": { - "type": "string" - }, - "label": { - "type": "array", - "items": { - "type": "string", - "nullable": true - } - }, - "hint": { - "type": "array", - "items": { - "type": "string", - "nullable": true - } - }, - "name": { - "type": "string" - }, - "required": { - "type": "boolean" - }, - "appearance": { - "type": "string" - }, - "parameters": { - "type": "string" - }, - "kobo--matrix_list": { - "type": "string" - }, - "kobo--rank-constraint-message": { - "type": "string" - }, - "kobo--rank-items": { - "type": "string" - }, - "kobo--score-choices": { - "type": "string" - }, - "kobo--locking-profile": { - "type": "string" - }, - "tags": { - "type": "array", - "items": { - "type": "string" - } - }, - "select_from_list_name": { - "type": "string" - }, - "body::accept": { - "type": "string" - } - }, - "additionalProperties": true, - "required": [ - "$kuid", - "type" - ] - } - }, - "choices": { - "type": "array", - "items": { - "type": "object", - "properties": { - "$autovalue": { - "type": "string" - }, - "$kuid": { - "type": "string" - }, - "label": { - "type": "array", - "items": { - "type": "string", - "nullable": true - } - }, - "list_name": { - "type": "string" - }, - "name": { - "type": "string" - }, - "media::image": { - "type": "array", - "items": { - "type": "string" - } - }, - "$autoname": { - "type": "string" - } - }, - "additionalProperties": true, - "required": [ - "$autovalue", - "$kuid", - "list_name", - "name" - ] - } - }, - "settings": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "version": { - "type": "string" - }, - "id_string": { - "type": "string" - }, - "style": { - "type": "string" - }, - "form_id": { - "type": "string" - }, - "title": { - "type": "string" - }, - "kobo--lock_all": { - "type": "boolean" - }, - "kobo--locking-profile": { - "type": "string" - }, - "default_language": { - "type": "string", - "nullable": true - } - } - }, - "translated": { - "type": "array", - "items": { - "type": "string" - } - }, - "translations": { - "type": "array", - "items": { - "type": "string", - "nullable": true - } - }, - "translations_0": { - "type": "string", - "nullable": true - }, - "kobo--locking-profiles": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": {} - } - } - } + "type": "string" }, "name": { "type": "string" diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index f34943ed0b..f8b19286e6 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -1056,58 +1056,7 @@ paths: examples: UpdatingAnAsset: value: - content: - schema: string - survey: - - $kuid: string - type: string - $xpath: string - $autoname: string - calculation: string - label: - - string - hint: - - string - name: string - required: true - appearance: string - parameters: string - kobo--matrix_list: string - kobo--rank-constraint-message: string - kobo--rank-items: string - kobo--score-choices: string - kobo--locking-profile: string - tags: - - string - select_from_list_name: string - body::accept: string - choices: - - $autovalue: string - $kuid: string - label: - - string - list_name: string - name: string - media::image: - - string - $autoname: string - settings: - name: string - version: string - id_string: string - style: string - form_id: string - title: string - kobo--lock_all: true - kobo--locking-profile: string - default_language: string - translated: - - string - translations: - - string - translations_0: string - kobo--locking-profiles: - - {} + content: string name: string summary: Updating an asset DataSharingOfTheProject: @@ -20818,134 +20767,7 @@ components: - type: object properties: content: - type: object - properties: - schema: - type: string - survey: - type: array - items: - type: object - properties: - $kuid: - type: string - type: - type: string - $xpath: - type: string - $autoname: - type: string - calculation: - type: string - label: - type: array - items: - type: string - nullable: true - hint: - type: array - items: - type: string - nullable: true - name: - type: string - required: - type: boolean - appearance: - type: string - parameters: - type: string - kobo--matrix_list: - type: string - kobo--rank-constraint-message: - type: string - kobo--rank-items: - type: string - kobo--score-choices: - type: string - kobo--locking-profile: - type: string - tags: - type: array - items: - type: string - select_from_list_name: - type: string - body::accept: - type: string - additionalProperties: true - required: - - $kuid - - type - choices: - type: array - items: - type: object - properties: - $autovalue: - type: string - $kuid: - type: string - label: - type: array - items: - type: string - nullable: true - list_name: - type: string - name: - type: string - media::image: - type: array - items: - type: string - $autoname: - type: string - additionalProperties: true - required: - - $autovalue - - $kuid - - list_name - - name - settings: - type: object - properties: - name: - type: string - version: - type: string - id_string: - type: string - style: - type: string - form_id: - type: string - title: - type: string - kobo--lock_all: - type: boolean - kobo--locking-profile: - type: string - default_language: - type: string - nullable: true - translated: - type: array - items: - type: string - translations: - type: array - items: - type: string - nullable: true - translations_0: - type: string - nullable: true - kobo--locking-profiles: - type: array - items: - type: object - additionalProperties: {} + type: string name: type: string required: From 5febed4e36b0f768677bb6d30ee2149bc8533d80 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 14:18:16 +0200 Subject: [PATCH 67/86] darker fix --- kpi/views/v2/asset.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kpi/views/v2/asset.py b/kpi/views/v2/asset.py index e4af7c89f4..bfc3beaa40 100644 --- a/kpi/views/v2/asset.py +++ b/kpi/views/v2/asset.py @@ -299,7 +299,9 @@ OpenApiExample( name='Updating an asset', value={ - 'content': generate_example_from_schema(ASSET_CONTENT_REQUEST_SCHEMA), + 'content': generate_example_from_schema( + ASSET_CONTENT_REQUEST_SCHEMA + ), 'name': generate_example_from_schema(ASSET_NAME_SCHEMA), }, request_only=True, From 79710f43ae9b379a213524943ce5d22ad119a8ab Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 14:35:04 +0200 Subject: [PATCH 68/86] cr fix --- jsapp/js/assetUtils.ts | 8 +++++--- jsapp/js/components/modalForms/LibraryAssetForm.tsx | 4 +++- .../project/FormLanguagesManager/FormLanguagesManager.tsx | 4 +--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/jsapp/js/assetUtils.ts b/jsapp/js/assetUtils.ts index 0d274421e8..bf8f792b1e 100644 --- a/jsapp/js/assetUtils.ts +++ b/jsapp/js/assetUtils.ts @@ -154,14 +154,16 @@ export function getCountryDisplayString(asset: AssetResponse | ProjectViewAsset) * and then switching to french would result in seeing spanish labels) */ const countries = [] - // Backend always returns country as an array (or null/undefined) + // Backend schema specifies country as array, but old assets (pre-Dec 2022) + // may still have it as a single object if they haven't been updated since + // standardization was added, or if the migration was skipped. if (Array.isArray(asset.settings.country)) { for (const country of asset.settings.country) { countries.push(envStore.getCountryLabel(country.value)) } } else { - // We leave this for legacy reasons - there might be some very old assets with country being a single object - countries.push(envStore.getCountryLabel(asset.settings.country.value)) + // Legacy fallback: single object format from pre-standardization assets + countries.push(envStore.getCountryLabel((asset.settings.country as any).value)) } if (countries.length === 0) { diff --git a/jsapp/js/components/modalForms/LibraryAssetForm.tsx b/jsapp/js/components/modalForms/LibraryAssetForm.tsx index e962c929b6..68c460d9fe 100644 --- a/jsapp/js/components/modalForms/LibraryAssetForm.tsx +++ b/jsapp/js/components/modalForms/LibraryAssetForm.tsx @@ -162,11 +162,13 @@ export const LibraryAssetForm = ({ asset, assetType, onSetModalTitle: _onSetModa return [] } + // Backend schema specifies array, but old assets may have single object if (Array.isArray(value)) { return value.map((item) => item.value) } - return [value.value] + // Legacy fallback: single object from pre-Dec 2022 assets + return [(value as any).value] } const fromSingleSelectValue = (newValue: string | null, option?: LabelValuePair): LabelValuePair | null => { diff --git a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx index 3690237b49..44cc8a9b56 100644 --- a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx +++ b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.tsx @@ -3,7 +3,6 @@ import { useQuery, useQueryClient } from '@tanstack/react-query' import cloneDeep from 'lodash.clonedeep' import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import type { PaginatedListResponse } from '#/UniversalTable' -import type { PatchedAssetPatchRequestOneOfContent } from '#/api/models/patchedAssetPatchRequestOneOfContent' import { assetsPartialUpdate } from '#/api/react-query/manage-projects-and-library-content' import ButtonNew from '#/components/common/ButtonNew' import ModalNew from '#/components/common/ModalNew' @@ -117,8 +116,7 @@ export default function FormLanguagesManager(props: FormLanguagesManagerProps) { try { const response = await assetsPartialUpdate(asset.uid, { name: asset.name, - // Backend accepts JSON string for content field in PATCH requests - content: JSON.stringify(content) as unknown as PatchedAssetPatchRequestOneOfContent, + content: JSON.stringify(content), }) if (response.status === 200) { From f02ae85210d327af6420a7c86d917d86fa7a4e25 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 14:36:32 +0200 Subject: [PATCH 69/86] comment --- jsapp/js/dataInterface.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jsapp/js/dataInterface.ts b/jsapp/js/dataInterface.ts index f48a9a9a51..f343d82f3a 100644 --- a/jsapp/js/dataInterface.ts +++ b/jsapp/js/dataInterface.ts @@ -620,8 +620,9 @@ export interface AssetTableSettings extends AssetTableSettingsObject { export interface AssetSettings { sector?: LabelValuePair | null | {} - // Backend always returns country as array (even when empty: []) - // Legacy code might have treated it as single object in some cases, but array is correct + // Backend schema specifies array, but old assets (pre-Dec 2022) may still have + // single object if not updated since standardization or if migration was skipped. + // Runtime: LabelValuePair[] | LabelValuePair | null, but typed as array for new code. country?: LabelValuePair[] | null description?: string 'data-table'?: AssetTableSettings From c9c6e54ad2f37db3cbc27574954290ee98f0882d Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 15:26:05 +0200 Subject: [PATCH 70/86] improve be schemas --- kpi/schema_extensions/v2/assets/extensions.py | 50 ++++++++----------- kpi/schema_extensions/v2/assets/schema.py | 22 +++----- kpi/schema_extensions/v2/generic/schema.py | 4 ++ 3 files changed, 32 insertions(+), 44 deletions(-) diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 19610c81ef..4eab9603ce 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -14,6 +14,8 @@ GENERIC_ARRAY_SCHEMA, GENERIC_OBJECT_SCHEMA, GENERIC_STRING_SCHEMA, + NULLABLE_ARRAY_SCHEMA, + NULLABLE_STRING_SCHEMA, USER_URL_SCHEMA, ) from kpi.utils.schema_extensions.url_builder import build_url_type @@ -42,7 +44,7 @@ class AccessTypeFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.AccessTypeField' def map_serializer_field(self, auto_schema, direction): - return {**GENERIC_ARRAY_SCHEMA, 'nullable': True} + return NULLABLE_ARRAY_SCHEMA class AdvancedFeatureFieldExtension(OpenApiSerializerFieldExtension): @@ -394,8 +396,8 @@ def map_serializer_field(self, auto_schema, direction): required=['count', 'next', 'previous', 'results'], properties={ 'count': build_basic_type(OpenApiTypes.INT), - 'next': {**GENERIC_STRING_SCHEMA, 'nullable': True}, - 'previous': {**GENERIC_STRING_SCHEMA, 'nullable': True}, + 'next': NULLABLE_STRING_SCHEMA, + 'previous': NULLABLE_STRING_SCHEMA, 'results': build_array_type( schema=build_object_type( required=[ @@ -622,20 +624,7 @@ class SettingsFieldExtension(OpenApiSerializerFieldExtension): target_class = 'kpi.schema_extensions.v2.assets.fields.SettingsField' def map_serializer_field(self, auto_schema, direction): - # Sector can be: null (no selection), {} (empty default), - # or {label, value} (LabelValuePair) - sector_schema = { - **build_object_type( - properties={ - 'label': GENERIC_STRING_SCHEMA, - 'value': GENERIC_STRING_SCHEMA, - } - ), - 'nullable': True, - } - - # Country is an array of {label, value} objects (LabelValuePair[]), - # nullable for form state + # Base LabelValuePair schema reused for multiple fields label_value_pair_schema = build_object_type( properties={ 'label': GENERIC_STRING_SCHEMA, @@ -643,26 +632,27 @@ def map_serializer_field(self, auto_schema, direction): } ) - # collects_pii and operational_purpose are also LabelValuePair objects, - # nullable - collects_pii_schema = {**label_value_pair_schema, 'nullable': True} - operational_purpose_schema = { + # Nullable LabelValuePair for optional fields + nullable_label_value_pair_schema = { **label_value_pair_schema, 'nullable': True, } + # Country is an array of LabelValuePair objects, nullable + nullable_label_value_pair_array_schema = { + **build_array_type(schema=label_value_pair_schema), + 'nullable': True, + } + return build_object_type( properties={ - 'sector': sector_schema, - 'country': { - **build_array_type(schema=label_value_pair_schema), - 'nullable': True, - }, + 'sector': nullable_label_value_pair_schema, + 'country': nullable_label_value_pair_array_schema, 'description': GENERIC_STRING_SCHEMA, - 'collects_pii': collects_pii_schema, - 'organization': {**GENERIC_STRING_SCHEMA, 'nullable': True}, + 'collects_pii': nullable_label_value_pair_schema, + 'organization': NULLABLE_STRING_SCHEMA, 'country_codes': GENERIC_ARRAY_SCHEMA, - 'operational_purpose': operational_purpose_schema, + 'operational_purpose': nullable_label_value_pair_schema, } ) @@ -702,7 +692,7 @@ def map_serializer_field(self, auto_schema, direction): 'languages': GENERIC_ARRAY_SCHEMA, 'row_count': build_basic_type(OpenApiTypes.INT), 'name_quality': name_quality_schema, - 'default_translation': {**GENERIC_STRING_SCHEMA, 'nullable': True}, + 'default_translation': NULLABLE_STRING_SCHEMA, 'naming_conflicts': build_array_type(GENERIC_STRING_SCHEMA), } ) diff --git a/kpi/schema_extensions/v2/assets/schema.py b/kpi/schema_extensions/v2/assets/schema.py index 04bbc5b1f4..6a31f5f805 100644 --- a/kpi/schema_extensions/v2/assets/schema.py +++ b/kpi/schema_extensions/v2/assets/schema.py @@ -5,6 +5,8 @@ ) from drf_spectacular.types import OpenApiTypes +from kpi.schema_extensions.v2.generic.schema import NULLABLE_STRING_SCHEMA + """ Common schemas to avoid redundancy """ @@ -193,12 +195,8 @@ '$xpath': build_basic_type(OpenApiTypes.STR), '$autoname': build_basic_type(OpenApiTypes.STR), 'calculation': build_basic_type(OpenApiTypes.STR), - 'label': build_array_type( - schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} - ), - 'hint': build_array_type( - schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} - ), + 'label': build_array_type(schema=NULLABLE_STRING_SCHEMA), + 'hint': build_array_type(schema=NULLABLE_STRING_SCHEMA), 'name': build_basic_type(OpenApiTypes.STR), 'required': build_basic_type(OpenApiTypes.BOOL), 'appearance': build_basic_type(OpenApiTypes.STR), @@ -220,9 +218,7 @@ properties={ '$autovalue': build_basic_type(OpenApiTypes.STR), '$kuid': build_basic_type(OpenApiTypes.STR), - 'label': build_array_type( - schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} - ), + 'label': build_array_type(schema=NULLABLE_STRING_SCHEMA), 'list_name': build_basic_type(OpenApiTypes.STR), 'name': build_basic_type(OpenApiTypes.STR), 'media::image': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), @@ -241,7 +237,7 @@ 'title': build_basic_type(OpenApiTypes.STR), 'kobo--lock_all': build_basic_type(OpenApiTypes.BOOL), 'kobo--locking-profile': build_basic_type(OpenApiTypes.STR), - 'default_language': {**build_basic_type(OpenApiTypes.STR), 'nullable': True}, + 'default_language': NULLABLE_STRING_SCHEMA, } ) @@ -252,10 +248,8 @@ 'choices': build_array_type(schema=SURVEY_CHOICE_SCHEMA), 'settings': ASSET_CONTENT_SETTINGS_SCHEMA, 'translated': build_array_type(schema=build_basic_type(OpenApiTypes.STR)), - 'translations': build_array_type( - schema={**build_basic_type(OpenApiTypes.STR), 'nullable': True} - ), - 'translations_0': {**build_basic_type(OpenApiTypes.STR), 'nullable': True}, + 'translations': build_array_type(schema=NULLABLE_STRING_SCHEMA), + 'translations_0': NULLABLE_STRING_SCHEMA, 'kobo--locking-profiles': build_array_type( schema=build_basic_type(OpenApiTypes.OBJECT) ), diff --git a/kpi/schema_extensions/v2/generic/schema.py b/kpi/schema_extensions/v2/generic/schema.py index fccc499adb..506755adfb 100644 --- a/kpi/schema_extensions/v2/generic/schema.py +++ b/kpi/schema_extensions/v2/generic/schema.py @@ -73,6 +73,8 @@ GENERIC_STRING_SCHEMA = build_basic_type(OpenApiTypes.STR) +NULLABLE_STRING_SCHEMA = {**build_basic_type(OpenApiTypes.STR), 'nullable': True} + GENERIC_INT_SCHEMA = build_basic_type(OpenApiTypes.INT) GENERIC_OBJECT_SCHEMA = build_object_type(properties={}) @@ -81,4 +83,6 @@ GENERIC_DATETIME_SCHEMA = build_basic_type(OpenApiTypes.DATETIME) +NULLABLE_ARRAY_SCHEMA = {**build_array_type(schema=build_basic_type(OpenApiTypes.STR)), 'nullable': True} + USER_URL_SCHEMA = build_url_type('api_v2:user-kpi-detail', username='bob') From 33ad561699822c84c58f5ecff3be8eee157711f0 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 15:41:43 +0200 Subject: [PATCH 71/86] fix darker --- kpi/schema_extensions/v2/generic/schema.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kpi/schema_extensions/v2/generic/schema.py b/kpi/schema_extensions/v2/generic/schema.py index 506755adfb..7640e51ecc 100644 --- a/kpi/schema_extensions/v2/generic/schema.py +++ b/kpi/schema_extensions/v2/generic/schema.py @@ -83,6 +83,9 @@ GENERIC_DATETIME_SCHEMA = build_basic_type(OpenApiTypes.DATETIME) -NULLABLE_ARRAY_SCHEMA = {**build_array_type(schema=build_basic_type(OpenApiTypes.STR)), 'nullable': True} +NULLABLE_ARRAY_SCHEMA = { + **build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + 'nullable': True, +} USER_URL_SCHEMA = build_url_type('api_v2:user-kpi-detail', username='bob') From c22fa78237101ed7ac28812e85ee4ee63221b129 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 16:17:29 +0200 Subject: [PATCH 72/86] cr fix --- jsapp/js/api/orval.operationName.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jsapp/js/api/orval.operationName.js b/jsapp/js/api/orval.operationName.js index 6c1c9be64d..a2c45a7e95 100644 --- a/jsapp/js/api/orval.operationName.js +++ b/jsapp/js/api/orval.operationName.js @@ -1,7 +1,7 @@ -import { keyword } from 'esutils' +const { keyword } = require('esutils') /** - * Copied some orvel internals and modified one line in order to drop the annoying `ApiV2` prefix to everything. + * Copied some orval internals and modified one line in order to drop the annoying `ApiV2` prefix to everything. */ const unicodes = (s, prefix) => { @@ -109,5 +109,7 @@ const getOperationId = (operation, route, verb) => { ) } -export const operationName = (operation, route, verb) => +const operationName = (operation, route, verb) => sanitize(camel(getOperationId(operation, route, verb)), { es5keyword: true }) + +module.exports = { operationName } From 749e3181beb7796332516c6c53623dbc027569b7 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 16:50:19 +0200 Subject: [PATCH 73/86] separate mocks --- .../authentication-allauth-headless.msw.ts | 4125 ++++++++++++++++ .../authentication-allauth-headless.ts | 4181 +---------------- .../configuration.msw.ts} | 89 +- .../configuration/configuration.ts | 97 + .../form-content/form-content.msw.ts | 548 +++ .../{ => form-content}/form-content.ts | 550 +-- .../library-collections.msw.ts | 130 + .../library-collections.ts | 130 +- .../js/api/react-query/logging/logging.msw.ts | 407 ++ .../api/react-query/{ => logging}/logging.ts | 405 +- .../manage-permissions.msw.ts | 196 + .../manage-permissions.ts | 198 +- ...anage-projects-and-library-content.msw.ts} | 2724 +---------- .../manage-projects-and-library-content.ts | 2672 +++++++++++ jsapp/js/api/react-query/other/other.msw.ts | 1051 +++++ jsapp/js/api/react-query/{ => other}/other.ts | 1063 +---- jsapp/js/api/react-query/scim/scim.msw.ts | 487 ++ jsapp/js/api/react-query/{ => scim}/scim.ts | 495 +- .../server-logs-superusers.msw.ts} | 1087 +---- .../server-logs-superusers.ts | 1079 +++++ .../survey-data-rest-services.msw.ts | 433 ++ .../survey-data-rest-services.ts | 437 +- .../survey-data/survey-data.msw.ts | 3020 ++++++++++++ .../{ => survey-data}/survey-data.ts | 3072 +----------- .../user-team-organization-usage.msw.ts | 2287 +++++++++ .../user-team-organization-usage.ts | 2321 +-------- .../AttachmentActionsDropdown.mocks.ts | 2 +- .../AssetTagsModal/AssetTagsModal.stories.tsx | 2 +- .../activity/FormActivity.stories.tsx | 2 +- .../components/locking/lockingUtils.mocks.ts | 2 +- .../components/map/FormMapWrapper.stories.tsx | 2 +- .../components/reports/reports.utils.tests.ts | 2 +- .../BulkProcessingBanner.stories.tsx | 2 +- .../submissions/DataTableWrapper.stories.tsx | 4 +- .../submissions/submissionUtils.mocks.ts | 2 +- .../submissions/tableUtils.mocks.ts | 2 +- .../useDataTableBulkActions.tests.ts | 2 +- jsapp/js/endpoints/assetHistory.mocks.ts | 2 +- jsapp/js/endpoints/assets.mocks.ts | 2 +- jsapp/js/endpoints/assets.templates.ts | 2 +- jsapp/js/endpoints/bulkActions.mocks.ts | 2 +- jsapp/js/endpoints/environment.mocks.ts | 2 +- jsapp/js/endpoints/formMedia.mocks.ts | 2 +- jsapp/js/endpoints/languageDetail.mocks.ts | 2 +- jsapp/js/endpoints/me.mocks.ts | 2 +- jsapp/js/endpoints/organization.mocks.ts | 2 +- .../FormLanguagesManager.stories.tsx | 2 +- .../project/FormMedia/FormMedia.stories.tsx | 2 +- orval.config.js | 8 +- 49 files changed, 16874 insertions(+), 16464 deletions(-) create mode 100644 jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.msw.ts rename jsapp/js/api/react-query/{ => authentication-allauth-headless}/authentication-allauth-headless.ts (60%) rename jsapp/js/api/react-query/{configuration.ts => configuration/configuration.msw.ts} (70%) create mode 100644 jsapp/js/api/react-query/configuration/configuration.ts create mode 100644 jsapp/js/api/react-query/form-content/form-content.msw.ts rename jsapp/js/api/react-query/{ => form-content}/form-content.ts (60%) create mode 100644 jsapp/js/api/react-query/library-collections/library-collections.msw.ts rename jsapp/js/api/react-query/{ => library-collections}/library-collections.ts (72%) create mode 100644 jsapp/js/api/react-query/logging/logging.msw.ts rename jsapp/js/api/react-query/{ => logging}/logging.ts (54%) create mode 100644 jsapp/js/api/react-query/manage-permissions/manage-permissions.msw.ts rename jsapp/js/api/react-query/{ => manage-permissions}/manage-permissions.ts (77%) rename jsapp/js/api/react-query/{manage-projects-and-library-content.ts => manage-projects-and-library-content/manage-projects-and-library-content.msw.ts} (73%) create mode 100644 jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.ts create mode 100644 jsapp/js/api/react-query/other/other.msw.ts rename jsapp/js/api/react-query/{ => other}/other.ts (55%) create mode 100644 jsapp/js/api/react-query/scim/scim.msw.ts rename jsapp/js/api/react-query/{ => scim}/scim.ts (72%) rename jsapp/js/api/react-query/{server-logs-superusers.ts => server-logs-superusers/server-logs-superusers.msw.ts} (61%) create mode 100644 jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.ts create mode 100644 jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.msw.ts rename jsapp/js/api/react-query/{ => survey-data-rest-services}/survey-data-rest-services.ts (61%) create mode 100644 jsapp/js/api/react-query/survey-data/survey-data.msw.ts rename jsapp/js/api/react-query/{ => survey-data}/survey-data.ts (59%) create mode 100644 jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.msw.ts rename jsapp/js/api/react-query/{ => user-team-organization-usage}/user-team-organization-usage.ts (52%) diff --git a/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.msw.ts b/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.msw.ts new file mode 100644 index 0000000000..1360bd115d --- /dev/null +++ b/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.msw.ts @@ -0,0 +1,4125 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import type { AuthenticatedByCodeResponse } from '../../models/authenticatedByCodeResponse' + +import type { AuthenticatedByPasswordAnd2FAResponse } from '../../models/authenticatedByPasswordAnd2FAResponse' + +import type { AuthenticatedByPasswordResponse } from '../../models/authenticatedByPasswordResponse' + +import type { AuthenticatedResponse } from '../../models/authenticatedResponse' + +import { AuthenticatorType } from '../../models/authenticatorType' + +import type { AuthenticatorsResponse } from '../../models/authenticatorsResponse' + +import type { ConfigurationResponse } from '../../models/configurationResponse' + +import type { EmailAddressesResponse } from '../../models/emailAddressesResponse' + +import type { EmailVerificationInfoResponse } from '../../models/emailVerificationInfoResponse' + +import type { PasswordResetInfoResponse } from '../../models/passwordResetInfoResponse' + +import type { PhoneNumberChangeResponse } from '../../models/phoneNumberChangeResponse' + +import type { PhoneNumbersResponse } from '../../models/phoneNumbersResponse' + +import type { ProviderAccountsResponse } from '../../models/providerAccountsResponse' + +import type { ProviderSignupResponse } from '../../models/providerSignupResponse' + +import type { RecoveryCodesAuthenticator } from '../../models/recoveryCodesAuthenticator' + +import type { RecoveryCodesResponse } from '../../models/recoveryCodesResponse' + +import type { RefreshTokenResponse } from '../../models/refreshTokenResponse' + +import type { SessionsResponse } from '../../models/sessionsResponse' + +import type { StatusOKResponse } from '../../models/statusOKResponse' + +import type { TOTPAuthenticator } from '../../models/tOTPAuthenticator' + +import type { TOTPAuthenticatorResponse } from '../../models/tOTPAuthenticatorResponse' + +import type { WebAuthnAuthenticator } from '../../models/webAuthnAuthenticator' + +export const getApiV2AllauthBrowserV1ConfigGetResponseMock = ( + overrideResponse: Partial = {}, +): ConfigurationResponse => ({ + data: { + account: { + login_methods: faker.helpers.arrayElement([ + faker.helpers.arrayElements(['email', 'username'] as const), + undefined, + ]), + is_open_for_signup: faker.datatype.boolean(), + email_verification_by_code_enabled: faker.datatype.boolean(), + login_by_code_enabled: faker.datatype.boolean(), + password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + socialaccount: faker.helpers.arrayElement([ + { + providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + })), + }, + undefined, + ]), + mfa: faker.helpers.arrayElement([ + { supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType)) }, + undefined, + ]), + usersessions: faker.helpers.arrayElement([{ track_activity: faker.datatype.boolean() }, undefined]), + }, + status: faker.helpers.arrayElement([200] as const), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1ConfigGetResponseMock = ( + overrideResponse: Partial = {}, +): ConfigurationResponse => ({ + data: { + account: { + login_methods: faker.helpers.arrayElement([ + faker.helpers.arrayElements(['email', 'username'] as const), + undefined, + ]), + is_open_for_signup: faker.datatype.boolean(), + email_verification_by_code_enabled: faker.datatype.boolean(), + login_by_code_enabled: faker.datatype.boolean(), + password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + socialaccount: faker.helpers.arrayElement([ + { + providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + })), + }, + undefined, + ]), + mfa: faker.helpers.arrayElement([ + { supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType)) }, + undefined, + ]), + usersessions: faker.helpers.arrayElement([{ track_activity: faker.datatype.boolean() }, undefined]), + }, + status: faker.helpers.arrayElement([200] as const), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthLoginPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthLoginPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailVerificationInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + meta: { is_authenticating: faker.datatype.boolean() }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailVerificationInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + meta: { is_authenticating: faker.datatype.boolean() }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock = ( + overrideResponse: Partial = {}, +): PasswordResetInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: faker.helpers.arrayElement([ + { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthPasswordResetGetResponseMock = ( + overrideResponse: Partial = {}, +): PasswordResetInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: faker.helpers.arrayElement([ + { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthPasswordResetPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthProviderTokenPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderSignupResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + account: { + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + }, + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthProviderSignupGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderSignupResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + account: { + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + }, + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthProviderSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByCodeResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByCodeResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountProvidersGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountProvidersGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountProvidersDeleteResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailPostResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailPutResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AccountEmailPatchResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailPostResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailPutResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AccountEmailPatchResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailDeleteResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountPhoneGetResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumbersResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountPhonePostResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumberChangeResponse => ({ + status: faker.helpers.arrayElement([202] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountPhoneGetResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumbersResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountPhonePostResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumberChangeResponse => ({ + status: faker.helpers.arrayElement([202] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = ( + overrideResponse: Partial = {}, +): WebAuthnAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['webauthn'] as const), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatorsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock() }, + { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock() }, + { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock() }, + ]), + ), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = ( + overrideResponse: Partial = {}, +): WebAuthnAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['webauthn'] as const), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatorsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock() }, + { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock() }, + { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock() }, + ]), + ), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...{ + unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...{ + unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSessionGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSessionGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1TokensRefreshPostResponseMock = ( + overrideResponse: Partial = {}, +): RefreshTokenResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + access_token: faker.string.alpha({ length: { min: 10, max: 20 } }), + refresh_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSessionsGetResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSessionsGetResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSessionsDeleteResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1ConfigGetMockHandler = ( + overrideResponse?: + | ConfigurationResponse + | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/config', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1ConfigGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1ConfigGetMockHandler = ( + overrideResponse?: + | ConfigurationResponse + | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/config', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1ConfigGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthLoginPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/login', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthLoginPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthLoginPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/login', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthLoginPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler = ( + overrideResponse?: + | EmailVerificationInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailVerificationInfoResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler = ( + overrideResponse?: + | EmailVerificationInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailVerificationInfoResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/email/verify/resend', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/email/verify/resend', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/phone/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify/resend', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/phone/verify/resend', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/reauthenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/reauthenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/password/request', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/password/request', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler = ( + overrideResponse?: + | PasswordResetInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PasswordResetInfoResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthPasswordResetGetMockHandler = ( + overrideResponse?: + | PasswordResetInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PasswordResetInfoResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPasswordResetGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthPasswordResetPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPasswordResetPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/redirect', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/token', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthProviderTokenPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/provider/token', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthProviderTokenPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler = ( + overrideResponse?: + | ProviderSignupResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderSignupResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthProviderSignupGetMockHandler = ( + overrideResponse?: + | ProviderSignupResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderSignupResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthProviderSignupGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthProviderSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthProviderSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/2fa/authenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/2fa/authenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/2fa/reauthenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/2fa/reauthenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler = ( + overrideResponse?: + | AuthenticatedByCodeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByCodeResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/code/confirm', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler = ( + overrideResponse?: + | AuthenticatedByCodeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByCodeResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/code/confirm', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountProvidersGetMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/providers', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountProvidersGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/account/providers', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountProvidersGetMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/providers', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountProvidersGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountProvidersDeleteMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/account/providers', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountProvidersDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailGetMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailPostMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailPutMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.put('*/api/v2/allauth/browser/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailPutResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailPatchMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.patch('*/api/v2/allauth/browser/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailPatchResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountEmailGetMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountEmailPostMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountEmailPutMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.put('*/api/v2/allauth/app/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailPutResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountEmailPatchMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.patch('*/api/v2/allauth/app/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailPatchResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountEmailDeleteMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountPhoneGetMockHandler = ( + overrideResponse?: + | PhoneNumbersResponse + | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/phone', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountPhoneGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountPhonePostMockHandler = ( + overrideResponse?: + | PhoneNumberChangeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PhoneNumberChangeResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/phone', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountPhonePostResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountPhoneGetMockHandler = ( + overrideResponse?: + | PhoneNumbersResponse + | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/phone', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountPhoneGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountPhonePostMockHandler = ( + overrideResponse?: + | PhoneNumberChangeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PhoneNumberChangeResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/account/phone', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountPhonePostResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler = ( + overrideResponse?: + | AuthenticatorsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatorsResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler = ( + overrideResponse?: + | AuthenticatorsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatorsResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler = ( + overrideResponse?: + | RecoveryCodesResponse + | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler = ( + overrideResponse?: + | RecoveryCodesResponse + | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionGetMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/session', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSessionGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.delete('*/api/v2/allauth/browser/v1/auth/session', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthAppV1AuthSessionGetMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/session', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSessionGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthSessionDeleteMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.delete('*/api/v2/allauth/app/v1/auth/session', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthAppV1TokensRefreshPostMockHandler = ( + overrideResponse?: + | RefreshTokenResponse + | ((info: Parameters[1]>[0]) => Promise | RefreshTokenResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/tokens/refresh', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1TokensRefreshPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/password/change', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthAppV1AccountPasswordChangePostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/app/v1/account/password/change', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionsGetMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSessionsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthSessionsGetMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSessionsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AllauthAppV1AuthSessionsDeleteMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSessionsDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getAuthenticationAllauthHeadlessMock = () => [ + getApiV2AllauthBrowserV1ConfigGetMockHandler(), + getApiV2AllauthAppV1ConfigGetMockHandler(), + getApiV2AllauthBrowserV1AuthLoginPostMockHandler(), + getApiV2AllauthAppV1AuthLoginPostMockHandler(), + getApiV2AllauthBrowserV1AuthSignupPostMockHandler(), + getApiV2AllauthAppV1AuthSignupPostMockHandler(), + getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler(), + getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler(), + getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler(), + getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler(), + getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler(), + getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler(), + getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler(), + getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler(), + getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler(), + getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler(), + getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler(), + getApiV2AllauthAppV1AuthReauthenticatePostMockHandler(), + getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler(), + getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler(), + getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler(), + getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler(), + getApiV2AllauthAppV1AuthPasswordResetGetMockHandler(), + getApiV2AllauthAppV1AuthPasswordResetPostMockHandler(), + getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler(), + getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler(), + getApiV2AllauthAppV1AuthProviderTokenPostMockHandler(), + getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler(), + getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler(), + getApiV2AllauthAppV1AuthProviderSignupGetMockHandler(), + getApiV2AllauthAppV1AuthProviderSignupPostMockHandler(), + getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler(), + getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler(), + getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler(), + getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler(), + getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler(), + getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler(), + getApiV2AllauthBrowserV1AccountProvidersGetMockHandler(), + getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler(), + getApiV2AllauthAppV1AccountProvidersGetMockHandler(), + getApiV2AllauthAppV1AccountProvidersDeleteMockHandler(), + getApiV2AllauthBrowserV1AccountEmailGetMockHandler(), + getApiV2AllauthBrowserV1AccountEmailPostMockHandler(), + getApiV2AllauthBrowserV1AccountEmailPutMockHandler(), + getApiV2AllauthBrowserV1AccountEmailPatchMockHandler(), + getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler(), + getApiV2AllauthAppV1AccountEmailGetMockHandler(), + getApiV2AllauthAppV1AccountEmailPostMockHandler(), + getApiV2AllauthAppV1AccountEmailPutMockHandler(), + getApiV2AllauthAppV1AccountEmailPatchMockHandler(), + getApiV2AllauthAppV1AccountEmailDeleteMockHandler(), + getApiV2AllauthBrowserV1AccountPhoneGetMockHandler(), + getApiV2AllauthBrowserV1AccountPhonePostMockHandler(), + getApiV2AllauthAppV1AccountPhoneGetMockHandler(), + getApiV2AllauthAppV1AccountPhonePostMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler(), + getApiV2AllauthBrowserV1AuthSessionGetMockHandler(), + getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler(), + getApiV2AllauthAppV1AuthSessionGetMockHandler(), + getApiV2AllauthAppV1AuthSessionDeleteMockHandler(), + getApiV2AllauthAppV1TokensRefreshPostMockHandler(), + getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler(), + getApiV2AllauthAppV1AccountPasswordChangePostMockHandler(), + getApiV2AllauthBrowserV1AuthSessionsGetMockHandler(), + getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler(), + getApiV2AllauthAppV1AuthSessionsGetMockHandler(), + getApiV2AllauthAppV1AuthSessionsDeleteMockHandler(), +] diff --git a/jsapp/js/api/react-query/authentication-allauth-headless.ts b/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.ts similarity index 60% rename from jsapp/js/api/react-query/authentication-allauth-headless.ts rename to jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.ts index feaf4d33d8..042476b18e 100644 --- a/jsapp/js/api/react-query/authentication-allauth-headless.ts +++ b/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.ts @@ -19,119 +19,107 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { AddAuthenticatorConflictResponse } from '../models/addAuthenticatorConflictResponse' +import type { AddAuthenticatorConflictResponse } from '../../models/addAuthenticatorConflictResponse' -import type { AuthenticationOrReauthenticationResponse } from '../models/authenticationOrReauthenticationResponse' +import type { AuthenticatedByCodeResponse } from '../../models/authenticatedByCodeResponse' -import type { AuthenticationResponse } from '../models/authenticationResponse' +import type { AuthenticatedByPasswordAnd2FAResponse } from '../../models/authenticatedByPasswordAnd2FAResponse' -import type { ChangePasswordBody } from '../models/changePasswordBody' +import type { AuthenticatedByPasswordResponse } from '../../models/authenticatedByPasswordResponse' -import type { ConfirmLoginCodeBody } from '../models/confirmLoginCodeBody' +import type { AuthenticatedResponse } from '../../models/authenticatedResponse' -import type { ConflictResponse } from '../models/conflictResponse' +import type { AuthenticationOrReauthenticationResponse } from '../../models/authenticationOrReauthenticationResponse' -import type { EmailBody } from '../models/emailBody' +import type { AuthenticationResponse } from '../../models/authenticationResponse' -import type { EndSessionsBody } from '../models/endSessionsBody' +import type { AuthenticatorsResponse } from '../../models/authenticatorsResponse' -import type { ErrorResponse } from '../models/errorResponse' +import type { ChangePasswordBody } from '../../models/changePasswordBody' -import type { ForbiddenResponse } from '../models/forbiddenResponse' +import type { ConfigurationResponse } from '../../models/configurationResponse' -import type { LoginBody } from '../models/loginBody' +import type { ConfirmLoginCodeBody } from '../../models/confirmLoginCodeBody' -import type { MFAAuthenticateBody } from '../models/mFAAuthenticateBody' +import type { ConflictResponse } from '../../models/conflictResponse' -import type { MarkPrimaryEmailBody } from '../models/markPrimaryEmailBody' +import type { EmailAddressesResponse } from '../../models/emailAddressesResponse' -import type { NotFoundResponse } from '../models/notFoundResponse' +import type { EmailBody } from '../../models/emailBody' -import type { PhoneBody } from '../models/phoneBody' +import type { EmailVerificationInfoResponse } from '../../models/emailVerificationInfoResponse' -import type { ProviderAccountBody } from '../models/providerAccountBody' +import type { EndSessionsBody } from '../../models/endSessionsBody' -import type { ProviderRedirectBody } from '../models/providerRedirectBody' +import type { ErrorResponse } from '../../models/errorResponse' -import type { ProviderSignupBody } from '../models/providerSignupBody' +import type { ForbiddenResponse } from '../../models/forbiddenResponse' -import type { ProviderTokenBody } from '../models/providerTokenBody' +import type { LoginBody } from '../../models/loginBody' -import type { ReauthenticateBody } from '../models/reauthenticateBody' +import type { MFAAuthenticateBody } from '../../models/mFAAuthenticateBody' -import type { ReauthenticationRequiredResponse } from '../models/reauthenticationRequiredResponse' +import type { MarkPrimaryEmailBody } from '../../models/markPrimaryEmailBody' -import type { RefreshTokenBody } from '../models/refreshTokenBody' +import type { NotFoundResponse } from '../../models/notFoundResponse' -import type { RequestPasswordBody } from '../models/requestPasswordBody' +import type { PasswordResetInfoResponse } from '../../models/passwordResetInfoResponse' -import type { ResetPasswordBody } from '../models/resetPasswordBody' +import type { PhoneBody } from '../../models/phoneBody' -import type { SessionGoneResponse } from '../models/sessionGoneResponse' +import type { PhoneNumberChangeResponse } from '../../models/phoneNumberChangeResponse' -import type { SetupTOTPBody } from '../models/setupTOTPBody' +import type { PhoneNumbersResponse } from '../../models/phoneNumbersResponse' -import type { SignupBody } from '../models/signupBody' +import type { ProviderAccountBody } from '../../models/providerAccountBody' -import type { TOTPAuthenticatorNotFoundResponse } from '../models/tOTPAuthenticatorNotFoundResponse' +import type { ProviderAccountsResponse } from '../../models/providerAccountsResponse' -import type { TooManyRequestsResponse } from '../models/tooManyRequestsResponse' +import type { ProviderRedirectBody } from '../../models/providerRedirectBody' -import type { UnauthenticatedResponse } from '../models/unauthenticatedResponse' +import type { ProviderSignupBody } from '../../models/providerSignupBody' -import type { VerifyEmailBody } from '../models/verifyEmailBody' +import type { ProviderSignupResponse } from '../../models/providerSignupResponse' -import type { VerifyPhoneBody } from '../models/verifyPhoneBody' +import type { ProviderTokenBody } from '../../models/providerTokenBody' -import { faker } from '@faker-js/faker' +import type { ReauthenticateBody } from '../../models/reauthenticateBody' -import { http, HttpResponse } from 'msw' +import type { ReauthenticationRequiredResponse } from '../../models/reauthenticationRequiredResponse' -import type { AuthenticatedByCodeResponse } from '../models/authenticatedByCodeResponse' +import type { RecoveryCodesResponse } from '../../models/recoveryCodesResponse' -import type { AuthenticatedByPasswordAnd2FAResponse } from '../models/authenticatedByPasswordAnd2FAResponse' +import type { RefreshTokenBody } from '../../models/refreshTokenBody' -import type { AuthenticatedByPasswordResponse } from '../models/authenticatedByPasswordResponse' +import type { RefreshTokenResponse } from '../../models/refreshTokenResponse' -import type { AuthenticatedResponse } from '../models/authenticatedResponse' +import type { RequestPasswordBody } from '../../models/requestPasswordBody' -import { AuthenticatorType } from '../models/authenticatorType' +import type { ResetPasswordBody } from '../../models/resetPasswordBody' -import type { AuthenticatorsResponse } from '../models/authenticatorsResponse' +import type { SessionGoneResponse } from '../../models/sessionGoneResponse' -import type { ConfigurationResponse } from '../models/configurationResponse' +import type { SessionsResponse } from '../../models/sessionsResponse' -import type { EmailAddressesResponse } from '../models/emailAddressesResponse' +import type { SetupTOTPBody } from '../../models/setupTOTPBody' -import type { EmailVerificationInfoResponse } from '../models/emailVerificationInfoResponse' +import type { SignupBody } from '../../models/signupBody' -import type { PasswordResetInfoResponse } from '../models/passwordResetInfoResponse' +import type { StatusOKResponse } from '../../models/statusOKResponse' -import type { PhoneNumberChangeResponse } from '../models/phoneNumberChangeResponse' +import type { TOTPAuthenticatorNotFoundResponse } from '../../models/tOTPAuthenticatorNotFoundResponse' -import type { PhoneNumbersResponse } from '../models/phoneNumbersResponse' +import type { TOTPAuthenticatorResponse } from '../../models/tOTPAuthenticatorResponse' -import type { ProviderAccountsResponse } from '../models/providerAccountsResponse' +import type { TooManyRequestsResponse } from '../../models/tooManyRequestsResponse' -import type { ProviderSignupResponse } from '../models/providerSignupResponse' +import type { UnauthenticatedResponse } from '../../models/unauthenticatedResponse' -import type { RecoveryCodesAuthenticator } from '../models/recoveryCodesAuthenticator' +import type { VerifyEmailBody } from '../../models/verifyEmailBody' -import type { RecoveryCodesResponse } from '../models/recoveryCodesResponse' +import type { VerifyPhoneBody } from '../../models/verifyPhoneBody' -import type { RefreshTokenResponse } from '../models/refreshTokenResponse' - -import type { SessionsResponse } from '../models/sessionsResponse' - -import type { StatusOKResponse } from '../models/statusOKResponse' - -import type { TOTPAuthenticator } from '../models/tOTPAuthenticator' - -import type { TOTPAuthenticatorResponse } from '../models/tOTPAuthenticatorResponse' - -import type { WebAuthnAuthenticator } from '../models/webAuthnAuthenticator' - -import { fetchWithAuth } from '../orval.mutator' +import { fetchWithAuth } from '../../orval.mutator' type SecondParameter unknown> = Parameters[1] @@ -8122,4070 +8110,3 @@ export const useAllauthAppV1AuthSessionsDelete = = {}, -): ConfigurationResponse => ({ - data: { - account: { - login_methods: faker.helpers.arrayElement([ - faker.helpers.arrayElements(['email', 'username'] as const), - undefined, - ]), - is_open_for_signup: faker.datatype.boolean(), - email_verification_by_code_enabled: faker.datatype.boolean(), - login_by_code_enabled: faker.datatype.boolean(), - password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - socialaccount: faker.helpers.arrayElement([ - { - providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - })), - }, - undefined, - ]), - mfa: faker.helpers.arrayElement([ - { supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType)) }, - undefined, - ]), - usersessions: faker.helpers.arrayElement([{ track_activity: faker.datatype.boolean() }, undefined]), - }, - status: faker.helpers.arrayElement([200] as const), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1ConfigGetResponseMock = ( - overrideResponse: Partial = {}, -): ConfigurationResponse => ({ - data: { - account: { - login_methods: faker.helpers.arrayElement([ - faker.helpers.arrayElements(['email', 'username'] as const), - undefined, - ]), - is_open_for_signup: faker.datatype.boolean(), - email_verification_by_code_enabled: faker.datatype.boolean(), - login_by_code_enabled: faker.datatype.boolean(), - password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - socialaccount: faker.helpers.arrayElement([ - { - providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - })), - }, - undefined, - ]), - mfa: faker.helpers.arrayElement([ - { supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType)) }, - undefined, - ]), - usersessions: faker.helpers.arrayElement([{ track_activity: faker.datatype.boolean() }, undefined]), - }, - status: faker.helpers.arrayElement([200] as const), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthLoginPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthLoginPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthSignupPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthSignupPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock = ( - overrideResponse: Partial = {}, -): EmailVerificationInfoResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - meta: { is_authenticating: faker.datatype.boolean() }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock = ( - overrideResponse: Partial = {}, -): EmailVerificationInfoResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - meta: { is_authenticating: faker.datatype.boolean() }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthReauthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock = ( - overrideResponse: Partial = {}, -): PasswordResetInfoResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: faker.helpers.arrayElement([ - { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthPasswordResetGetResponseMock = ( - overrideResponse: Partial = {}, -): PasswordResetInfoResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: faker.helpers.arrayElement([ - { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthPasswordResetPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthProviderTokenPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock = ( - overrideResponse: Partial = {}, -): ProviderSignupResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - account: { - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - }, - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthProviderSignupGetResponseMock = ( - overrideResponse: Partial = {}, -): ProviderSignupResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - account: { - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - }, - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthProviderSignupPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordAnd2FAResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordAnd2FAResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordAnd2FAResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordAnd2FAResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByCodeResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByCodeResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountProvidersGetResponseMock = ( - overrideResponse: Partial = {}, -): ProviderAccountsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock = ( - overrideResponse: Partial = {}, -): ProviderAccountsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountProvidersGetResponseMock = ( - overrideResponse: Partial = {}, -): ProviderAccountsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountProvidersDeleteResponseMock = ( - overrideResponse: Partial = {}, -): ProviderAccountsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountEmailGetResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountEmailPostResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountEmailPutResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthBrowserV1AccountEmailPatchResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountEmailGetResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountEmailPostResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountEmailPutResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthAppV1AccountEmailPatchResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountEmailDeleteResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountPhoneGetResponseMock = ( - overrideResponse: Partial = {}, -): PhoneNumbersResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountPhonePostResponseMock = ( - overrideResponse: Partial = {}, -): PhoneNumberChangeResponse => ({ - status: faker.helpers.arrayElement([202] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountPhoneGetResponseMock = ( - overrideResponse: Partial = {}, -): PhoneNumbersResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountPhonePostResponseMock = ( - overrideResponse: Partial = {}, -): PhoneNumberChangeResponse => ({ - status: faker.helpers.arrayElement([202] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = ( - overrideResponse: Partial = {}, -): RecoveryCodesAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['recovery_codes'] as const), - total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = ( - overrideResponse: Partial = {}, -): WebAuthnAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['webauthn'] as const), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatorsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock() }, - { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock() }, - { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock() }, - ]), - ), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = ( - overrideResponse: Partial = {}, -): RecoveryCodesAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['recovery_codes'] as const), - total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = ( - overrideResponse: Partial = {}, -): WebAuthnAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['webauthn'] as const), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatorsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock() }, - { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock() }, - { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock() }, - ]), - ), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticatorResponse => ({ - status: faker.helpers.arrayElement([200] as const), - meta: faker.helpers.arrayElement([ - { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - data: { - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticatorResponse => ({ - status: faker.helpers.arrayElement([200] as const), - meta: faker.helpers.arrayElement([ - { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - data: { - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticatorResponse => ({ - status: faker.helpers.arrayElement([200] as const), - meta: faker.helpers.arrayElement([ - { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - data: { - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticatorResponse => ({ - status: faker.helpers.arrayElement([200] as const), - meta: faker.helpers.arrayElement([ - { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - data: { - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock = ( - overrideResponse: Partial = {}, -): RecoveryCodesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['recovery_codes'] as const), - total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - ...{ - unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock = ( - overrideResponse: Partial = {}, -): RecoveryCodesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['recovery_codes'] as const), - total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - ...{ - unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthSessionGetResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthSessionGetResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1TokensRefreshPostResponseMock = ( - overrideResponse: Partial = {}, -): RefreshTokenResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - access_token: faker.string.alpha({ length: { min: 10, max: 20 } }), - refresh_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthSessionsGetResponseMock = ( - overrideResponse: Partial = {}, -): SessionsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), - ip: faker.string.alpha({ length: { min: 10, max: 20 } }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - is_current: faker.datatype.boolean(), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - last_seen_at: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock = ( - overrideResponse: Partial = {}, -): SessionsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), - ip: faker.string.alpha({ length: { min: 10, max: 20 } }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - is_current: faker.datatype.boolean(), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - last_seen_at: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthSessionsGetResponseMock = ( - overrideResponse: Partial = {}, -): SessionsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), - ip: faker.string.alpha({ length: { min: 10, max: 20 } }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - is_current: faker.datatype.boolean(), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - last_seen_at: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthSessionsDeleteResponseMock = ( - overrideResponse: Partial = {}, -): SessionsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), - ip: faker.string.alpha({ length: { min: 10, max: 20 } }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - is_current: faker.datatype.boolean(), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - last_seen_at: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1ConfigGetMockHandler = ( - overrideResponse?: - | ConfigurationResponse - | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/config', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1ConfigGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1ConfigGetMockHandler = ( - overrideResponse?: - | ConfigurationResponse - | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/config', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1ConfigGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthLoginPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/login', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthLoginPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthLoginPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/login', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthLoginPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthSignupPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthSignupPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthSignupPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthSignupPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler = ( - overrideResponse?: - | EmailVerificationInfoResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailVerificationInfoResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler = ( - overrideResponse?: - | EmailVerificationInfoResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailVerificationInfoResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/email/verify/resend', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/email/verify/resend', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/phone/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify/resend', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/phone/verify/resend', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/reauthenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthReauthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/reauthenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthReauthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/password/request', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/password/request', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler = ( - overrideResponse?: - | PasswordResetInfoResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PasswordResetInfoResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthPasswordResetGetMockHandler = ( - overrideResponse?: - | PasswordResetInfoResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PasswordResetInfoResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthPasswordResetGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthPasswordResetPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthPasswordResetPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/provider/redirect', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/provider/token', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthProviderTokenPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/provider/token', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthProviderTokenPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler = ( - overrideResponse?: - | ProviderSignupResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderSignupResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthProviderSignupGetMockHandler = ( - overrideResponse?: - | ProviderSignupResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderSignupResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthProviderSignupGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthProviderSignupPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthProviderSignupPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordAnd2FAResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordAnd2FAResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/2fa/authenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordAnd2FAResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordAnd2FAResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/2fa/authenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordAnd2FAResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordAnd2FAResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/2fa/reauthenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordAnd2FAResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordAnd2FAResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/2fa/reauthenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler = ( - overrideResponse?: - | AuthenticatedByCodeResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByCodeResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/code/confirm', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler = ( - overrideResponse?: - | AuthenticatedByCodeResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByCodeResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/code/confirm', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountProvidersGetMockHandler = ( - overrideResponse?: - | ProviderAccountsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderAccountsResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/providers', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountProvidersGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler = ( - overrideResponse?: - | ProviderAccountsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderAccountsResponse), -) => { - return http.delete('*/api/v2/allauth/browser/v1/account/providers', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountProvidersGetMockHandler = ( - overrideResponse?: - | ProviderAccountsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderAccountsResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/providers', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountProvidersGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountProvidersDeleteMockHandler = ( - overrideResponse?: - | ProviderAccountsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderAccountsResponse), -) => { - return http.delete('*/api/v2/allauth/app/v1/account/providers', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountProvidersDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountEmailGetMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountEmailGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountEmailPostMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountEmailPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountEmailPutMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.put('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountEmailPutResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountEmailPatchMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.patch('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountEmailPatchResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.delete('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountEmailGetMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountEmailGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountEmailPostMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountEmailPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountEmailPutMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.put('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountEmailPutResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountEmailPatchMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.patch('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountEmailPatchResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountEmailDeleteMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.delete('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountEmailDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountPhoneGetMockHandler = ( - overrideResponse?: - | PhoneNumbersResponse - | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/phone', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountPhoneGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountPhonePostMockHandler = ( - overrideResponse?: - | PhoneNumberChangeResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PhoneNumberChangeResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/account/phone', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountPhonePostResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountPhoneGetMockHandler = ( - overrideResponse?: - | PhoneNumbersResponse - | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/phone', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountPhoneGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountPhonePostMockHandler = ( - overrideResponse?: - | PhoneNumberChangeResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PhoneNumberChangeResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/account/phone', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountPhonePostResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler = ( - overrideResponse?: - | AuthenticatorsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatorsResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/authenticators', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler = ( - overrideResponse?: - | AuthenticatorsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatorsResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/authenticators', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler = ( - overrideResponse?: - | TOTPAuthenticatorResponse - | (( - info: Parameters[1]>[0], - ) => Promise | TOTPAuthenticatorResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler = ( - overrideResponse?: - | TOTPAuthenticatorResponse - | (( - info: Parameters[1]>[0], - ) => Promise | TOTPAuthenticatorResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.delete('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler = ( - overrideResponse?: - | TOTPAuthenticatorResponse - | (( - info: Parameters[1]>[0], - ) => Promise | TOTPAuthenticatorResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler = ( - overrideResponse?: - | TOTPAuthenticatorResponse - | (( - info: Parameters[1]>[0], - ) => Promise | TOTPAuthenticatorResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.delete('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler = ( - overrideResponse?: - | RecoveryCodesResponse - | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.post('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler = ( - overrideResponse?: - | RecoveryCodesResponse - | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.post('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthBrowserV1AuthSessionGetMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/auth/session', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthSessionGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.delete('*/api/v2/allauth/browser/v1/auth/session', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthAppV1AuthSessionGetMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/auth/session', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthSessionGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthSessionDeleteMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.delete('*/api/v2/allauth/app/v1/auth/session', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthAppV1TokensRefreshPostMockHandler = ( - overrideResponse?: - | RefreshTokenResponse - | ((info: Parameters[1]>[0]) => Promise | RefreshTokenResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/tokens/refresh', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1TokensRefreshPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.post('*/api/v2/allauth/browser/v1/account/password/change', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthAppV1AccountPasswordChangePostMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.post('*/api/v2/allauth/app/v1/account/password/change', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthBrowserV1AuthSessionsGetMockHandler = ( - overrideResponse?: - | SessionsResponse - | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthSessionsGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler = ( - overrideResponse?: - | SessionsResponse - | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), -) => { - return http.delete('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthSessionsGetMockHandler = ( - overrideResponse?: - | SessionsResponse - | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthSessionsGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthSessionsDeleteMockHandler = ( - overrideResponse?: - | SessionsResponse - | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), -) => { - return http.delete('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthSessionsDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getAuthenticationAllauthHeadlessMock = () => [ - getApiV2AllauthBrowserV1ConfigGetMockHandler(), - getApiV2AllauthAppV1ConfigGetMockHandler(), - getApiV2AllauthBrowserV1AuthLoginPostMockHandler(), - getApiV2AllauthAppV1AuthLoginPostMockHandler(), - getApiV2AllauthBrowserV1AuthSignupPostMockHandler(), - getApiV2AllauthAppV1AuthSignupPostMockHandler(), - getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler(), - getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler(), - getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler(), - getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler(), - getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler(), - getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler(), - getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler(), - getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler(), - getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler(), - getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler(), - getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler(), - getApiV2AllauthAppV1AuthReauthenticatePostMockHandler(), - getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler(), - getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler(), - getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler(), - getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler(), - getApiV2AllauthAppV1AuthPasswordResetGetMockHandler(), - getApiV2AllauthAppV1AuthPasswordResetPostMockHandler(), - getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler(), - getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler(), - getApiV2AllauthAppV1AuthProviderTokenPostMockHandler(), - getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler(), - getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler(), - getApiV2AllauthAppV1AuthProviderSignupGetMockHandler(), - getApiV2AllauthAppV1AuthProviderSignupPostMockHandler(), - getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler(), - getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler(), - getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler(), - getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler(), - getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler(), - getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler(), - getApiV2AllauthBrowserV1AccountProvidersGetMockHandler(), - getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler(), - getApiV2AllauthAppV1AccountProvidersGetMockHandler(), - getApiV2AllauthAppV1AccountProvidersDeleteMockHandler(), - getApiV2AllauthBrowserV1AccountEmailGetMockHandler(), - getApiV2AllauthBrowserV1AccountEmailPostMockHandler(), - getApiV2AllauthBrowserV1AccountEmailPutMockHandler(), - getApiV2AllauthBrowserV1AccountEmailPatchMockHandler(), - getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler(), - getApiV2AllauthAppV1AccountEmailGetMockHandler(), - getApiV2AllauthAppV1AccountEmailPostMockHandler(), - getApiV2AllauthAppV1AccountEmailPutMockHandler(), - getApiV2AllauthAppV1AccountEmailPatchMockHandler(), - getApiV2AllauthAppV1AccountEmailDeleteMockHandler(), - getApiV2AllauthBrowserV1AccountPhoneGetMockHandler(), - getApiV2AllauthBrowserV1AccountPhonePostMockHandler(), - getApiV2AllauthAppV1AccountPhoneGetMockHandler(), - getApiV2AllauthAppV1AccountPhonePostMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler(), - getApiV2AllauthBrowserV1AuthSessionGetMockHandler(), - getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler(), - getApiV2AllauthAppV1AuthSessionGetMockHandler(), - getApiV2AllauthAppV1AuthSessionDeleteMockHandler(), - getApiV2AllauthAppV1TokensRefreshPostMockHandler(), - getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler(), - getApiV2AllauthAppV1AccountPasswordChangePostMockHandler(), - getApiV2AllauthBrowserV1AuthSessionsGetMockHandler(), - getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler(), - getApiV2AllauthAppV1AuthSessionsGetMockHandler(), - getApiV2AllauthAppV1AuthSessionsDeleteMockHandler(), -] diff --git a/jsapp/js/api/react-query/configuration.ts b/jsapp/js/api/react-query/configuration/configuration.msw.ts similarity index 70% rename from jsapp/js/api/react-query/configuration.ts rename to jsapp/js/api/react-query/configuration/configuration.msw.ts index 9ab9781e53..7e57ce7fd7 100644 --- a/jsapp/js/api/react-query/configuration.ts +++ b/jsapp/js/api/react-query/configuration/configuration.msw.ts @@ -9,96 +9,11 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { useQuery } from '@tanstack/react-query' -import type { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query' - import { faker } from '@faker-js/faker' import { http, HttpResponse } from 'msw' -import type { EnvironmentResponse } from '../models/environmentResponse' - -import { fetchWithAuth } from '../orval.mutator' - -type SecondParameter unknown> = Parameters[1] - -/** - * Retrieve Kobo server environment configurations. - -This endpoint provides a wide range of configuration details required by the frontend client, including: -- Legal, support, and community URLs (e.g. Terms of Service, Privacy Policy). -- Frontend configuration (retry times, usage limit enforcement, etc). -- Global static lists (sectors, countries, interface languages, operational purposes). -- Metadata configuration (available project and user metadata fields). -- Features configurations (MFA, password entropy meter, custom guidance text). -- Additional integrations and features (Stripe public key, ASR & MT enablement, Social apps). - - */ -export type environmentRetrieveResponse200 = { - data: EnvironmentResponse - status: 200 -} - -export type environmentRetrieveResponseComposite = environmentRetrieveResponse200 - -export type environmentRetrieveResponse = environmentRetrieveResponseComposite & { - headers: Headers -} - -export const getEnvironmentRetrieveUrl = () => { - return `/api/v2/environment/` -} - -export const environmentRetrieve = async (options?: RequestInit): Promise => { - return fetchWithAuth(getEnvironmentRetrieveUrl(), { - ...options, - method: 'GET', - }) -} - -export const getEnvironmentRetrieveQueryKey = () => { - return ['api', 'v2', 'environment'] as const -} - -export const getEnvironmentRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getEnvironmentRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - environmentRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type EnvironmentRetrieveQueryResult = NonNullable>> -export type EnvironmentRetrieveQueryError = unknown - -export function useEnvironmentRetrieve< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getEnvironmentRetrieveQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} +import type { EnvironmentResponse } from '../../models/environmentResponse' export const getApiV2EnvironmentRetrieveResponseMock = ( overrideResponse: Partial = {}, @@ -209,7 +124,7 @@ export const getApiV2EnvironmentRetrieveMockHandler = ( | EnvironmentResponse | ((info: Parameters[1]>[0]) => Promise | EnvironmentResponse), ) => { - return http.get('*/api/v2/environment{/}?', async (info) => { + return http.get('*/api/v2/environment/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/configuration/configuration.ts b/jsapp/js/api/react-query/configuration/configuration.ts new file mode 100644 index 0000000000..c6fac2287d --- /dev/null +++ b/jsapp/js/api/react-query/configuration/configuration.ts @@ -0,0 +1,97 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { useQuery } from '@tanstack/react-query' +import type { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query' + +import type { EnvironmentResponse } from '../../models/environmentResponse' + +import { fetchWithAuth } from '../../orval.mutator' + +type SecondParameter unknown> = Parameters[1] + +/** + * Retrieve Kobo server environment configurations. + +This endpoint provides a wide range of configuration details required by the frontend client, including: +- Legal, support, and community URLs (e.g. Terms of Service, Privacy Policy). +- Frontend configuration (retry times, usage limit enforcement, etc). +- Global static lists (sectors, countries, interface languages, operational purposes). +- Metadata configuration (available project and user metadata fields). +- Features configurations (MFA, password entropy meter, custom guidance text). +- Additional integrations and features (Stripe public key, ASR & MT enablement, Social apps). + + */ +export type environmentRetrieveResponse200 = { + data: EnvironmentResponse + status: 200 +} + +export type environmentRetrieveResponseComposite = environmentRetrieveResponse200 + +export type environmentRetrieveResponse = environmentRetrieveResponseComposite & { + headers: Headers +} + +export const getEnvironmentRetrieveUrl = () => { + return `/api/v2/environment/` +} + +export const environmentRetrieve = async (options?: RequestInit): Promise => { + return fetchWithAuth(getEnvironmentRetrieveUrl(), { + ...options, + method: 'GET', + }) +} + +export const getEnvironmentRetrieveQueryKey = () => { + return ['api', 'v2', 'environment'] as const +} + +export const getEnvironmentRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getEnvironmentRetrieveQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + environmentRetrieve({ signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type EnvironmentRetrieveQueryResult = NonNullable>> +export type EnvironmentRetrieveQueryError = unknown + +export function useEnvironmentRetrieve< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getEnvironmentRetrieveQueryOptions(options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} diff --git a/jsapp/js/api/react-query/form-content/form-content.msw.ts b/jsapp/js/api/react-query/form-content/form-content.msw.ts new file mode 100644 index 0000000000..63aa1d2bd5 --- /dev/null +++ b/jsapp/js/api/react-query/form-content/form-content.msw.ts @@ -0,0 +1,548 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import type { AssetSnapshotResponse } from '../../models/assetSnapshotResponse' + +import type { AssetValidContentResponse } from '../../models/assetValidContentResponse' + +import type { ContentResponse } from '../../models/contentResponse' + +import type { OpenRosaXFormResponse } from '../../models/openRosaXFormResponse' + +import type { PaginatedAssetSnapshotResponseList } from '../../models/paginatedAssetSnapshotResponseList' + +export const getApiV2AssetSnapshotsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetSnapshotResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + xml: faker.internet.url(), + enketopreviewlink: faker.internet.url(), + asset: faker.internet.url(), + asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + details: { + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + warnings: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + source: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetSnapshotsCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetSnapshotResponse => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + xml: faker.internet.url(), + enketopreviewlink: faker.internet.url(), + asset: faker.internet.url(), + asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + details: { + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + warnings: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + source: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetSnapshotsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetSnapshotResponse => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + xml: faker.internet.url(), + enketopreviewlink: faker.internet.url(), + asset: faker.internet.url(), + asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + details: { + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + warnings: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + source: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetSnapshotsXformRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OpenRosaXFormResponse => ({ + html: { + head: faker.helpers.arrayElement([ + { + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + model: faker.helpers.arrayElement([ + { + instance: faker.helpers.arrayElement([ + { + instanceUuid: faker.helpers.arrayElement([ + { + fieldName: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + meta: faker.helpers.arrayElement([ + { + instanceID: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + body: faker.helpers.arrayElement([ + { + input: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + hint: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OpenRosaXFormResponse => ({ + html: { + head: faker.helpers.arrayElement([ + { + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + model: faker.helpers.arrayElement([ + { + instance: faker.helpers.arrayElement([ + { + instanceUuid: faker.helpers.arrayElement([ + { + fieldName: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + meta: faker.helpers.arrayElement([ + { + instanceID: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + body: faker.helpers.arrayElement([ + { + input: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + hint: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsContentRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ContentResponse => ({ + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + data: { + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsTableViewRetrieveResponseMock = (): string => faker.word.sample() + +export const getApiV2AssetsValidContentRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetValidContentResponse => ({ + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + data: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsXlsRetrieveResponseMock = (): string => faker.word.sample() + +export const getApiV2AssetSnapshotsListMockHandler = ( + overrideResponse?: + | PaginatedAssetSnapshotResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetSnapshotResponseList), +) => { + return http.get('*/api/v2/asset_snapshots/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSnapshotsCreateMockHandler = ( + overrideResponse?: + | AssetSnapshotResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetSnapshotResponse), +) => { + return http.post('*/api/v2/asset_snapshots/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSnapshotsRetrieveMockHandler = ( + overrideResponse?: + | AssetSnapshotResponse + | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSnapshotsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetSnapshotsPreviewRetrieveMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AssetSnapshotsXformRetrieveMockHandler = ( + overrideResponse?: + | OpenRosaXFormResponse + | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsXformRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler = ( + overrideResponse?: + | OpenRosaXFormResponse + | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsContentRetrieveMockHandler = ( + overrideResponse?: + | ContentResponse + | ((info: Parameters[1]>[0]) => Promise | ContentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/content/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsContentRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsTableViewRetrieveMockHandler = ( + overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), +) => { + return http.get('*/api/v2/assets/:uidAsset/table_view/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsTableViewRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsValidContentRetrieveMockHandler = ( + overrideResponse?: + | AssetValidContentResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetValidContentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/valid_content/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsValidContentRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsXlsRetrieveMockHandler = ( + overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), +) => { + return http.get('*/api/v2/assets/:uidAsset/xls/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsXlsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getFormContentMock = () => [ + getApiV2AssetSnapshotsListMockHandler(), + getApiV2AssetSnapshotsCreateMockHandler(), + getApiV2AssetSnapshotsRetrieveMockHandler(), + getApiV2AssetSnapshotsDestroyMockHandler(), + getApiV2AssetSnapshotsPreviewRetrieveMockHandler(), + getApiV2AssetSnapshotsXformRetrieveMockHandler(), + getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler(), + getApiV2AssetsContentRetrieveMockHandler(), + getApiV2AssetsTableViewRetrieveMockHandler(), + getApiV2AssetsValidContentRetrieveMockHandler(), + getApiV2AssetsXlsRetrieveMockHandler(), +] diff --git a/jsapp/js/api/react-query/form-content.ts b/jsapp/js/api/react-query/form-content/form-content.ts similarity index 60% rename from jsapp/js/api/react-query/form-content.ts rename to jsapp/js/api/react-query/form-content/form-content.ts index a2af1b129a..57ce837713 100644 --- a/jsapp/js/api/react-query/form-content.ts +++ b/jsapp/js/api/react-query/form-content/form-content.ts @@ -19,31 +19,27 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { AssetSnapshotCreateRequest } from '../models/assetSnapshotCreateRequest' +import type { AssetSnapshotCreateRequest } from '../../models/assetSnapshotCreateRequest' -import type { AssetSnapshotsListParams } from '../models/assetSnapshotsListParams' +import type { AssetSnapshotResponse } from '../../models/assetSnapshotResponse' -import type { AssetSnapshotsRetrieveParams } from '../models/assetSnapshotsRetrieveParams' +import type { AssetSnapshotsListParams } from '../../models/assetSnapshotsListParams' -import type { ErrorDetail } from '../models/errorDetail' +import type { AssetSnapshotsRetrieveParams } from '../../models/assetSnapshotsRetrieveParams' -import type { ErrorObject } from '../models/errorObject' +import type { AssetValidContentResponse } from '../../models/assetValidContentResponse' -import { faker } from '@faker-js/faker' +import type { ContentResponse } from '../../models/contentResponse' -import { http, HttpResponse } from 'msw' +import type { ErrorDetail } from '../../models/errorDetail' -import type { AssetSnapshotResponse } from '../models/assetSnapshotResponse' +import type { ErrorObject } from '../../models/errorObject' -import type { AssetValidContentResponse } from '../models/assetValidContentResponse' +import type { OpenRosaXFormResponse } from '../../models/openRosaXFormResponse' -import type { ContentResponse } from '../models/contentResponse' +import type { PaginatedAssetSnapshotResponseList } from '../../models/paginatedAssetSnapshotResponseList' -import type { OpenRosaXFormResponse } from '../models/openRosaXFormResponse' - -import type { PaginatedAssetSnapshotResponseList } from '../models/paginatedAssetSnapshotResponseList' - -import { fetchWithAuth } from '../orval.mutator' +import { fetchWithAuth } from '../../orval.mutator' type SecondParameter unknown> = Parameters[1] @@ -1037,527 +1033,3 @@ export function useAssetsXlsRetrieve = {}, -): PaginatedAssetSnapshotResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - owner: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - xml: faker.internet.url(), - enketopreviewlink: faker.internet.url(), - asset: faker.internet.url(), - asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - details: { - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - warnings: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - }, - source: { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translation: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AssetSnapshotsCreateResponseMock = ( - overrideResponse: Partial = {}, -): AssetSnapshotResponse => ({ - url: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - owner: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - xml: faker.internet.url(), - enketopreviewlink: faker.internet.url(), - asset: faker.internet.url(), - asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - details: { - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - warnings: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - }, - source: { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translation: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetSnapshotsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetSnapshotResponse => ({ - url: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - owner: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - xml: faker.internet.url(), - enketopreviewlink: faker.internet.url(), - asset: faker.internet.url(), - asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - details: { - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - warnings: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - }, - source: { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translation: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetSnapshotsXformRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): OpenRosaXFormResponse => ({ - html: { - head: faker.helpers.arrayElement([ - { - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - model: faker.helpers.arrayElement([ - { - instance: faker.helpers.arrayElement([ - { - instanceUuid: faker.helpers.arrayElement([ - { - fieldName: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - meta: faker.helpers.arrayElement([ - { - instanceID: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - body: faker.helpers.arrayElement([ - { - input: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - hint: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): OpenRosaXFormResponse => ({ - html: { - head: faker.helpers.arrayElement([ - { - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - model: faker.helpers.arrayElement([ - { - instance: faker.helpers.arrayElement([ - { - instanceUuid: faker.helpers.arrayElement([ - { - fieldName: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - meta: faker.helpers.arrayElement([ - { - instanceID: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - body: faker.helpers.arrayElement([ - { - input: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - hint: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsContentRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ContentResponse => ({ - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - data: { - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - settings: faker.helpers.arrayElement([{}, undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsTableViewRetrieveResponseMock = (): string => faker.word.sample() - -export const getApiV2AssetsValidContentRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetValidContentResponse => ({ - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - data: { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([{}, undefined]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsXlsRetrieveResponseMock = (): string => faker.word.sample() - -export const getApiV2AssetSnapshotsListMockHandler = ( - overrideResponse?: - | PaginatedAssetSnapshotResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetSnapshotResponseList), -) => { - return http.get('*/api/v2/asset_snapshots{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSnapshotsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSnapshotsCreateMockHandler = ( - overrideResponse?: - | AssetSnapshotResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AssetSnapshotResponse), -) => { - return http.post('*/api/v2/asset_snapshots{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSnapshotsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSnapshotsRetrieveMockHandler = ( - overrideResponse?: - | AssetSnapshotResponse - | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse), -) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSnapshotsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSnapshotsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetSnapshotsPreviewRetrieveMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AssetSnapshotsXformRetrieveMockHandler = ( - overrideResponse?: - | OpenRosaXFormResponse - | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), -) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSnapshotsXformRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler = ( - overrideResponse?: - | OpenRosaXFormResponse - | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), -) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsContentRetrieveMockHandler = ( - overrideResponse?: - | ContentResponse - | ((info: Parameters[1]>[0]) => Promise | ContentResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/content{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsContentRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsTableViewRetrieveMockHandler = ( - overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), -) => { - return http.get('*/api/v2/assets/:uidAsset/table_view{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsTableViewRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsValidContentRetrieveMockHandler = ( - overrideResponse?: - | AssetValidContentResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AssetValidContentResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/valid_content{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsValidContentRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsXlsRetrieveMockHandler = ( - overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), -) => { - return http.get('*/api/v2/assets/:uidAsset/xls{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsXlsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getFormContentMock = () => [ - getApiV2AssetSnapshotsListMockHandler(), - getApiV2AssetSnapshotsCreateMockHandler(), - getApiV2AssetSnapshotsRetrieveMockHandler(), - getApiV2AssetSnapshotsDestroyMockHandler(), - getApiV2AssetSnapshotsPreviewRetrieveMockHandler(), - getApiV2AssetSnapshotsXformRetrieveMockHandler(), - getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler(), - getApiV2AssetsContentRetrieveMockHandler(), - getApiV2AssetsTableViewRetrieveMockHandler(), - getApiV2AssetsValidContentRetrieveMockHandler(), - getApiV2AssetsXlsRetrieveMockHandler(), -] diff --git a/jsapp/js/api/react-query/library-collections/library-collections.msw.ts b/jsapp/js/api/react-query/library-collections/library-collections.msw.ts new file mode 100644 index 0000000000..bc0298c49d --- /dev/null +++ b/jsapp/js/api/react-query/library-collections/library-collections.msw.ts @@ -0,0 +1,130 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import type { AssetSubscriptionResponse } from '../../models/assetSubscriptionResponse' + +import type { PaginatedAssetSubscriptionResponseList } from '../../models/paginatedAssetSubscriptionResponseList' + +export const getApiV2AssetSubscriptionsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetSubscriptionResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2AssetSubscriptionsCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetSubscriptionResponse => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetSubscriptionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetSubscriptionResponse => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetSubscriptionsListMockHandler = ( + overrideResponse?: + | PaginatedAssetSubscriptionResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetSubscriptionResponseList), +) => { + return http.get('*/api/v2/asset_subscriptions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSubscriptionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSubscriptionsCreateMockHandler = ( + overrideResponse?: + | AssetSubscriptionResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetSubscriptionResponse), +) => { + return http.post('*/api/v2/asset_subscriptions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSubscriptionsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSubscriptionsRetrieveMockHandler = ( + overrideResponse?: + | AssetSubscriptionResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetSubscriptionResponse), +) => { + return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSubscriptionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetSubscriptionsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} +export const getLibraryCollectionsMock = () => [ + getApiV2AssetSubscriptionsListMockHandler(), + getApiV2AssetSubscriptionsCreateMockHandler(), + getApiV2AssetSubscriptionsRetrieveMockHandler(), + getApiV2AssetSubscriptionsDestroyMockHandler(), +] diff --git a/jsapp/js/api/react-query/library-collections.ts b/jsapp/js/api/react-query/library-collections/library-collections.ts similarity index 72% rename from jsapp/js/api/react-query/library-collections.ts rename to jsapp/js/api/react-query/library-collections/library-collections.ts index bda068a3a3..67ac4d8d2f 100644 --- a/jsapp/js/api/react-query/library-collections.ts +++ b/jsapp/js/api/react-query/library-collections/library-collections.ts @@ -19,23 +19,19 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { AssetSubscriptionRequest } from '../models/assetSubscriptionRequest' +import type { AssetSubscriptionRequest } from '../../models/assetSubscriptionRequest' -import type { AssetSubscriptionsListParams } from '../models/assetSubscriptionsListParams' +import type { AssetSubscriptionResponse } from '../../models/assetSubscriptionResponse' -import type { ErrorDetail } from '../models/errorDetail' +import type { AssetSubscriptionsListParams } from '../../models/assetSubscriptionsListParams' -import type { ErrorObject } from '../models/errorObject' +import type { ErrorDetail } from '../../models/errorDetail' -import { faker } from '@faker-js/faker' +import type { ErrorObject } from '../../models/errorObject' -import { http, HttpResponse } from 'msw' +import type { PaginatedAssetSubscriptionResponseList } from '../../models/paginatedAssetSubscriptionResponseList' -import type { AssetSubscriptionResponse } from '../models/assetSubscriptionResponse' - -import type { PaginatedAssetSubscriptionResponseList } from '../models/paginatedAssetSubscriptionResponseList' - -import { fetchWithAuth } from '../orval.mutator' +import { fetchWithAuth } from '../../orval.mutator' type SecondParameter unknown> = Parameters[1] @@ -391,115 +387,3 @@ export const useAssetSubscriptionsDestroy = = {}, -): PaginatedAssetSubscriptionResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - asset: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2AssetSubscriptionsCreateResponseMock = ( - overrideResponse: Partial = {}, -): AssetSubscriptionResponse => ({ - url: faker.internet.url(), - asset: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetSubscriptionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetSubscriptionResponse => ({ - url: faker.internet.url(), - asset: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetSubscriptionsListMockHandler = ( - overrideResponse?: - | PaginatedAssetSubscriptionResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetSubscriptionResponseList), -) => { - return http.get('*/api/v2/asset_subscriptions{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSubscriptionsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSubscriptionsCreateMockHandler = ( - overrideResponse?: - | AssetSubscriptionResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AssetSubscriptionResponse), -) => { - return http.post('*/api/v2/asset_subscriptions{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSubscriptionsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSubscriptionsRetrieveMockHandler = ( - overrideResponse?: - | AssetSubscriptionResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AssetSubscriptionResponse), -) => { - return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSubscriptionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSubscriptionsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} -export const getLibraryCollectionsMock = () => [ - getApiV2AssetSubscriptionsListMockHandler(), - getApiV2AssetSubscriptionsCreateMockHandler(), - getApiV2AssetSubscriptionsRetrieveMockHandler(), - getApiV2AssetSubscriptionsDestroyMockHandler(), -] diff --git a/jsapp/js/api/react-query/logging/logging.msw.ts b/jsapp/js/api/react-query/logging/logging.msw.ts new file mode 100644 index 0000000000..185e434334 --- /dev/null +++ b/jsapp/js/api/react-query/logging/logging.msw.ts @@ -0,0 +1,407 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import type { ExportCreateResponse } from '../../models/exportCreateResponse' + +import type { ExportListResponse } from '../../models/exportListResponse' + +import type { HistoryActionResponse } from '../../models/historyActionResponse' + +import type { HistoryExportResponse } from '../../models/historyExportResponse' + +import type { PaginatedAccessLogResponseList } from '../../models/paginatedAccessLogResponseList' + +import type { PaginatedHistoryListResponseList } from '../../models/paginatedHistoryListResponseList' + +export const getApiV2AccessLogsMeListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAccessLogResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + initial_user_username: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + authorized_app_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2AccessLogsMeExportListResponseMock = (): ExportListResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 24 } }), + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })) + +export const getApiV2AccessLogsMeExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportCreateResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 32 } }), ...overrideResponse }) + +export const getApiV2AssetsHistoryListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedHistoryListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user: faker.internet.url(), + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + old: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + removed: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + description: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + 'data-table': faker.helpers.arrayElement([ + { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + }, + undefined, + ]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'asset-files': faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + permissions: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + latest_deployed_version_uid: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + submission: faker.helpers.arrayElement([ + { + root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + hook: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + bulk_action: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + params: faker.helpers.arrayElement([{}, undefined]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + total_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + processed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + completed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + failed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + cancelled_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + name: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + shared_fields: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsHistoryActionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): HistoryActionResponse => ({ + actions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsHistoryExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): HistoryExportResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AccessLogsMeListMockHandler = ( + overrideResponse?: + | PaginatedAccessLogResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAccessLogResponseList), +) => { + return http.get('*/api/v2/access-logs/me/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsMeListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AccessLogsMeExportListMockHandler = ( + overrideResponse?: + | ExportListResponse[] + | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), +) => { + return http.get('*/api/v2/access-logs/me/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsMeExportListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AccessLogsMeExportCreateMockHandler = ( + overrideResponse?: + | ExportCreateResponse + | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), +) => { + return http.post('*/api/v2/access-logs/me/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsMeExportCreateResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHistoryListMockHandler = ( + overrideResponse?: + | PaginatedHistoryListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedHistoryListResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/history/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHistoryListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHistoryActionsRetrieveMockHandler = ( + overrideResponse?: + | HistoryActionResponse + | ((info: Parameters[1]>[0]) => Promise | HistoryActionResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/history/actions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHistoryActionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHistoryExportCreateMockHandler = ( + overrideResponse?: + | HistoryExportResponse + | (( + info: Parameters[1]>[0], + ) => Promise | HistoryExportResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/history/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHistoryExportCreateResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getLoggingMock = () => [ + getApiV2AccessLogsMeListMockHandler(), + getApiV2AccessLogsMeExportListMockHandler(), + getApiV2AccessLogsMeExportCreateMockHandler(), + getApiV2AssetsHistoryListMockHandler(), + getApiV2AssetsHistoryActionsRetrieveMockHandler(), + getApiV2AssetsHistoryExportCreateMockHandler(), +] diff --git a/jsapp/js/api/react-query/logging.ts b/jsapp/js/api/react-query/logging/logging.ts similarity index 54% rename from jsapp/js/api/react-query/logging.ts rename to jsapp/js/api/react-query/logging/logging.ts index a3254c0be2..9f5370be03 100644 --- a/jsapp/js/api/react-query/logging.ts +++ b/jsapp/js/api/react-query/logging/logging.ts @@ -19,29 +19,25 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { AccessLogsMeListParams } from '../models/accessLogsMeListParams' +import type { AccessLogsMeListParams } from '../../models/accessLogsMeListParams' -import type { AssetsHistoryListParams } from '../models/assetsHistoryListParams' +import type { AssetsHistoryListParams } from '../../models/assetsHistoryListParams' -import type { ErrorDetail } from '../models/errorDetail' +import type { ErrorDetail } from '../../models/errorDetail' -import { faker } from '@faker-js/faker' +import type { ExportCreateResponse } from '../../models/exportCreateResponse' -import { http, HttpResponse } from 'msw' +import type { ExportListResponse } from '../../models/exportListResponse' -import type { ExportCreateResponse } from '../models/exportCreateResponse' +import type { HistoryActionResponse } from '../../models/historyActionResponse' -import type { ExportListResponse } from '../models/exportListResponse' +import type { HistoryExportResponse } from '../../models/historyExportResponse' -import type { HistoryActionResponse } from '../models/historyActionResponse' +import type { PaginatedAccessLogResponseList } from '../../models/paginatedAccessLogResponseList' -import type { HistoryExportResponse } from '../models/historyExportResponse' +import type { PaginatedHistoryListResponseList } from '../../models/paginatedHistoryListResponseList' -import type { PaginatedAccessLogResponseList } from '../models/paginatedAccessLogResponseList' - -import type { PaginatedHistoryListResponseList } from '../models/paginatedHistoryListResponseList' - -import { fetchWithAuth } from '../orval.mutator' +import { fetchWithAuth } from '../../orval.mutator' type SecondParameter unknown> = Parameters[1] @@ -711,384 +707,3 @@ export const useAssetsHistoryExportCreate = = {}, -): PaginatedAccessLogResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: { - source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - initial_user_username: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - authorized_app_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - action: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2AccessLogsMeExportListResponseMock = (): ExportListResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 24 } }), - status: faker.string.alpha({ length: { min: 10, max: 32 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - })) - -export const getApiV2AccessLogsMeExportCreateResponseMock = ( - overrideResponse: Partial = {}, -): ExportCreateResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 32 } }), ...overrideResponse }) - -export const getApiV2AssetsHistoryListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedHistoryListResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user: faker.internet.url(), - user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: { - source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - old: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - removed: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - description: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - 'data-table': faker.helpers.arrayElement([ - { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, - undefined, - ]), - }, - undefined, - ]), - asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'asset-files': faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - permissions: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - latest_deployed_version_uid: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - submission: faker.helpers.arrayElement([ - { - root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - hook: faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - undefined, - ]), - bulk_action: faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - params: faker.helpers.arrayElement([{}, undefined]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - total_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - processed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - completed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - failed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - cancelled_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - name: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - shared_fields: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsHistoryActionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): HistoryActionResponse => ({ - actions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2AssetsHistoryExportCreateResponseMock = ( - overrideResponse: Partial = {}, -): HistoryExportResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2AccessLogsMeListMockHandler = ( - overrideResponse?: - | PaginatedAccessLogResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAccessLogResponseList), -) => { - return http.get('*/api/v2/access-logs/me{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AccessLogsMeListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AccessLogsMeExportListMockHandler = ( - overrideResponse?: - | ExportListResponse[] - | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), -) => { - return http.get('*/api/v2/access-logs/me/export{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AccessLogsMeExportListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AccessLogsMeExportCreateMockHandler = ( - overrideResponse?: - | ExportCreateResponse - | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), -) => { - return http.post('*/api/v2/access-logs/me/export{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AccessLogsMeExportCreateResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHistoryListMockHandler = ( - overrideResponse?: - | PaginatedHistoryListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedHistoryListResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/history{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHistoryListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHistoryActionsRetrieveMockHandler = ( - overrideResponse?: - | HistoryActionResponse - | ((info: Parameters[1]>[0]) => Promise | HistoryActionResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/history/actions{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHistoryActionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHistoryExportCreateMockHandler = ( - overrideResponse?: - | HistoryExportResponse - | (( - info: Parameters[1]>[0], - ) => Promise | HistoryExportResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/history/export{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHistoryExportCreateResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getLoggingMock = () => [ - getApiV2AccessLogsMeListMockHandler(), - getApiV2AccessLogsMeExportListMockHandler(), - getApiV2AccessLogsMeExportCreateMockHandler(), - getApiV2AssetsHistoryListMockHandler(), - getApiV2AssetsHistoryActionsRetrieveMockHandler(), - getApiV2AssetsHistoryExportCreateMockHandler(), -] diff --git a/jsapp/js/api/react-query/manage-permissions/manage-permissions.msw.ts b/jsapp/js/api/react-query/manage-permissions/manage-permissions.msw.ts new file mode 100644 index 0000000000..f42da318e1 --- /dev/null +++ b/jsapp/js/api/react-query/manage-permissions/manage-permissions.msw.ts @@ -0,0 +1,196 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import type { PermissionAssignmentResponse } from '../../models/permissionAssignmentResponse' + +export const getApiV2AssetsPermissionAssignmentsListResponseMock = (): PermissionAssignmentResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsPermissionAssignmentsCreateResponseMock = ( + overrideResponse: Partial = {}, +): PermissionAssignmentResponse => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsPermissionAssignmentsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PermissionAssignmentResponse => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock = (): PermissionAssignmentResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock = (): PermissionAssignmentResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsPermissionAssignmentsListMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse[]), +) => { + return http.get('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPermissionAssignmentsCreateMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPermissionAssignmentsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse[]), +) => { + return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse[]), +) => { + return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getManagePermissionsMock = () => [ + getApiV2AssetsPermissionAssignmentsListMockHandler(), + getApiV2AssetsPermissionAssignmentsCreateMockHandler(), + getApiV2AssetsPermissionAssignmentsRetrieveMockHandler(), + getApiV2AssetsPermissionAssignmentsDestroyMockHandler(), + getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler(), + getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler(), + getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler(), +] diff --git a/jsapp/js/api/react-query/manage-permissions.ts b/jsapp/js/api/react-query/manage-permissions/manage-permissions.ts similarity index 77% rename from jsapp/js/api/react-query/manage-permissions.ts rename to jsapp/js/api/react-query/manage-permissions/manage-permissions.ts index 03e422e0d2..82b8f5bd55 100644 --- a/jsapp/js/api/react-query/manage-permissions.ts +++ b/jsapp/js/api/react-query/manage-permissions/manage-permissions.ts @@ -19,23 +19,19 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { ErrorDetail } from '../models/errorDetail' +import type { ErrorDetail } from '../../models/errorDetail' -import type { ErrorObject } from '../models/errorObject' +import type { ErrorObject } from '../../models/errorObject' -import type { PatchedPermissionAssignmentCloneRequest } from '../models/patchedPermissionAssignmentCloneRequest' +import type { PatchedPermissionAssignmentCloneRequest } from '../../models/patchedPermissionAssignmentCloneRequest' -import type { PermissionAssignmentBulkRequest } from '../models/permissionAssignmentBulkRequest' +import type { PermissionAssignmentBulkRequest } from '../../models/permissionAssignmentBulkRequest' -import type { PermissionAssignmentCreateRequest } from '../models/permissionAssignmentCreateRequest' +import type { PermissionAssignmentCreateRequest } from '../../models/permissionAssignmentCreateRequest' -import { faker } from '@faker-js/faker' +import type { PermissionAssignmentResponse } from '../../models/permissionAssignmentResponse' -import { http, HttpResponse } from 'msw' - -import type { PermissionAssignmentResponse } from '../models/permissionAssignmentResponse' - -import { fetchWithAuth } from '../orval.mutator' +import { fetchWithAuth } from '../../orval.mutator' type SecondParameter unknown> = Parameters[1] @@ -755,183 +751,3 @@ export const useAssetsPermissionAssignmentsClonePartialUpdate = < return useMutation(mutationOptions) } - -export const getApiV2AssetsPermissionAssignmentsListResponseMock = (): PermissionAssignmentResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - user: faker.internet.url(), - permission: faker.internet.url(), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2AssetsPermissionAssignmentsCreateResponseMock = ( - overrideResponse: Partial = {}, -): PermissionAssignmentResponse => ({ - url: faker.internet.url(), - user: faker.internet.url(), - permission: faker.internet.url(), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsPermissionAssignmentsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PermissionAssignmentResponse => ({ - url: faker.internet.url(), - user: faker.internet.url(), - permission: faker.internet.url(), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock = (): PermissionAssignmentResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - user: faker.internet.url(), - permission: faker.internet.url(), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock = (): PermissionAssignmentResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - user: faker.internet.url(), - permission: faker.internet.url(), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2AssetsPermissionAssignmentsListMockHandler = ( - overrideResponse?: - | PermissionAssignmentResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | PermissionAssignmentResponse[]), -) => { - return http.get('*/api/v2/assets/:uidAsset/permission-assignments{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPermissionAssignmentsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPermissionAssignmentsCreateMockHandler = ( - overrideResponse?: - | PermissionAssignmentResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PermissionAssignmentResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/permission-assignments{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPermissionAssignmentsCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = ( - overrideResponse?: - | PermissionAssignmentResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PermissionAssignmentResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPermissionAssignmentsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPermissionAssignmentsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = ( - overrideResponse?: - | PermissionAssignmentResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | PermissionAssignmentResponse[]), -) => { - return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler = ( - overrideResponse?: - | PermissionAssignmentResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | PermissionAssignmentResponse[]), -) => { - return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getManagePermissionsMock = () => [ - getApiV2AssetsPermissionAssignmentsListMockHandler(), - getApiV2AssetsPermissionAssignmentsCreateMockHandler(), - getApiV2AssetsPermissionAssignmentsRetrieveMockHandler(), - getApiV2AssetsPermissionAssignmentsDestroyMockHandler(), - getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler(), - getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler(), - getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler(), -] diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.msw.ts similarity index 73% rename from jsapp/js/api/react-query/manage-projects-and-library-content.ts rename to jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.msw.ts index 03e3fd6b4a..9027cb565d 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.msw.ts @@ -9,2677 +9,53 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { AssetBulkRequest } from '../models/assetBulkRequest' - -import type { AssetCreateRequest } from '../models/assetCreateRequest' - -import type { AssetsCountsListParams } from '../models/assetsCountsListParams' - -import type { AssetsListParams } from '../models/assetsListParams' - -import type { AssetsMinimalListRetrieveParams } from '../models/assetsMinimalListRetrieveParams' - -import type { AssetsRetrieveParams } from '../models/assetsRetrieveParams' - -import type { AssetsVersionsListParams } from '../models/assetsVersionsListParams' - -import type { DeploymentCreateRequest } from '../models/deploymentCreateRequest' - -import type { ErrorDetail } from '../models/errorDetail' - -import type { ErrorObject } from '../models/errorObject' - -import type { ImportCreateRequest } from '../models/importCreateRequest' - -import type { ImportsListParams } from '../models/importsListParams' - -import type { PatchedAssetPatchRequest } from '../models/patchedAssetPatchRequest' - -import type { PatchedDeploymentPatchRequest } from '../models/patchedDeploymentPatchRequest' - -import type { PatchedInviteUpdatePayload } from '../models/patchedInviteUpdatePayload' - -import type { ProjectInviteCreatePayload } from '../models/projectInviteCreatePayload' - -import type { ProjectOwnershipInvitesListParams } from '../models/projectOwnershipInvitesListParams' - -import type { TagsListParams } from '../models/tagsListParams' - import { faker } from '@faker-js/faker' import { http, HttpResponse } from 'msw' -import type { Asset } from '../models/asset' - -import type { AssetBulkResponse } from '../models/assetBulkResponse' - -import { AssetDeploymentStatusEnum } from '../models/assetDeploymentStatusEnum' - -import type { AssetListCount } from '../models/assetListCount' - -import type { AssetMetadataResponse } from '../models/assetMetadataResponse' - -import { AssetTypeEnum } from '../models/assetTypeEnum' - -import type { DeploymentResponse } from '../models/deploymentResponse' - -import type { HashResponse } from '../models/hashResponse' - -import type { ImportCreateResponse } from '../models/importCreateResponse' - -import type { ImportResponse } from '../models/importResponse' - -import { InviteStatusChoicesEnum } from '../models/inviteStatusChoicesEnum' - -import type { PaginatedAssetCountResponseList } from '../models/paginatedAssetCountResponseList' - -import type { PaginatedAssetList } from '../models/paginatedAssetList' - -import type { PaginatedAssetMinimalListList } from '../models/paginatedAssetMinimalListList' - -import type { PaginatedImportResponseList } from '../models/paginatedImportResponseList' - -import type { PaginatedProjectInviteResponseList } from '../models/paginatedProjectInviteResponseList' - -import type { PaginatedTagListResponseList } from '../models/paginatedTagListResponseList' - -import type { PaginatedVersionListResponseList } from '../models/paginatedVersionListResponseList' - -import type { ProjectInviteResponse } from '../models/projectInviteResponse' - -import type { TagRetrieveResponse } from '../models/tagRetrieveResponse' - -import type { TransferListResponse } from '../models/transferListResponse' - -import type { VersionRetrieveResponse } from '../models/versionRetrieveResponse' - -import { fetchWithAuth } from '../orval.mutator' - -type SecondParameter unknown> = Parameters[1] - -/** - * ## Get user's assets - - -Search can be made with `q` parameter. -Search filters can be returned with results by passing `metadata=on` to querystring. - - -Results can be sorted with `ordering` parameter, e.g.: - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/?ordering=-name -``` - - -Allowed fields are: - -- `asset_type` -- `date_modified` -- `date_deployed` -- `date_modified__date` -- `date_deployed__date` -- `name` -- `settings__sector` -- `settings__sector__value` -- `settings__description` -- `owner__username` -- `owner__extra_details__data__name` -- `owner__extra_details__data__organization` -- `owner__email` -- `_deployment_status` -- `subscribers_count` - - -Note: Collections can be displayed first with parameter `collections_first`, e.g.: - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/?collections_first=true&ordering=-name -``` - - */ -export type assetsListResponse200 = { - data: PaginatedAssetList - status: 200 -} - -export type assetsListResponseComposite = assetsListResponse200 - -export type assetsListResponse = assetsListResponseComposite & { - headers: Headers -} - -export const getAssetsListUrl = (params?: AssetsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/assets/?${stringifiedParams}` : `/api/v2/assets/` -} - -export const assetsList = async (params?: AssetsListParams, options?: RequestInit): Promise => { - return fetchWithAuth(getAssetsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsListQueryKey = (params?: AssetsListParams) => { - return ['api', 'v2', 'assets', ...(params ? [params] : [])] as const -} - -export const getAssetsListQueryOptions = >, TError = unknown>( - params?: AssetsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsListQueryResult = NonNullable>> -export type AssetsListQueryError = unknown - -export function useAssetsList>, TError = unknown>( - params?: AssetsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create or clone an asset - -When cloning an asset, you must provide: - -- the name (as a string), -- the `clone_from` (the uid representing the asset), -- the asset_type - -Where `asset_type` must be one of these values: - -* block (can be cloned to `block`, `question`, `survey`, `template`) -* question (can be cloned to `question`, `survey`, `template`) -* survey (can be cloned to `block`, `question`, `survey`, `template`) -* template (can be cloned to `survey`, `template`) - -Settings are cloned only when type of assets are `survey` or `template`. -In that case, `share-metadata` is not preserved. - -When creating a new `block` or `question` asset, settings are not saved either. - - */ -export type assetsCreateResponse201 = { - data: Asset - status: 201 -} - -export type assetsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsCreateResponseComposite = assetsCreateResponse201 | assetsCreateResponse400 | assetsCreateResponse401 - -export type assetsCreateResponse = assetsCreateResponseComposite & { - headers: Headers -} - -export const getAssetsCreateUrl = () => { - return `/api/v2/assets/` -} - -export const assetsCreate = async ( - assetCreateRequest: AssetCreateRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(assetCreateRequest), - }) -} - -export const getAssetsCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetCreateRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions>, TError, { data: AssetCreateRequest }, TContext> => { - const mutationKey = ['assetsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: AssetCreateRequest }> = ( - props, - ) => { - const { data } = props ?? {} - - return assetsCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsCreateMutationResult = NonNullable>> -export type AssetsCreateMutationBody = AssetCreateRequest -export type AssetsCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetCreateRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Get a user's current asset - - */ -export type assetsRetrieveResponse200 = { - data: Asset - status: 200 -} - -export type assetsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsRetrieveResponseComposite = assetsRetrieveResponse200 | assetsRetrieveResponse404 - -export type assetsRetrieveResponse = assetsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsRetrieveUrl = (uidAsset: string, params?: AssetsRetrieveParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/` -} - -export const assetsRetrieve = async ( - uidAsset: string, - params?: AssetsRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsRetrieveUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsRetrieveQueryKey = (uidAsset: string, params?: AssetsRetrieveParams) => { - return ['api', 'v2', 'assets', uidAsset, ...(params ? [params] : [])] as const -} - -export const getAssetsRetrieveQueryOptions = >, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsRetrieveQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsRetrieve(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsRetrieveQueryResult = NonNullable>> -export type AssetsRetrieveQueryError = ErrorDetail - -export function useAssetsRetrieve>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsRetrieveQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update or connect a user's asset - -Updates a project or connect project's data from this project to other projects - -When `Data sharing`: - -`fields`: Optional. List of questions whose responses will be shared. If -missing or empty, all responses will be shared. Questions must be -identified by full group path separated by slashes, e.g. -`group/subgroup/question_name`. - - */ -export type assetsPartialUpdateResponse200 = { - data: Asset - status: 200 -} - -export type assetsPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsPartialUpdateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsPartialUpdateResponseComposite = - | assetsPartialUpdateResponse200 - | assetsPartialUpdateResponse400 - | assetsPartialUpdateResponse401 - -export type assetsPartialUpdateResponse = assetsPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsPartialUpdateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/` -} - -export const assetsPartialUpdate = async ( - uidAsset: string, - patchedAssetPatchRequest: PatchedAssetPatchRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsPartialUpdateUrl(uidAsset), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedAssetPatchRequest), - }) -} - -export const getAssetsPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedAssetPatchRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedAssetPatchRequest }, - TContext -> => { - const mutationKey = ['assetsPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: PatchedAssetPatchRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsPartialUpdate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsPartialUpdateMutationResult = NonNullable>> -export type AssetsPartialUpdateMutationBody = PatchedAssetPatchRequest -export type AssetsPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useAssetsPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedAssetPatchRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete a user's asset - - */ -export type assetsDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsDestroyResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsDestroyResponseComposite = assetsDestroyResponse204 | assetsDestroyResponse401 - -export type assetsDestroyResponse = assetsDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsDestroyUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/` -} - -export const assetsDestroy = async (uidAsset: string, options?: RequestInit): Promise => { - return fetchWithAuth(getAssetsDestroyUrl(uidAsset), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetsDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions>, TError, { uidAsset: string }, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, { uidAsset: string }, TContext> => { - const mutationKey = ['assetsDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { uidAsset: string }> = (props) => { - const { uidAsset } = props ?? {} - - return assetsDestroy(uidAsset, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDestroyMutationResult = NonNullable>> - -export type AssetsDestroyMutationError = ErrorDetail - -export const useAssetsDestroy = (options?: { - mutation?: UseMutationOptions>, TError, { uidAsset: string }, TContext> - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Count the daily amount of submissions - -Returns up to the last 31 days of daily counts and total counts of submissions to a survey. - - -Use the `days` query to get the daily counts from the last x amount of days. -Default amount is 30 days - - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/counts/?days=7 -``` - - */ -export type assetsCountsListResponse200 = { - data: PaginatedAssetCountResponseList - status: 200 -} - -export type assetsCountsListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsCountsListResponseComposite = assetsCountsListResponse200 | assetsCountsListResponse401 - -export type assetsCountsListResponse = assetsCountsListResponseComposite & { - headers: Headers -} - -export const getAssetsCountsListUrl = (uidAsset: string, params?: AssetsCountsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/counts/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/counts/` -} - -export const assetsCountsList = async ( - uidAsset: string, - params?: AssetsCountsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsCountsListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsCountsListQueryKey = (uidAsset: string, params?: AssetsCountsListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'counts', ...(params ? [params] : [])] as const -} - -export const getAssetsCountsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsCountsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsCountsListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsCountsList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsCountsListQueryResult = NonNullable>> -export type AssetsCountsListQueryError = ErrorDetail +import type { Asset } from '../../models/asset' -export function useAssetsCountsList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsCountsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsCountsListQueryOptions(uidAsset, params, options) +import type { AssetBulkResponse } from '../../models/assetBulkResponse' - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } +import { AssetDeploymentStatusEnum } from '../../models/assetDeploymentStatusEnum' - query.queryKey = queryOptions.queryKey +import type { AssetListCount } from '../../models/assetListCount' - return query -} +import type { AssetMetadataResponse } from '../../models/assetMetadataResponse' -/** - * ## Retrieve the existing deployment (if any) +import { AssetTypeEnum } from '../../models/assetTypeEnum' - */ -export type assetsDeploymentRetrieveResponse200 = { - data: DeploymentResponse - status: 200 -} +import type { DeploymentResponse } from '../../models/deploymentResponse' -export type assetsDeploymentRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} +import type { HashResponse } from '../../models/hashResponse' -export type assetsDeploymentRetrieveResponseComposite = - | assetsDeploymentRetrieveResponse200 - | assetsDeploymentRetrieveResponse404 +import type { ImportCreateResponse } from '../../models/importCreateResponse' -export type assetsDeploymentRetrieveResponse = assetsDeploymentRetrieveResponseComposite & { - headers: Headers -} +import type { ImportResponse } from '../../models/importResponse' -export const getAssetsDeploymentRetrieveUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/deployment/` -} +import { InviteStatusChoicesEnum } from '../../models/inviteStatusChoicesEnum' -export const assetsDeploymentRetrieve = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDeploymentRetrieveUrl(uidAsset), { - ...options, - method: 'GET', - }) -} +import type { PaginatedAssetCountResponseList } from '../../models/paginatedAssetCountResponseList' -export const getAssetsDeploymentRetrieveQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'deployment'] as const -} +import type { PaginatedAssetList } from '../../models/paginatedAssetList' -export const getAssetsDeploymentRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} +import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' - const queryKey = queryOptions?.queryKey ?? getAssetsDeploymentRetrieveQueryKey(uidAsset) +import type { PaginatedImportResponseList } from '../../models/paginatedImportResponseList' - const queryFn: QueryFunction>> = ({ signal }) => - assetsDeploymentRetrieve(uidAsset, { signal, ...requestOptions }) +import type { PaginatedProjectInviteResponseList } from '../../models/paginatedProjectInviteResponseList' - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} +import type { PaginatedTagListResponseList } from '../../models/paginatedTagListResponseList' -export type AssetsDeploymentRetrieveQueryResult = NonNullable>> -export type AssetsDeploymentRetrieveQueryError = ErrorDetail +import type { PaginatedVersionListResponseList } from '../../models/paginatedVersionListResponseList' -export function useAssetsDeploymentRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDeploymentRetrieveQueryOptions(uidAsset, options) +import type { ProjectInviteResponse } from '../../models/projectInviteResponse' - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } +import type { TagRetrieveResponse } from '../../models/tagRetrieveResponse' - query.queryKey = queryOptions.queryKey +import type { TransferListResponse } from '../../models/transferListResponse' - return query -} - -/** - * ## (Re)Deploy a form - -Deploy a new form or re-deploy an existing one. - - */ -export type assetsDeploymentCreateResponse200 = { - data: DeploymentResponse - status: 200 -} - -export type assetsDeploymentCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsDeploymentCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsDeploymentCreateResponseComposite = - | assetsDeploymentCreateResponse200 - | assetsDeploymentCreateResponse400 - | assetsDeploymentCreateResponse401 - -export type assetsDeploymentCreateResponse = assetsDeploymentCreateResponseComposite & { - headers: Headers -} - -export const getAssetsDeploymentCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/deployment/` -} - -export const assetsDeploymentCreate = async ( - uidAsset: string, - deploymentCreateRequest: DeploymentCreateRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDeploymentCreateUrl(uidAsset), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(deploymentCreateRequest), - }) -} - -export const getAssetsDeploymentCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: DeploymentCreateRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: DeploymentCreateRequest }, - TContext -> => { - const mutationKey = ['assetsDeploymentCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: DeploymentCreateRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsDeploymentCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDeploymentCreateMutationResult = NonNullable>> -export type AssetsDeploymentCreateMutationBody = DeploymentCreateRequest -export type AssetsDeploymentCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsDeploymentCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: DeploymentCreateRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDeploymentCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## (Un)Archive the existing deployment. - -Update the `active` field of the existing deployment. - -To overwrite the entire deployment (including the form contents), use a PUT request. - - */ -export type assetsDeploymentPartialUpdateResponse200 = { - data: DeploymentResponse - status: 200 -} - -export type assetsDeploymentPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsDeploymentPartialUpdateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsDeploymentPartialUpdateResponseComposite = - | assetsDeploymentPartialUpdateResponse200 - | assetsDeploymentPartialUpdateResponse400 - | assetsDeploymentPartialUpdateResponse401 - -export type assetsDeploymentPartialUpdateResponse = assetsDeploymentPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsDeploymentPartialUpdateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/deployment/` -} - -export const assetsDeploymentPartialUpdate = async ( - uidAsset: string, - patchedDeploymentPatchRequest: PatchedDeploymentPatchRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDeploymentPartialUpdateUrl(uidAsset), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedDeploymentPatchRequest), - }) -} - -export const getAssetsDeploymentPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDeploymentPatchRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDeploymentPatchRequest }, - TContext -> => { - const mutationKey = ['assetsDeploymentPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: PatchedDeploymentPatchRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsDeploymentPartialUpdate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDeploymentPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsDeploymentPartialUpdateMutationBody = PatchedDeploymentPatchRequest -export type AssetsDeploymentPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useAssetsDeploymentPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDeploymentPatchRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDeploymentPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## List the versions of forms - - */ -export type assetsVersionsListResponse200 = { - data: PaginatedVersionListResponseList - status: 200 -} - -export type assetsVersionsListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsVersionsListResponseComposite = assetsVersionsListResponse200 | assetsVersionsListResponse404 - -export type assetsVersionsListResponse = assetsVersionsListResponseComposite & { - headers: Headers -} - -export const getAssetsVersionsListUrl = (uidAsset: string, params?: AssetsVersionsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/versions/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/versions/` -} - -export const assetsVersionsList = async ( - uidAsset: string, - params?: AssetsVersionsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsVersionsListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsVersionsListQueryKey = (uidAsset: string, params?: AssetsVersionsListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'versions', ...(params ? [params] : [])] as const -} - -export const getAssetsVersionsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsVersionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsVersionsListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsVersionsList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsVersionsListQueryResult = NonNullable>> -export type AssetsVersionsListQueryError = ErrorDetail - -export function useAssetsVersionsList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsVersionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsVersionsListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve asset versions - -Returns the details of an asset version - - */ -export type assetsVersionsRetrieveResponse200 = { - data: VersionRetrieveResponse - status: 200 -} - -export type assetsVersionsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsVersionsRetrieveResponseComposite = - | assetsVersionsRetrieveResponse200 - | assetsVersionsRetrieveResponse404 - -export type assetsVersionsRetrieveResponse = assetsVersionsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsVersionsRetrieveUrl = (uidAsset: string, uidVersion: string) => { - return `/api/v2/assets/${uidAsset}/versions/${uidVersion}/` -} - -export const assetsVersionsRetrieve = async ( - uidAsset: string, - uidVersion: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsVersionsRetrieveUrl(uidAsset, uidVersion), { - ...options, - method: 'GET', - }) -} - -export const getAssetsVersionsRetrieveQueryKey = (uidAsset: string, uidVersion: string) => { - return ['api', 'v2', 'assets', uidAsset, 'versions', uidVersion] as const -} - -export const getAssetsVersionsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidVersion: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsVersionsRetrieveQueryKey(uidAsset, uidVersion) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsVersionsRetrieve(uidAsset, uidVersion, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidVersion), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsVersionsRetrieveQueryResult = NonNullable>> -export type AssetsVersionsRetrieveQueryError = ErrorDetail - -export function useAssetsVersionsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidVersion: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsVersionsRetrieveQueryOptions(uidAsset, uidVersion, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## This route will render the XForm into syntax-highlighted HTML. - -It is useful for debugging pyxform transformations - - */ -export type assetsXformRetrieveResponse200 = { - data: string - status: 200 -} - -export type assetsXformRetrieveResponse404 = { - data: void - status: 404 -} - -export type assetsXformRetrieveResponseComposite = assetsXformRetrieveResponse200 | assetsXformRetrieveResponse404 - -export type assetsXformRetrieveResponse = assetsXformRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsXformRetrieveUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/xform/` -} - -export const assetsXformRetrieve = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsXformRetrieveUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsXformRetrieveQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'xform'] as const -} - -export const getAssetsXformRetrieveQueryOptions = < - TData = Awaited>, - TError = void, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsXformRetrieveQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsXformRetrieve(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsXformRetrieveQueryResult = NonNullable>> -export type AssetsXformRetrieveQueryError = void - -export function useAssetsXformRetrieve>, TError = void>( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsXformRetrieveQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Perform bulk actions on assets - -Actions available: - -- `archive` -- `delete` -- `unarchive` -- `undelete` (superusers only) - - */ -export type assetsBulkCreateResponse200 = { - data: AssetBulkResponse - status: 200 -} - -export type assetsBulkCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsBulkCreateResponseComposite = assetsBulkCreateResponse200 | assetsBulkCreateResponse404 - -export type assetsBulkCreateResponse = assetsBulkCreateResponseComposite & { - headers: Headers -} - -export const getAssetsBulkCreateUrl = () => { - return `/api/v2/assets/bulk/` -} - -export const assetsBulkCreate = async ( - assetBulkRequest: AssetBulkRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsBulkCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(assetBulkRequest), - }) -} - -export const getAssetsBulkCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetBulkRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions>, TError, { data: AssetBulkRequest }, TContext> => { - const mutationKey = ['assetsBulkCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: AssetBulkRequest }> = ( - props, - ) => { - const { data } = props ?? {} - - return assetsBulkCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsBulkCreateMutationResult = NonNullable>> -export type AssetsBulkCreateMutationBody = AssetBulkRequest -export type AssetsBulkCreateMutationError = ErrorDetail - -export const useAssetsBulkCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetBulkRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsBulkCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Return counts of deployed, archived, and draft assets - - */ -export type assetsCountsRetrieveResponse200 = { - data: AssetListCount - status: 200 -} - -export type assetsCountsRetrieveResponseComposite = assetsCountsRetrieveResponse200 - -export type assetsCountsRetrieveResponse = assetsCountsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsCountsRetrieveUrl = () => { - return `/api/v2/assets/counts/` -} - -export const assetsCountsRetrieve = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAssetsCountsRetrieveUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAssetsCountsRetrieveQueryKey = () => { - return ['api', 'v2', 'assets', 'counts'] as const -} - -export const getAssetsCountsRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsCountsRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - assetsCountsRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsCountsRetrieveQueryResult = NonNullable>> -export type AssetsCountsRetrieveQueryError = unknown - -export function useAssetsCountsRetrieve< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsCountsRetrieveQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get a hash of all `version_id`s of all accessible assets by the current user. - -Useful to detect any changes in assets with only one call to `API` - - */ -export type assetsHashRetrieveResponse200 = { - data: HashResponse - status: 200 -} - -export type assetsHashRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsHashRetrieveResponseComposite = assetsHashRetrieveResponse200 | assetsHashRetrieveResponse401 - -export type assetsHashRetrieveResponse = assetsHashRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsHashRetrieveUrl = () => { - return `/api/v2/assets/hash/` -} - -export const assetsHashRetrieve = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAssetsHashRetrieveUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAssetsHashRetrieveQueryKey = () => { - return ['api', 'v2', 'assets', 'hash'] as const -} - -export const getAssetsHashRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsHashRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - assetsHashRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsHashRetrieveQueryResult = NonNullable>> -export type AssetsHashRetrieveQueryError = ErrorDetail - -export function useAssetsHashRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsHashRetrieveQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get metadata for all authenticated user' assets - - */ -export type assetsMetadataRetrieveResponse200 = { - data: AssetMetadataResponse - status: 200 -} - -export type assetsMetadataRetrieveResponseComposite = assetsMetadataRetrieveResponse200 - -export type assetsMetadataRetrieveResponse = assetsMetadataRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsMetadataRetrieveUrl = () => { - return `/api/v2/assets/metadata/` -} - -export const assetsMetadataRetrieve = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAssetsMetadataRetrieveUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAssetsMetadataRetrieveQueryKey = () => { - return ['api', 'v2', 'assets', 'metadata'] as const -} - -export const getAssetsMetadataRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsMetadataRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - assetsMetadataRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsMetadataRetrieveQueryResult = NonNullable>> -export type AssetsMetadataRetrieveQueryError = unknown - -export function useAssetsMetadataRetrieve< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsMetadataRetrieveQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Return a minimal listing of assets with their deployment status - -Returns a paginated list of assets visible to the current user, including only `uid`, `name`, and `deployment_status` (`draft`, `deployed`, or `archived`). - -Use the `q` query parameter to filter by asset type (e.g. `?q=asset_type:survey`). - -Responses do not include a `count` field. Use the `next` and `previous` links to paginate through results. - - */ -export type assetsMinimalListRetrieveResponse200 = { - data: PaginatedAssetMinimalListList - status: 200 -} - -export type assetsMinimalListRetrieveResponseComposite = assetsMinimalListRetrieveResponse200 - -export type assetsMinimalListRetrieveResponse = assetsMinimalListRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsMinimalListRetrieveUrl = (params?: AssetsMinimalListRetrieveParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/minimal-list/?${stringifiedParams}` - : `/api/v2/assets/minimal-list/` -} - -export const assetsMinimalListRetrieve = async ( - params?: AssetsMinimalListRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsMinimalListRetrieveUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsMinimalListRetrieveQueryKey = (params?: AssetsMinimalListRetrieveParams) => { - return ['api', 'v2', 'assets', 'minimal-list', ...(params ? [params] : [])] as const -} - -export const getAssetsMinimalListRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: AssetsMinimalListRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsMinimalListRetrieveQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsMinimalListRetrieve(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsMinimalListRetrieveQueryResult = NonNullable>> -export type AssetsMinimalListRetrieveQueryError = unknown - -export function useAssetsMinimalListRetrieve< - TData = Awaited>, - TError = unknown, ->( - params?: AssetsMinimalListRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsMinimalListRetrieveQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List imported files - - */ -export type importsListResponse200 = { - data: PaginatedImportResponseList - status: 200 -} - -export type importsListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type importsListResponseComposite = importsListResponse200 | importsListResponse401 - -export type importsListResponse = importsListResponseComposite & { - headers: Headers -} - -export const getImportsListUrl = (params?: ImportsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/imports/?${stringifiedParams}` : `/api/v2/imports/` -} - -export const importsList = async (params?: ImportsListParams, options?: RequestInit): Promise => { - return fetchWithAuth(getImportsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getImportsListQueryKey = (params?: ImportsListParams) => { - return ['api', 'v2', 'imports', ...(params ? [params] : [])] as const -} - -export const getImportsListQueryOptions = >, TError = ErrorDetail>( - params?: ImportsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getImportsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - importsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ImportsListQueryResult = NonNullable>> -export type ImportsListQueryError = ErrorDetail - -export function useImportsList>, TError = ErrorDetail>( - params?: ImportsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getImportsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Import file - -_**Note**: this endpoint is expecting a multipart/form-data_ - - */ -export type importsCreateResponse201 = { - data: ImportCreateResponse - status: 201 -} - -export type importsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type importsCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type importsCreateResponseComposite = - | importsCreateResponse201 - | importsCreateResponse400 - | importsCreateResponse401 - -export type importsCreateResponse = importsCreateResponseComposite & { - headers: Headers -} - -export const getImportsCreateUrl = () => { - return `/api/v2/imports/` -} - -export const importsCreate = async ( - importCreateRequest: ImportCreateRequest, - options?: RequestInit, -): Promise => { - const formData = new FormData() - formData.append(`destination`, importCreateRequest.destination) - formData.append(`url`, importCreateRequest.url) - if (importCreateRequest.name !== undefined) { - formData.append(`name`, importCreateRequest.name) - } - formData.append(`assetUid`, importCreateRequest.assetUid) - - return fetchWithAuth(getImportsCreateUrl(), { - ...options, - method: 'POST', - body: formData, - }) -} - -export const getImportsCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ImportCreateRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions>, TError, { data: ImportCreateRequest }, TContext> => { - const mutationKey = ['importsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: ImportCreateRequest }> = ( - props, - ) => { - const { data } = props ?? {} - - return importsCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ImportsCreateMutationResult = NonNullable>> -export type ImportsCreateMutationBody = ImportCreateRequest -export type ImportsCreateMutationError = ErrorObject | ErrorDetail - -export const useImportsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ImportCreateRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getImportsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve imported files - - */ -export type importsRetrieveResponse200 = { - data: ImportResponse - status: 200 -} - -export type importsRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type importsRetrieveResponseComposite = importsRetrieveResponse200 | importsRetrieveResponse401 - -export type importsRetrieveResponse = importsRetrieveResponseComposite & { - headers: Headers -} - -export const getImportsRetrieveUrl = (uidImport: string) => { - return `/api/v2/imports/${uidImport}/` -} - -export const importsRetrieve = async (uidImport: string, options?: RequestInit): Promise => { - return fetchWithAuth(getImportsRetrieveUrl(uidImport), { - ...options, - method: 'GET', - }) -} - -export const getImportsRetrieveQueryKey = (uidImport: string) => { - return ['api', 'v2', 'imports', uidImport] as const -} - -export const getImportsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidImport: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getImportsRetrieveQueryKey(uidImport) - - const queryFn: QueryFunction>> = ({ signal }) => - importsRetrieve(uidImport, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidImport, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ImportsRetrieveQueryResult = NonNullable>> -export type ImportsRetrieveQueryError = ErrorDetail - -export function useImportsRetrieve>, TError = ErrorDetail>( - uidImport: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getImportsRetrieveQueryOptions(uidImport, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List of invites - -Invites sent or received by current user about transferring project ownership. - -List can be filtered with `mode` parameter, e.g.: display only received invites. - -Possible values for `mode`: -- `sender` -- `recipient` - - - */ -export type projectOwnershipInvitesListResponse200 = { - data: PaginatedProjectInviteResponseList - status: 200 -} - -export type projectOwnershipInvitesListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectOwnershipInvitesListResponseComposite = - | projectOwnershipInvitesListResponse200 - | projectOwnershipInvitesListResponse403 - -export type projectOwnershipInvitesListResponse = projectOwnershipInvitesListResponseComposite & { - headers: Headers -} - -export const getProjectOwnershipInvitesListUrl = (params?: ProjectOwnershipInvitesListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/project-ownership/invites/?${stringifiedParams}` - : `/api/v2/project-ownership/invites/` -} - -export const projectOwnershipInvitesList = async ( - params?: ProjectOwnershipInvitesListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectOwnershipInvitesListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getProjectOwnershipInvitesListQueryKey = (params?: ProjectOwnershipInvitesListParams) => { - return ['api', 'v2', 'project-ownership', 'invites', ...(params ? [params] : [])] as const -} - -export const getProjectOwnershipInvitesListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: ProjectOwnershipInvitesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - projectOwnershipInvitesList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectOwnershipInvitesListQueryResult = NonNullable< - Awaited> -> -export type ProjectOwnershipInvitesListQueryError = ErrorDetail - -export function useProjectOwnershipInvitesList< - TData = Awaited>, - TError = ErrorDetail, ->( - params?: ProjectOwnershipInvitesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectOwnershipInvitesListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create (send) an invite - -Where the assets `uid` are given in the payload's list - - - - */ -export type projectOwnershipInvitesCreateResponse201 = { - data: ProjectInviteResponse - status: 201 -} - -export type projectOwnershipInvitesCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type projectOwnershipInvitesCreateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectOwnershipInvitesCreateResponseComposite = - | projectOwnershipInvitesCreateResponse201 - | projectOwnershipInvitesCreateResponse400 - | projectOwnershipInvitesCreateResponse403 - -export type projectOwnershipInvitesCreateResponse = projectOwnershipInvitesCreateResponseComposite & { - headers: Headers -} - -export const getProjectOwnershipInvitesCreateUrl = () => { - return `/api/v2/project-ownership/invites/` -} - -export const projectOwnershipInvitesCreate = async ( - projectInviteCreatePayload: ProjectInviteCreatePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectOwnershipInvitesCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(projectInviteCreatePayload), - }) -} - -export const getProjectOwnershipInvitesCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProjectInviteCreatePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ProjectInviteCreatePayload }, - TContext -> => { - const mutationKey = ['projectOwnershipInvitesCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ProjectInviteCreatePayload } - > = (props) => { - const { data } = props ?? {} - - return projectOwnershipInvitesCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ProjectOwnershipInvitesCreateMutationResult = NonNullable< - Awaited> -> -export type ProjectOwnershipInvitesCreateMutationBody = ProjectInviteCreatePayload -export type ProjectOwnershipInvitesCreateMutationError = ErrorObject | ErrorDetail - -export const useProjectOwnershipInvitesCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProjectInviteCreatePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getProjectOwnershipInvitesCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Invite detail - -It can be useful to monitor the invite status while the transfer is being processed - - */ -export type projectOwnershipInvitesRetrieveResponse200 = { - data: ProjectInviteResponse - status: 200 -} - -export type projectOwnershipInvitesRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectOwnershipInvitesRetrieveResponseComposite = - | projectOwnershipInvitesRetrieveResponse200 - | projectOwnershipInvitesRetrieveResponse403 - -export type projectOwnershipInvitesRetrieveResponse = projectOwnershipInvitesRetrieveResponseComposite & { - headers: Headers -} - -export const getProjectOwnershipInvitesRetrieveUrl = (uidInvite: string) => { - return `/api/v2/project-ownership/invites/${uidInvite}/` -} - -export const projectOwnershipInvitesRetrieve = async ( - uidInvite: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectOwnershipInvitesRetrieveUrl(uidInvite), { - ...options, - method: 'GET', - }) -} - -export const getProjectOwnershipInvitesRetrieveQueryKey = (uidInvite: string) => { - return ['api', 'v2', 'project-ownership', 'invites', uidInvite] as const -} - -export const getProjectOwnershipInvitesRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidInvite: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesRetrieveQueryKey(uidInvite) - - const queryFn: QueryFunction>> = ({ signal }) => - projectOwnershipInvitesRetrieve(uidInvite, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidInvite, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectOwnershipInvitesRetrieveQueryResult = NonNullable< - Awaited> -> -export type ProjectOwnershipInvitesRetrieveQueryError = ErrorDetail - -export function useProjectOwnershipInvitesRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidInvite: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectOwnershipInvitesRetrieveQueryOptions(uidInvite, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update an invite status - -Update the status of an invite. -Status accepted: -- `cancelled` -- `accepted` -- `declined` - -**Notes**: -- _When submitting `accepted` the invite status becomes automatically `in_progress`_ -- _Only the sender can cancel an invite, and **if only if** the invite is still pending._ -- _Only the recipient can accept or decline, **if and only if** the invite is still pending._ - - - */ -export type projectOwnershipInvitesPartialUpdateResponse200 = { - data: ProjectInviteResponse - status: 200 -} - -export type projectOwnershipInvitesPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type projectOwnershipInvitesPartialUpdateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectOwnershipInvitesPartialUpdateResponseComposite = - | projectOwnershipInvitesPartialUpdateResponse200 - | projectOwnershipInvitesPartialUpdateResponse400 - | projectOwnershipInvitesPartialUpdateResponse403 - -export type projectOwnershipInvitesPartialUpdateResponse = projectOwnershipInvitesPartialUpdateResponseComposite & { - headers: Headers -} - -export const getProjectOwnershipInvitesPartialUpdateUrl = (uidInvite: string) => { - return `/api/v2/project-ownership/invites/${uidInvite}/` -} - -export const projectOwnershipInvitesPartialUpdate = async ( - uidInvite: string, - patchedInviteUpdatePayload: PatchedInviteUpdatePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getProjectOwnershipInvitesPartialUpdateUrl(uidInvite), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedInviteUpdatePayload), - }, - ) -} - -export const getProjectOwnershipInvitesPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidInvite: string; data: PatchedInviteUpdatePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidInvite: string; data: PatchedInviteUpdatePayload }, - TContext -> => { - const mutationKey = ['projectOwnershipInvitesPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidInvite: string; data: PatchedInviteUpdatePayload } - > = (props) => { - const { uidInvite, data } = props ?? {} - - return projectOwnershipInvitesPartialUpdate(uidInvite, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ProjectOwnershipInvitesPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type ProjectOwnershipInvitesPartialUpdateMutationBody = PatchedInviteUpdatePayload -export type ProjectOwnershipInvitesPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useProjectOwnershipInvitesPartialUpdate = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidInvite: string; data: PatchedInviteUpdatePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getProjectOwnershipInvitesPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete invite - - */ -export type projectOwnershipInvitesDestroyResponse204 = { - data: void - status: 204 -} - -export type projectOwnershipInvitesDestroyResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectOwnershipInvitesDestroyResponseComposite = - | projectOwnershipInvitesDestroyResponse204 - | projectOwnershipInvitesDestroyResponse403 - -export type projectOwnershipInvitesDestroyResponse = projectOwnershipInvitesDestroyResponseComposite & { - headers: Headers -} - -export const getProjectOwnershipInvitesDestroyUrl = (uidInvite: string) => { - return `/api/v2/project-ownership/invites/${uidInvite}/` -} - -export const projectOwnershipInvitesDestroy = async ( - uidInvite: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectOwnershipInvitesDestroyUrl(uidInvite), { - ...options, - method: 'DELETE', - }) -} - -export const getProjectOwnershipInvitesDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidInvite: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidInvite: string }, - TContext -> => { - const mutationKey = ['projectOwnershipInvitesDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidInvite: string } - > = (props) => { - const { uidInvite } = props ?? {} - - return projectOwnershipInvitesDestroy(uidInvite, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ProjectOwnershipInvitesDestroyMutationResult = NonNullable< - Awaited> -> - -export type ProjectOwnershipInvitesDestroyMutationError = ErrorDetail - -export const useProjectOwnershipInvitesDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidInvite: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getProjectOwnershipInvitesDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve transfer details - - */ -export type projectOwnershipInvitesTransfersRetrieveResponse200 = { - data: TransferListResponse - status: 200 -} - -export type projectOwnershipInvitesTransfersRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type projectOwnershipInvitesTransfersRetrieveResponseComposite = - | projectOwnershipInvitesTransfersRetrieveResponse200 - | projectOwnershipInvitesTransfersRetrieveResponse401 - -export type projectOwnershipInvitesTransfersRetrieveResponse = - projectOwnershipInvitesTransfersRetrieveResponseComposite & { - headers: Headers - } - -export const getProjectOwnershipInvitesTransfersRetrieveUrl = (uidInvite: string, uidTransfer: string) => { - return `/api/v2/project-ownership/invites/${uidInvite}/transfers/${uidTransfer}/` -} - -export const projectOwnershipInvitesTransfersRetrieve = async ( - uidInvite: string, - uidTransfer: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getProjectOwnershipInvitesTransfersRetrieveUrl(uidInvite, uidTransfer), - { - ...options, - method: 'GET', - }, - ) -} - -export const getProjectOwnershipInvitesTransfersRetrieveQueryKey = (uidInvite: string, uidTransfer: string) => { - return ['api', 'v2', 'project-ownership', 'invites', uidInvite, 'transfers', uidTransfer] as const -} - -export const getProjectOwnershipInvitesTransfersRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidInvite: string, - uidTransfer: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesTransfersRetrieveQueryKey(uidInvite, uidTransfer) - - const queryFn: QueryFunction>> = ({ signal }) => - projectOwnershipInvitesTransfersRetrieve(uidInvite, uidTransfer, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidInvite && uidTransfer), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectOwnershipInvitesTransfersRetrieveQueryResult = NonNullable< - Awaited> -> -export type ProjectOwnershipInvitesTransfersRetrieveQueryError = ErrorDetail - -export function useProjectOwnershipInvitesTransfersRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidInvite: string, - uidTransfer: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectOwnershipInvitesTransfersRetrieveQueryOptions(uidInvite, uidTransfer, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List current user's assets' tags - - */ -export type tagsListResponse200 = { - data: PaginatedTagListResponseList - status: 200 -} - -export type tagsListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type tagsListResponseComposite = tagsListResponse200 | tagsListResponse401 - -export type tagsListResponse = tagsListResponseComposite & { - headers: Headers -} - -export const getTagsListUrl = (params?: TagsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/tags/?${stringifiedParams}` : `/api/v2/tags/` -} - -export const tagsList = async (params?: TagsListParams, options?: RequestInit): Promise => { - return fetchWithAuth(getTagsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getTagsListQueryKey = (params?: TagsListParams) => { - return ['api', 'v2', 'tags', ...(params ? [params] : [])] as const -} - -export const getTagsListQueryOptions = >, TError = ErrorDetail>( - params?: TagsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getTagsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - tagsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type TagsListQueryResult = NonNullable>> -export type TagsListQueryError = ErrorDetail - -export function useTagsList>, TError = ErrorDetail>( - params?: TagsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getTagsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve a tag's data - - */ -export type tagsRetrieveResponse200 = { - data: TagRetrieveResponse - status: 200 -} - -export type tagsRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type tagsRetrieveResponseComposite = tagsRetrieveResponse200 | tagsRetrieveResponse401 - -export type tagsRetrieveResponse = tagsRetrieveResponseComposite & { - headers: Headers -} - -export const getTagsRetrieveUrl = (taguidUid: string) => { - return `/api/v2/tags/${taguidUid}/` -} - -export const tagsRetrieve = async (taguidUid: string, options?: RequestInit): Promise => { - return fetchWithAuth(getTagsRetrieveUrl(taguidUid), { - ...options, - method: 'GET', - }) -} - -export const getTagsRetrieveQueryKey = (taguidUid: string) => { - return ['api', 'v2', 'tags', taguidUid] as const -} - -export const getTagsRetrieveQueryOptions = >, TError = ErrorDetail>( - taguidUid: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getTagsRetrieveQueryKey(taguidUid) - - const queryFn: QueryFunction>> = ({ signal }) => - tagsRetrieve(taguidUid, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!taguidUid, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type TagsRetrieveQueryResult = NonNullable>> -export type TagsRetrieveQueryError = ErrorDetail - -export function useTagsRetrieve>, TError = ErrorDetail>( - taguidUid: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getTagsRetrieveQueryOptions(taguidUid, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} +import type { VersionRetrieveResponse } from '../../models/versionRetrieveResponse' export const getApiV2AssetsListResponseMock = ( overrideResponse: Partial = {}, @@ -7260,7 +4636,7 @@ export const getApiV2AssetsListMockHandler = ( | PaginatedAssetList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), ) => { - return http.get('*/api/v2/assets{/}?', async (info) => { + return http.get('*/api/v2/assets/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7277,7 +4653,7 @@ export const getApiV2AssetsListMockHandler = ( export const getApiV2AssetsCreateMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { - return http.post('*/api/v2/assets{/}?', async (info) => { + return http.post('*/api/v2/assets/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7294,7 +4670,7 @@ export const getApiV2AssetsCreateMockHandler = ( export const getApiV2AssetsRetrieveMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { - return http.get('*/api/v2/assets/:uidAsset{/}?', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7311,7 +4687,7 @@ export const getApiV2AssetsRetrieveMockHandler = ( export const getApiV2AssetsPartialUpdateMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { - return http.patch('*/api/v2/assets/:uidAsset{/}?', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7328,7 +4704,7 @@ export const getApiV2AssetsPartialUpdateMockHandler = ( export const getApiV2AssetsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset{/}?', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -7343,7 +4719,7 @@ export const getApiV2AssetsCountsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetCountResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/counts{/}?', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/counts/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7362,7 +4738,7 @@ export const getApiV2AssetsDeploymentRetrieveMockHandler = ( | DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/deployment/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7381,7 +4757,7 @@ export const getApiV2AssetsDeploymentCreateMockHandler = ( | DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/deployment/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7400,7 +4776,7 @@ export const getApiV2AssetsDeploymentPartialUpdateMockHandler = ( | DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/deployment/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7421,7 +4797,7 @@ export const getApiV2AssetsVersionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedVersionListResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/versions{/}?', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/versions/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7442,7 +4818,7 @@ export const getApiV2AssetsVersionsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | VersionRetrieveResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion{/}?', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7459,7 +4835,7 @@ export const getApiV2AssetsVersionsRetrieveMockHandler = ( export const getApiV2AssetsXformRetrieveMockHandler = ( overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), ) => { - return http.get('*/api/v2/assets/:uidAsset/xform{/}?', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/xform/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7478,7 +4854,7 @@ export const getApiV2AssetsBulkCreateMockHandler = ( | AssetBulkResponse | ((info: Parameters[1]>[0]) => Promise | AssetBulkResponse), ) => { - return http.post('*/api/v2/assets/bulk{/}?', async (info) => { + return http.post('*/api/v2/assets/bulk/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7497,7 +4873,7 @@ export const getApiV2AssetsCountsRetrieveMockHandler = ( | AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount), ) => { - return http.get('*/api/v2/assets/counts{/}?', async (info) => { + return http.get('*/api/v2/assets/counts/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7516,7 +4892,7 @@ export const getApiV2AssetsHashRetrieveMockHandler = ( | HashResponse | ((info: Parameters[1]>[0]) => Promise | HashResponse), ) => { - return http.get('*/api/v2/assets/hash{/}?', async (info) => { + return http.get('*/api/v2/assets/hash/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7535,7 +4911,7 @@ export const getApiV2AssetsMetadataRetrieveMockHandler = ( | AssetMetadataResponse | ((info: Parameters[1]>[0]) => Promise | AssetMetadataResponse), ) => { - return http.get('*/api/v2/assets/metadata{/}?', async (info) => { + return http.get('*/api/v2/assets/metadata/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7556,7 +4932,7 @@ export const getApiV2AssetsMinimalListRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetMinimalListList), ) => { - return http.get('*/api/v2/assets/minimal-list{/}?', async (info) => { + return http.get('*/api/v2/assets/minimal-list/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7577,7 +4953,7 @@ export const getApiV2ImportsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedImportResponseList), ) => { - return http.get('*/api/v2/imports{/}?', async (info) => { + return http.get('*/api/v2/imports/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7596,7 +4972,7 @@ export const getApiV2ImportsCreateMockHandler = ( | ImportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ImportCreateResponse), ) => { - return http.post('*/api/v2/imports{/}?', async (info) => { + return http.post('*/api/v2/imports/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7615,7 +4991,7 @@ export const getApiV2ImportsRetrieveMockHandler = ( | ImportResponse | ((info: Parameters[1]>[0]) => Promise | ImportResponse), ) => { - return http.get('*/api/v2/imports/:uidImport{/}?', async (info) => { + return http.get('*/api/v2/imports/:uidImport/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7636,7 +5012,7 @@ export const getApiV2ProjectOwnershipInvitesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectInviteResponseList), ) => { - return http.get('*/api/v2/project-ownership/invites{/}?', async (info) => { + return http.get('*/api/v2/project-ownership/invites/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7657,7 +5033,7 @@ export const getApiV2ProjectOwnershipInvitesCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectInviteResponse), ) => { - return http.post('*/api/v2/project-ownership/invites{/}?', async (info) => { + return http.post('*/api/v2/project-ownership/invites/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7676,7 +5052,7 @@ export const getApiV2ProjectOwnershipInvitesRetrieveMockHandler = ( | ProjectInviteResponse | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse), ) => { - return http.get('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { + return http.get('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7697,7 +5073,7 @@ export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectInviteResponse), ) => { - return http.patch('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { + return http.patch('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7714,7 +5090,7 @@ export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = ( export const getApiV2ProjectOwnershipInvitesDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { + return http.delete('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -7727,7 +5103,7 @@ export const getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler = ( | TransferListResponse | ((info: Parameters[1]>[0]) => Promise | TransferListResponse), ) => { - return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer{/}?', async (info) => { + return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7748,7 +5124,7 @@ export const getApiV2TagsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedTagListResponseList), ) => { - return http.get('*/api/v2/tags{/}?', async (info) => { + return http.get('*/api/v2/tags/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -7767,7 +5143,7 @@ export const getApiV2TagsRetrieveMockHandler = ( | TagRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | TagRetrieveResponse), ) => { - return http.get('*/api/v2/tags/:taguidUid{/}?', async (info) => { + return http.get('*/api/v2/tags/:taguidUid/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.ts new file mode 100644 index 0000000000..9a964a2818 --- /dev/null +++ b/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.ts @@ -0,0 +1,2672 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { useMutation, useQuery } from '@tanstack/react-query' +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult, +} from '@tanstack/react-query' + +import type { Asset } from '../../models/asset' + +import type { AssetBulkRequest } from '../../models/assetBulkRequest' + +import type { AssetBulkResponse } from '../../models/assetBulkResponse' + +import type { AssetCreateRequest } from '../../models/assetCreateRequest' + +import type { AssetListCount } from '../../models/assetListCount' + +import type { AssetMetadataResponse } from '../../models/assetMetadataResponse' + +import type { AssetsCountsListParams } from '../../models/assetsCountsListParams' + +import type { AssetsListParams } from '../../models/assetsListParams' + +import type { AssetsMinimalListRetrieveParams } from '../../models/assetsMinimalListRetrieveParams' + +import type { AssetsRetrieveParams } from '../../models/assetsRetrieveParams' + +import type { AssetsVersionsListParams } from '../../models/assetsVersionsListParams' + +import type { DeploymentCreateRequest } from '../../models/deploymentCreateRequest' + +import type { DeploymentResponse } from '../../models/deploymentResponse' + +import type { ErrorDetail } from '../../models/errorDetail' + +import type { ErrorObject } from '../../models/errorObject' + +import type { HashResponse } from '../../models/hashResponse' + +import type { ImportCreateRequest } from '../../models/importCreateRequest' + +import type { ImportCreateResponse } from '../../models/importCreateResponse' + +import type { ImportResponse } from '../../models/importResponse' + +import type { ImportsListParams } from '../../models/importsListParams' + +import type { PaginatedAssetCountResponseList } from '../../models/paginatedAssetCountResponseList' + +import type { PaginatedAssetList } from '../../models/paginatedAssetList' + +import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' + +import type { PaginatedImportResponseList } from '../../models/paginatedImportResponseList' + +import type { PaginatedProjectInviteResponseList } from '../../models/paginatedProjectInviteResponseList' + +import type { PaginatedTagListResponseList } from '../../models/paginatedTagListResponseList' + +import type { PaginatedVersionListResponseList } from '../../models/paginatedVersionListResponseList' + +import type { PatchedAssetPatchRequest } from '../../models/patchedAssetPatchRequest' + +import type { PatchedDeploymentPatchRequest } from '../../models/patchedDeploymentPatchRequest' + +import type { PatchedInviteUpdatePayload } from '../../models/patchedInviteUpdatePayload' + +import type { ProjectInviteCreatePayload } from '../../models/projectInviteCreatePayload' + +import type { ProjectInviteResponse } from '../../models/projectInviteResponse' + +import type { ProjectOwnershipInvitesListParams } from '../../models/projectOwnershipInvitesListParams' + +import type { TagRetrieveResponse } from '../../models/tagRetrieveResponse' + +import type { TagsListParams } from '../../models/tagsListParams' + +import type { TransferListResponse } from '../../models/transferListResponse' + +import type { VersionRetrieveResponse } from '../../models/versionRetrieveResponse' + +import { fetchWithAuth } from '../../orval.mutator' + +type SecondParameter unknown> = Parameters[1] + +/** + * ## Get user's assets + + +Search can be made with `q` parameter. +Search filters can be returned with results by passing `metadata=on` to querystring. + + +Results can be sorted with `ordering` parameter, e.g.: + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/?ordering=-name +``` + + +Allowed fields are: + +- `asset_type` +- `date_modified` +- `date_deployed` +- `date_modified__date` +- `date_deployed__date` +- `name` +- `settings__sector` +- `settings__sector__value` +- `settings__description` +- `owner__username` +- `owner__extra_details__data__name` +- `owner__extra_details__data__organization` +- `owner__email` +- `_deployment_status` +- `subscribers_count` + + +Note: Collections can be displayed first with parameter `collections_first`, e.g.: + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/?collections_first=true&ordering=-name +``` + + */ +export type assetsListResponse200 = { + data: PaginatedAssetList + status: 200 +} + +export type assetsListResponseComposite = assetsListResponse200 + +export type assetsListResponse = assetsListResponseComposite & { + headers: Headers +} + +export const getAssetsListUrl = (params?: AssetsListParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 ? `/api/v2/assets/?${stringifiedParams}` : `/api/v2/assets/` +} + +export const assetsList = async (params?: AssetsListParams, options?: RequestInit): Promise => { + return fetchWithAuth(getAssetsListUrl(params), { + ...options, + method: 'GET', + }) +} + +export const getAssetsListQueryKey = (params?: AssetsListParams) => { + return ['api', 'v2', 'assets', ...(params ? [params] : [])] as const +} + +export const getAssetsListQueryOptions = >, TError = unknown>( + params?: AssetsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsListQueryKey(params) + + const queryFn: QueryFunction>> = ({ signal }) => + assetsList(params, { signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsListQueryResult = NonNullable>> +export type AssetsListQueryError = unknown + +export function useAssetsList>, TError = unknown>( + params?: AssetsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsListQueryOptions(params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Create or clone an asset + +When cloning an asset, you must provide: + +- the name (as a string), +- the `clone_from` (the uid representing the asset), +- the asset_type + +Where `asset_type` must be one of these values: + +* block (can be cloned to `block`, `question`, `survey`, `template`) +* question (can be cloned to `question`, `survey`, `template`) +* survey (can be cloned to `block`, `question`, `survey`, `template`) +* template (can be cloned to `survey`, `template`) + +Settings are cloned only when type of assets are `survey` or `template`. +In that case, `share-metadata` is not preserved. + +When creating a new `block` or `question` asset, settings are not saved either. + + */ +export type assetsCreateResponse201 = { + data: Asset + status: 201 +} + +export type assetsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsCreateResponseComposite = assetsCreateResponse201 | assetsCreateResponse400 | assetsCreateResponse401 + +export type assetsCreateResponse = assetsCreateResponseComposite & { + headers: Headers +} + +export const getAssetsCreateUrl = () => { + return `/api/v2/assets/` +} + +export const assetsCreate = async ( + assetCreateRequest: AssetCreateRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsCreateUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(assetCreateRequest), + }) +} + +export const getAssetsCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetCreateRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, { data: AssetCreateRequest }, TContext> => { + const mutationKey = ['assetsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: AssetCreateRequest }> = ( + props, + ) => { + const { data } = props ?? {} + + return assetsCreate(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type AssetsCreateMutationResult = NonNullable>> +export type AssetsCreateMutationBody = AssetCreateRequest +export type AssetsCreateMutationError = ErrorObject | ErrorDetail + +export const useAssetsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetCreateRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## Get a user's current asset + + */ +export type assetsRetrieveResponse200 = { + data: Asset + status: 200 +} + +export type assetsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsRetrieveResponseComposite = assetsRetrieveResponse200 | assetsRetrieveResponse404 + +export type assetsRetrieveResponse = assetsRetrieveResponseComposite & { + headers: Headers +} + +export const getAssetsRetrieveUrl = (uidAsset: string, params?: AssetsRetrieveParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/` +} + +export const assetsRetrieve = async ( + uidAsset: string, + params?: AssetsRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsRetrieveUrl(uidAsset, params), { + ...options, + method: 'GET', + }) +} + +export const getAssetsRetrieveQueryKey = (uidAsset: string, params?: AssetsRetrieveParams) => { + return ['api', 'v2', 'assets', uidAsset, ...(params ? [params] : [])] as const +} + +export const getAssetsRetrieveQueryOptions = >, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsRetrieveQueryKey(uidAsset, params) + + const queryFn: QueryFunction>> = ({ signal }) => + assetsRetrieve(uidAsset, params, { signal, ...requestOptions }) + + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsRetrieveQueryResult = NonNullable>> +export type AssetsRetrieveQueryError = ErrorDetail + +export function useAssetsRetrieve>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsRetrieveQueryOptions(uidAsset, params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Update or connect a user's asset + +Updates a project or connect project's data from this project to other projects + +When `Data sharing`: + +`fields`: Optional. List of questions whose responses will be shared. If +missing or empty, all responses will be shared. Questions must be +identified by full group path separated by slashes, e.g. +`group/subgroup/question_name`. + + */ +export type assetsPartialUpdateResponse200 = { + data: Asset + status: 200 +} + +export type assetsPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsPartialUpdateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsPartialUpdateResponseComposite = + | assetsPartialUpdateResponse200 + | assetsPartialUpdateResponse400 + | assetsPartialUpdateResponse401 + +export type assetsPartialUpdateResponse = assetsPartialUpdateResponseComposite & { + headers: Headers +} + +export const getAssetsPartialUpdateUrl = (uidAsset: string) => { + return `/api/v2/assets/${uidAsset}/` +} + +export const assetsPartialUpdate = async ( + uidAsset: string, + patchedAssetPatchRequest: PatchedAssetPatchRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsPartialUpdateUrl(uidAsset), { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedAssetPatchRequest), + }) +} + +export const getAssetsPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedAssetPatchRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedAssetPatchRequest }, + TContext +> => { + const mutationKey = ['assetsPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: PatchedAssetPatchRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsPartialUpdate(uidAsset, data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type AssetsPartialUpdateMutationResult = NonNullable>> +export type AssetsPartialUpdateMutationBody = PatchedAssetPatchRequest +export type AssetsPartialUpdateMutationError = ErrorObject | ErrorDetail + +export const useAssetsPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedAssetPatchRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## Delete a user's asset + + */ +export type assetsDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsDestroyResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsDestroyResponseComposite = assetsDestroyResponse204 | assetsDestroyResponse401 + +export type assetsDestroyResponse = assetsDestroyResponseComposite & { + headers: Headers +} + +export const getAssetsDestroyUrl = (uidAsset: string) => { + return `/api/v2/assets/${uidAsset}/` +} + +export const assetsDestroy = async (uidAsset: string, options?: RequestInit): Promise => { + return fetchWithAuth(getAssetsDestroyUrl(uidAsset), { + ...options, + method: 'DELETE', + }) +} + +export const getAssetsDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, { uidAsset: string }, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, { uidAsset: string }, TContext> => { + const mutationKey = ['assetsDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { uidAsset: string }> = (props) => { + const { uidAsset } = props ?? {} + + return assetsDestroy(uidAsset, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type AssetsDestroyMutationResult = NonNullable>> + +export type AssetsDestroyMutationError = ErrorDetail + +export const useAssetsDestroy = (options?: { + mutation?: UseMutationOptions>, TError, { uidAsset: string }, TContext> + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDestroyMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## Count the daily amount of submissions + +Returns up to the last 31 days of daily counts and total counts of submissions to a survey. + + +Use the `days` query to get the daily counts from the last x amount of days. +Default amount is 30 days + + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/counts/?days=7 +``` + + */ +export type assetsCountsListResponse200 = { + data: PaginatedAssetCountResponseList + status: 200 +} + +export type assetsCountsListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsCountsListResponseComposite = assetsCountsListResponse200 | assetsCountsListResponse401 + +export type assetsCountsListResponse = assetsCountsListResponseComposite & { + headers: Headers +} + +export const getAssetsCountsListUrl = (uidAsset: string, params?: AssetsCountsListParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/counts/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/counts/` +} + +export const assetsCountsList = async ( + uidAsset: string, + params?: AssetsCountsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsCountsListUrl(uidAsset, params), { + ...options, + method: 'GET', + }) +} + +export const getAssetsCountsListQueryKey = (uidAsset: string, params?: AssetsCountsListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'counts', ...(params ? [params] : [])] as const +} + +export const getAssetsCountsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsCountsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsCountsListQueryKey(uidAsset, params) + + const queryFn: QueryFunction>> = ({ signal }) => + assetsCountsList(uidAsset, params, { signal, ...requestOptions }) + + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsCountsListQueryResult = NonNullable>> +export type AssetsCountsListQueryError = ErrorDetail + +export function useAssetsCountsList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsCountsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsCountsListQueryOptions(uidAsset, params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Retrieve the existing deployment (if any) + + */ +export type assetsDeploymentRetrieveResponse200 = { + data: DeploymentResponse + status: 200 +} + +export type assetsDeploymentRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDeploymentRetrieveResponseComposite = + | assetsDeploymentRetrieveResponse200 + | assetsDeploymentRetrieveResponse404 + +export type assetsDeploymentRetrieveResponse = assetsDeploymentRetrieveResponseComposite & { + headers: Headers +} + +export const getAssetsDeploymentRetrieveUrl = (uidAsset: string) => { + return `/api/v2/assets/${uidAsset}/deployment/` +} + +export const assetsDeploymentRetrieve = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDeploymentRetrieveUrl(uidAsset), { + ...options, + method: 'GET', + }) +} + +export const getAssetsDeploymentRetrieveQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'deployment'] as const +} + +export const getAssetsDeploymentRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsDeploymentRetrieveQueryKey(uidAsset) + + const queryFn: QueryFunction>> = ({ signal }) => + assetsDeploymentRetrieve(uidAsset, { signal, ...requestOptions }) + + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsDeploymentRetrieveQueryResult = NonNullable>> +export type AssetsDeploymentRetrieveQueryError = ErrorDetail + +export function useAssetsDeploymentRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDeploymentRetrieveQueryOptions(uidAsset, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## (Re)Deploy a form + +Deploy a new form or re-deploy an existing one. + + */ +export type assetsDeploymentCreateResponse200 = { + data: DeploymentResponse + status: 200 +} + +export type assetsDeploymentCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsDeploymentCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsDeploymentCreateResponseComposite = + | assetsDeploymentCreateResponse200 + | assetsDeploymentCreateResponse400 + | assetsDeploymentCreateResponse401 + +export type assetsDeploymentCreateResponse = assetsDeploymentCreateResponseComposite & { + headers: Headers +} + +export const getAssetsDeploymentCreateUrl = (uidAsset: string) => { + return `/api/v2/assets/${uidAsset}/deployment/` +} + +export const assetsDeploymentCreate = async ( + uidAsset: string, + deploymentCreateRequest: DeploymentCreateRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDeploymentCreateUrl(uidAsset), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(deploymentCreateRequest), + }) +} + +export const getAssetsDeploymentCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: DeploymentCreateRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: DeploymentCreateRequest }, + TContext +> => { + const mutationKey = ['assetsDeploymentCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: DeploymentCreateRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsDeploymentCreate(uidAsset, data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type AssetsDeploymentCreateMutationResult = NonNullable>> +export type AssetsDeploymentCreateMutationBody = DeploymentCreateRequest +export type AssetsDeploymentCreateMutationError = ErrorObject | ErrorDetail + +export const useAssetsDeploymentCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: DeploymentCreateRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDeploymentCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## (Un)Archive the existing deployment. + +Update the `active` field of the existing deployment. + +To overwrite the entire deployment (including the form contents), use a PUT request. + + */ +export type assetsDeploymentPartialUpdateResponse200 = { + data: DeploymentResponse + status: 200 +} + +export type assetsDeploymentPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsDeploymentPartialUpdateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsDeploymentPartialUpdateResponseComposite = + | assetsDeploymentPartialUpdateResponse200 + | assetsDeploymentPartialUpdateResponse400 + | assetsDeploymentPartialUpdateResponse401 + +export type assetsDeploymentPartialUpdateResponse = assetsDeploymentPartialUpdateResponseComposite & { + headers: Headers +} + +export const getAssetsDeploymentPartialUpdateUrl = (uidAsset: string) => { + return `/api/v2/assets/${uidAsset}/deployment/` +} + +export const assetsDeploymentPartialUpdate = async ( + uidAsset: string, + patchedDeploymentPatchRequest: PatchedDeploymentPatchRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDeploymentPartialUpdateUrl(uidAsset), { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedDeploymentPatchRequest), + }) +} + +export const getAssetsDeploymentPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDeploymentPatchRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDeploymentPatchRequest }, + TContext +> => { + const mutationKey = ['assetsDeploymentPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: PatchedDeploymentPatchRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsDeploymentPartialUpdate(uidAsset, data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type AssetsDeploymentPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsDeploymentPartialUpdateMutationBody = PatchedDeploymentPatchRequest +export type AssetsDeploymentPartialUpdateMutationError = ErrorObject | ErrorDetail + +export const useAssetsDeploymentPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDeploymentPatchRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDeploymentPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## List the versions of forms + + */ +export type assetsVersionsListResponse200 = { + data: PaginatedVersionListResponseList + status: 200 +} + +export type assetsVersionsListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsVersionsListResponseComposite = assetsVersionsListResponse200 | assetsVersionsListResponse404 + +export type assetsVersionsListResponse = assetsVersionsListResponseComposite & { + headers: Headers +} + +export const getAssetsVersionsListUrl = (uidAsset: string, params?: AssetsVersionsListParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/versions/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/versions/` +} + +export const assetsVersionsList = async ( + uidAsset: string, + params?: AssetsVersionsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsVersionsListUrl(uidAsset, params), { + ...options, + method: 'GET', + }) +} + +export const getAssetsVersionsListQueryKey = (uidAsset: string, params?: AssetsVersionsListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'versions', ...(params ? [params] : [])] as const +} + +export const getAssetsVersionsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsVersionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsVersionsListQueryKey(uidAsset, params) + + const queryFn: QueryFunction>> = ({ signal }) => + assetsVersionsList(uidAsset, params, { signal, ...requestOptions }) + + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsVersionsListQueryResult = NonNullable>> +export type AssetsVersionsListQueryError = ErrorDetail + +export function useAssetsVersionsList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsVersionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsVersionsListQueryOptions(uidAsset, params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Retrieve asset versions + +Returns the details of an asset version + + */ +export type assetsVersionsRetrieveResponse200 = { + data: VersionRetrieveResponse + status: 200 +} + +export type assetsVersionsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsVersionsRetrieveResponseComposite = + | assetsVersionsRetrieveResponse200 + | assetsVersionsRetrieveResponse404 + +export type assetsVersionsRetrieveResponse = assetsVersionsRetrieveResponseComposite & { + headers: Headers +} + +export const getAssetsVersionsRetrieveUrl = (uidAsset: string, uidVersion: string) => { + return `/api/v2/assets/${uidAsset}/versions/${uidVersion}/` +} + +export const assetsVersionsRetrieve = async ( + uidAsset: string, + uidVersion: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsVersionsRetrieveUrl(uidAsset, uidVersion), { + ...options, + method: 'GET', + }) +} + +export const getAssetsVersionsRetrieveQueryKey = (uidAsset: string, uidVersion: string) => { + return ['api', 'v2', 'assets', uidAsset, 'versions', uidVersion] as const +} + +export const getAssetsVersionsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidVersion: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsVersionsRetrieveQueryKey(uidAsset, uidVersion) + + const queryFn: QueryFunction>> = ({ signal }) => + assetsVersionsRetrieve(uidAsset, uidVersion, { signal, ...requestOptions }) + + return { queryKey, queryFn, enabled: !!(uidAsset && uidVersion), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsVersionsRetrieveQueryResult = NonNullable>> +export type AssetsVersionsRetrieveQueryError = ErrorDetail + +export function useAssetsVersionsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidVersion: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsVersionsRetrieveQueryOptions(uidAsset, uidVersion, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## This route will render the XForm into syntax-highlighted HTML. + +It is useful for debugging pyxform transformations + + */ +export type assetsXformRetrieveResponse200 = { + data: string + status: 200 +} + +export type assetsXformRetrieveResponse404 = { + data: void + status: 404 +} + +export type assetsXformRetrieveResponseComposite = assetsXformRetrieveResponse200 | assetsXformRetrieveResponse404 + +export type assetsXformRetrieveResponse = assetsXformRetrieveResponseComposite & { + headers: Headers +} + +export const getAssetsXformRetrieveUrl = (uidAsset: string) => { + return `/api/v2/assets/${uidAsset}/xform/` +} + +export const assetsXformRetrieve = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsXformRetrieveUrl(uidAsset), { + ...options, + method: 'GET', + }) +} + +export const getAssetsXformRetrieveQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'xform'] as const +} + +export const getAssetsXformRetrieveQueryOptions = < + TData = Awaited>, + TError = void, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsXformRetrieveQueryKey(uidAsset) + + const queryFn: QueryFunction>> = ({ signal }) => + assetsXformRetrieve(uidAsset, { signal, ...requestOptions }) + + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsXformRetrieveQueryResult = NonNullable>> +export type AssetsXformRetrieveQueryError = void + +export function useAssetsXformRetrieve>, TError = void>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsXformRetrieveQueryOptions(uidAsset, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Perform bulk actions on assets + +Actions available: + +- `archive` +- `delete` +- `unarchive` +- `undelete` (superusers only) + + */ +export type assetsBulkCreateResponse200 = { + data: AssetBulkResponse + status: 200 +} + +export type assetsBulkCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsBulkCreateResponseComposite = assetsBulkCreateResponse200 | assetsBulkCreateResponse404 + +export type assetsBulkCreateResponse = assetsBulkCreateResponseComposite & { + headers: Headers +} + +export const getAssetsBulkCreateUrl = () => { + return `/api/v2/assets/bulk/` +} + +export const assetsBulkCreate = async ( + assetBulkRequest: AssetBulkRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsBulkCreateUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(assetBulkRequest), + }) +} + +export const getAssetsBulkCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetBulkRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, { data: AssetBulkRequest }, TContext> => { + const mutationKey = ['assetsBulkCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: AssetBulkRequest }> = ( + props, + ) => { + const { data } = props ?? {} + + return assetsBulkCreate(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type AssetsBulkCreateMutationResult = NonNullable>> +export type AssetsBulkCreateMutationBody = AssetBulkRequest +export type AssetsBulkCreateMutationError = ErrorDetail + +export const useAssetsBulkCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetBulkRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsBulkCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## Return counts of deployed, archived, and draft assets + + */ +export type assetsCountsRetrieveResponse200 = { + data: AssetListCount + status: 200 +} + +export type assetsCountsRetrieveResponseComposite = assetsCountsRetrieveResponse200 + +export type assetsCountsRetrieveResponse = assetsCountsRetrieveResponseComposite & { + headers: Headers +} + +export const getAssetsCountsRetrieveUrl = () => { + return `/api/v2/assets/counts/` +} + +export const assetsCountsRetrieve = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAssetsCountsRetrieveUrl(), { + ...options, + method: 'GET', + }) +} + +export const getAssetsCountsRetrieveQueryKey = () => { + return ['api', 'v2', 'assets', 'counts'] as const +} + +export const getAssetsCountsRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsCountsRetrieveQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + assetsCountsRetrieve({ signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsCountsRetrieveQueryResult = NonNullable>> +export type AssetsCountsRetrieveQueryError = unknown + +export function useAssetsCountsRetrieve< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsCountsRetrieveQueryOptions(options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Get a hash of all `version_id`s of all accessible assets by the current user. + +Useful to detect any changes in assets with only one call to `API` + + */ +export type assetsHashRetrieveResponse200 = { + data: HashResponse + status: 200 +} + +export type assetsHashRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsHashRetrieveResponseComposite = assetsHashRetrieveResponse200 | assetsHashRetrieveResponse401 + +export type assetsHashRetrieveResponse = assetsHashRetrieveResponseComposite & { + headers: Headers +} + +export const getAssetsHashRetrieveUrl = () => { + return `/api/v2/assets/hash/` +} + +export const assetsHashRetrieve = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAssetsHashRetrieveUrl(), { + ...options, + method: 'GET', + }) +} + +export const getAssetsHashRetrieveQueryKey = () => { + return ['api', 'v2', 'assets', 'hash'] as const +} + +export const getAssetsHashRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsHashRetrieveQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + assetsHashRetrieve({ signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsHashRetrieveQueryResult = NonNullable>> +export type AssetsHashRetrieveQueryError = ErrorDetail + +export function useAssetsHashRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsHashRetrieveQueryOptions(options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Get metadata for all authenticated user' assets + + */ +export type assetsMetadataRetrieveResponse200 = { + data: AssetMetadataResponse + status: 200 +} + +export type assetsMetadataRetrieveResponseComposite = assetsMetadataRetrieveResponse200 + +export type assetsMetadataRetrieveResponse = assetsMetadataRetrieveResponseComposite & { + headers: Headers +} + +export const getAssetsMetadataRetrieveUrl = () => { + return `/api/v2/assets/metadata/` +} + +export const assetsMetadataRetrieve = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAssetsMetadataRetrieveUrl(), { + ...options, + method: 'GET', + }) +} + +export const getAssetsMetadataRetrieveQueryKey = () => { + return ['api', 'v2', 'assets', 'metadata'] as const +} + +export const getAssetsMetadataRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsMetadataRetrieveQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + assetsMetadataRetrieve({ signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsMetadataRetrieveQueryResult = NonNullable>> +export type AssetsMetadataRetrieveQueryError = unknown + +export function useAssetsMetadataRetrieve< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsMetadataRetrieveQueryOptions(options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Return a minimal listing of assets with their deployment status + +Returns a paginated list of assets visible to the current user, including only `uid`, `name`, and `deployment_status` (`draft`, `deployed`, or `archived`). + +Use the `q` query parameter to filter by asset type (e.g. `?q=asset_type:survey`). + +Responses do not include a `count` field. Use the `next` and `previous` links to paginate through results. + + */ +export type assetsMinimalListRetrieveResponse200 = { + data: PaginatedAssetMinimalListList + status: 200 +} + +export type assetsMinimalListRetrieveResponseComposite = assetsMinimalListRetrieveResponse200 + +export type assetsMinimalListRetrieveResponse = assetsMinimalListRetrieveResponseComposite & { + headers: Headers +} + +export const getAssetsMinimalListRetrieveUrl = (params?: AssetsMinimalListRetrieveParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 + ? `/api/v2/assets/minimal-list/?${stringifiedParams}` + : `/api/v2/assets/minimal-list/` +} + +export const assetsMinimalListRetrieve = async ( + params?: AssetsMinimalListRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsMinimalListRetrieveUrl(params), { + ...options, + method: 'GET', + }) +} + +export const getAssetsMinimalListRetrieveQueryKey = (params?: AssetsMinimalListRetrieveParams) => { + return ['api', 'v2', 'assets', 'minimal-list', ...(params ? [params] : [])] as const +} + +export const getAssetsMinimalListRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: AssetsMinimalListRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAssetsMinimalListRetrieveQueryKey(params) + + const queryFn: QueryFunction>> = ({ signal }) => + assetsMinimalListRetrieve(params, { signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AssetsMinimalListRetrieveQueryResult = NonNullable>> +export type AssetsMinimalListRetrieveQueryError = unknown + +export function useAssetsMinimalListRetrieve< + TData = Awaited>, + TError = unknown, +>( + params?: AssetsMinimalListRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsMinimalListRetrieveQueryOptions(params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## List imported files + + */ +export type importsListResponse200 = { + data: PaginatedImportResponseList + status: 200 +} + +export type importsListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type importsListResponseComposite = importsListResponse200 | importsListResponse401 + +export type importsListResponse = importsListResponseComposite & { + headers: Headers +} + +export const getImportsListUrl = (params?: ImportsListParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 ? `/api/v2/imports/?${stringifiedParams}` : `/api/v2/imports/` +} + +export const importsList = async (params?: ImportsListParams, options?: RequestInit): Promise => { + return fetchWithAuth(getImportsListUrl(params), { + ...options, + method: 'GET', + }) +} + +export const getImportsListQueryKey = (params?: ImportsListParams) => { + return ['api', 'v2', 'imports', ...(params ? [params] : [])] as const +} + +export const getImportsListQueryOptions = >, TError = ErrorDetail>( + params?: ImportsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getImportsListQueryKey(params) + + const queryFn: QueryFunction>> = ({ signal }) => + importsList(params, { signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type ImportsListQueryResult = NonNullable>> +export type ImportsListQueryError = ErrorDetail + +export function useImportsList>, TError = ErrorDetail>( + params?: ImportsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getImportsListQueryOptions(params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Import file + +_**Note**: this endpoint is expecting a multipart/form-data_ + + */ +export type importsCreateResponse201 = { + data: ImportCreateResponse + status: 201 +} + +export type importsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type importsCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type importsCreateResponseComposite = + | importsCreateResponse201 + | importsCreateResponse400 + | importsCreateResponse401 + +export type importsCreateResponse = importsCreateResponseComposite & { + headers: Headers +} + +export const getImportsCreateUrl = () => { + return `/api/v2/imports/` +} + +export const importsCreate = async ( + importCreateRequest: ImportCreateRequest, + options?: RequestInit, +): Promise => { + const formData = new FormData() + formData.append(`destination`, importCreateRequest.destination) + formData.append(`url`, importCreateRequest.url) + if (importCreateRequest.name !== undefined) { + formData.append(`name`, importCreateRequest.name) + } + formData.append(`assetUid`, importCreateRequest.assetUid) + + return fetchWithAuth(getImportsCreateUrl(), { + ...options, + method: 'POST', + body: formData, + }) +} + +export const getImportsCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ImportCreateRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, { data: ImportCreateRequest }, TContext> => { + const mutationKey = ['importsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: ImportCreateRequest }> = ( + props, + ) => { + const { data } = props ?? {} + + return importsCreate(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ImportsCreateMutationResult = NonNullable>> +export type ImportsCreateMutationBody = ImportCreateRequest +export type ImportsCreateMutationError = ErrorObject | ErrorDetail + +export const useImportsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ImportCreateRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getImportsCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## Retrieve imported files + + */ +export type importsRetrieveResponse200 = { + data: ImportResponse + status: 200 +} + +export type importsRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type importsRetrieveResponseComposite = importsRetrieveResponse200 | importsRetrieveResponse401 + +export type importsRetrieveResponse = importsRetrieveResponseComposite & { + headers: Headers +} + +export const getImportsRetrieveUrl = (uidImport: string) => { + return `/api/v2/imports/${uidImport}/` +} + +export const importsRetrieve = async (uidImport: string, options?: RequestInit): Promise => { + return fetchWithAuth(getImportsRetrieveUrl(uidImport), { + ...options, + method: 'GET', + }) +} + +export const getImportsRetrieveQueryKey = (uidImport: string) => { + return ['api', 'v2', 'imports', uidImport] as const +} + +export const getImportsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidImport: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getImportsRetrieveQueryKey(uidImport) + + const queryFn: QueryFunction>> = ({ signal }) => + importsRetrieve(uidImport, { signal, ...requestOptions }) + + return { queryKey, queryFn, enabled: !!uidImport, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type ImportsRetrieveQueryResult = NonNullable>> +export type ImportsRetrieveQueryError = ErrorDetail + +export function useImportsRetrieve>, TError = ErrorDetail>( + uidImport: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getImportsRetrieveQueryOptions(uidImport, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## List of invites + +Invites sent or received by current user about transferring project ownership. + +List can be filtered with `mode` parameter, e.g.: display only received invites. + +Possible values for `mode`: +- `sender` +- `recipient` + + + */ +export type projectOwnershipInvitesListResponse200 = { + data: PaginatedProjectInviteResponseList + status: 200 +} + +export type projectOwnershipInvitesListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectOwnershipInvitesListResponseComposite = + | projectOwnershipInvitesListResponse200 + | projectOwnershipInvitesListResponse403 + +export type projectOwnershipInvitesListResponse = projectOwnershipInvitesListResponseComposite & { + headers: Headers +} + +export const getProjectOwnershipInvitesListUrl = (params?: ProjectOwnershipInvitesListParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 + ? `/api/v2/project-ownership/invites/?${stringifiedParams}` + : `/api/v2/project-ownership/invites/` +} + +export const projectOwnershipInvitesList = async ( + params?: ProjectOwnershipInvitesListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectOwnershipInvitesListUrl(params), { + ...options, + method: 'GET', + }) +} + +export const getProjectOwnershipInvitesListQueryKey = (params?: ProjectOwnershipInvitesListParams) => { + return ['api', 'v2', 'project-ownership', 'invites', ...(params ? [params] : [])] as const +} + +export const getProjectOwnershipInvitesListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: ProjectOwnershipInvitesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesListQueryKey(params) + + const queryFn: QueryFunction>> = ({ signal }) => + projectOwnershipInvitesList(params, { signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type ProjectOwnershipInvitesListQueryResult = NonNullable< + Awaited> +> +export type ProjectOwnershipInvitesListQueryError = ErrorDetail + +export function useProjectOwnershipInvitesList< + TData = Awaited>, + TError = ErrorDetail, +>( + params?: ProjectOwnershipInvitesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectOwnershipInvitesListQueryOptions(params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Create (send) an invite + +Where the assets `uid` are given in the payload's list + + + + */ +export type projectOwnershipInvitesCreateResponse201 = { + data: ProjectInviteResponse + status: 201 +} + +export type projectOwnershipInvitesCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type projectOwnershipInvitesCreateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectOwnershipInvitesCreateResponseComposite = + | projectOwnershipInvitesCreateResponse201 + | projectOwnershipInvitesCreateResponse400 + | projectOwnershipInvitesCreateResponse403 + +export type projectOwnershipInvitesCreateResponse = projectOwnershipInvitesCreateResponseComposite & { + headers: Headers +} + +export const getProjectOwnershipInvitesCreateUrl = () => { + return `/api/v2/project-ownership/invites/` +} + +export const projectOwnershipInvitesCreate = async ( + projectInviteCreatePayload: ProjectInviteCreatePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectOwnershipInvitesCreateUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(projectInviteCreatePayload), + }) +} + +export const getProjectOwnershipInvitesCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProjectInviteCreatePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ProjectInviteCreatePayload }, + TContext +> => { + const mutationKey = ['projectOwnershipInvitesCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ProjectInviteCreatePayload } + > = (props) => { + const { data } = props ?? {} + + return projectOwnershipInvitesCreate(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ProjectOwnershipInvitesCreateMutationResult = NonNullable< + Awaited> +> +export type ProjectOwnershipInvitesCreateMutationBody = ProjectInviteCreatePayload +export type ProjectOwnershipInvitesCreateMutationError = ErrorObject | ErrorDetail + +export const useProjectOwnershipInvitesCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProjectInviteCreatePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getProjectOwnershipInvitesCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## Invite detail + +It can be useful to monitor the invite status while the transfer is being processed + + */ +export type projectOwnershipInvitesRetrieveResponse200 = { + data: ProjectInviteResponse + status: 200 +} + +export type projectOwnershipInvitesRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectOwnershipInvitesRetrieveResponseComposite = + | projectOwnershipInvitesRetrieveResponse200 + | projectOwnershipInvitesRetrieveResponse403 + +export type projectOwnershipInvitesRetrieveResponse = projectOwnershipInvitesRetrieveResponseComposite & { + headers: Headers +} + +export const getProjectOwnershipInvitesRetrieveUrl = (uidInvite: string) => { + return `/api/v2/project-ownership/invites/${uidInvite}/` +} + +export const projectOwnershipInvitesRetrieve = async ( + uidInvite: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectOwnershipInvitesRetrieveUrl(uidInvite), { + ...options, + method: 'GET', + }) +} + +export const getProjectOwnershipInvitesRetrieveQueryKey = (uidInvite: string) => { + return ['api', 'v2', 'project-ownership', 'invites', uidInvite] as const +} + +export const getProjectOwnershipInvitesRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidInvite: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesRetrieveQueryKey(uidInvite) + + const queryFn: QueryFunction>> = ({ signal }) => + projectOwnershipInvitesRetrieve(uidInvite, { signal, ...requestOptions }) + + return { queryKey, queryFn, enabled: !!uidInvite, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type ProjectOwnershipInvitesRetrieveQueryResult = NonNullable< + Awaited> +> +export type ProjectOwnershipInvitesRetrieveQueryError = ErrorDetail + +export function useProjectOwnershipInvitesRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidInvite: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectOwnershipInvitesRetrieveQueryOptions(uidInvite, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Update an invite status + +Update the status of an invite. +Status accepted: +- `cancelled` +- `accepted` +- `declined` + +**Notes**: +- _When submitting `accepted` the invite status becomes automatically `in_progress`_ +- _Only the sender can cancel an invite, and **if only if** the invite is still pending._ +- _Only the recipient can accept or decline, **if and only if** the invite is still pending._ + + + */ +export type projectOwnershipInvitesPartialUpdateResponse200 = { + data: ProjectInviteResponse + status: 200 +} + +export type projectOwnershipInvitesPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type projectOwnershipInvitesPartialUpdateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectOwnershipInvitesPartialUpdateResponseComposite = + | projectOwnershipInvitesPartialUpdateResponse200 + | projectOwnershipInvitesPartialUpdateResponse400 + | projectOwnershipInvitesPartialUpdateResponse403 + +export type projectOwnershipInvitesPartialUpdateResponse = projectOwnershipInvitesPartialUpdateResponseComposite & { + headers: Headers +} + +export const getProjectOwnershipInvitesPartialUpdateUrl = (uidInvite: string) => { + return `/api/v2/project-ownership/invites/${uidInvite}/` +} + +export const projectOwnershipInvitesPartialUpdate = async ( + uidInvite: string, + patchedInviteUpdatePayload: PatchedInviteUpdatePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getProjectOwnershipInvitesPartialUpdateUrl(uidInvite), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedInviteUpdatePayload), + }, + ) +} + +export const getProjectOwnershipInvitesPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidInvite: string; data: PatchedInviteUpdatePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidInvite: string; data: PatchedInviteUpdatePayload }, + TContext +> => { + const mutationKey = ['projectOwnershipInvitesPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidInvite: string; data: PatchedInviteUpdatePayload } + > = (props) => { + const { uidInvite, data } = props ?? {} + + return projectOwnershipInvitesPartialUpdate(uidInvite, data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ProjectOwnershipInvitesPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type ProjectOwnershipInvitesPartialUpdateMutationBody = PatchedInviteUpdatePayload +export type ProjectOwnershipInvitesPartialUpdateMutationError = ErrorObject | ErrorDetail + +export const useProjectOwnershipInvitesPartialUpdate = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidInvite: string; data: PatchedInviteUpdatePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getProjectOwnershipInvitesPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## Delete invite + + */ +export type projectOwnershipInvitesDestroyResponse204 = { + data: void + status: 204 +} + +export type projectOwnershipInvitesDestroyResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectOwnershipInvitesDestroyResponseComposite = + | projectOwnershipInvitesDestroyResponse204 + | projectOwnershipInvitesDestroyResponse403 + +export type projectOwnershipInvitesDestroyResponse = projectOwnershipInvitesDestroyResponseComposite & { + headers: Headers +} + +export const getProjectOwnershipInvitesDestroyUrl = (uidInvite: string) => { + return `/api/v2/project-ownership/invites/${uidInvite}/` +} + +export const projectOwnershipInvitesDestroy = async ( + uidInvite: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectOwnershipInvitesDestroyUrl(uidInvite), { + ...options, + method: 'DELETE', + }) +} + +export const getProjectOwnershipInvitesDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidInvite: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidInvite: string }, + TContext +> => { + const mutationKey = ['projectOwnershipInvitesDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidInvite: string } + > = (props) => { + const { uidInvite } = props ?? {} + + return projectOwnershipInvitesDestroy(uidInvite, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ProjectOwnershipInvitesDestroyMutationResult = NonNullable< + Awaited> +> + +export type ProjectOwnershipInvitesDestroyMutationError = ErrorDetail + +export const useProjectOwnershipInvitesDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidInvite: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getProjectOwnershipInvitesDestroyMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## Retrieve transfer details + + */ +export type projectOwnershipInvitesTransfersRetrieveResponse200 = { + data: TransferListResponse + status: 200 +} + +export type projectOwnershipInvitesTransfersRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type projectOwnershipInvitesTransfersRetrieveResponseComposite = + | projectOwnershipInvitesTransfersRetrieveResponse200 + | projectOwnershipInvitesTransfersRetrieveResponse401 + +export type projectOwnershipInvitesTransfersRetrieveResponse = + projectOwnershipInvitesTransfersRetrieveResponseComposite & { + headers: Headers + } + +export const getProjectOwnershipInvitesTransfersRetrieveUrl = (uidInvite: string, uidTransfer: string) => { + return `/api/v2/project-ownership/invites/${uidInvite}/transfers/${uidTransfer}/` +} + +export const projectOwnershipInvitesTransfersRetrieve = async ( + uidInvite: string, + uidTransfer: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getProjectOwnershipInvitesTransfersRetrieveUrl(uidInvite, uidTransfer), + { + ...options, + method: 'GET', + }, + ) +} + +export const getProjectOwnershipInvitesTransfersRetrieveQueryKey = (uidInvite: string, uidTransfer: string) => { + return ['api', 'v2', 'project-ownership', 'invites', uidInvite, 'transfers', uidTransfer] as const +} + +export const getProjectOwnershipInvitesTransfersRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidInvite: string, + uidTransfer: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesTransfersRetrieveQueryKey(uidInvite, uidTransfer) + + const queryFn: QueryFunction>> = ({ signal }) => + projectOwnershipInvitesTransfersRetrieve(uidInvite, uidTransfer, { signal, ...requestOptions }) + + return { queryKey, queryFn, enabled: !!(uidInvite && uidTransfer), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type ProjectOwnershipInvitesTransfersRetrieveQueryResult = NonNullable< + Awaited> +> +export type ProjectOwnershipInvitesTransfersRetrieveQueryError = ErrorDetail + +export function useProjectOwnershipInvitesTransfersRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidInvite: string, + uidTransfer: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectOwnershipInvitesTransfersRetrieveQueryOptions(uidInvite, uidTransfer, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## List current user's assets' tags + + */ +export type tagsListResponse200 = { + data: PaginatedTagListResponseList + status: 200 +} + +export type tagsListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type tagsListResponseComposite = tagsListResponse200 | tagsListResponse401 + +export type tagsListResponse = tagsListResponseComposite & { + headers: Headers +} + +export const getTagsListUrl = (params?: TagsListParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 ? `/api/v2/tags/?${stringifiedParams}` : `/api/v2/tags/` +} + +export const tagsList = async (params?: TagsListParams, options?: RequestInit): Promise => { + return fetchWithAuth(getTagsListUrl(params), { + ...options, + method: 'GET', + }) +} + +export const getTagsListQueryKey = (params?: TagsListParams) => { + return ['api', 'v2', 'tags', ...(params ? [params] : [])] as const +} + +export const getTagsListQueryOptions = >, TError = ErrorDetail>( + params?: TagsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getTagsListQueryKey(params) + + const queryFn: QueryFunction>> = ({ signal }) => + tagsList(params, { signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type TagsListQueryResult = NonNullable>> +export type TagsListQueryError = ErrorDetail + +export function useTagsList>, TError = ErrorDetail>( + params?: TagsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getTagsListQueryOptions(params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Retrieve a tag's data + + */ +export type tagsRetrieveResponse200 = { + data: TagRetrieveResponse + status: 200 +} + +export type tagsRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type tagsRetrieveResponseComposite = tagsRetrieveResponse200 | tagsRetrieveResponse401 + +export type tagsRetrieveResponse = tagsRetrieveResponseComposite & { + headers: Headers +} + +export const getTagsRetrieveUrl = (taguidUid: string) => { + return `/api/v2/tags/${taguidUid}/` +} + +export const tagsRetrieve = async (taguidUid: string, options?: RequestInit): Promise => { + return fetchWithAuth(getTagsRetrieveUrl(taguidUid), { + ...options, + method: 'GET', + }) +} + +export const getTagsRetrieveQueryKey = (taguidUid: string) => { + return ['api', 'v2', 'tags', taguidUid] as const +} + +export const getTagsRetrieveQueryOptions = >, TError = ErrorDetail>( + taguidUid: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getTagsRetrieveQueryKey(taguidUid) + + const queryFn: QueryFunction>> = ({ signal }) => + tagsRetrieve(taguidUid, { signal, ...requestOptions }) + + return { queryKey, queryFn, enabled: !!taguidUid, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type TagsRetrieveQueryResult = NonNullable>> +export type TagsRetrieveQueryError = ErrorDetail + +export function useTagsRetrieve>, TError = ErrorDetail>( + taguidUid: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getTagsRetrieveQueryOptions(taguidUid, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} diff --git a/jsapp/js/api/react-query/other/other.msw.ts b/jsapp/js/api/react-query/other/other.msw.ts new file mode 100644 index 0000000000..073484048d --- /dev/null +++ b/jsapp/js/api/react-query/other/other.msw.ts @@ -0,0 +1,1051 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import { BlankEnum } from '../../models/blankEnum' + +import type { ChangePlan } from '../../models/changePlan' + +import type { CheckoutLink } from '../../models/checkoutLink' + +import { CollectionMethodEnum } from '../../models/collectionMethodEnum' + +import type { CustomerPortalPostResponse } from '../../models/customerPortalPostResponse' + +import type { Language } from '../../models/language' + +import type { OneTimeAddOn } from '../../models/oneTimeAddOn' + +import type { PaginatedLanguageListList } from '../../models/paginatedLanguageListList' + +import type { PaginatedOneTimeAddOnList } from '../../models/paginatedOneTimeAddOnList' + +import type { PaginatedPermissionResponseList } from '../../models/paginatedPermissionResponseList' + +import type { PaginatedProductList } from '../../models/paginatedProductList' + +import type { PaginatedSubscriptionList } from '../../models/paginatedSubscriptionList' + +import type { PaginatedTranscriptionServiceList } from '../../models/paginatedTranscriptionServiceList' + +import type { PaginatedTranslationServiceList } from '../../models/paginatedTranslationServiceList' + +import type { PermissionResponse } from '../../models/permissionResponse' + +import { ProrationBehaviorEnum } from '../../models/prorationBehaviorEnum' + +import { StripeIntervalEnum } from '../../models/stripeIntervalEnum' + +import { StripePriceType } from '../../models/stripePriceType' + +import { StripeProductType } from '../../models/stripeProductType' + +import { StripeUsageType } from '../../models/stripeUsageType' + +import type { Subscription } from '../../models/subscription' + +import { SubscriptionScheduleStatusEnum } from '../../models/subscriptionScheduleStatusEnum' + +import { SubscriptionStatusEnum } from '../../models/subscriptionStatusEnum' + +import type { TermsOfServiceResponse } from '../../models/termsOfServiceResponse' + +import type { TranscriptionService } from '../../models/transcriptionService' + +import type { TranslationService } from '../../models/translationService' + +export const getApiV2LanguagesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedLanguageListList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + transcription_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + translation_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + url: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2LanguagesRetrieveResponseMock = (overrideResponse: Partial = {}): Language => ({ + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + transcription_services: { + [faker.string.alphanumeric(5)]: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + translation_services: { + [faker.string.alphanumeric(5)]: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + regions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + })), + ...overrideResponse, +}) + +export const getApiV2PermissionsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedPermissionResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + codename: faker.string.alpha({ length: { min: 10, max: 20 } }), + implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2PermissionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PermissionResponse => ({ + url: faker.internet.url(), + codename: faker.string.alpha({ length: { min: 10, max: 20 } }), + implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2StripeAddonsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedOneTimeAddOnList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 27 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_available: faker.datatype.boolean(), + usage_limits: faker.helpers.arrayElement([{}, undefined]), + total_usage_limits: { + [faker.string.alphanumeric(5)]: {}, + }, + limits_remaining: faker.helpers.arrayElement([{}, undefined]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + product: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2StripeAddonsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OneTimeAddOn => ({ + id: faker.string.alpha({ length: { min: 10, max: 27 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_available: faker.datatype.boolean(), + usage_limits: faker.helpers.arrayElement([{}, undefined]), + total_usage_limits: { + [faker.string.alphanumeric(5)]: {}, + }, + limits_remaining: faker.helpers.arrayElement([{}, undefined]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + product: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2StripeChangePlanRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ChangePlan => ({ + price_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + subscription_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: 1, max: undefined, multipleOf: undefined }), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2StripeCheckoutLinkCreateResponseMock = ( + overrideResponse: Partial = {}, +): CheckoutLink => ({ + price_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + organization_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: 1, max: undefined, multipleOf: undefined }), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2StripeCustomerPortalCreateResponseMock = ( + overrideResponse: Partial = {}, +): CustomerPortalPostResponse => ({ url: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2StripeProductsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProductList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + name: faker.string.alpha({ length: { min: 10, max: 5000 } }), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + type: faker.helpers.arrayElement(Object.values(StripeProductType)), + prices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), + currency: faker.string.alpha({ length: { min: 10, max: 3 } }), + type: faker.helpers.arrayElement(Object.values(StripePriceType)), + recurring: { + ...{ + interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), + interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + meter: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), + }, + }, + unit_amount: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), + null, + ]), + undefined, + ]), + human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.datatype.boolean(), + product: faker.string.alpha({ length: { min: 10, max: 20 } }), + transform_quantity: faker.helpers.arrayElement([{}, undefined]), + })), + metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + })), + ...overrideResponse, +}) + +export const getApiV2StripeSubscriptionsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedSubscriptionList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + price: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), + currency: faker.string.alpha({ length: { min: 10, max: 3 } }), + type: faker.helpers.arrayElement(Object.values(StripePriceType)), + recurring: { + ...{ + interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), + interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + meter: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), + }, + }, + unit_amount: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), + null, + ]), + undefined, + ]), + human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.datatype.boolean(), + product: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + name: faker.string.alpha({ length: { min: 10, max: 5000 } }), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + type: faker.helpers.arrayElement(Object.values(StripeProductType)), + metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + transform_quantity: faker.helpers.arrayElement([{}, undefined]), + }, + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + })), + schedule: { + phases: { + [faker.string.alphanumeric(5)]: {}, + }, + status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum)), + }, + application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?d{0,3}(?:.d{0,2})?$'), null]), + djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + stripe_data: faker.helpers.arrayElement([{}, undefined]), + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + created: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + metadata: faker.helpers.arrayElement([{}, undefined]), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + billing_cycle_anchor: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + billing_thresholds: faker.helpers.arrayElement([{}, undefined]), + cancel_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + canceled_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + days_until_due: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), + null, + ]), + undefined, + ]), + discount: faker.helpers.arrayElement([{}, undefined]), + ended_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + next_pending_invoice_item_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + pause_collection: faker.helpers.arrayElement([{}, undefined]), + pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), + pending_update: faker.helpers.arrayElement([{}, undefined]), + proration_behavior: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)), + faker.helpers.arrayElement(Object.values(BlankEnum)), + ]), + undefined, + ]), + proration_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), + null, + ]), + undefined, + ]), + start_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), + trial_end: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + trial_start: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + djstripe_owner_account: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + customer: faker.string.alpha({ length: { min: 10, max: 20 } }), + default_payment_method: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + default_source: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + latest_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_setup_intent: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + plan: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), null]), + undefined, + ]), + default_tax_rates: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2StripeSubscriptionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): Subscription => ({ + items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + price: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), + currency: faker.string.alpha({ length: { min: 10, max: 3 } }), + type: faker.helpers.arrayElement(Object.values(StripePriceType)), + recurring: { + ...{ + interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), + interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + meter: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), + }, + }, + unit_amount: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), + null, + ]), + undefined, + ]), + human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.datatype.boolean(), + product: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + name: faker.string.alpha({ length: { min: 10, max: 5000 } }), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + type: faker.helpers.arrayElement(Object.values(StripeProductType)), + metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + transform_quantity: faker.helpers.arrayElement([{}, undefined]), + }, + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + })), + schedule: { + phases: { + [faker.string.alphanumeric(5)]: {}, + }, + status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum)), + }, + application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?d{0,3}(?:.d{0,2})?$'), null]), + djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + stripe_data: faker.helpers.arrayElement([{}, undefined]), + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + created: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + metadata: faker.helpers.arrayElement([{}, undefined]), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + billing_cycle_anchor: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + billing_thresholds: faker.helpers.arrayElement([{}, undefined]), + cancel_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + canceled_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + days_until_due: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + discount: faker.helpers.arrayElement([{}, undefined]), + ended_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + next_pending_invoice_item_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + pause_collection: faker.helpers.arrayElement([{}, undefined]), + pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), + pending_update: faker.helpers.arrayElement([{}, undefined]), + proration_behavior: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)), + faker.helpers.arrayElement(Object.values(BlankEnum)), + ]), + undefined, + ]), + proration_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + start_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), + trial_end: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + trial_start: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + djstripe_owner_account: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + customer: faker.string.alpha({ length: { min: 10, max: 20 } }), + default_payment_method: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + default_source: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + latest_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_setup_intent: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + plan: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), null]), + undefined, + ]), + default_tax_rates: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2TermsOfServiceListResponseMock = (): TermsOfServiceResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + slug: faker.string.alpha({ length: { min: 10, max: 20 } }), + body: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2TermsOfServiceRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TermsOfServiceResponse => ({ + url: faker.internet.url(), + slug: faker.string.alpha({ length: { min: 10, max: 20 } }), + body: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2TranscriptionServicesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedTranscriptionServiceList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + })), + ...overrideResponse, +}) + +export const getApiV2TranscriptionServicesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TranscriptionService => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + ...overrideResponse, +}) + +export const getApiV2TranslationServicesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedTranslationServiceList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + })), + ...overrideResponse, +}) + +export const getApiV2TranslationServicesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TranslationService => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + ...overrideResponse, +}) + +export const getApiV2LanguagesListMockHandler = ( + overrideResponse?: + | PaginatedLanguageListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedLanguageListList), +) => { + return http.get('*/api/v2/languages/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2LanguagesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2LanguagesRetrieveMockHandler = ( + overrideResponse?: Language | ((info: Parameters[1]>[0]) => Promise | Language), +) => { + return http.get('*/api/v2/languages/:code/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2LanguagesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2PermissionsListMockHandler = ( + overrideResponse?: + | PaginatedPermissionResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedPermissionResponseList), +) => { + return http.get('*/api/v2/permissions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2PermissionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2PermissionsRetrieveMockHandler = ( + overrideResponse?: + | PermissionResponse + | ((info: Parameters[1]>[0]) => Promise | PermissionResponse), +) => { + return http.get('*/api/v2/permissions/:codename/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2PermissionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeAddonsListMockHandler = ( + overrideResponse?: + | PaginatedOneTimeAddOnList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedOneTimeAddOnList), +) => { + return http.get('*/api/v2/stripe/addons/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeAddonsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeAddonsRetrieveMockHandler = ( + overrideResponse?: + | OneTimeAddOn + | ((info: Parameters[1]>[0]) => Promise | OneTimeAddOn), +) => { + return http.get('*/api/v2/stripe/addons/:id/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeAddonsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeChangePlanRetrieveMockHandler = ( + overrideResponse?: + | ChangePlan + | ((info: Parameters[1]>[0]) => Promise | ChangePlan), +) => { + return http.get('*/api/v2/stripe/change-plan', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeChangePlanRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeCheckoutLinkCreateMockHandler = ( + overrideResponse?: + | CheckoutLink + | ((info: Parameters[1]>[0]) => Promise | CheckoutLink), +) => { + return http.post('*/api/v2/stripe/checkout-link', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeCheckoutLinkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeCustomerPortalCreateMockHandler = ( + overrideResponse?: + | CustomerPortalPostResponse + | (( + info: Parameters[1]>[0], + ) => Promise | CustomerPortalPostResponse), +) => { + return http.post('*/api/v2/stripe/customer-portal', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeCustomerPortalCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeProductsListMockHandler = ( + overrideResponse?: + | PaginatedProductList + | ((info: Parameters[1]>[0]) => Promise | PaginatedProductList), +) => { + return http.get('*/api/v2/stripe/products/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeProductsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeSubscriptionsListMockHandler = ( + overrideResponse?: + | PaginatedSubscriptionList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedSubscriptionList), +) => { + return http.get('*/api/v2/stripe/subscriptions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeSubscriptionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2StripeSubscriptionsRetrieveMockHandler = ( + overrideResponse?: + | Subscription + | ((info: Parameters[1]>[0]) => Promise | Subscription), +) => { + return http.get('*/api/v2/stripe/subscriptions/:id/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeSubscriptionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TermsOfServiceListMockHandler = ( + overrideResponse?: + | TermsOfServiceResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | TermsOfServiceResponse[]), +) => { + return http.get('*/api/v2/terms-of-service/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TermsOfServiceListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TermsOfServiceRetrieveMockHandler = ( + overrideResponse?: + | TermsOfServiceResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TermsOfServiceResponse), +) => { + return http.get('*/api/v2/terms-of-service/:slug/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TermsOfServiceRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TranscriptionServicesListMockHandler = ( + overrideResponse?: + | PaginatedTranscriptionServiceList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedTranscriptionServiceList), +) => { + return http.get('*/api/v2/transcription-services/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranscriptionServicesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TranscriptionServicesRetrieveMockHandler = ( + overrideResponse?: + | TranscriptionService + | ((info: Parameters[1]>[0]) => Promise | TranscriptionService), +) => { + return http.get('*/api/v2/transcription-services/:code/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranscriptionServicesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TranslationServicesListMockHandler = ( + overrideResponse?: + | PaginatedTranslationServiceList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedTranslationServiceList), +) => { + return http.get('*/api/v2/translation-services/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranslationServicesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2TranslationServicesRetrieveMockHandler = ( + overrideResponse?: + | TranslationService + | ((info: Parameters[1]>[0]) => Promise | TranslationService), +) => { + return http.get('*/api/v2/translation-services/:code/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranslationServicesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getOtherMock = () => [ + getApiV2LanguagesListMockHandler(), + getApiV2LanguagesRetrieveMockHandler(), + getApiV2PermissionsListMockHandler(), + getApiV2PermissionsRetrieveMockHandler(), + getApiV2StripeAddonsListMockHandler(), + getApiV2StripeAddonsRetrieveMockHandler(), + getApiV2StripeChangePlanRetrieveMockHandler(), + getApiV2StripeCheckoutLinkCreateMockHandler(), + getApiV2StripeCustomerPortalCreateMockHandler(), + getApiV2StripeProductsListMockHandler(), + getApiV2StripeSubscriptionsListMockHandler(), + getApiV2StripeSubscriptionsRetrieveMockHandler(), + getApiV2TermsOfServiceListMockHandler(), + getApiV2TermsOfServiceRetrieveMockHandler(), + getApiV2TranscriptionServicesListMockHandler(), + getApiV2TranscriptionServicesRetrieveMockHandler(), + getApiV2TranslationServicesListMockHandler(), + getApiV2TranslationServicesRetrieveMockHandler(), +] diff --git a/jsapp/js/api/react-query/other.ts b/jsapp/js/api/react-query/other/other.ts similarity index 55% rename from jsapp/js/api/react-query/other.ts rename to jsapp/js/api/react-query/other/other.ts index 933c2a5802..90e69d0c30 100644 --- a/jsapp/js/api/react-query/other.ts +++ b/jsapp/js/api/react-query/other/other.ts @@ -19,83 +19,61 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { CustomerPortal } from '../models/customerPortal' +import type { ChangePlan } from '../../models/changePlan' -import type { ErrorDetail } from '../models/errorDetail' +import type { CheckoutLink } from '../../models/checkoutLink' -import type { ErrorObject } from '../models/errorObject' +import type { CustomerPortal } from '../../models/customerPortal' -import type { LanguagesListParams } from '../models/languagesListParams' +import type { CustomerPortalPostResponse } from '../../models/customerPortalPostResponse' -import type { PermissionsListParams } from '../models/permissionsListParams' +import type { ErrorDetail } from '../../models/errorDetail' -import type { StripeAddonsListParams } from '../models/stripeAddonsListParams' +import type { ErrorObject } from '../../models/errorObject' -import type { StripeProductsListParams } from '../models/stripeProductsListParams' +import type { Language } from '../../models/language' -import type { StripeSubscriptionsListParams } from '../models/stripeSubscriptionsListParams' +import type { LanguagesListParams } from '../../models/languagesListParams' -import type { TranscriptionServicesListParams } from '../models/transcriptionServicesListParams' +import type { OneTimeAddOn } from '../../models/oneTimeAddOn' -import type { TranslationServicesListParams } from '../models/translationServicesListParams' +import type { PaginatedLanguageListList } from '../../models/paginatedLanguageListList' -import { faker } from '@faker-js/faker' +import type { PaginatedOneTimeAddOnList } from '../../models/paginatedOneTimeAddOnList' -import { http, HttpResponse } from 'msw' +import type { PaginatedPermissionResponseList } from '../../models/paginatedPermissionResponseList' -import { BlankEnum } from '../models/blankEnum' +import type { PaginatedProductList } from '../../models/paginatedProductList' -import type { ChangePlan } from '../models/changePlan' +import type { PaginatedSubscriptionList } from '../../models/paginatedSubscriptionList' -import type { CheckoutLink } from '../models/checkoutLink' +import type { PaginatedTranscriptionServiceList } from '../../models/paginatedTranscriptionServiceList' -import { CollectionMethodEnum } from '../models/collectionMethodEnum' +import type { PaginatedTranslationServiceList } from '../../models/paginatedTranslationServiceList' -import type { CustomerPortalPostResponse } from '../models/customerPortalPostResponse' +import type { PermissionResponse } from '../../models/permissionResponse' -import type { Language } from '../models/language' +import type { PermissionsListParams } from '../../models/permissionsListParams' -import type { OneTimeAddOn } from '../models/oneTimeAddOn' +import type { StripeAddonsListParams } from '../../models/stripeAddonsListParams' -import type { PaginatedLanguageListList } from '../models/paginatedLanguageListList' +import type { StripeProductsListParams } from '../../models/stripeProductsListParams' -import type { PaginatedOneTimeAddOnList } from '../models/paginatedOneTimeAddOnList' +import type { StripeSubscriptionsListParams } from '../../models/stripeSubscriptionsListParams' -import type { PaginatedPermissionResponseList } from '../models/paginatedPermissionResponseList' +import type { Subscription } from '../../models/subscription' -import type { PaginatedProductList } from '../models/paginatedProductList' +import type { TermsOfServiceResponse } from '../../models/termsOfServiceResponse' -import type { PaginatedSubscriptionList } from '../models/paginatedSubscriptionList' +import type { TranscriptionService } from '../../models/transcriptionService' -import type { PaginatedTranscriptionServiceList } from '../models/paginatedTranscriptionServiceList' +import type { TranscriptionServicesListParams } from '../../models/transcriptionServicesListParams' -import type { PaginatedTranslationServiceList } from '../models/paginatedTranslationServiceList' +import type { TranslationService } from '../../models/translationService' -import type { PermissionResponse } from '../models/permissionResponse' +import type { TranslationServicesListParams } from '../../models/translationServicesListParams' -import { ProrationBehaviorEnum } from '../models/prorationBehaviorEnum' - -import { StripeIntervalEnum } from '../models/stripeIntervalEnum' - -import { StripePriceType } from '../models/stripePriceType' - -import { StripeProductType } from '../models/stripeProductType' - -import { StripeUsageType } from '../models/stripeUsageType' - -import type { Subscription } from '../models/subscription' - -import { SubscriptionScheduleStatusEnum } from '../models/subscriptionScheduleStatusEnum' - -import { SubscriptionStatusEnum } from '../models/subscriptionStatusEnum' - -import type { TermsOfServiceResponse } from '../models/termsOfServiceResponse' - -import type { TranscriptionService } from '../models/transcriptionService' - -import type { TranslationService } from '../models/translationService' - -import { fetchWithAuth } from '../orval.mutator' +import { fetchWithAuth } from '../../orval.mutator' type SecondParameter unknown> = Parameters[1] @@ -1731,988 +1709,3 @@ export function useTranslationServicesRetrieve< return query } - -export const getApiV2LanguagesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedLanguageListList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - transcription_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - translation_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - url: faker.internet.url(), - })), - ...overrideResponse, -}) - -export const getApiV2LanguagesRetrieveResponseMock = (overrideResponse: Partial = {}): Language => ({ - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - transcription_services: { - [faker.string.alphanumeric(5)]: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - translation_services: { - [faker.string.alphanumeric(5)]: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - regions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - })), - ...overrideResponse, -}) - -export const getApiV2PermissionsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedPermissionResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - codename: faker.string.alpha({ length: { min: 10, max: 20 } }), - implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.internet.url(), - ), - contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.internet.url(), - ), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2PermissionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PermissionResponse => ({ - url: faker.internet.url(), - codename: faker.string.alpha({ length: { min: 10, max: 20 } }), - implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.internet.url(), - ), - contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.internet.url(), - ), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2StripeAddonsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedOneTimeAddOnList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 27 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_available: faker.datatype.boolean(), - usage_limits: faker.helpers.arrayElement([{}, undefined]), - total_usage_limits: { - [faker.string.alphanumeric(5)]: {}, - }, - limits_remaining: faker.helpers.arrayElement([{}, undefined]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - product: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2StripeAddonsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): OneTimeAddOn => ({ - id: faker.string.alpha({ length: { min: 10, max: 27 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_available: faker.datatype.boolean(), - usage_limits: faker.helpers.arrayElement([{}, undefined]), - total_usage_limits: { - [faker.string.alphanumeric(5)]: {}, - }, - limits_remaining: faker.helpers.arrayElement([{}, undefined]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - product: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2StripeChangePlanRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ChangePlan => ({ - price_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - subscription_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - quantity: faker.helpers.arrayElement([ - faker.number.int({ min: 1, max: undefined, multipleOf: undefined }), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2StripeCheckoutLinkCreateResponseMock = ( - overrideResponse: Partial = {}, -): CheckoutLink => ({ - price_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - organization_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - quantity: faker.helpers.arrayElement([ - faker.number.int({ min: 1, max: undefined, multipleOf: undefined }), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2StripeCustomerPortalCreateResponseMock = ( - overrideResponse: Partial = {}, -): CustomerPortalPostResponse => ({ url: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2StripeProductsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedProductList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - name: faker.string.alpha({ length: { min: 10, max: 5000 } }), - description: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - type: faker.helpers.arrayElement(Object.values(StripeProductType)), - prices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), - currency: faker.string.alpha({ length: { min: 10, max: 3 } }), - type: faker.helpers.arrayElement(Object.values(StripePriceType)), - recurring: { - ...{ - interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), - interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - meter: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), - }, - }, - unit_amount: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), - null, - ]), - undefined, - ]), - human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: faker.helpers.arrayElement([{}, undefined]), - active: faker.datatype.boolean(), - product: faker.string.alpha({ length: { min: 10, max: 20 } }), - transform_quantity: faker.helpers.arrayElement([{}, undefined]), - })), - metadata: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - })), - ...overrideResponse, -}) - -export const getApiV2StripeSubscriptionsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedSubscriptionList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - price: { - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), - currency: faker.string.alpha({ length: { min: 10, max: 3 } }), - type: faker.helpers.arrayElement(Object.values(StripePriceType)), - recurring: { - ...{ - interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), - interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - meter: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), - }, - }, - unit_amount: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), - null, - ]), - undefined, - ]), - human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: faker.helpers.arrayElement([{}, undefined]), - active: faker.datatype.boolean(), - product: { - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - name: faker.string.alpha({ length: { min: 10, max: 5000 } }), - description: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - type: faker.helpers.arrayElement(Object.values(StripeProductType)), - metadata: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - transform_quantity: faker.helpers.arrayElement([{}, undefined]), - }, - quantity: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: 0, max: 2147483647, multipleOf: undefined }), null]), - undefined, - ]), - })), - schedule: { - phases: { - [faker.string.alphanumeric(5)]: {}, - }, - status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum)), - }, - application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?d{0,3}(?:.d{0,2})?$'), null]), - djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, - stripe_data: faker.helpers.arrayElement([{}, undefined]), - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - created: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - metadata: faker.helpers.arrayElement([{}, undefined]), - description: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - billing_cycle_anchor: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - billing_thresholds: faker.helpers.arrayElement([{}, undefined]), - cancel_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - canceled_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), - current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, - current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, - days_until_due: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), - null, - ]), - undefined, - ]), - discount: faker.helpers.arrayElement([{}, undefined]), - ended_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - next_pending_invoice_item_invoice: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - pause_collection: faker.helpers.arrayElement([{}, undefined]), - pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), - pending_update: faker.helpers.arrayElement([{}, undefined]), - proration_behavior: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)), - faker.helpers.arrayElement(Object.values(BlankEnum)), - ]), - undefined, - ]), - proration_date: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - quantity: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), - null, - ]), - undefined, - ]), - start_date: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), - trial_end: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - trial_start: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - djstripe_owner_account: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - customer: faker.string.alpha({ length: { min: 10, max: 20 } }), - default_payment_method: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - default_source: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - latest_invoice: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_setup_intent: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - plan: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), null]), - undefined, - ]), - default_tax_rates: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2StripeSubscriptionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): Subscription => ({ - items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - price: { - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), - currency: faker.string.alpha({ length: { min: 10, max: 3 } }), - type: faker.helpers.arrayElement(Object.values(StripePriceType)), - recurring: { - ...{ - interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), - interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - meter: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), - }, - }, - unit_amount: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), - null, - ]), - undefined, - ]), - human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: faker.helpers.arrayElement([{}, undefined]), - active: faker.datatype.boolean(), - product: { - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - name: faker.string.alpha({ length: { min: 10, max: 5000 } }), - description: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - type: faker.helpers.arrayElement(Object.values(StripeProductType)), - metadata: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - transform_quantity: faker.helpers.arrayElement([{}, undefined]), - }, - quantity: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: 0, max: 2147483647, multipleOf: undefined }), null]), - undefined, - ]), - })), - schedule: { - phases: { - [faker.string.alphanumeric(5)]: {}, - }, - status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum)), - }, - application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?d{0,3}(?:.d{0,2})?$'), null]), - djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, - stripe_data: faker.helpers.arrayElement([{}, undefined]), - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - created: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - metadata: faker.helpers.arrayElement([{}, undefined]), - description: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - billing_cycle_anchor: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - billing_thresholds: faker.helpers.arrayElement([{}, undefined]), - cancel_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - canceled_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), - current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, - current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, - days_until_due: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), null]), - undefined, - ]), - discount: faker.helpers.arrayElement([{}, undefined]), - ended_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - next_pending_invoice_item_invoice: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - pause_collection: faker.helpers.arrayElement([{}, undefined]), - pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), - pending_update: faker.helpers.arrayElement([{}, undefined]), - proration_behavior: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)), - faker.helpers.arrayElement(Object.values(BlankEnum)), - ]), - undefined, - ]), - proration_date: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - quantity: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), null]), - undefined, - ]), - start_date: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), - trial_end: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - trial_start: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - djstripe_owner_account: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - customer: faker.string.alpha({ length: { min: 10, max: 20 } }), - default_payment_method: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - default_source: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - latest_invoice: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_setup_intent: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - plan: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), null]), - undefined, - ]), - default_tax_rates: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2TermsOfServiceListResponseMock = (): TermsOfServiceResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - slug: faker.string.alpha({ length: { min: 10, max: 20 } }), - body: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2TermsOfServiceRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): TermsOfServiceResponse => ({ - url: faker.internet.url(), - slug: faker.string.alpha({ length: { min: 10, max: 20 } }), - body: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2TranscriptionServicesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedTranscriptionServiceList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 100 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - })), - ...overrideResponse, -}) - -export const getApiV2TranscriptionServicesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): TranscriptionService => ({ - name: faker.string.alpha({ length: { min: 10, max: 100 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - ...overrideResponse, -}) - -export const getApiV2TranslationServicesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedTranslationServiceList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 100 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - })), - ...overrideResponse, -}) - -export const getApiV2TranslationServicesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): TranslationService => ({ - name: faker.string.alpha({ length: { min: 10, max: 100 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - ...overrideResponse, -}) - -export const getApiV2LanguagesListMockHandler = ( - overrideResponse?: - | PaginatedLanguageListList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedLanguageListList), -) => { - return http.get('*/api/v2/languages{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2LanguagesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2LanguagesRetrieveMockHandler = ( - overrideResponse?: Language | ((info: Parameters[1]>[0]) => Promise | Language), -) => { - return http.get('*/api/v2/languages/:code{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2LanguagesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2PermissionsListMockHandler = ( - overrideResponse?: - | PaginatedPermissionResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedPermissionResponseList), -) => { - return http.get('*/api/v2/permissions{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2PermissionsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2PermissionsRetrieveMockHandler = ( - overrideResponse?: - | PermissionResponse - | ((info: Parameters[1]>[0]) => Promise | PermissionResponse), -) => { - return http.get('*/api/v2/permissions/:codename{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2PermissionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeAddonsListMockHandler = ( - overrideResponse?: - | PaginatedOneTimeAddOnList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedOneTimeAddOnList), -) => { - return http.get('*/api/v2/stripe/addons{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeAddonsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeAddonsRetrieveMockHandler = ( - overrideResponse?: - | OneTimeAddOn - | ((info: Parameters[1]>[0]) => Promise | OneTimeAddOn), -) => { - return http.get('*/api/v2/stripe/addons/:id{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeAddonsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeChangePlanRetrieveMockHandler = ( - overrideResponse?: - | ChangePlan - | ((info: Parameters[1]>[0]) => Promise | ChangePlan), -) => { - return http.get('*/api/v2/stripe/change-plan', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeChangePlanRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeCheckoutLinkCreateMockHandler = ( - overrideResponse?: - | CheckoutLink - | ((info: Parameters[1]>[0]) => Promise | CheckoutLink), -) => { - return http.post('*/api/v2/stripe/checkout-link', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeCheckoutLinkCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeCustomerPortalCreateMockHandler = ( - overrideResponse?: - | CustomerPortalPostResponse - | (( - info: Parameters[1]>[0], - ) => Promise | CustomerPortalPostResponse), -) => { - return http.post('*/api/v2/stripe/customer-portal', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeCustomerPortalCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeProductsListMockHandler = ( - overrideResponse?: - | PaginatedProductList - | ((info: Parameters[1]>[0]) => Promise | PaginatedProductList), -) => { - return http.get('*/api/v2/stripe/products{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeProductsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeSubscriptionsListMockHandler = ( - overrideResponse?: - | PaginatedSubscriptionList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedSubscriptionList), -) => { - return http.get('*/api/v2/stripe/subscriptions{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeSubscriptionsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeSubscriptionsRetrieveMockHandler = ( - overrideResponse?: - | Subscription - | ((info: Parameters[1]>[0]) => Promise | Subscription), -) => { - return http.get('*/api/v2/stripe/subscriptions/:id{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeSubscriptionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TermsOfServiceListMockHandler = ( - overrideResponse?: - | TermsOfServiceResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | TermsOfServiceResponse[]), -) => { - return http.get('*/api/v2/terms-of-service{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TermsOfServiceListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TermsOfServiceRetrieveMockHandler = ( - overrideResponse?: - | TermsOfServiceResponse - | (( - info: Parameters[1]>[0], - ) => Promise | TermsOfServiceResponse), -) => { - return http.get('*/api/v2/terms-of-service/:slug{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TermsOfServiceRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TranscriptionServicesListMockHandler = ( - overrideResponse?: - | PaginatedTranscriptionServiceList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedTranscriptionServiceList), -) => { - return http.get('*/api/v2/transcription-services{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TranscriptionServicesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TranscriptionServicesRetrieveMockHandler = ( - overrideResponse?: - | TranscriptionService - | ((info: Parameters[1]>[0]) => Promise | TranscriptionService), -) => { - return http.get('*/api/v2/transcription-services/:code{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TranscriptionServicesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TranslationServicesListMockHandler = ( - overrideResponse?: - | PaginatedTranslationServiceList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedTranslationServiceList), -) => { - return http.get('*/api/v2/translation-services{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TranslationServicesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TranslationServicesRetrieveMockHandler = ( - overrideResponse?: - | TranslationService - | ((info: Parameters[1]>[0]) => Promise | TranslationService), -) => { - return http.get('*/api/v2/translation-services/:code{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TranslationServicesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getOtherMock = () => [ - getApiV2LanguagesListMockHandler(), - getApiV2LanguagesRetrieveMockHandler(), - getApiV2PermissionsListMockHandler(), - getApiV2PermissionsRetrieveMockHandler(), - getApiV2StripeAddonsListMockHandler(), - getApiV2StripeAddonsRetrieveMockHandler(), - getApiV2StripeChangePlanRetrieveMockHandler(), - getApiV2StripeCheckoutLinkCreateMockHandler(), - getApiV2StripeCustomerPortalCreateMockHandler(), - getApiV2StripeProductsListMockHandler(), - getApiV2StripeSubscriptionsListMockHandler(), - getApiV2StripeSubscriptionsRetrieveMockHandler(), - getApiV2TermsOfServiceListMockHandler(), - getApiV2TermsOfServiceRetrieveMockHandler(), - getApiV2TranscriptionServicesListMockHandler(), - getApiV2TranscriptionServicesRetrieveMockHandler(), - getApiV2TranslationServicesListMockHandler(), - getApiV2TranslationServicesRetrieveMockHandler(), -] diff --git a/jsapp/js/api/react-query/scim/scim.msw.ts b/jsapp/js/api/react-query/scim/scim.msw.ts new file mode 100644 index 0000000000..ec33e2a8a2 --- /dev/null +++ b/jsapp/js/api/react-query/scim/scim.msw.ts @@ -0,0 +1,487 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import type { PaginatedScimGroupList } from '../../models/paginatedScimGroupList' + +import type { PaginatedScimUserList } from '../../models/paginatedScimUserList' + +import type { ScimGroup } from '../../models/scimGroup' + +import type { ScimUser } from '../../models/scimUser' + +import type { ScimV2ResourceTypesRetrieve200 } from '../../models/scimV2ResourceTypesRetrieve200' + +import type { ScimV2SchemasRetrieve200 } from '../../models/scimV2SchemasRetrieve200' + +import type { ScimV2ServiceProviderConfigRetrieve200 } from '../../models/scimV2ServiceProviderConfigRetrieve200' + +export const getApiV2ScimV2GroupsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedScimGroupList => ({ + schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + totalResults: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + itemsPerPage: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + startIndex: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsCreateResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsRetrieveResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsUpdateResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2ResourceTypesRetrieveResponseMock = (): ScimV2ResourceTypesRetrieve200 => ({ + [faker.string.alphanumeric(5)]: {}, +}) + +export const getApiV2ScimV2SchemasRetrieveResponseMock = (): ScimV2SchemasRetrieve200 => ({ + [faker.string.alphanumeric(5)]: {}, +}) + +export const getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock = (): ScimV2ServiceProviderConfigRetrieve200 => ({ + [faker.string.alphanumeric(5)]: {}, +}) + +export const getApiV2ScimV2UsersListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedScimUserList => ({ + schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + totalResults: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + itemsPerPage: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + startIndex: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersCreateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersRetrieveResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersUpdateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersPartialUpdateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsListMockHandler = ( + overrideResponse?: + | PaginatedScimGroupList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedScimGroupList), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2GroupsCreateMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.post('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2GroupsRetrieveMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2GroupsUpdateMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.put('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2GroupsPartialUpdateMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.patch('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2GroupsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2ScimV2ResourceTypesRetrieveMockHandler = ( + overrideResponse?: + | ScimV2ResourceTypesRetrieve200 + | (( + info: Parameters[1]>[0], + ) => Promise | ScimV2ResourceTypesRetrieve200), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/ResourceTypes', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2ResourceTypesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2SchemasRetrieveMockHandler = ( + overrideResponse?: + | ScimV2SchemasRetrieve200 + | (( + info: Parameters[1]>[0], + ) => Promise | ScimV2SchemasRetrieve200), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Schemas', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2SchemasRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler = ( + overrideResponse?: + | ScimV2ServiceProviderConfigRetrieve200 + | (( + info: Parameters[1]>[0], + ) => Promise | ScimV2ServiceProviderConfigRetrieve200), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/ServiceProviderConfig', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersListMockHandler = ( + overrideResponse?: + | PaginatedScimUserList + | ((info: Parameters[1]>[0]) => Promise | PaginatedScimUserList), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersCreateMockHandler = ( + overrideResponse?: + | ScimUser + | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.post('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersRetrieveMockHandler = ( + overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersUpdateMockHandler = ( + overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.put('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersPartialUpdateMockHandler = ( + overrideResponse?: + | ScimUser + | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.patch('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ScimV2UsersDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} +export const getScimMock = () => [ + getApiV2ScimV2GroupsListMockHandler(), + getApiV2ScimV2GroupsCreateMockHandler(), + getApiV2ScimV2GroupsRetrieveMockHandler(), + getApiV2ScimV2GroupsUpdateMockHandler(), + getApiV2ScimV2GroupsPartialUpdateMockHandler(), + getApiV2ScimV2GroupsDestroyMockHandler(), + getApiV2ScimV2ResourceTypesRetrieveMockHandler(), + getApiV2ScimV2SchemasRetrieveMockHandler(), + getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler(), + getApiV2ScimV2UsersListMockHandler(), + getApiV2ScimV2UsersCreateMockHandler(), + getApiV2ScimV2UsersRetrieveMockHandler(), + getApiV2ScimV2UsersUpdateMockHandler(), + getApiV2ScimV2UsersPartialUpdateMockHandler(), + getApiV2ScimV2UsersDestroyMockHandler(), +] diff --git a/jsapp/js/api/react-query/scim.ts b/jsapp/js/api/react-query/scim/scim.ts similarity index 72% rename from jsapp/js/api/react-query/scim.ts rename to jsapp/js/api/react-query/scim/scim.ts index 9d0304dd9a..bc1385070e 100644 --- a/jsapp/js/api/react-query/scim.ts +++ b/jsapp/js/api/react-query/scim/scim.ts @@ -19,41 +19,37 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { PatchedScimGroup } from '../models/patchedScimGroup' +import type { PaginatedScimGroupList } from '../../models/paginatedScimGroupList' -import type { PatchedScimUser } from '../models/patchedScimUser' +import type { PaginatedScimUserList } from '../../models/paginatedScimUserList' -import type { ScimError } from '../models/scimError' +import type { PatchedScimGroup } from '../../models/patchedScimGroup' -import type { ScimV2GroupsListParams } from '../models/scimV2GroupsListParams' +import type { PatchedScimUser } from '../../models/patchedScimUser' -import type { ScimV2UsersCreate400 } from '../models/scimV2UsersCreate400' +import type { ScimError } from '../../models/scimError' -import type { ScimV2UsersCreate409 } from '../models/scimV2UsersCreate409' +import type { ScimGroup } from '../../models/scimGroup' -import type { ScimV2UsersListParams } from '../models/scimV2UsersListParams' +import type { ScimUser } from '../../models/scimUser' -import type { ScimV2UsersUpdate409 } from '../models/scimV2UsersUpdate409' +import type { ScimV2GroupsListParams } from '../../models/scimV2GroupsListParams' -import { faker } from '@faker-js/faker' +import type { ScimV2ResourceTypesRetrieve200 } from '../../models/scimV2ResourceTypesRetrieve200' -import { http, HttpResponse } from 'msw' +import type { ScimV2SchemasRetrieve200 } from '../../models/scimV2SchemasRetrieve200' -import type { PaginatedScimGroupList } from '../models/paginatedScimGroupList' +import type { ScimV2ServiceProviderConfigRetrieve200 } from '../../models/scimV2ServiceProviderConfigRetrieve200' -import type { PaginatedScimUserList } from '../models/paginatedScimUserList' +import type { ScimV2UsersCreate400 } from '../../models/scimV2UsersCreate400' -import type { ScimGroup } from '../models/scimGroup' +import type { ScimV2UsersCreate409 } from '../../models/scimV2UsersCreate409' -import type { ScimUser } from '../models/scimUser' +import type { ScimV2UsersListParams } from '../../models/scimV2UsersListParams' -import type { ScimV2ResourceTypesRetrieve200 } from '../models/scimV2ResourceTypesRetrieve200' +import type { ScimV2UsersUpdate409 } from '../../models/scimV2UsersUpdate409' -import type { ScimV2SchemasRetrieve200 } from '../models/scimV2SchemasRetrieve200' - -import type { ScimV2ServiceProviderConfigRetrieve200 } from '../models/scimV2ServiceProviderConfigRetrieve200' - -import { fetchWithAuth } from '../orval.mutator' +import { fetchWithAuth } from '../../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B @@ -1410,462 +1406,3 @@ export const useScimV2UsersDestroy = (op return useMutation(mutationOptions) } - -export const getApiV2ScimV2GroupsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedScimGroupList => ({ - schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - totalResults: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - itemsPerPage: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - startIndex: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), - externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - members: {}, - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - ...overrideResponse, -}) - -export const getApiV2ScimV2GroupsCreateResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), - externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - members: {}, - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2GroupsRetrieveResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), - externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - members: {}, - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2GroupsUpdateResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), - externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - members: {}, - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2GroupsPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): ScimGroup => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), - externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - members: {}, - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2ResourceTypesRetrieveResponseMock = (): ScimV2ResourceTypesRetrieve200 => ({ - [faker.string.alphanumeric(5)]: {}, -}) - -export const getApiV2ScimV2SchemasRetrieveResponseMock = (): ScimV2SchemasRetrieve200 => ({ - [faker.string.alphanumeric(5)]: {}, -}) - -export const getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock = (): ScimV2ServiceProviderConfigRetrieve200 => ({ - [faker.string.alphanumeric(5)]: {}, -}) - -export const getApiV2ScimV2UsersListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedScimUserList => ({ - schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - totalResults: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - itemsPerPage: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - startIndex: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - userName: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: { - [faker.string.alphanumeric(5)]: {}, - }, - emails: {}, - active: faker.datatype.boolean(), - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - ...overrideResponse, -}) - -export const getApiV2ScimV2UsersCreateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - userName: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: { - [faker.string.alphanumeric(5)]: {}, - }, - emails: {}, - active: faker.datatype.boolean(), - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2UsersRetrieveResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - userName: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: { - [faker.string.alphanumeric(5)]: {}, - }, - emails: {}, - active: faker.datatype.boolean(), - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2UsersUpdateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - userName: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: { - [faker.string.alphanumeric(5)]: {}, - }, - emails: {}, - active: faker.datatype.boolean(), - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2UsersPartialUpdateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - userName: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: { - [faker.string.alphanumeric(5)]: {}, - }, - emails: {}, - active: faker.datatype.boolean(), - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2GroupsListMockHandler = ( - overrideResponse?: - | PaginatedScimGroupList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedScimGroupList), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2GroupsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2GroupsCreateMockHandler = ( - overrideResponse?: - | ScimGroup - | ((info: Parameters[1]>[0]) => Promise | ScimGroup), -) => { - return http.post('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2GroupsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2GroupsRetrieveMockHandler = ( - overrideResponse?: - | ScimGroup - | ((info: Parameters[1]>[0]) => Promise | ScimGroup), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2GroupsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2GroupsUpdateMockHandler = ( - overrideResponse?: - | ScimGroup - | ((info: Parameters[1]>[0]) => Promise | ScimGroup), -) => { - return http.put('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2GroupsUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2GroupsPartialUpdateMockHandler = ( - overrideResponse?: - | ScimGroup - | ((info: Parameters[1]>[0]) => Promise | ScimGroup), -) => { - return http.patch('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2GroupsPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2GroupsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2ScimV2ResourceTypesRetrieveMockHandler = ( - overrideResponse?: - | ScimV2ResourceTypesRetrieve200 - | (( - info: Parameters[1]>[0], - ) => Promise | ScimV2ResourceTypesRetrieve200), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/ResourceTypes', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2ResourceTypesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2SchemasRetrieveMockHandler = ( - overrideResponse?: - | ScimV2SchemasRetrieve200 - | (( - info: Parameters[1]>[0], - ) => Promise | ScimV2SchemasRetrieve200), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Schemas', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2SchemasRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler = ( - overrideResponse?: - | ScimV2ServiceProviderConfigRetrieve200 - | (( - info: Parameters[1]>[0], - ) => Promise | ScimV2ServiceProviderConfigRetrieve200), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/ServiceProviderConfig', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersListMockHandler = ( - overrideResponse?: - | PaginatedScimUserList - | ((info: Parameters[1]>[0]) => Promise | PaginatedScimUserList), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2UsersListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersCreateMockHandler = ( - overrideResponse?: - | ScimUser - | ((info: Parameters[1]>[0]) => Promise | ScimUser), -) => { - return http.post('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2UsersCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersRetrieveMockHandler = ( - overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2UsersRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersUpdateMockHandler = ( - overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), -) => { - return http.put('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2UsersUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersPartialUpdateMockHandler = ( - overrideResponse?: - | ScimUser - | ((info: Parameters[1]>[0]) => Promise | ScimUser), -) => { - return http.patch('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2UsersPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} -export const getScimMock = () => [ - getApiV2ScimV2GroupsListMockHandler(), - getApiV2ScimV2GroupsCreateMockHandler(), - getApiV2ScimV2GroupsRetrieveMockHandler(), - getApiV2ScimV2GroupsUpdateMockHandler(), - getApiV2ScimV2GroupsPartialUpdateMockHandler(), - getApiV2ScimV2GroupsDestroyMockHandler(), - getApiV2ScimV2ResourceTypesRetrieveMockHandler(), - getApiV2ScimV2SchemasRetrieveMockHandler(), - getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler(), - getApiV2ScimV2UsersListMockHandler(), - getApiV2ScimV2UsersCreateMockHandler(), - getApiV2ScimV2UsersRetrieveMockHandler(), - getApiV2ScimV2UsersUpdateMockHandler(), - getApiV2ScimV2UsersPartialUpdateMockHandler(), - getApiV2ScimV2UsersDestroyMockHandler(), -] diff --git a/jsapp/js/api/react-query/server-logs-superusers.ts b/jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.msw.ts similarity index 61% rename from jsapp/js/api/react-query/server-logs-superusers.ts rename to jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.msw.ts index 46f6247dfb..4b094c7f3a 100644 --- a/jsapp/js/api/react-query/server-logs-superusers.ts +++ b/jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.msw.ts @@ -9,1080 +9,25 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { AccessLogsListParams } from '../models/accessLogsListParams' - -import type { AuditLogsListParams } from '../models/auditLogsListParams' - -import type { ErrorDetail } from '../models/errorDetail' - -import type { ErrorObject } from '../models/errorObject' - -import type { ProjectHistoryLogsListParams } from '../models/projectHistoryLogsListParams' - -import type { UserReportsListParams } from '../models/userReportsListParams' - import { faker } from '@faker-js/faker' import { http, HttpResponse } from 'msw' -import type { ExportCreateResponse } from '../models/exportCreateResponse' - -import type { ExportHistoryResponse } from '../models/exportHistoryResponse' - -import type { ExportListResponse } from '../models/exportListResponse' - -import type { PaginatedAuditLogResponseList } from '../models/paginatedAuditLogResponseList' - -import type { PaginatedProjectHistoryLogResponseList } from '../models/paginatedProjectHistoryLogResponseList' - -import type { PaginatedSuperUserAccessLogResponseList } from '../models/paginatedSuperUserAccessLogResponseList' - -import type { PaginatedUserReportsListResponseList } from '../models/paginatedUserReportsListResponseList' - -import type { ServiceUsageBalanceData } from '../models/serviceUsageBalanceData' - -import { fetchWithAuth } from '../orval.mutator' - -type SecondParameter unknown> = Parameters[1] - -/** - * ## List all access logs for all users - -⚠️ _Only available to superusers_ - -Submissions will be grouped together by user by hour - -**Filterable fields:** - -- date_created -- user_uid -- user__username -- metadata__source -- metadata__auth_type -- metadata__ip_address - -**Some examples:** - -1. All logs from a specific IP address - `api/v2/access-logs/?q=metadata__ip_address:"127.0.0.1"` - -2. All logs created after Jan 1, 2025 - `api/v2/access-logs/?q=date_created__gte:"2025-01-01"` - -*Notes: Do not forget to wrap search terms in double-quotes if they contain spaces -(e.g. date and time "2022-11-15 20:34")* - - */ -export type accessLogsListResponse200 = { - data: PaginatedSuperUserAccessLogResponseList - status: 200 -} - -export type accessLogsListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type accessLogsListResponseComposite = accessLogsListResponse200 | accessLogsListResponse403 - -export type accessLogsListResponse = accessLogsListResponseComposite & { - headers: Headers -} - -export const getAccessLogsListUrl = (params?: AccessLogsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/access-logs/?${stringifiedParams}` : `/api/v2/access-logs/` -} - -export const accessLogsList = async ( - params?: AccessLogsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAccessLogsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getAccessLogsListQueryKey = (params?: AccessLogsListParams) => { - return ['api', 'v2', 'access-logs', ...(params ? [params] : [])] as const -} - -export const getAccessLogsListQueryOptions = >, TError = ErrorDetail>( - params?: AccessLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAccessLogsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - accessLogsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AccessLogsListQueryResult = NonNullable>> -export type AccessLogsListQueryError = ErrorDetail - -export function useAccessLogsList>, TError = ErrorDetail>( - params?: AccessLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAccessLogsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List all access logs export tasks for all users - -⚠️ _Only available to superusers_ - - */ -export type accessLogsExportListResponse200 = { - data: ExportListResponse[] - status: 200 -} - -export type accessLogsExportListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type accessLogsExportListResponseComposite = accessLogsExportListResponse200 | accessLogsExportListResponse403 - -export type accessLogsExportListResponse = accessLogsExportListResponseComposite & { - headers: Headers -} - -export const getAccessLogsExportListUrl = () => { - return `/api/v2/access-logs/export/` -} - -export const accessLogsExportList = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAccessLogsExportListUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAccessLogsExportListQueryKey = () => { - return ['api', 'v2', 'access-logs', 'export'] as const -} - -export const getAccessLogsExportListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAccessLogsExportListQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - accessLogsExportList({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AccessLogsExportListQueryResult = NonNullable>> -export type AccessLogsExportListQueryError = ErrorDetail - -export function useAccessLogsExportList< - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAccessLogsExportListQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create an export task for all users - -⚠️ _Only available to superusers_ - - */ -export type accessLogsExportCreateResponse202 = { - data: ExportCreateResponse - status: 202 -} - -export type accessLogsExportCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type accessLogsExportCreateResponseComposite = - | accessLogsExportCreateResponse202 - | accessLogsExportCreateResponse401 - -export type accessLogsExportCreateResponse = accessLogsExportCreateResponseComposite & { - headers: Headers -} - -export const getAccessLogsExportCreateUrl = () => { - return `/api/v2/access-logs/export/` -} - -export const accessLogsExportCreate = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAccessLogsExportCreateUrl(), { - ...options, - method: 'POST', - }) -} - -export const getAccessLogsExportCreateMutationOptions = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['accessLogsExportCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return accessLogsExportCreate(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AccessLogsExportCreateMutationResult = NonNullable>> - -export type AccessLogsExportCreateMutationError = ErrorDetail - -export const useAccessLogsExportCreate = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}) => { - const mutationOptions = getAccessLogsExportCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## List actions performed by users. - -⚠️ _Only available to superusers_ - -Results from this endpoint can be filtered by a Boolean query specified in the `q` parameter. - -**Filterable fields:** - -* app_label -* model_name -* action - Available actions: - * create - * delete - * in-trash - * put-back - * remove - * update - * auth -* log_type - Available log types: - * access - * project-history - * data-editing - * submission-management - * user-management - * asset-management -* date_created -* user_uid -* user__username -* user__email -* user__is_superuser -* metadata__asset_uid -* metadata__auth_type - -*Notes: Some logs may have additional filterable fields in the metadata* - -**Some examples:** - -* All deleted submissions - `api/v2/audit-logs/?q=action:delete` -* All deleted submissions of a specific project `aTJ3vi2KRGYj2NytSzBPp7` - `api/v2/audit-logs/?q=action:delete AND metadata__asset_uid:aTJ3vi2KRGYj2NytSzBPp7` -* All submissions deleted by a specific user `my_username` - `api/v2/audit-logs/?q=action:delete AND user__username:my_username` -* All deleted submissions submitted after a specific date - `/api/v2/audit-logs/?q=action:delete AND date_created__gte:2022-11-15` -* All deleted submissions submitted after a specific date **and time** - `/api/v2/audit-logs/?q=action:delete AND date_created__gte:"2022-11-15 20:34"` -* All authentications from superusers - `api/v2/audit-logs/?q=action:auth AND user__is_superuser:True` - -*Notes: Do not forget to wrap search terms in double-quotes if they contain spaces -(e.g. date and time "2022-11-15 20:34")* - - */ -export type auditLogsListResponse200 = { - data: PaginatedAuditLogResponseList - status: 200 -} - -export type auditLogsListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type auditLogsListResponseComposite = auditLogsListResponse200 | auditLogsListResponse403 - -export type auditLogsListResponse = auditLogsListResponseComposite & { - headers: Headers -} - -export const getAuditLogsListUrl = (params?: AuditLogsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/audit-logs/?${stringifiedParams}` : `/api/v2/audit-logs/` -} - -export const auditLogsList = async ( - params?: AuditLogsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAuditLogsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getAuditLogsListQueryKey = (params?: AuditLogsListParams) => { - return ['api', 'v2', 'audit-logs', ...(params ? [params] : [])] as const -} - -export const getAuditLogsListQueryOptions = >, TError = ErrorDetail>( - params?: AuditLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAuditLogsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - auditLogsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AuditLogsListQueryResult = NonNullable>> -export type AuditLogsListQueryError = ErrorDetail - -export function useAuditLogsList>, TError = ErrorDetail>( - params?: AuditLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAuditLogsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List all project history logs for all projects. - -⚠️_Only available to superusers_ - -Results from this endpoint can be filtered by a Boolean query -specified in the `q` parameter. - -**Filterable fields for all project history logs:** - -* date_created -* user_uid -* user__username -* user__email -* user__is_superuser -* metadata__source -* metadata__ip_address -* metadata__asset_uid -* metadata__log_subtype - * available subtypes: "project", "permission" -* action - -available actions: - -> add-media -> add-submission -> allow-anonymous-submissions -> archive -> clone-permissions -> connect-project -> delete-media -> delete-service -> delete-submission -> deploy -> disable-sharing -> disallow-anonymous-submissions -> disconnect-project -> enable-sharing -> export -> modify-imported-fields -> modify-qa-data -> modify-service -> modify-sharing -> modify-submission -> modify-user-permissions -> redeploy -> register-service -> replace-form -> share-data-publicly -> share-form-publicly -> transfer -> unarchive -> unshare-data-publicly -> unshare-form-publicly -> update-content -> update-name -> update-settings -> update-qa - -**Filterable fields by action:** - -* add-media - - a. metadata__asset-file__uid - - b. metadata__asset-file__filename - -* add-submission - - a. metadata__submission__submitted_by - - b. metadata__submission__root_uuid - -* archive - - a. metadata__latest_version_uid - -* clone-permissions - - a. metadata__cloned_from - -* connect-project - - a. metadata__paired-data__source_uid - - b. metadata__paired-data__source_name - -* delete-media - - a. metadata__asset-file__uid - - b. metadata__asset-file__filename - -* delete-service - - a. metadata__hook__uid - - b. metadata__hook__endpoint - - c. metadata__hook__active - -* delete-submission - - a. metadata__submission__submitted_by +import type { ExportCreateResponse } from '../../models/exportCreateResponse' - b. metadata__submission__root_uuid +import type { ExportHistoryResponse } from '../../models/exportHistoryResponse' -* deploy +import type { ExportListResponse } from '../../models/exportListResponse' - a. metadata__latest_version_uid +import type { PaginatedAuditLogResponseList } from '../../models/paginatedAuditLogResponseList' - b. metadata__latest_deployed_version_uid +import type { PaginatedProjectHistoryLogResponseList } from '../../models/paginatedProjectHistoryLogResponseList' -* disconnect-project +import type { PaginatedSuperUserAccessLogResponseList } from '../../models/paginatedSuperUserAccessLogResponseList' - a. metadata__paired-data__source_uid +import type { PaginatedUserReportsListResponseList } from '../../models/paginatedUserReportsListResponseList' - b. metadata__paired-data__source_name - -* modify-imported-fields - - a. metadata__paired-data__source_uid - - b. metadata__paired-data__source_name - -* modify-qa-data - - a. metadata__submission__submitted_by - - b. metadata__submission__root_uuid - -* modify-service - - a. metadata__hook__uid - - b. metadata__hook__endpoint - - c. metadata__hook__active - -* modify-submission - - a. metadata__submission__submitted_by - - b. metadata__submission__root_uuid - - b. metadata__submission__status (only present if changed) - -* modify-user-permissions - - a. metadata__permissions__username - -* redeploy - - a. metadata__latest_version_uid - - b. metadata__latest_deployed_version_uid - -* register-service - - a. metadata__hook__uid - - b. metadata__hook__endpoint - - c. metadata__hook__active - -* transfer - - a. metadata__username - -* unarchive - - a. metadata__latest_version_uid - -* update-name - - a. metadata__name__old - - b. metadata__name__new - -* update-settings - - a. metadata__settings__description__old - - b. metadata__settings__description__new - -This endpoint can be paginated with 'start' and 'limit' parameters - - */ -export type projectHistoryLogsListResponse200 = { - data: PaginatedProjectHistoryLogResponseList - status: 200 -} - -export type projectHistoryLogsListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectHistoryLogsListResponseComposite = - | projectHistoryLogsListResponse200 - | projectHistoryLogsListResponse403 - -export type projectHistoryLogsListResponse = projectHistoryLogsListResponseComposite & { - headers: Headers -} - -export const getProjectHistoryLogsListUrl = (params?: ProjectHistoryLogsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/project-history-logs/?${stringifiedParams}` - : `/api/v2/project-history-logs/` -} - -export const projectHistoryLogsList = async ( - params?: ProjectHistoryLogsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectHistoryLogsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getProjectHistoryLogsListQueryKey = (params?: ProjectHistoryLogsListParams) => { - return ['api', 'v2', 'project-history-logs', ...(params ? [params] : [])] as const -} - -export const getProjectHistoryLogsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: ProjectHistoryLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - projectHistoryLogsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectHistoryLogsListQueryResult = NonNullable>> -export type ProjectHistoryLogsListQueryError = ErrorDetail - -export function useProjectHistoryLogsList< - TData = Awaited>, - TError = ErrorDetail, ->( - params?: ProjectHistoryLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectHistoryLogsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List of Project History Exports - -⚠️ _Only available to superusers_ - - */ -export type projectHistoryLogsExportRetrieveResponse202 = { - data: ExportHistoryResponse - status: 202 -} - -export type projectHistoryLogsExportRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectHistoryLogsExportRetrieveResponseComposite = - | projectHistoryLogsExportRetrieveResponse202 - | projectHistoryLogsExportRetrieveResponse403 - -export type projectHistoryLogsExportRetrieveResponse = projectHistoryLogsExportRetrieveResponseComposite & { - headers: Headers -} - -export const getProjectHistoryLogsExportRetrieveUrl = () => { - return `/api/v2/project-history-logs/export/` -} - -export const projectHistoryLogsExportRetrieve = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectHistoryLogsExportRetrieveUrl(), { - ...options, - method: 'GET', - }) -} - -export const getProjectHistoryLogsExportRetrieveQueryKey = () => { - return ['api', 'v2', 'project-history-logs', 'export'] as const -} - -export const getProjectHistoryLogsExportRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsExportRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - projectHistoryLogsExportRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectHistoryLogsExportRetrieveQueryResult = NonNullable< - Awaited> -> -export type ProjectHistoryLogsExportRetrieveQueryError = ErrorDetail - -export function useProjectHistoryLogsExportRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectHistoryLogsExportRetrieveQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create an export of projects history logs - -⚠️ _Only available to superusers_ - -Export project history logs and send it by email to the requesting user. - - */ -export type projectHistoryLogsExportCreateResponse202 = { - data: ExportHistoryResponse - status: 202 -} - -export type projectHistoryLogsExportCreateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectHistoryLogsExportCreateResponseComposite = - | projectHistoryLogsExportCreateResponse202 - | projectHistoryLogsExportCreateResponse403 - -export type projectHistoryLogsExportCreateResponse = projectHistoryLogsExportCreateResponseComposite & { - headers: Headers -} - -export const getProjectHistoryLogsExportCreateUrl = () => { - return `/api/v2/project-history-logs/export/` -} - -export const projectHistoryLogsExportCreate = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectHistoryLogsExportCreateUrl(), { - ...options, - method: 'POST', - }) -} - -export const getProjectHistoryLogsExportCreateMutationOptions = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['projectHistoryLogsExportCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return projectHistoryLogsExportCreate(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ProjectHistoryLogsExportCreateMutationResult = NonNullable< - Awaited> -> - -export type ProjectHistoryLogsExportCreateMutationError = ErrorDetail - -export const useProjectHistoryLogsExportCreate = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}) => { - const mutationOptions = getProjectHistoryLogsExportCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * # List user reports - -⚠️ _Only available to superusers_ - -## Filterable fields by string: - -Supports partial filtering -- username -- first_name -- last_name -- email -- user_uid -- organization__name -- organization__role (e.g., admin, member, owner) -- organization__website -- extra_details__data__organization_type -- `extra_details__data__` (other string fields, e.g., name, sector, country...) - -## Filterable fields by int: - -Supports exact matching and range operators (e.g., gte, lte) - -**Total NLP Usage** -- service_usage__total_nlp_usage__asr_seconds_all_time -- service_usage__total_nlp_usage__mt_characters_all_time -- service_usage__total_nlp_usage__asr_seconds_current_period -- service_usage__total_nlp_usage__mt_characters_current_period - -**Total Storage/Submissions** -- service_usage__total_storage_bytes -- service_usage__total_submission_count__cumulative -- service_usage__total_submission_count__current_period - -**Service Usage Balances** - -Prefix: `service_usage__balances____` - -Metric: -- submission -- asr_seconds -- mt_characters -- storage_bytes - -Value: -- balance_value -- balance_percent -- effective_limit - -Ex: `service_usage__balances__submission__balance_value` - -**Asset Count** -- asset_count -- active_project_count - -## Filterable fields by date: -Supports exact matching and range operators (e.g., gte, lte) - -- date_joined -- last_login -- last_updated (Represents the last modified timestamp of the materialized view) -- extra_details__date_removal_requested -- extra_details__date_removed -- extra_details_password_date_changed - -## Filterable fields by boolean: - -- is_superuser -- is_staff -- is_active -- validated_email -- extra_details__validated_password -- mfa_is_active -- sso_is_active -- accepted_tos -- extra_details__data__newsletter_subscription -- service_usage__balances__*metric*__exceeded (metric: submission, asr_seconds, mt_characters, storage_bytes) -- account_restricted - -## Filterable fields by list: - -Subscription filtering: - -Has subscriptions - -`?q=subscriptions__0__id__isnull:False` - -No subscriptions - -`?q=subscriptions__0__id__isnull:True` - -Subscription id - -`?q=subscriptions[]__id:sub_1QwPItAR39rDI89stzLJ040p` - -Active subscriptions - -`?q=subscriptions[]__status:active` - - */ -export type userReportsListResponse200 = { - data: PaginatedUserReportsListResponseList - status: 200 -} - -export type userReportsListResponse400 = { - data: ErrorObject - status: 400 -} - -export type userReportsListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type userReportsListResponseComposite = - | userReportsListResponse200 - | userReportsListResponse400 - | userReportsListResponse403 - -export type userReportsListResponse = userReportsListResponseComposite & { - headers: Headers -} - -export const getUserReportsListUrl = (params?: UserReportsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/user-reports/?${stringifiedParams}` : `/api/v2/user-reports/` -} - -export const userReportsList = async ( - params?: UserReportsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getUserReportsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getUserReportsListQueryKey = (params?: UserReportsListParams) => { - return ['api', 'v2', 'user-reports', ...(params ? [params] : [])] as const -} - -export const getUserReportsListQueryOptions = < - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - params?: UserReportsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getUserReportsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - userReportsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type UserReportsListQueryResult = NonNullable>> -export type UserReportsListQueryError = ErrorObject | ErrorDetail - -export function useUserReportsList< - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - params?: UserReportsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getUserReportsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} +import type { ServiceUsageBalanceData } from '../../models/serviceUsageBalanceData' export const getApiV2AccessLogsListResponseMock = ( overrideResponse: Partial = {}, @@ -1951,7 +896,7 @@ export const getApiV2AccessLogsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedSuperUserAccessLogResponseList), ) => { - return http.get('*/api/v2/access-logs{/}?', async (info) => { + return http.get('*/api/v2/access-logs/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1970,7 +915,7 @@ export const getApiV2AccessLogsExportListMockHandler = ( | ExportListResponse[] | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), ) => { - return http.get('*/api/v2/access-logs/export{/}?', async (info) => { + return http.get('*/api/v2/access-logs/export/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1989,7 +934,7 @@ export const getApiV2AccessLogsExportCreateMockHandler = ( | ExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), ) => { - return http.post('*/api/v2/access-logs/export{/}?', async (info) => { + return http.post('*/api/v2/access-logs/export/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2010,7 +955,7 @@ export const getApiV2AuditLogsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAuditLogResponseList), ) => { - return http.get('*/api/v2/audit-logs{/}?', async (info) => { + return http.get('*/api/v2/audit-logs/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2031,7 +976,7 @@ export const getApiV2ProjectHistoryLogsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectHistoryLogResponseList), ) => { - return http.get('*/api/v2/project-history-logs{/}?', async (info) => { + return http.get('*/api/v2/project-history-logs/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2050,7 +995,7 @@ export const getApiV2ProjectHistoryLogsExportRetrieveMockHandler = ( | ExportHistoryResponse | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse), ) => { - return http.get('*/api/v2/project-history-logs/export{/}?', async (info) => { + return http.get('*/api/v2/project-history-logs/export/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2071,7 +1016,7 @@ export const getApiV2ProjectHistoryLogsExportCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ExportHistoryResponse), ) => { - return http.post('*/api/v2/project-history-logs/export{/}?', async (info) => { + return http.post('*/api/v2/project-history-logs/export/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2092,7 +1037,7 @@ export const getApiV2UserReportsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedUserReportsListResponseList), ) => { - return http.get('*/api/v2/user-reports{/}?', async (info) => { + return http.get('*/api/v2/user-reports/', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.ts b/jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.ts new file mode 100644 index 0000000000..d753203c53 --- /dev/null +++ b/jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.ts @@ -0,0 +1,1079 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { useMutation, useQuery } from '@tanstack/react-query' +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult, +} from '@tanstack/react-query' + +import type { AccessLogsListParams } from '../../models/accessLogsListParams' + +import type { AuditLogsListParams } from '../../models/auditLogsListParams' + +import type { ErrorDetail } from '../../models/errorDetail' + +import type { ErrorObject } from '../../models/errorObject' + +import type { ExportCreateResponse } from '../../models/exportCreateResponse' + +import type { ExportHistoryResponse } from '../../models/exportHistoryResponse' + +import type { ExportListResponse } from '../../models/exportListResponse' + +import type { PaginatedAuditLogResponseList } from '../../models/paginatedAuditLogResponseList' + +import type { PaginatedProjectHistoryLogResponseList } from '../../models/paginatedProjectHistoryLogResponseList' + +import type { PaginatedSuperUserAccessLogResponseList } from '../../models/paginatedSuperUserAccessLogResponseList' + +import type { PaginatedUserReportsListResponseList } from '../../models/paginatedUserReportsListResponseList' + +import type { ProjectHistoryLogsListParams } from '../../models/projectHistoryLogsListParams' + +import type { UserReportsListParams } from '../../models/userReportsListParams' + +import { fetchWithAuth } from '../../orval.mutator' + +type SecondParameter unknown> = Parameters[1] + +/** + * ## List all access logs for all users + +⚠️ _Only available to superusers_ + +Submissions will be grouped together by user by hour + +**Filterable fields:** + +- date_created +- user_uid +- user__username +- metadata__source +- metadata__auth_type +- metadata__ip_address + +**Some examples:** + +1. All logs from a specific IP address + `api/v2/access-logs/?q=metadata__ip_address:"127.0.0.1"` + +2. All logs created after Jan 1, 2025 + `api/v2/access-logs/?q=date_created__gte:"2025-01-01"` + +*Notes: Do not forget to wrap search terms in double-quotes if they contain spaces +(e.g. date and time "2022-11-15 20:34")* + + */ +export type accessLogsListResponse200 = { + data: PaginatedSuperUserAccessLogResponseList + status: 200 +} + +export type accessLogsListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type accessLogsListResponseComposite = accessLogsListResponse200 | accessLogsListResponse403 + +export type accessLogsListResponse = accessLogsListResponseComposite & { + headers: Headers +} + +export const getAccessLogsListUrl = (params?: AccessLogsListParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 ? `/api/v2/access-logs/?${stringifiedParams}` : `/api/v2/access-logs/` +} + +export const accessLogsList = async ( + params?: AccessLogsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAccessLogsListUrl(params), { + ...options, + method: 'GET', + }) +} + +export const getAccessLogsListQueryKey = (params?: AccessLogsListParams) => { + return ['api', 'v2', 'access-logs', ...(params ? [params] : [])] as const +} + +export const getAccessLogsListQueryOptions = >, TError = ErrorDetail>( + params?: AccessLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAccessLogsListQueryKey(params) + + const queryFn: QueryFunction>> = ({ signal }) => + accessLogsList(params, { signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AccessLogsListQueryResult = NonNullable>> +export type AccessLogsListQueryError = ErrorDetail + +export function useAccessLogsList>, TError = ErrorDetail>( + params?: AccessLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAccessLogsListQueryOptions(params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## List all access logs export tasks for all users + +⚠️ _Only available to superusers_ + + */ +export type accessLogsExportListResponse200 = { + data: ExportListResponse[] + status: 200 +} + +export type accessLogsExportListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type accessLogsExportListResponseComposite = accessLogsExportListResponse200 | accessLogsExportListResponse403 + +export type accessLogsExportListResponse = accessLogsExportListResponseComposite & { + headers: Headers +} + +export const getAccessLogsExportListUrl = () => { + return `/api/v2/access-logs/export/` +} + +export const accessLogsExportList = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAccessLogsExportListUrl(), { + ...options, + method: 'GET', + }) +} + +export const getAccessLogsExportListQueryKey = () => { + return ['api', 'v2', 'access-logs', 'export'] as const +} + +export const getAccessLogsExportListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAccessLogsExportListQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + accessLogsExportList({ signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AccessLogsExportListQueryResult = NonNullable>> +export type AccessLogsExportListQueryError = ErrorDetail + +export function useAccessLogsExportList< + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAccessLogsExportListQueryOptions(options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Create an export task for all users + +⚠️ _Only available to superusers_ + + */ +export type accessLogsExportCreateResponse202 = { + data: ExportCreateResponse + status: 202 +} + +export type accessLogsExportCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type accessLogsExportCreateResponseComposite = + | accessLogsExportCreateResponse202 + | accessLogsExportCreateResponse401 + +export type accessLogsExportCreateResponse = accessLogsExportCreateResponseComposite & { + headers: Headers +} + +export const getAccessLogsExportCreateUrl = () => { + return `/api/v2/access-logs/export/` +} + +export const accessLogsExportCreate = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAccessLogsExportCreateUrl(), { + ...options, + method: 'POST', + }) +} + +export const getAccessLogsExportCreateMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['accessLogsExportCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return accessLogsExportCreate(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type AccessLogsExportCreateMutationResult = NonNullable>> + +export type AccessLogsExportCreateMutationError = ErrorDetail + +export const useAccessLogsExportCreate = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}) => { + const mutationOptions = getAccessLogsExportCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## List actions performed by users. + +⚠️ _Only available to superusers_ + +Results from this endpoint can be filtered by a Boolean query specified in the `q` parameter. + +**Filterable fields:** + +* app_label +* model_name +* action + Available actions: + * create + * delete + * in-trash + * put-back + * remove + * update + * auth +* log_type + Available log types: + * access + * project-history + * data-editing + * submission-management + * user-management + * asset-management +* date_created +* user_uid +* user__username +* user__email +* user__is_superuser +* metadata__asset_uid +* metadata__auth_type + +*Notes: Some logs may have additional filterable fields in the metadata* + +**Some examples:** + +* All deleted submissions + `api/v2/audit-logs/?q=action:delete` +* All deleted submissions of a specific project `aTJ3vi2KRGYj2NytSzBPp7` + `api/v2/audit-logs/?q=action:delete AND metadata__asset_uid:aTJ3vi2KRGYj2NytSzBPp7` +* All submissions deleted by a specific user `my_username` + `api/v2/audit-logs/?q=action:delete AND user__username:my_username` +* All deleted submissions submitted after a specific date + `/api/v2/audit-logs/?q=action:delete AND date_created__gte:2022-11-15` +* All deleted submissions submitted after a specific date **and time** + `/api/v2/audit-logs/?q=action:delete AND date_created__gte:"2022-11-15 20:34"` +* All authentications from superusers + `api/v2/audit-logs/?q=action:auth AND user__is_superuser:True` + +*Notes: Do not forget to wrap search terms in double-quotes if they contain spaces +(e.g. date and time "2022-11-15 20:34")* + + */ +export type auditLogsListResponse200 = { + data: PaginatedAuditLogResponseList + status: 200 +} + +export type auditLogsListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type auditLogsListResponseComposite = auditLogsListResponse200 | auditLogsListResponse403 + +export type auditLogsListResponse = auditLogsListResponseComposite & { + headers: Headers +} + +export const getAuditLogsListUrl = (params?: AuditLogsListParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 ? `/api/v2/audit-logs/?${stringifiedParams}` : `/api/v2/audit-logs/` +} + +export const auditLogsList = async ( + params?: AuditLogsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAuditLogsListUrl(params), { + ...options, + method: 'GET', + }) +} + +export const getAuditLogsListQueryKey = (params?: AuditLogsListParams) => { + return ['api', 'v2', 'audit-logs', ...(params ? [params] : [])] as const +} + +export const getAuditLogsListQueryOptions = >, TError = ErrorDetail>( + params?: AuditLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAuditLogsListQueryKey(params) + + const queryFn: QueryFunction>> = ({ signal }) => + auditLogsList(params, { signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AuditLogsListQueryResult = NonNullable>> +export type AuditLogsListQueryError = ErrorDetail + +export function useAuditLogsList>, TError = ErrorDetail>( + params?: AuditLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAuditLogsListQueryOptions(params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## List all project history logs for all projects. + +⚠️_Only available to superusers_ + +Results from this endpoint can be filtered by a Boolean query +specified in the `q` parameter. + +**Filterable fields for all project history logs:** + +* date_created +* user_uid +* user__username +* user__email +* user__is_superuser +* metadata__source +* metadata__ip_address +* metadata__asset_uid +* metadata__log_subtype + * available subtypes: "project", "permission" +* action + +available actions: + +> add-media +> add-submission +> allow-anonymous-submissions +> archive +> clone-permissions +> connect-project +> delete-media +> delete-service +> delete-submission +> deploy +> disable-sharing +> disallow-anonymous-submissions +> disconnect-project +> enable-sharing +> export +> modify-imported-fields +> modify-qa-data +> modify-service +> modify-sharing +> modify-submission +> modify-user-permissions +> redeploy +> register-service +> replace-form +> share-data-publicly +> share-form-publicly +> transfer +> unarchive +> unshare-data-publicly +> unshare-form-publicly +> update-content +> update-name +> update-settings +> update-qa + +**Filterable fields by action:** + +* add-media + + a. metadata__asset-file__uid + + b. metadata__asset-file__filename + +* add-submission + + a. metadata__submission__submitted_by + + b. metadata__submission__root_uuid + +* archive + + a. metadata__latest_version_uid + +* clone-permissions + + a. metadata__cloned_from + +* connect-project + + a. metadata__paired-data__source_uid + + b. metadata__paired-data__source_name + +* delete-media + + a. metadata__asset-file__uid + + b. metadata__asset-file__filename + +* delete-service + + a. metadata__hook__uid + + b. metadata__hook__endpoint + + c. metadata__hook__active + +* delete-submission + + a. metadata__submission__submitted_by + + b. metadata__submission__root_uuid + +* deploy + + a. metadata__latest_version_uid + + b. metadata__latest_deployed_version_uid + +* disconnect-project + + a. metadata__paired-data__source_uid + + b. metadata__paired-data__source_name + +* modify-imported-fields + + a. metadata__paired-data__source_uid + + b. metadata__paired-data__source_name + +* modify-qa-data + + a. metadata__submission__submitted_by + + b. metadata__submission__root_uuid + +* modify-service + + a. metadata__hook__uid + + b. metadata__hook__endpoint + + c. metadata__hook__active + +* modify-submission + + a. metadata__submission__submitted_by + + b. metadata__submission__root_uuid + + b. metadata__submission__status (only present if changed) + +* modify-user-permissions + + a. metadata__permissions__username + +* redeploy + + a. metadata__latest_version_uid + + b. metadata__latest_deployed_version_uid + +* register-service + + a. metadata__hook__uid + + b. metadata__hook__endpoint + + c. metadata__hook__active + +* transfer + + a. metadata__username + +* unarchive + + a. metadata__latest_version_uid + +* update-name + + a. metadata__name__old + + b. metadata__name__new + +* update-settings + + a. metadata__settings__description__old + + b. metadata__settings__description__new + +This endpoint can be paginated with 'start' and 'limit' parameters + + */ +export type projectHistoryLogsListResponse200 = { + data: PaginatedProjectHistoryLogResponseList + status: 200 +} + +export type projectHistoryLogsListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectHistoryLogsListResponseComposite = + | projectHistoryLogsListResponse200 + | projectHistoryLogsListResponse403 + +export type projectHistoryLogsListResponse = projectHistoryLogsListResponseComposite & { + headers: Headers +} + +export const getProjectHistoryLogsListUrl = (params?: ProjectHistoryLogsListParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 + ? `/api/v2/project-history-logs/?${stringifiedParams}` + : `/api/v2/project-history-logs/` +} + +export const projectHistoryLogsList = async ( + params?: ProjectHistoryLogsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectHistoryLogsListUrl(params), { + ...options, + method: 'GET', + }) +} + +export const getProjectHistoryLogsListQueryKey = (params?: ProjectHistoryLogsListParams) => { + return ['api', 'v2', 'project-history-logs', ...(params ? [params] : [])] as const +} + +export const getProjectHistoryLogsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: ProjectHistoryLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsListQueryKey(params) + + const queryFn: QueryFunction>> = ({ signal }) => + projectHistoryLogsList(params, { signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type ProjectHistoryLogsListQueryResult = NonNullable>> +export type ProjectHistoryLogsListQueryError = ErrorDetail + +export function useProjectHistoryLogsList< + TData = Awaited>, + TError = ErrorDetail, +>( + params?: ProjectHistoryLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectHistoryLogsListQueryOptions(params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## List of Project History Exports + +⚠️ _Only available to superusers_ + + */ +export type projectHistoryLogsExportRetrieveResponse202 = { + data: ExportHistoryResponse + status: 202 +} + +export type projectHistoryLogsExportRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectHistoryLogsExportRetrieveResponseComposite = + | projectHistoryLogsExportRetrieveResponse202 + | projectHistoryLogsExportRetrieveResponse403 + +export type projectHistoryLogsExportRetrieveResponse = projectHistoryLogsExportRetrieveResponseComposite & { + headers: Headers +} + +export const getProjectHistoryLogsExportRetrieveUrl = () => { + return `/api/v2/project-history-logs/export/` +} + +export const projectHistoryLogsExportRetrieve = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectHistoryLogsExportRetrieveUrl(), { + ...options, + method: 'GET', + }) +} + +export const getProjectHistoryLogsExportRetrieveQueryKey = () => { + return ['api', 'v2', 'project-history-logs', 'export'] as const +} + +export const getProjectHistoryLogsExportRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsExportRetrieveQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + projectHistoryLogsExportRetrieve({ signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type ProjectHistoryLogsExportRetrieveQueryResult = NonNullable< + Awaited> +> +export type ProjectHistoryLogsExportRetrieveQueryError = ErrorDetail + +export function useProjectHistoryLogsExportRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectHistoryLogsExportRetrieveQueryOptions(options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * ## Create an export of projects history logs + +⚠️ _Only available to superusers_ + +Export project history logs and send it by email to the requesting user. + + */ +export type projectHistoryLogsExportCreateResponse202 = { + data: ExportHistoryResponse + status: 202 +} + +export type projectHistoryLogsExportCreateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectHistoryLogsExportCreateResponseComposite = + | projectHistoryLogsExportCreateResponse202 + | projectHistoryLogsExportCreateResponse403 + +export type projectHistoryLogsExportCreateResponse = projectHistoryLogsExportCreateResponseComposite & { + headers: Headers +} + +export const getProjectHistoryLogsExportCreateUrl = () => { + return `/api/v2/project-history-logs/export/` +} + +export const projectHistoryLogsExportCreate = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectHistoryLogsExportCreateUrl(), { + ...options, + method: 'POST', + }) +} + +export const getProjectHistoryLogsExportCreateMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['projectHistoryLogsExportCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return projectHistoryLogsExportCreate(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ProjectHistoryLogsExportCreateMutationResult = NonNullable< + Awaited> +> + +export type ProjectHistoryLogsExportCreateMutationError = ErrorDetail + +export const useProjectHistoryLogsExportCreate = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}) => { + const mutationOptions = getProjectHistoryLogsExportCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * # List user reports + +⚠️ _Only available to superusers_ + +## Filterable fields by string: + +Supports partial filtering +- username +- first_name +- last_name +- email +- user_uid +- organization__name +- organization__role (e.g., admin, member, owner) +- organization__website +- extra_details__data__organization_type +- `extra_details__data__` (other string fields, e.g., name, sector, country...) + +## Filterable fields by int: + +Supports exact matching and range operators (e.g., gte, lte) + +**Total NLP Usage** +- service_usage__total_nlp_usage__asr_seconds_all_time +- service_usage__total_nlp_usage__mt_characters_all_time +- service_usage__total_nlp_usage__asr_seconds_current_period +- service_usage__total_nlp_usage__mt_characters_current_period + +**Total Storage/Submissions** +- service_usage__total_storage_bytes +- service_usage__total_submission_count__cumulative +- service_usage__total_submission_count__current_period + +**Service Usage Balances** + +Prefix: `service_usage__balances____` + +Metric: +- submission +- asr_seconds +- mt_characters +- storage_bytes + +Value: +- balance_value +- balance_percent +- effective_limit + +Ex: `service_usage__balances__submission__balance_value` + +**Asset Count** +- asset_count +- active_project_count + +## Filterable fields by date: +Supports exact matching and range operators (e.g., gte, lte) + +- date_joined +- last_login +- last_updated (Represents the last modified timestamp of the materialized view) +- extra_details__date_removal_requested +- extra_details__date_removed +- extra_details_password_date_changed + +## Filterable fields by boolean: + +- is_superuser +- is_staff +- is_active +- validated_email +- extra_details__validated_password +- mfa_is_active +- sso_is_active +- accepted_tos +- extra_details__data__newsletter_subscription +- service_usage__balances__*metric*__exceeded (metric: submission, asr_seconds, mt_characters, storage_bytes) +- account_restricted + +## Filterable fields by list: + +Subscription filtering: + +Has subscriptions + +`?q=subscriptions__0__id__isnull:False` + +No subscriptions + +`?q=subscriptions__0__id__isnull:True` + +Subscription id + +`?q=subscriptions[]__id:sub_1QwPItAR39rDI89stzLJ040p` + +Active subscriptions + +`?q=subscriptions[]__status:active` + + */ +export type userReportsListResponse200 = { + data: PaginatedUserReportsListResponseList + status: 200 +} + +export type userReportsListResponse400 = { + data: ErrorObject + status: 400 +} + +export type userReportsListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type userReportsListResponseComposite = + | userReportsListResponse200 + | userReportsListResponse400 + | userReportsListResponse403 + +export type userReportsListResponse = userReportsListResponseComposite & { + headers: Headers +} + +export const getUserReportsListUrl = (params?: UserReportsListParams) => { + const normalizedParams = new URLSearchParams() + + Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 ? `/api/v2/user-reports/?${stringifiedParams}` : `/api/v2/user-reports/` +} + +export const userReportsList = async ( + params?: UserReportsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getUserReportsListUrl(params), { + ...options, + method: 'GET', + }) +} + +export const getUserReportsListQueryKey = (params?: UserReportsListParams) => { + return ['api', 'v2', 'user-reports', ...(params ? [params] : [])] as const +} + +export const getUserReportsListQueryOptions = < + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + params?: UserReportsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getUserReportsListQueryKey(params) + + const queryFn: QueryFunction>> = ({ signal }) => + userReportsList(params, { signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type UserReportsListQueryResult = NonNullable>> +export type UserReportsListQueryError = ErrorObject | ErrorDetail + +export function useUserReportsList< + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + params?: UserReportsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getUserReportsListQueryOptions(params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + + query.queryKey = queryOptions.queryKey + + return query +} diff --git a/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.msw.ts b/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.msw.ts new file mode 100644 index 0000000000..3de9d07081 --- /dev/null +++ b/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.msw.ts @@ -0,0 +1,433 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import { AuthLevelEnum } from '../../models/authLevelEnum' + +import { ExportTypeEnum } from '../../models/exportTypeEnum' + +import type { Hook } from '../../models/hook' + +import type { HookLog } from '../../models/hookLog' + +import type { HookRetryResponse } from '../../models/hookRetryResponse' + +import type { LogsRetryResponse } from '../../models/logsRetryResponse' + +import type { PaginatedHookList } from '../../models/paginatedHookList' + +import type { PaginatedHookLogList } from '../../models/paginatedHookLogList' + +export const getApiV2AssetsHooksListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedHookList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksCreateResponseMock = (overrideResponse: Partial = {}): Hook => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksRetrieveResponseMock = (overrideResponse: Partial = {}): Hook => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksPartialUpdateResponseMock = (overrideResponse: Partial = {}): Hook => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksLogsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedHookLogList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + tries: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.helpers.arrayElement([0, 1, 3, 2] as const), + status_str: faker.string.alpha({ length: { min: 10, max: 20 } }), + status_code: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + message: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksLogsRetrieveResponseMock = (overrideResponse: Partial = {}): HookLog => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + tries: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.helpers.arrayElement([0, 1, 3, 2] as const), + status_str: faker.string.alpha({ length: { min: 10, max: 20 } }), + status_code: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + message: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + ...overrideResponse, +}) + +export const getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): LogsRetryResponse => ({ + detail: faker.string.alpha({ length: { min: 10, max: 20 } }), + pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksRetryPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): HookRetryResponse => ({ + detail: faker.string.alpha({ length: { min: 10, max: 20 } }), + pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsHooksListMockHandler = ( + overrideResponse?: + | PaginatedHookList + | ((info: Parameters[1]>[0]) => Promise | PaginatedHookList), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksCreateMockHandler = ( + overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), +) => { + return http.post('*/api/v2/assets/:uidAsset/hooks/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksRetrieveMockHandler = ( + overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksPartialUpdateMockHandler = ( + overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), +) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsHooksLogsListMockHandler = ( + overrideResponse?: + | PaginatedHookLogList + | ((info: Parameters[1]>[0]) => Promise | PaginatedHookLogList), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksLogsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksLogsRetrieveMockHandler = ( + overrideResponse?: HookLog | ((info: Parameters[1]>[0]) => Promise | HookLog), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksLogsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler = ( + overrideResponse?: + | LogsRetryResponse + | ((info: Parameters[1]>[0]) => Promise | LogsRetryResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsHooksRetryPartialUpdateMockHandler = ( + overrideResponse?: + | HookRetryResponse + | ((info: Parameters[1]>[0]) => Promise | HookRetryResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksRetryPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getSurveyDataRestServicesMock = () => [ + getApiV2AssetsHooksListMockHandler(), + getApiV2AssetsHooksCreateMockHandler(), + getApiV2AssetsHooksRetrieveMockHandler(), + getApiV2AssetsHooksPartialUpdateMockHandler(), + getApiV2AssetsHooksDestroyMockHandler(), + getApiV2AssetsHooksLogsListMockHandler(), + getApiV2AssetsHooksLogsRetrieveMockHandler(), + getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler(), + getApiV2AssetsHooksRetryPartialUpdateMockHandler(), +] diff --git a/jsapp/js/api/react-query/survey-data-rest-services.ts b/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.ts similarity index 61% rename from jsapp/js/api/react-query/survey-data-rest-services.ts rename to jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.ts index 7a64bb0490..61387a7e2e 100644 --- a/jsapp/js/api/react-query/survey-data-rest-services.ts +++ b/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.ts @@ -19,39 +19,31 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { AssetsHooksListParams } from '../models/assetsHooksListParams' +import type { AssetsHooksListParams } from '../../models/assetsHooksListParams' -import type { AssetsHooksLogsListParams } from '../models/assetsHooksLogsListParams' +import type { AssetsHooksLogsListParams } from '../../models/assetsHooksLogsListParams' -import type { ErrorDetail } from '../models/errorDetail' +import type { ErrorDetail } from '../../models/errorDetail' -import type { ErrorObject } from '../models/errorObject' +import type { ErrorObject } from '../../models/errorObject' -import type { PatchedHook } from '../models/patchedHook' +import type { Hook } from '../../models/hook' -import type { PatchedHookLog } from '../models/patchedHookLog' +import type { HookLog } from '../../models/hookLog' -import { faker } from '@faker-js/faker' +import type { HookRetryResponse } from '../../models/hookRetryResponse' -import { http, HttpResponse } from 'msw' +import type { LogsRetryResponse } from '../../models/logsRetryResponse' -import { AuthLevelEnum } from '../models/authLevelEnum' +import type { PaginatedHookList } from '../../models/paginatedHookList' -import { ExportTypeEnum } from '../models/exportTypeEnum' +import type { PaginatedHookLogList } from '../../models/paginatedHookLogList' -import type { Hook } from '../models/hook' +import type { PatchedHook } from '../../models/patchedHook' -import type { HookLog } from '../models/hookLog' +import type { PatchedHookLog } from '../../models/patchedHookLog' -import type { HookRetryResponse } from '../models/hookRetryResponse' - -import type { LogsRetryResponse } from '../models/logsRetryResponse' - -import type { PaginatedHookList } from '../models/paginatedHookList' - -import type { PaginatedHookLogList } from '../models/paginatedHookLogList' - -import { fetchWithAuth } from '../orval.mutator' +import { fetchWithAuth } from '../../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B @@ -970,406 +962,3 @@ export const useAssetsHooksRetryPartialUpdate = = {}, -): PaginatedHookList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), - export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), - failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - logs_url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 255 } }), - payload_template: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - settings: faker.helpers.arrayElement([ - { - password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - custom_headers: faker.helpers.arrayElement([ - { - value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value_field_2: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - subset_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksCreateResponseMock = (overrideResponse: Partial = {}): Hook => ({ - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), - export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), - failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - logs_url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 255 } }), - payload_template: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - settings: faker.helpers.arrayElement([ - { - password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - custom_headers: faker.helpers.arrayElement([ - { - value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - subset_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksRetrieveResponseMock = (overrideResponse: Partial = {}): Hook => ({ - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), - export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), - failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - logs_url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 255 } }), - payload_template: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - settings: faker.helpers.arrayElement([ - { - password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - custom_headers: faker.helpers.arrayElement([ - { - value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - subset_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksPartialUpdateResponseMock = (overrideResponse: Partial = {}): Hook => ({ - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), - export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), - failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - logs_url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 255 } }), - payload_template: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - settings: faker.helpers.arrayElement([ - { - password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - custom_headers: faker.helpers.arrayElement([ - { - value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - subset_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksLogsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedHookLogList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - tries: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.helpers.arrayElement([0, 1, 3, 2] as const), - status_str: faker.string.alpha({ length: { min: 10, max: 20 } }), - status_code: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - message: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksLogsRetrieveResponseMock = (overrideResponse: Partial = {}): HookLog => ({ - url: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - tries: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.helpers.arrayElement([0, 1, 3, 2] as const), - status_str: faker.string.alpha({ length: { min: 10, max: 20 } }), - status_code: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - message: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - ...overrideResponse, -}) - -export const getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): LogsRetryResponse => ({ - detail: faker.string.alpha({ length: { min: 10, max: 20 } }), - pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksRetryPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): HookRetryResponse => ({ - detail: faker.string.alpha({ length: { min: 10, max: 20 } }), - pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksListMockHandler = ( - overrideResponse?: - | PaginatedHookList - | ((info: Parameters[1]>[0]) => Promise | PaginatedHookList), -) => { - return http.get('*/api/v2/assets/:uidAsset/hooks{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksCreateMockHandler = ( - overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), -) => { - return http.post('*/api/v2/assets/:uidAsset/hooks{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksRetrieveMockHandler = ( - overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), -) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksPartialUpdateMockHandler = ( - overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), -) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsHooksLogsListMockHandler = ( - overrideResponse?: - | PaginatedHookLogList - | ((info: Parameters[1]>[0]) => Promise | PaginatedHookLogList), -) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksLogsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksLogsRetrieveMockHandler = ( - overrideResponse?: HookLog | ((info: Parameters[1]>[0]) => Promise | HookLog), -) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksLogsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler = ( - overrideResponse?: - | LogsRetryResponse - | ((info: Parameters[1]>[0]) => Promise | LogsRetryResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksRetryPartialUpdateMockHandler = ( - overrideResponse?: - | HookRetryResponse - | ((info: Parameters[1]>[0]) => Promise | HookRetryResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksRetryPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getSurveyDataRestServicesMock = () => [ - getApiV2AssetsHooksListMockHandler(), - getApiV2AssetsHooksCreateMockHandler(), - getApiV2AssetsHooksRetrieveMockHandler(), - getApiV2AssetsHooksPartialUpdateMockHandler(), - getApiV2AssetsHooksDestroyMockHandler(), - getApiV2AssetsHooksLogsListMockHandler(), - getApiV2AssetsHooksLogsRetrieveMockHandler(), - getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler(), - getApiV2AssetsHooksRetryPartialUpdateMockHandler(), -] diff --git a/jsapp/js/api/react-query/survey-data/survey-data.msw.ts b/jsapp/js/api/react-query/survey-data/survey-data.msw.ts new file mode 100644 index 0000000000..081c1eb882 --- /dev/null +++ b/jsapp/js/api/react-query/survey-data/survey-data.msw.ts @@ -0,0 +1,3020 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import { ActionEnum } from '../../models/actionEnum' + +import { ActionIdEnum } from '../../models/actionIdEnum' + +import type { AdvancedFeatureCreateResponse } from '../../models/advancedFeatureCreateResponse' + +import type { AdvancedFeatureResponse } from '../../models/advancedFeatureResponse' + +import type { AssetAttachmentAudioDurationResponse } from '../../models/assetAttachmentAudioDurationResponse' + +import type { BulkAcceptResponse } from '../../models/bulkAcceptResponse' + +import type { BulkActionCreateResponse } from '../../models/bulkActionCreateResponse' + +import type { BulkActionListResponse } from '../../models/bulkActionListResponse' + +import type { BulkActionResponse } from '../../models/bulkActionResponse' + +import { BulkActionResponseStatusEnum } from '../../models/bulkActionResponseStatusEnum' + +import { BulkActionSubmissionStatusResponseStatusEnum } from '../../models/bulkActionSubmissionStatusResponseStatusEnum' + +import type { DataBulkUpdateResponse } from '../../models/dataBulkUpdateResponse' + +import type { DataResponse } from '../../models/dataResponse' + +import type { DataStatusesUpdate } from '../../models/dataStatusesUpdate' + +import type { DataSupplementAutomaticQualDataIntegerResponse } from '../../models/dataSupplementAutomaticQualDataIntegerResponse' + +import type { DataSupplementAutomaticQualDataSelectMultipleResponse } from '../../models/dataSupplementAutomaticQualDataSelectMultipleResponse' + +import type { DataSupplementAutomaticQualDataSelectOneResponse } from '../../models/dataSupplementAutomaticQualDataSelectOneResponse' + +import type { DataSupplementAutomaticQualDataTextResponse } from '../../models/dataSupplementAutomaticQualDataTextResponse' + +import type { DataSupplementManualQualDataInteger } from '../../models/dataSupplementManualQualDataInteger' + +import type { DataSupplementManualQualDataSelectMultiple } from '../../models/dataSupplementManualQualDataSelectMultiple' + +import type { DataSupplementManualQualDataSelectOne } from '../../models/dataSupplementManualQualDataSelectOne' + +import type { DataSupplementManualQualDataTags } from '../../models/dataSupplementManualQualDataTags' + +import type { DataSupplementManualQualDataText } from '../../models/dataSupplementManualQualDataText' + +import type { DataSupplementResponse } from '../../models/dataSupplementResponse' + +import type { DataValidationStatus } from '../../models/dataValidationStatus' + +import { DataValidationStatusLabelEnum } from '../../models/dataValidationStatusLabelEnum' + +import { DataValidationStatusUidEnum } from '../../models/dataValidationStatusUidEnum' + +import type { DataValidationStatusUpdateResponse } from '../../models/dataValidationStatusUpdateResponse' + +import type { EnketoEditResponse } from '../../models/enketoEditResponse' + +import type { EnketoViewResponse } from '../../models/enketoViewResponse' + +import type { ExportResponse } from '../../models/exportResponse' + +import type { ExportSettingResponse } from '../../models/exportSettingResponse' + +import type { ExternalResponse } from '../../models/externalResponse' + +import type { FilesResponse } from '../../models/filesResponse' + +import type { PaginatedDataResponseList } from '../../models/paginatedDataResponseList' + +import type { PaginatedExportResponseList } from '../../models/paginatedExportResponseList' + +import type { PaginatedExportSettingResponseList } from '../../models/paginatedExportSettingResponseList' + +import type { PaginatedFilesResponseList } from '../../models/paginatedFilesResponseList' + +import type { PaginatedPairedDataResponseList } from '../../models/paginatedPairedDataResponseList' + +import type { PairedDataResponse } from '../../models/pairedDataResponse' + +import { QualSelectQuestionParamsTypeEnum } from '../../models/qualSelectQuestionParamsTypeEnum' + +import { QualSimpleQuestionParamsTypeEnum } from '../../models/qualSimpleQuestionParamsTypeEnum' + +import type { ReportResponse } from '../../models/reportResponse' + +import type { SupplementalDataContentAutomaticComplete } from '../../models/supplementalDataContentAutomaticComplete' + +import type { SupplementalDataContentAutomaticDeleted } from '../../models/supplementalDataContentAutomaticDeleted' + +import type { SupplementalDataContentAutomaticFailed } from '../../models/supplementalDataContentAutomaticFailed' + +import type { SupplementalDataContentAutomaticInProgress } from '../../models/supplementalDataContentAutomaticInProgress' + +export const getApiV2AssetsAdvancedFeaturesListResponseMock = (): AdvancedFeatureResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsAdvancedFeaturesCreateResponseMock = ( + overrideResponse: Partial = {}, +): AdvancedFeatureCreateResponse => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AdvancedFeatureResponse => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): AdvancedFeatureResponse => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionListResponse => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + previous: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionCreateResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + skipped_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsAttachmentsAudioDurationCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetAttachmentAudioDurationResponse => ({ + attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + seconds: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + })), + total: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataValidationStatusMock = ( + overrideResponse: Partial = {}, +): DataValidationStatus => ({ + ...{ + timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticInProgress => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'in_progress', + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticFailed => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'failed', + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticComplete => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'complete', + value: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticDeleted => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'deleted', + value: null, + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataInteger => ({ + ...{ + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataText => ({ + ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectOne => ({ + ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectMultiple => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataTags => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataIntegerResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataTextResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectOneResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedDataResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + download_url: faker.internet.url(), + download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), + media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + _status: faker.string.alpha({ length: { min: 10, max: 20 } }), + _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), + ), + _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + _validation_status: faker.helpers.arrayElement([{ ...getApiV2AssetsDataListResponseDataValidationStatusMock() }]), + _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), + _supplementalDetails: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + { + [faker.string.alphanumeric(5)]: { + manual_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + _dependency: faker.helpers.arrayElement([ + { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, + undefined, + ]), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + ]), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataValidationStatusMock = ( + overrideResponse: Partial = {}, +): DataValidationStatus => ({ + ...{ + timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticInProgress => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'in_progress', + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticFailed => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'failed', + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticComplete => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'complete', + value: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticDeleted => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'deleted', + value: null, + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataInteger => ({ + ...{ + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataText => ({ + ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectOne => ({ + ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectMultiple => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataTags => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataIntegerResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataTextResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectOneResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseMock = (overrideResponse: Partial = {}): DataResponse => ({ + _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + download_url: faker.internet.url(), + download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), + media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + _status: faker.string.alpha({ length: { min: 10, max: 20 } }), + _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), + ), + _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + _validation_status: faker.helpers.arrayElement([{ ...getApiV2AssetsDataRetrieveResponseDataValidationStatusMock() }]), + _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), + _supplementalDetails: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + { + [faker.string.alphanumeric(5)]: { + manual_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + _dependency: faker.helpers.arrayElement([ + { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, + undefined, + ]), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + ]), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock = ( + overrideResponse: Partial = {}, +): DataValidationStatus => ({ + ...{ + timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticInProgress => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'in_progress', + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticFailed => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'failed', + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticComplete => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'complete', + value: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticDeleted => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'deleted', + value: null, + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataInteger => ({ + ...{ + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataText => ({ + ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectOne => ({ + ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectMultiple => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataTags => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataIntegerResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataTextResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectOneResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseMock = ( + overrideResponse: Partial = {}, +): DataResponse => ({ + _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + download_url: faker.internet.url(), + download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), + media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + _status: faker.string.alpha({ length: { min: 10, max: 20 } }), + _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), + ), + _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + _validation_status: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock() }, + ]), + _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), + _supplementalDetails: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + { + [faker.string.alphanumeric(5)]: { + manual_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock() }, + { + ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock(), + }, + { + ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock(), + }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + _dependency: faker.helpers.arrayElement([ + { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, + undefined, + ]), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + ]), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEditRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoEditResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoEditRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoEditResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoEditResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoViewResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoViewRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoViewResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataValidationStatusRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): DataValidationStatusUpdateResponse => ({ + timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataValidationStatusPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataValidationStatusUpdateResponse => ({ + timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataSupplementRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AssetsDataSupplementPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AssetsDataBulkPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataBulkUpdateResponse => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + successes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + failures: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status_code: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsDataSupplementsBulkCreateResponseMock = ( + overrideResponse: Partial = {}, +): BulkAcceptResponse => ({ + accepted_count: faker.number.int({ min: 0, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataStatusesUpdate => ({ detail: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AssetsExportSettingsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedExportSettingResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsExportSettingsCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportSettingResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportSettingsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExportSettingResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportSettingsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): ExportSettingResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedExportResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + message: {}, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + result: faker.internet.url(), + data: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source: faker.helpers.arrayElement([faker.internet.url(), undefined]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + processing_time_seconds: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsExportsCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportResponse => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + message: {}, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + result: faker.internet.url(), + data: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source: faker.helpers.arrayElement([faker.internet.url(), undefined]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + processing_time_seconds: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExportResponse => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + message: {}, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + result: faker.internet.url(), + data: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source: faker.helpers.arrayElement([faker.internet.url(), undefined]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + processing_time_seconds: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsFilesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedFilesResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + asset: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + description: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: faker.internet.url(), + metadata: { + hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsFilesCreateResponseMock = ( + overrideResponse: Partial = {}, +): FilesResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + asset: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + description: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: faker.internet.url(), + metadata: { + hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsFilesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): FilesResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + asset: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + description: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: faker.internet.url(), + metadata: { + hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedPairedDataResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataCreateResponseMock = ( + overrideResponse: Partial = {}, +): PairedDataResponse => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PairedDataResponse => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): PairedDataResponse => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataExternalRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExternalResponse => ({ + root: { + data: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + field_value_1: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + field_value_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsReportsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ReportResponse => ({ + url: faker.internet.url(), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + list: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + row: faker.helpers.arrayElement([ + { type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + data: faker.helpers.arrayElement([ + { + total_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + not_provided: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + provided: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + show_graph: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([{}, undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesListMockHandler = ( + overrideResponse?: + | AdvancedFeatureResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureResponse[]), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesCreateMockHandler = ( + overrideResponse?: + | AdvancedFeatureCreateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureCreateResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesRetrieveMockHandler = ( + overrideResponse?: + | AdvancedFeatureResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler = ( + overrideResponse?: + | AdvancedFeatureResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler = ( + overrideResponse?: + | BulkActionListResponse + | (( + info: Parameters[1]>[0], + ) => Promise | BulkActionListResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler = ( + overrideResponse?: + | BulkActionCreateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | BulkActionCreateResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler = ( + overrideResponse?: + | BulkActionResponse + | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = ( + overrideResponse?: + | BulkActionResponse + | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAttachmentsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/attachments/:id/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = ( + overrideResponse?: + | AssetAttachmentAudioDurationResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetAttachmentAudioDurationResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAttachmentsAudioDurationCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsAttachmentsBulkDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 202 }) + }) +} + +export const getApiV2AssetsDataListMockHandler = ( + overrideResponse?: + | PaginatedDataResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedDataResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataRetrieveMockHandler = ( + overrideResponse?: + | DataResponse + | ((info: Parameters[1]>[0]) => Promise | DataResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsDataDuplicateCreateMockHandler = ( + overrideResponse?: + | DataResponse + | ((info: Parameters[1]>[0]) => Promise | DataResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataDuplicateCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataEditRetrieveMockHandler = ( + overrideResponse?: + | EnketoEditResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/edit/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEditRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataEnketoEditRetrieveMockHandler = ( + overrideResponse?: + | EnketoEditResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoEditRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler = ( + overrideResponse?: + | EnketoEditResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler = ( + overrideResponse?: + | EnketoViewResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataEnketoViewRetrieveMockHandler = ( + overrideResponse?: + | EnketoViewResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoViewRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataValidationStatusRetrieveMockHandler = ( + overrideResponse?: + | DataValidationStatusUpdateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataValidationStatusUpdateResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataValidationStatusRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = ( + overrideResponse?: + | DataValidationStatusUpdateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataValidationStatusUpdateResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataValidationStatusPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataValidationStatusDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsDataSupplementRetrieveMockHandler = ( + overrideResponse?: + | DataSupplementResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataSupplementResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataSupplementRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = ( + overrideResponse?: + | DataSupplementResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataSupplementResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataSupplementPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataAttachmentsListMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getAttachmentRetrieveMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getAttachmentThumbnailMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AssetsDataBulkPartialUpdateMockHandler = ( + overrideResponse?: + | DataBulkUpdateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataBulkUpdateResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataBulkPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataBulkDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AssetsDataSupplementsBulkCreateMockHandler = ( + overrideResponse?: + | BulkAcceptResponse + | ((info: Parameters[1]>[0]) => Promise | BulkAcceptResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataSupplementsBulkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = ( + overrideResponse?: + | DataStatusesUpdate + | ((info: Parameters[1]>[0]) => Promise | DataStatusesUpdate), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsDataValidationStatusesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsExportSettingsListMockHandler = ( + overrideResponse?: + | PaginatedExportSettingResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedExportSettingResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportSettingsCreateMockHandler = ( + overrideResponse?: + | ExportSettingResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ExportSettingResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportSettingsRetrieveMockHandler = ( + overrideResponse?: + | ExportSettingResponse + | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = ( + overrideResponse?: + | ExportSettingResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ExportSettingResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportSettingsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsExportSettingsDataRetrieveMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AssetsExportsListMockHandler = ( + overrideResponse?: + | PaginatedExportResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedExportResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/exports/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportsCreateMockHandler = ( + overrideResponse?: + | ExportResponse + | ((info: Parameters[1]>[0]) => Promise | ExportResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/exports/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportsRetrieveMockHandler = ( + overrideResponse?: + | ExportResponse + | ((info: Parameters[1]>[0]) => Promise | ExportResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsExportsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsFilesListMockHandler = ( + overrideResponse?: + | PaginatedFilesResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedFilesResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/files/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsFilesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsFilesCreateMockHandler = ( + overrideResponse?: + | FilesResponse + | ((info: Parameters[1]>[0]) => Promise | FilesResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/files/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsFilesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsFilesRetrieveMockHandler = ( + overrideResponse?: + | FilesResponse + | ((info: Parameters[1]>[0]) => Promise | FilesResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsFilesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsFilesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsFilesContentRetrieveMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) + }) +} + +export const getApiV2AssetsPairedDataListMockHandler = ( + overrideResponse?: + | PaginatedPairedDataResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedPairedDataResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPairedDataCreateMockHandler = ( + overrideResponse?: + | PairedDataResponse + | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPairedDataRetrieveMockHandler = ( + overrideResponse?: + | PairedDataResponse + | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPairedDataPartialUpdateMockHandler = ( + overrideResponse?: + | PairedDataResponse + | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsPairedDataDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = ( + overrideResponse?: + | ExternalResponse + | ((info: Parameters[1]>[0]) => Promise | ExternalResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataExternalRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2AssetsReportsRetrieveMockHandler = ( + overrideResponse?: + | ReportResponse + | ((info: Parameters[1]>[0]) => Promise | ReportResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/reports/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsReportsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} +export const getSurveyDataMock = () => [ + getApiV2AssetsAdvancedFeaturesListMockHandler(), + getApiV2AssetsAdvancedFeaturesCreateMockHandler(), + getApiV2AssetsAdvancedFeaturesRetrieveMockHandler(), + getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler(), + getApiV2AssetsAttachmentsDestroyMockHandler(), + getApiV2AssetsAttachmentsAudioDurationCreateMockHandler(), + getApiV2AssetsAttachmentsBulkDestroyMockHandler(), + getApiV2AssetsDataListMockHandler(), + getApiV2AssetsDataRetrieveMockHandler(), + getApiV2AssetsDataDestroyMockHandler(), + getApiV2AssetsDataDuplicateCreateMockHandler(), + getApiV2AssetsDataEditRetrieveMockHandler(), + getApiV2AssetsDataEnketoEditRetrieveMockHandler(), + getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler(), + getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler(), + getApiV2AssetsDataEnketoViewRetrieveMockHandler(), + getApiV2AssetsDataValidationStatusRetrieveMockHandler(), + getApiV2AssetsDataValidationStatusPartialUpdateMockHandler(), + getApiV2AssetsDataValidationStatusDestroyMockHandler(), + getApiV2AssetsDataSupplementRetrieveMockHandler(), + getApiV2AssetsDataSupplementPartialUpdateMockHandler(), + getApiV2AssetsDataAttachmentsListMockHandler(), + getAttachmentRetrieveMockHandler(), + getAttachmentThumbnailMockHandler(), + getApiV2AssetsDataBulkPartialUpdateMockHandler(), + getApiV2AssetsDataBulkDestroyMockHandler(), + getApiV2AssetsDataSupplementsBulkCreateMockHandler(), + getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler(), + getApiV2AssetsDataValidationStatusesDestroyMockHandler(), + getApiV2AssetsExportSettingsListMockHandler(), + getApiV2AssetsExportSettingsCreateMockHandler(), + getApiV2AssetsExportSettingsRetrieveMockHandler(), + getApiV2AssetsExportSettingsPartialUpdateMockHandler(), + getApiV2AssetsExportSettingsDestroyMockHandler(), + getApiV2AssetsExportSettingsDataRetrieveMockHandler(), + getApiV2AssetsExportsListMockHandler(), + getApiV2AssetsExportsCreateMockHandler(), + getApiV2AssetsExportsRetrieveMockHandler(), + getApiV2AssetsExportsDestroyMockHandler(), + getApiV2AssetsFilesListMockHandler(), + getApiV2AssetsFilesCreateMockHandler(), + getApiV2AssetsFilesRetrieveMockHandler(), + getApiV2AssetsFilesDestroyMockHandler(), + getApiV2AssetsFilesContentRetrieveMockHandler(), + getApiV2AssetsPairedDataListMockHandler(), + getApiV2AssetsPairedDataCreateMockHandler(), + getApiV2AssetsPairedDataRetrieveMockHandler(), + getApiV2AssetsPairedDataPartialUpdateMockHandler(), + getApiV2AssetsPairedDataDestroyMockHandler(), + getApiV2AssetsPairedDataExternalRetrieveMockHandler(), + getApiV2AssetsReportsRetrieveMockHandler(), +] diff --git a/jsapp/js/api/react-query/survey-data.ts b/jsapp/js/api/react-query/survey-data/survey-data.ts similarity index 59% rename from jsapp/js/api/react-query/survey-data.ts rename to jsapp/js/api/react-query/survey-data/survey-data.ts index bf9bae8854..a5852dc26e 100644 --- a/jsapp/js/api/react-query/survey-data.ts +++ b/jsapp/js/api/react-query/survey-data/survey-data.ts @@ -19,163 +19,115 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { AdvancedFeaturePostRequest } from '../models/advancedFeaturePostRequest' +import type { AdvancedFeatureCreateResponse } from '../../models/advancedFeatureCreateResponse' -import type { AssetAttachmentAudioDurationRequest } from '../models/assetAttachmentAudioDurationRequest' +import type { AdvancedFeaturePostRequest } from '../../models/advancedFeaturePostRequest' -import type { AssetsAdvancedFeaturesBulkActionsListParams } from '../models/assetsAdvancedFeaturesBulkActionsListParams' +import type { AdvancedFeatureResponse } from '../../models/advancedFeatureResponse' -import type { AssetsDataAttachmentsListParams } from '../models/assetsDataAttachmentsListParams' +import type { AssetAttachmentAudioDurationRequest } from '../../models/assetAttachmentAudioDurationRequest' -import type { AssetsDataListParams } from '../models/assetsDataListParams' +import type { AssetAttachmentAudioDurationResponse } from '../../models/assetAttachmentAudioDurationResponse' -import type { AssetsDataRetrieveParams } from '../models/assetsDataRetrieveParams' +import type { AssetsAdvancedFeaturesBulkActionsListParams } from '../../models/assetsAdvancedFeaturesBulkActionsListParams' -import type { AssetsExportSettingsDataRetrieveParams } from '../models/assetsExportSettingsDataRetrieveParams' +import type { AssetsDataAttachmentsListParams } from '../../models/assetsDataAttachmentsListParams' -import type { AssetsExportSettingsListParams } from '../models/assetsExportSettingsListParams' +import type { AssetsDataListParams } from '../../models/assetsDataListParams' -import type { AssetsExportsListParams } from '../models/assetsExportsListParams' +import type { AssetsDataRetrieveParams } from '../../models/assetsDataRetrieveParams' -import type { AssetsFilesListParams } from '../models/assetsFilesListParams' +import type { AssetsExportSettingsDataRetrieveParams } from '../../models/assetsExportSettingsDataRetrieveParams' -import type { AssetsPairedDataListParams } from '../models/assetsPairedDataListParams' +import type { AssetsExportSettingsListParams } from '../../models/assetsExportSettingsListParams' -import type { AttachmentRetrieveParams } from '../models/attachmentRetrieveParams' +import type { AssetsExportsListParams } from '../../models/assetsExportsListParams' -import type { BulkAcceptRequest } from '../models/bulkAcceptRequest' +import type { AssetsFilesListParams } from '../../models/assetsFilesListParams' -import type { BulkActionCreateRequest } from '../models/bulkActionCreateRequest' +import type { AssetsPairedDataListParams } from '../../models/assetsPairedDataListParams' -import type { CreateFilePayload } from '../models/createFilePayload' +import type { AttachmentRetrieveParams } from '../../models/attachmentRetrieveParams' -import type { DataBulkDelete } from '../models/dataBulkDelete' +import type { BulkAcceptRequest } from '../../models/bulkAcceptRequest' -import type { ErrorDetail } from '../models/errorDetail' +import type { BulkAcceptResponse } from '../../models/bulkAcceptResponse' -import type { ErrorObject } from '../models/errorObject' +import type { BulkActionCreateRequest } from '../../models/bulkActionCreateRequest' -import type { ExportCreatePayload } from '../models/exportCreatePayload' +import type { BulkActionCreateResponse } from '../../models/bulkActionCreateResponse' -import type { ExportSettingCreatePayload } from '../models/exportSettingCreatePayload' +import type { BulkActionListResponse } from '../../models/bulkActionListResponse' -import type { PairedData } from '../models/pairedData' +import type { BulkActionResponse } from '../../models/bulkActionResponse' -import type { PatchedAdvancedFeaturePatchRequest } from '../models/patchedAdvancedFeaturePatchRequest' +import type { CreateFilePayload } from '../../models/createFilePayload' -import type { PatchedBulkActionPatchRequest } from '../models/patchedBulkActionPatchRequest' +import type { DataBulkDelete } from '../../models/dataBulkDelete' -import type { PatchedDataBulkUpdate } from '../models/patchedDataBulkUpdate' +import type { DataBulkUpdateResponse } from '../../models/dataBulkUpdateResponse' -import type { PatchedDataSupplementPayload } from '../models/patchedDataSupplementPayload' +import type { DataResponse } from '../../models/dataResponse' -import type { PatchedDataValidationStatusUpdatePayload } from '../models/patchedDataValidationStatusUpdatePayload' +import type { DataStatusesUpdate } from '../../models/dataStatusesUpdate' -import type { PatchedDataValidationStatusesUpdatePayload } from '../models/patchedDataValidationStatusesUpdatePayload' +import type { DataSupplementResponse } from '../../models/dataSupplementResponse' -import type { PatchedExportSettingUpdatePayload } from '../models/patchedExportSettingUpdatePayload' +import type { DataValidationStatusUpdateResponse } from '../../models/dataValidationStatusUpdateResponse' -import type { PatchedPairedDataPatchPayload } from '../models/patchedPairedDataPatchPayload' +import type { EnketoEditResponse } from '../../models/enketoEditResponse' -import { faker } from '@faker-js/faker' +import type { EnketoViewResponse } from '../../models/enketoViewResponse' -import { http, HttpResponse } from 'msw' +import type { ErrorDetail } from '../../models/errorDetail' -import { ActionEnum } from '../models/actionEnum' +import type { ErrorObject } from '../../models/errorObject' -import { ActionIdEnum } from '../models/actionIdEnum' +import type { ExportCreatePayload } from '../../models/exportCreatePayload' -import type { AdvancedFeatureCreateResponse } from '../models/advancedFeatureCreateResponse' +import type { ExportResponse } from '../../models/exportResponse' -import type { AdvancedFeatureResponse } from '../models/advancedFeatureResponse' +import type { ExportSettingCreatePayload } from '../../models/exportSettingCreatePayload' -import type { AssetAttachmentAudioDurationResponse } from '../models/assetAttachmentAudioDurationResponse' +import type { ExportSettingResponse } from '../../models/exportSettingResponse' -import type { BulkAcceptResponse } from '../models/bulkAcceptResponse' +import type { ExternalResponse } from '../../models/externalResponse' -import type { BulkActionCreateResponse } from '../models/bulkActionCreateResponse' +import type { FilesResponse } from '../../models/filesResponse' -import type { BulkActionListResponse } from '../models/bulkActionListResponse' +import type { PaginatedDataResponseList } from '../../models/paginatedDataResponseList' -import type { BulkActionResponse } from '../models/bulkActionResponse' +import type { PaginatedExportResponseList } from '../../models/paginatedExportResponseList' -import { BulkActionResponseStatusEnum } from '../models/bulkActionResponseStatusEnum' +import type { PaginatedExportSettingResponseList } from '../../models/paginatedExportSettingResponseList' -import { BulkActionSubmissionStatusResponseStatusEnum } from '../models/bulkActionSubmissionStatusResponseStatusEnum' +import type { PaginatedFilesResponseList } from '../../models/paginatedFilesResponseList' -import type { DataBulkUpdateResponse } from '../models/dataBulkUpdateResponse' +import type { PaginatedPairedDataResponseList } from '../../models/paginatedPairedDataResponseList' -import type { DataResponse } from '../models/dataResponse' +import type { PairedData } from '../../models/pairedData' -import type { DataStatusesUpdate } from '../models/dataStatusesUpdate' +import type { PairedDataResponse } from '../../models/pairedDataResponse' -import type { DataSupplementAutomaticQualDataIntegerResponse } from '../models/dataSupplementAutomaticQualDataIntegerResponse' +import type { PatchedAdvancedFeaturePatchRequest } from '../../models/patchedAdvancedFeaturePatchRequest' -import type { DataSupplementAutomaticQualDataSelectMultipleResponse } from '../models/dataSupplementAutomaticQualDataSelectMultipleResponse' +import type { PatchedBulkActionPatchRequest } from '../../models/patchedBulkActionPatchRequest' -import type { DataSupplementAutomaticQualDataSelectOneResponse } from '../models/dataSupplementAutomaticQualDataSelectOneResponse' +import type { PatchedDataBulkUpdate } from '../../models/patchedDataBulkUpdate' -import type { DataSupplementAutomaticQualDataTextResponse } from '../models/dataSupplementAutomaticQualDataTextResponse' +import type { PatchedDataSupplementPayload } from '../../models/patchedDataSupplementPayload' -import type { DataSupplementManualQualDataInteger } from '../models/dataSupplementManualQualDataInteger' +import type { PatchedDataValidationStatusUpdatePayload } from '../../models/patchedDataValidationStatusUpdatePayload' -import type { DataSupplementManualQualDataSelectMultiple } from '../models/dataSupplementManualQualDataSelectMultiple' +import type { PatchedDataValidationStatusesUpdatePayload } from '../../models/patchedDataValidationStatusesUpdatePayload' -import type { DataSupplementManualQualDataSelectOne } from '../models/dataSupplementManualQualDataSelectOne' +import type { PatchedExportSettingUpdatePayload } from '../../models/patchedExportSettingUpdatePayload' -import type { DataSupplementManualQualDataTags } from '../models/dataSupplementManualQualDataTags' +import type { PatchedPairedDataPatchPayload } from '../../models/patchedPairedDataPatchPayload' -import type { DataSupplementManualQualDataText } from '../models/dataSupplementManualQualDataText' +import type { ReportResponse } from '../../models/reportResponse' -import type { DataSupplementResponse } from '../models/dataSupplementResponse' - -import type { DataValidationStatus } from '../models/dataValidationStatus' - -import { DataValidationStatusLabelEnum } from '../models/dataValidationStatusLabelEnum' - -import { DataValidationStatusUidEnum } from '../models/dataValidationStatusUidEnum' - -import type { DataValidationStatusUpdateResponse } from '../models/dataValidationStatusUpdateResponse' - -import type { EnketoEditResponse } from '../models/enketoEditResponse' - -import type { EnketoViewResponse } from '../models/enketoViewResponse' - -import type { ExportResponse } from '../models/exportResponse' - -import type { ExportSettingResponse } from '../models/exportSettingResponse' - -import type { ExternalResponse } from '../models/externalResponse' - -import type { FilesResponse } from '../models/filesResponse' - -import type { PaginatedDataResponseList } from '../models/paginatedDataResponseList' - -import type { PaginatedExportResponseList } from '../models/paginatedExportResponseList' - -import type { PaginatedExportSettingResponseList } from '../models/paginatedExportSettingResponseList' - -import type { PaginatedFilesResponseList } from '../models/paginatedFilesResponseList' - -import type { PaginatedPairedDataResponseList } from '../models/paginatedPairedDataResponseList' - -import type { PairedDataResponse } from '../models/pairedDataResponse' - -import { QualSelectQuestionParamsTypeEnum } from '../models/qualSelectQuestionParamsTypeEnum' - -import { QualSimpleQuestionParamsTypeEnum } from '../models/qualSimpleQuestionParamsTypeEnum' - -import type { ReportResponse } from '../models/reportResponse' - -import type { SupplementalDataContentAutomaticComplete } from '../models/supplementalDataContentAutomaticComplete' - -import type { SupplementalDataContentAutomaticDeleted } from '../models/supplementalDataContentAutomaticDeleted' - -import type { SupplementalDataContentAutomaticFailed } from '../models/supplementalDataContentAutomaticFailed' - -import type { SupplementalDataContentAutomaticInProgress } from '../models/supplementalDataContentAutomaticInProgress' - -import { fetchWithAuth } from '../orval.mutator' +import { fetchWithAuth } from '../../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B @@ -6203,2917 +6155,3 @@ export function useAssetsReportsRetrieve< return query } - -export const getApiV2AssetsAdvancedFeaturesListResponseMock = (): AdvancedFeatureResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.helpers.arrayElement(Object.values(ActionEnum)), - params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.uuid(), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - })), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - ]), - { uuid: faker.string.uuid() }, - ]), - ), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2AssetsAdvancedFeaturesCreateResponseMock = ( - overrideResponse: Partial = {}, -): AdvancedFeatureCreateResponse => ({ - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.helpers.arrayElement(Object.values(ActionEnum)), - params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - hint: faker.helpers.arrayElement([{}, undefined]), - }, - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.uuid(), - hint: faker.helpers.arrayElement([{}, undefined]), - })), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - ]), - { uuid: faker.string.uuid() }, - ]), - ), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AdvancedFeatureResponse => ({ - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.helpers.arrayElement(Object.values(ActionEnum)), - params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.uuid(), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - })), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - ]), - { uuid: faker.string.uuid() }, - ]), - ), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): AdvancedFeatureResponse => ({ - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.helpers.arrayElement(Object.values(ActionEnum)), - params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.uuid(), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - })), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - ]), - { uuid: faker.string.uuid() }, - ]), - ), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock = ( - overrideResponse: Partial = {}, -): BulkActionListResponse => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - previous: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), - action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - params: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), - created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - cancelled_by: faker.helpers.arrayElement([ - { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock = ( - overrideResponse: Partial = {}, -): BulkActionCreateResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), - action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - params: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), - created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - cancelled_by: faker.helpers.arrayElement([ - { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, - undefined, - ]), - skipped_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): BulkActionResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), - action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - params: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), - created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - cancelled_by: faker.helpers.arrayElement([ - { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): BulkActionResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), - action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - params: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), - created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - cancelled_by: faker.helpers.arrayElement([ - { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsAttachmentsAudioDurationCreateResponseMock = ( - overrideResponse: Partial = {}, -): AssetAttachmentAudioDurationResponse => ({ - attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - seconds: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - })), - total: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataValidationStatusMock = ( - overrideResponse: Partial = {}, -): DataValidationStatus => ({ - ...{ - timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), - by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticInProgress => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'in_progress', - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticFailed => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'failed', - error: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticComplete => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'complete', - value: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticDeleted => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'deleted', - value: null, - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataInteger => ({ - ...{ - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataText => ({ - ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectOne => ({ - ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectMultiple => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataTags => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataIntegerResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataTextResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectOneResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedDataResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - download_url: faker.internet.url(), - download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), - media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - _status: faker.string.alpha({ length: { min: 10, max: 20 } }), - _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), - ), - _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - _validation_status: faker.helpers.arrayElement([{ ...getApiV2AssetsDataListResponseDataValidationStatusMock() }]), - _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), - _supplementalDetails: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - { - [faker.string.alphanumeric(5)]: { - manual_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock() }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_bedrock_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock() }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - _dependency: faker.helpers.arrayElement([ - { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, - undefined, - ]), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - ]), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataValidationStatusMock = ( - overrideResponse: Partial = {}, -): DataValidationStatus => ({ - ...{ - timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), - by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticInProgress => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'in_progress', - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticFailed => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'failed', - error: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticComplete => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'complete', - value: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticDeleted => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'deleted', - value: null, - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataInteger => ({ - ...{ - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataText => ({ - ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectOne => ({ - ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectMultiple => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataTags => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataIntegerResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataTextResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectOneResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseMock = (overrideResponse: Partial = {}): DataResponse => ({ - _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - download_url: faker.internet.url(), - download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), - media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - _status: faker.string.alpha({ length: { min: 10, max: 20 } }), - _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), - ), - _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - _validation_status: faker.helpers.arrayElement([{ ...getApiV2AssetsDataRetrieveResponseDataValidationStatusMock() }]), - _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), - _supplementalDetails: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - { - [faker.string.alphanumeric(5)]: { - manual_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock() }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_bedrock_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock() }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - _dependency: faker.helpers.arrayElement([ - { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, - undefined, - ]), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - ]), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock = ( - overrideResponse: Partial = {}, -): DataValidationStatus => ({ - ...{ - timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), - by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticInProgress => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'in_progress', - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticFailed => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'failed', - error: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticComplete => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'complete', - value: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticDeleted => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'deleted', - value: null, - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataInteger => ({ - ...{ - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataText => ({ - ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectOne => ({ - ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectMultiple => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataTags => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataIntegerResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataTextResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectOneResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseMock = ( - overrideResponse: Partial = {}, -): DataResponse => ({ - _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - download_url: faker.internet.url(), - download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), - media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - _status: faker.string.alpha({ length: { min: 10, max: 20 } }), - _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), - ), - _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - _validation_status: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock() }, - ]), - _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), - _supplementalDetails: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - { - [faker.string.alphanumeric(5)]: { - manual_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock() }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_bedrock_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock() }, - { - ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock(), - }, - { - ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock(), - }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - _dependency: faker.helpers.arrayElement([ - { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, - undefined, - ]), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - ]), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataEditRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnketoEditResponse => ({ - url: faker.internet.url(), - version: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataEnketoEditRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnketoEditResponse => ({ - url: faker.internet.url(), - version: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnketoEditResponse => ({ - url: faker.internet.url(), - version: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnketoViewResponse => ({ - url: faker.internet.url(), - version: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataEnketoViewRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnketoViewResponse => ({ - url: faker.internet.url(), - version: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataValidationStatusRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): DataValidationStatusUpdateResponse => ({ - timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataValidationStatusPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): DataValidationStatusUpdateResponse => ({ - timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataSupplementRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): DataSupplementResponse => - ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) as DataSupplementResponse - -export const getApiV2AssetsDataSupplementPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): DataSupplementResponse => - ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) as DataSupplementResponse - -export const getApiV2AssetsDataBulkPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): DataBulkUpdateResponse => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - successes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - failures: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status_code: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsDataSupplementsBulkCreateResponseMock = ( - overrideResponse: Partial = {}, -): BulkAcceptResponse => ({ - accepted_count: faker.number.int({ min: 0, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): DataStatusesUpdate => ({ detail: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2AssetsExportSettingsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedExportSettingResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - data_url_csv: faker.internet.url(), - data_url_xlsx: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsExportSettingsCreateResponseMock = ( - overrideResponse: Partial = {}, -): ExportSettingResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - data_url_csv: faker.internet.url(), - data_url_xlsx: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsExportSettingsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ExportSettingResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - data_url_csv: faker.internet.url(), - data_url_xlsx: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsExportSettingsPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): ExportSettingResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - data_url_csv: faker.internet.url(), - data_url_xlsx: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsExportsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedExportResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - message: {}, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - result: faker.internet.url(), - data: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - source: faker.helpers.arrayElement([faker.internet.url(), undefined]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - processing_time_seconds: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsExportsCreateResponseMock = ( - overrideResponse: Partial = {}, -): ExportResponse => ({ - url: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - message: {}, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - result: faker.internet.url(), - data: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - source: faker.helpers.arrayElement([faker.internet.url(), undefined]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - processing_time_seconds: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsExportsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ExportResponse => ({ - url: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - message: {}, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - result: faker.internet.url(), - data: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - source: faker.helpers.arrayElement([faker.internet.url(), undefined]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - processing_time_seconds: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsFilesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedFilesResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - asset: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), - description: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - content: faker.internet.url(), - metadata: { - hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsFilesCreateResponseMock = ( - overrideResponse: Partial = {}, -): FilesResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - asset: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), - description: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - content: faker.internet.url(), - metadata: { - hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsFilesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): FilesResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - asset: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), - description: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - content: faker.internet.url(), - metadata: { - hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsPairedDataListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedPairedDataResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - source: faker.internet.url(), - source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsPairedDataCreateResponseMock = ( - overrideResponse: Partial = {}, -): PairedDataResponse => ({ - source: faker.internet.url(), - source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsPairedDataRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PairedDataResponse => ({ - source: faker.internet.url(), - source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsPairedDataPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): PairedDataResponse => ({ - source: faker.internet.url(), - source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsPairedDataExternalRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ExternalResponse => ({ - root: { - data: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - field_value_1: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - field_value_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsReportsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ReportResponse => ({ - url: faker.internet.url(), - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - list: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - row: faker.helpers.arrayElement([ - { type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, - undefined, - ]), - data: faker.helpers.arrayElement([ - { - total_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - not_provided: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - provided: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - show_graph: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - undefined, - ]), - kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([{}, undefined]), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesListMockHandler = ( - overrideResponse?: - | AdvancedFeatureResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | AdvancedFeatureResponse[]), -) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesCreateMockHandler = ( - overrideResponse?: - | AdvancedFeatureCreateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AdvancedFeatureCreateResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/advanced-features{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesRetrieveMockHandler = ( - overrideResponse?: - | AdvancedFeatureResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AdvancedFeatureResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler = ( - overrideResponse?: - | AdvancedFeatureResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AdvancedFeatureResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler = ( - overrideResponse?: - | BulkActionListResponse - | (( - info: Parameters[1]>[0], - ) => Promise | BulkActionListResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler = ( - overrideResponse?: - | BulkActionCreateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | BulkActionCreateResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler = ( - overrideResponse?: - | BulkActionResponse - | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = ( - overrideResponse?: - | BulkActionResponse - | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAttachmentsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/attachments/:id{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = ( - overrideResponse?: - | AssetAttachmentAudioDurationResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AssetAttachmentAudioDurationResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAttachmentsAudioDurationCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAttachmentsBulkDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 202 }) - }) -} - -export const getApiV2AssetsDataListMockHandler = ( - overrideResponse?: - | PaginatedDataResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedDataResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/data{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataRetrieveMockHandler = ( - overrideResponse?: - | DataResponse - | ((info: Parameters[1]>[0]) => Promise | DataResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/data/:id{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsDataDuplicateCreateMockHandler = ( - overrideResponse?: - | DataResponse - | ((info: Parameters[1]>[0]) => Promise | DataResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataDuplicateCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataEditRetrieveMockHandler = ( - overrideResponse?: - | EnketoEditResponse - | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/edit{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataEditRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataEnketoEditRetrieveMockHandler = ( - overrideResponse?: - | EnketoEditResponse - | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataEnketoEditRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler = ( - overrideResponse?: - | EnketoEditResponse - | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler = ( - overrideResponse?: - | EnketoViewResponse - | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataEnketoViewRetrieveMockHandler = ( - overrideResponse?: - | EnketoViewResponse - | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataEnketoViewRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataValidationStatusRetrieveMockHandler = ( - overrideResponse?: - | DataValidationStatusUpdateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | DataValidationStatusUpdateResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataValidationStatusRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = ( - overrideResponse?: - | DataValidationStatusUpdateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | DataValidationStatusUpdateResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataValidationStatusPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataValidationStatusDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsDataSupplementRetrieveMockHandler = ( - overrideResponse?: - | DataSupplementResponse - | (( - info: Parameters[1]>[0], - ) => Promise | DataSupplementResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataSupplementRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = ( - overrideResponse?: - | DataSupplementResponse - | (( - info: Parameters[1]>[0], - ) => Promise | DataSupplementResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataSupplementPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataAttachmentsListMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getAttachmentRetrieveMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getAttachmentThumbnailMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AssetsDataBulkPartialUpdateMockHandler = ( - overrideResponse?: - | DataBulkUpdateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | DataBulkUpdateResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/data/bulk{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataBulkPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataBulkDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/data/bulk{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AssetsDataSupplementsBulkCreateMockHandler = ( - overrideResponse?: - | BulkAcceptResponse - | ((info: Parameters[1]>[0]) => Promise | BulkAcceptResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataSupplementsBulkCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = ( - overrideResponse?: - | DataStatusesUpdate - | ((info: Parameters[1]>[0]) => Promise | DataStatusesUpdate), -) => { - return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataValidationStatusesDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsExportSettingsListMockHandler = ( - overrideResponse?: - | PaginatedExportSettingResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedExportSettingResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportSettingsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportSettingsCreateMockHandler = ( - overrideResponse?: - | ExportSettingResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ExportSettingResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/export-settings{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportSettingsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportSettingsRetrieveMockHandler = ( - overrideResponse?: - | ExportSettingResponse - | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportSettingsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = ( - overrideResponse?: - | ExportSettingResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ExportSettingResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportSettingsPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportSettingsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsExportSettingsDataRetrieveMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AssetsExportsListMockHandler = ( - overrideResponse?: - | PaginatedExportResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedExportResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/exports{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportsCreateMockHandler = ( - overrideResponse?: - | ExportResponse - | ((info: Parameters[1]>[0]) => Promise | ExportResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/exports{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportsRetrieveMockHandler = ( - overrideResponse?: - | ExportResponse - | ((info: Parameters[1]>[0]) => Promise | ExportResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsFilesListMockHandler = ( - overrideResponse?: - | PaginatedFilesResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedFilesResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/files{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsFilesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsFilesCreateMockHandler = ( - overrideResponse?: - | FilesResponse - | ((info: Parameters[1]>[0]) => Promise | FilesResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/files{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsFilesCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsFilesRetrieveMockHandler = ( - overrideResponse?: - | FilesResponse - | ((info: Parameters[1]>[0]) => Promise | FilesResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/files/:uidFile{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsFilesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsFilesDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsFilesContentRetrieveMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AssetsPairedDataListMockHandler = ( - overrideResponse?: - | PaginatedPairedDataResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedPairedDataResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPairedDataListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPairedDataCreateMockHandler = ( - overrideResponse?: - | PairedDataResponse - | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/paired-data{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPairedDataCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPairedDataRetrieveMockHandler = ( - overrideResponse?: - | PairedDataResponse - | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPairedDataRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPairedDataPartialUpdateMockHandler = ( - overrideResponse?: - | PairedDataResponse - | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPairedDataPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPairedDataDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = ( - overrideResponse?: - | ExternalResponse - | ((info: Parameters[1]>[0]) => Promise | ExternalResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPairedDataExternalRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsReportsRetrieveMockHandler = ( - overrideResponse?: - | ReportResponse - | ((info: Parameters[1]>[0]) => Promise | ReportResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/reports{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsReportsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getSurveyDataMock = () => [ - getApiV2AssetsAdvancedFeaturesListMockHandler(), - getApiV2AssetsAdvancedFeaturesCreateMockHandler(), - getApiV2AssetsAdvancedFeaturesRetrieveMockHandler(), - getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler(), - getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler(), - getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler(), - getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler(), - getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler(), - getApiV2AssetsAttachmentsDestroyMockHandler(), - getApiV2AssetsAttachmentsAudioDurationCreateMockHandler(), - getApiV2AssetsAttachmentsBulkDestroyMockHandler(), - getApiV2AssetsDataListMockHandler(), - getApiV2AssetsDataRetrieveMockHandler(), - getApiV2AssetsDataDestroyMockHandler(), - getApiV2AssetsDataDuplicateCreateMockHandler(), - getApiV2AssetsDataEditRetrieveMockHandler(), - getApiV2AssetsDataEnketoEditRetrieveMockHandler(), - getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler(), - getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler(), - getApiV2AssetsDataEnketoViewRetrieveMockHandler(), - getApiV2AssetsDataValidationStatusRetrieveMockHandler(), - getApiV2AssetsDataValidationStatusPartialUpdateMockHandler(), - getApiV2AssetsDataValidationStatusDestroyMockHandler(), - getApiV2AssetsDataSupplementRetrieveMockHandler(), - getApiV2AssetsDataSupplementPartialUpdateMockHandler(), - getApiV2AssetsDataAttachmentsListMockHandler(), - getAttachmentRetrieveMockHandler(), - getAttachmentThumbnailMockHandler(), - getApiV2AssetsDataBulkPartialUpdateMockHandler(), - getApiV2AssetsDataBulkDestroyMockHandler(), - getApiV2AssetsDataSupplementsBulkCreateMockHandler(), - getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler(), - getApiV2AssetsDataValidationStatusesDestroyMockHandler(), - getApiV2AssetsExportSettingsListMockHandler(), - getApiV2AssetsExportSettingsCreateMockHandler(), - getApiV2AssetsExportSettingsRetrieveMockHandler(), - getApiV2AssetsExportSettingsPartialUpdateMockHandler(), - getApiV2AssetsExportSettingsDestroyMockHandler(), - getApiV2AssetsExportSettingsDataRetrieveMockHandler(), - getApiV2AssetsExportsListMockHandler(), - getApiV2AssetsExportsCreateMockHandler(), - getApiV2AssetsExportsRetrieveMockHandler(), - getApiV2AssetsExportsDestroyMockHandler(), - getApiV2AssetsFilesListMockHandler(), - getApiV2AssetsFilesCreateMockHandler(), - getApiV2AssetsFilesRetrieveMockHandler(), - getApiV2AssetsFilesDestroyMockHandler(), - getApiV2AssetsFilesContentRetrieveMockHandler(), - getApiV2AssetsPairedDataListMockHandler(), - getApiV2AssetsPairedDataCreateMockHandler(), - getApiV2AssetsPairedDataRetrieveMockHandler(), - getApiV2AssetsPairedDataPartialUpdateMockHandler(), - getApiV2AssetsPairedDataDestroyMockHandler(), - getApiV2AssetsPairedDataExternalRetrieveMockHandler(), - getApiV2AssetsReportsRetrieveMockHandler(), -] diff --git a/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.msw.ts b/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.msw.ts new file mode 100644 index 0000000000..1acb66798f --- /dev/null +++ b/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.msw.ts @@ -0,0 +1,2287 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import { AssetDeploymentStatusEnum } from '../../models/assetDeploymentStatusEnum' + +import type { AssetListCount } from '../../models/assetListCount' + +import { AssetTypeEnum } from '../../models/assetTypeEnum' + +import { CustomAssetUsageDeploymentStatusEnum } from '../../models/customAssetUsageDeploymentStatusEnum' + +import type { EmailAddress } from '../../models/emailAddress' + +import type { InviteCreateResponse } from '../../models/inviteCreateResponse' + +import type { InviteResponse } from '../../models/inviteResponse' + +import { InviteStatusChoicesEnum } from '../../models/inviteStatusChoicesEnum' + +import { InviteeRoleEnum } from '../../models/inviteeRoleEnum' + +import type { MeListResponse } from '../../models/meListResponse' + +import type { MemberListResponse } from '../../models/memberListResponse' + +import { MemberRoleEnum } from '../../models/memberRoleEnum' + +import type { OrganizationResponse } from '../../models/organizationResponse' + +import type { OrganizationServiceUsageResponse } from '../../models/organizationServiceUsageResponse' + +import { OrganizationTypeEnum } from '../../models/organizationTypeEnum' + +import type { PaginatedAssetList } from '../../models/paginatedAssetList' + +import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' + +import type { PaginatedAssetUsageResponseList } from '../../models/paginatedAssetUsageResponseList' + +import type { PaginatedCustomAssetUsageList } from '../../models/paginatedCustomAssetUsageList' + +import type { PaginatedEmailAddressList } from '../../models/paginatedEmailAddressList' + +import type { PaginatedInviteResponseList } from '../../models/paginatedInviteResponseList' + +import type { PaginatedMemberListResponseList } from '../../models/paginatedMemberListResponseList' + +import type { PaginatedOrganizationResponseList } from '../../models/paginatedOrganizationResponseList' + +import type { PaginatedProjectViewAssetResponseList } from '../../models/paginatedProjectViewAssetResponseList' + +import type { PaginatedProjectViewListResponseList } from '../../models/paginatedProjectViewListResponseList' + +import type { PaginatedProjectViewUserResponseList } from '../../models/paginatedProjectViewUserResponseList' + +import type { PaginatedSocialAccountList } from '../../models/paginatedSocialAccountList' + +import type { PaginatedUserListResponseList } from '../../models/paginatedUserListResponseList' + +import type { ProjectViewExportCreateResponse } from '../../models/projectViewExportCreateResponse' + +import type { ProjectViewExportResponse } from '../../models/projectViewExportResponse' + +import type { ProjectViewListResponse } from '../../models/projectViewListResponse' + +import type { ServiceUsageBalanceData } from '../../models/serviceUsageBalanceData' + +import type { ServiceUsageResponse } from '../../models/serviceUsageResponse' + +import type { SocialAccount } from '../../models/socialAccount' + +import type { UserRetrieveResponse } from '../../models/userRetrieveResponse' + +export const getApiV2AssetUsageListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetUsageResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + asset: faker.internet.url(), + asset__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + nlp_usage_current_period: { + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + nlp_usage_all_time: { + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedOrganizationResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + website: faker.string.alpha({ length: { min: 10, max: 255 } }), + organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_owner: faker.datatype.boolean(), + is_mmo: faker.datatype.boolean(), + request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + members: faker.internet.url(), + assets: faker.internet.url(), + service_usage: faker.internet.url(), + asset_usage: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OrganizationResponse => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + website: faker.string.alpha({ length: { min: 10, max: 255 } }), + organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_owner: faker.datatype.boolean(), + is_mmo: faker.datatype.boolean(), + request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + members: faker.internet.url(), + assets: faker.internet.url(), + service_usage: faker.internet.url(), + asset_usage: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2OrganizationsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): OrganizationResponse => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + website: faker.string.alpha({ length: { min: 10, max: 255 } }), + organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_owner: faker.datatype.boolean(), + is_mmo: faker.datatype.boolean(), + request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + members: faker.internet.url(), + assets: faker.internet.url(), + service_usage: faker.internet.url(), + asset_usage: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetUsageListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedCustomAssetUsageList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + asset: faker.internet.url(), + asset__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + nlp_usage_current_period: { + ...{ + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + nlp_usage_all_time: { + ...{ + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment_status: faker.helpers.arrayElement(Object.values(CustomAssetUsageDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployed_versions: { + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: { + csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls: faker.string.alpha({ length: { min: 10, max: 20 } }), + zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + null, + ]), + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([ + { + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_styles: faker.helpers.arrayElement([ + { + colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + analysis_form_json: { + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + })), + undefined, + ]), + })), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetsCountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetListCount => ({ + deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetMinimalListList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 22 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsInvitesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedInviteResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsInvitesCreateResponseMock = (): InviteCreateResponse => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + invited_by: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + invitee_role: faker.helpers.arrayElement(['admin', 'member'] as const), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2OrganizationsInvitesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): InviteResponse => ({ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2OrganizationsInvitesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): InviteResponse => ({ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2OrganizationsMembersListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedMemberListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + url: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__email: faker.internet.email(), + user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__has_mfa_enabled: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + user__is_active: faker.datatype.boolean(), + invite: { + ...{ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsMembersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): MemberListResponse => ({ + role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + url: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__email: faker.internet.email(), + user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__has_mfa_enabled: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + user__is_active: faker.datatype.boolean(), + invite: { + ...{ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2OrganizationsMembersPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): MemberListResponse => ({ + role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + url: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__email: faker.internet.email(), + user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__has_mfa_enabled: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + user__is_active: faker.datatype.boolean(), + invite: { + ...{ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock = ( + overrideResponse: Partial = {}, +): ServiceUsageBalanceData => ({ + ...{ + effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + exceeded: faker.datatype.boolean(), + }, + ...overrideResponse, +}) + +export const getApiV2OrganizationsServiceUsageRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OrganizationServiceUsageResponse => ({ + total_nlp_usage: { + asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_submission_count: { + all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + balances: { + submission: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + storage_bytes: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + asr_seconds: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + mt_characters: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + llm_requests: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + }, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + ...overrideResponse, +}) + +export const getApiV2ProjectViewsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectViewListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 32 } }), + name: faker.internet.url(), + url: faker.internet.url(), + assets: faker.internet.url(), + assets_export: faker.internet.url(), + users: faker.internet.url(), + users_export: faker.internet.url(), + countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ProjectViewListResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 32 } }), + name: faker.internet.url(), + url: faker.internet.url(), + assets: faker.internet.url(), + assets_export: faker.internet.url(), + users: faker.internet.url(), + users_export: faker.internet.url(), + countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsExportRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ProjectViewExportResponse => ({ + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + result: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): ProjectViewExportCreateResponse => ({ + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsAssetsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectViewAssetResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner__email: faker.internet.email(), + owner__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner__organization: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + settings: { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + has_deployment: faker.datatype.boolean(), + deployment__active: faker.datatype.boolean(), + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment_status: faker.string.alpha({ length: { min: 10, max: 20 } }), + asset_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + })), + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsAssetsCountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetListCount => ({ + deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetMinimalListList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 22 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsUsersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectViewUserResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_superuser: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_active: faker.datatype.boolean(), + email: faker.internet.email(), + asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + metadata: { + city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + project_view_settings: faker.helpers.arrayElement([ + { + my_project_view_name: faker.helpers.arrayElement([ + { + order: faker.helpers.arrayElement([{}, undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock = ( + overrideResponse: Partial = {}, +): ServiceUsageBalanceData => ({ + ...{ + effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + exceeded: faker.datatype.boolean(), + }, + ...overrideResponse, +}) + +export const getApiV2ServiceUsageListResponseMock = (): ServiceUsageResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + total_nlp_usage: { + asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_submission_count: { + all_time: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + current_period: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + balances: { + submission: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + storage_bytes: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + asr_seconds: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + mt_characters: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + llm_requests: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + }, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + })) + +export const getApiV2UsersListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedUserListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_superuser: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_active: faker.datatype.boolean(), + email: faker.internet.email(), + asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + metadata: { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + project_views_settings: faker.helpers.arrayElement([ + { + kobo_my_project: faker.helpers.arrayElement([ + { + order: faker.helpers.arrayElement([{}, undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2UsersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): UserRetrieveResponse => ({ + url: faker.internet.url(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + public_collection_subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + public_collections_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getMeRetrieveResponseMock = (overrideResponse: Partial = {}): MeListResponse => ({ + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.internet.email(), + server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + projects_url: faker.internet.url(), + gravatar: faker.internet.url(), + last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + extra_details: { + bio: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + twitter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + linkedin: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + instagram: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_views_settings: faker.helpers.arrayElement([{}, undefined]), + require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + newsletter_subscription: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + git_rev: faker.helpers.arrayElement([ + faker.datatype.boolean(), + { + short: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + long: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + branch: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + tag: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + }, + ]), + social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + email: faker.helpers.arrayElement([faker.internet.email(), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + validated_password: faker.datatype.boolean(), + accepted_tos: faker.datatype.boolean(), + organization: { + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + extra_details__uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getMePartialUpdateResponseMock = (overrideResponse: Partial = {}): MeListResponse => ({ + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.internet.email(), + server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + projects_url: faker.internet.url(), + gravatar: faker.internet.url(), + last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + extra_details: { + bio: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + twitter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + linkedin: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + instagram: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_views_settings: faker.helpers.arrayElement([{}, undefined]), + require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + newsletter_subscription: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + git_rev: faker.helpers.arrayElement([ + faker.datatype.boolean(), + { + short: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + long: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + branch: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + tag: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + }, + ]), + social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + email: faker.helpers.arrayElement([faker.internet.email(), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + validated_password: faker.datatype.boolean(), + accepted_tos: faker.datatype.boolean(), + organization: { + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + extra_details__uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getMeEmailsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedEmailAddressList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getMeEmailsCreateResponseMock = (overrideResponse: Partial = {}): EmailAddress => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + ...overrideResponse, +}) + +export const getMeSocialAccountsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedSocialAccountList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.string.alpha({ length: { min: 10, max: 200 } }), + uid: faker.string.alpha({ length: { min: 10, max: 191 } }), + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + email: faker.internet.email(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getMeSocialAccountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): SocialAccount => ({ + provider: faker.string.alpha({ length: { min: 10, max: 200 } }), + uid: faker.string.alpha({ length: { min: 10, max: 191 } }), + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + email: faker.internet.email(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetUsageListMockHandler = ( + overrideResponse?: + | PaginatedAssetUsageResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetUsageResponseList), +) => { + return http.get('*/api/v2/asset_usage/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetUsageListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsListMockHandler = ( + overrideResponse?: + | PaginatedOrganizationResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedOrganizationResponseList), +) => { + return http.get('*/api/v2/organizations/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsRetrieveMockHandler = ( + overrideResponse?: + | OrganizationResponse + | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsPartialUpdateMockHandler = ( + overrideResponse?: + | OrganizationResponse + | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), +) => { + return http.patch('*/api/v2/organizations/:uidOrganization/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsAssetUsageListMockHandler = ( + overrideResponse?: + | PaginatedCustomAssetUsageList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedCustomAssetUsageList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/asset_usage/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetUsageListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsAssetsRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetList + | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsAssetsCountsRetrieveMockHandler = ( + overrideResponse?: + | AssetListCount + | ((info: Parameters[1]>[0]) => Promise | AssetListCount), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/counts/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetsCountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetMinimalListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetMinimalListList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsInvitesListMockHandler = ( + overrideResponse?: + | PaginatedInviteResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedInviteResponseList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsInvitesCreateMockHandler = ( + overrideResponse?: + | InviteCreateResponse + | ((info: Parameters[1]>[0]) => Promise | InviteCreateResponse), +) => { + return http.post('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsInvitesRetrieveMockHandler = ( + overrideResponse?: + | InviteResponse + | ((info: Parameters[1]>[0]) => Promise | InviteResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = ( + overrideResponse?: + | InviteResponse + | ((info: Parameters[1]>[0]) => Promise | InviteResponse), +) => { + return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsInvitesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2OrganizationsMembersListMockHandler = ( + overrideResponse?: + | PaginatedMemberListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedMemberListResponseList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/members/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsMembersListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsMembersRetrieveMockHandler = ( + overrideResponse?: + | MemberListResponse + | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsMembersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsMembersPartialUpdateMockHandler = ( + overrideResponse?: + | MemberListResponse + | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), +) => { + return http.patch('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsMembersPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2OrganizationsMembersDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getApiV2OrganizationsServiceUsageRetrieveMockHandler = ( + overrideResponse?: + | OrganizationServiceUsageResponse + | (( + info: Parameters[1]>[0], + ) => Promise | OrganizationServiceUsageResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/service_usage/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsServiceUsageRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsListMockHandler = ( + overrideResponse?: + | PaginatedProjectViewListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectViewListResponseList), +) => { + return http.get('*/api/v2/project-views/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsRetrieveMockHandler = ( + overrideResponse?: + | ProjectViewListResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectViewListResponse), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsExportRetrieveMockHandler = ( + overrideResponse?: + | ProjectViewExportResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectViewExportResponse), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsExportRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsExportCreateMockHandler = ( + overrideResponse?: + | ProjectViewExportCreateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectViewExportCreateResponse), +) => { + return http.post('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsExportCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsAssetsRetrieveMockHandler = ( + overrideResponse?: + | PaginatedProjectViewAssetResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectViewAssetResponseList), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsAssetsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsAssetsCountsRetrieveMockHandler = ( + overrideResponse?: + | AssetListCount + | ((info: Parameters[1]>[0]) => Promise | AssetListCount), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/counts/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsAssetsCountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetMinimalListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetMinimalListList), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ProjectViewsUsersRetrieveMockHandler = ( + overrideResponse?: + | PaginatedProjectViewUserResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectViewUserResponseList), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/users/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsUsersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2ServiceUsageListMockHandler = ( + overrideResponse?: + | ServiceUsageResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | ServiceUsageResponse[]), +) => { + return http.get('*/api/v2/service_usage/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ServiceUsageListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2UsersListMockHandler = ( + overrideResponse?: + | PaginatedUserListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedUserListResponseList), +) => { + return http.get('*/api/v2/users/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2UsersListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getApiV2UsersRetrieveMockHandler = ( + overrideResponse?: + | UserRetrieveResponse + | ((info: Parameters[1]>[0]) => Promise | UserRetrieveResponse), +) => { + return http.get('*/api/v2/users/:username/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2UsersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeRetrieveMockHandler = ( + overrideResponse?: + | MeListResponse + | ((info: Parameters[1]>[0]) => Promise | MeListResponse), +) => { + return http.get('*/me/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMePartialUpdateMockHandler = ( + overrideResponse?: + | MeListResponse + | ((info: Parameters[1]>[0]) => Promise | MeListResponse), +) => { + return http.patch('*/me/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMePartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/me/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} + +export const getMeEmailsListMockHandler = ( + overrideResponse?: + | PaginatedEmailAddressList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedEmailAddressList), +) => { + return http.get('*/me/emails/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeEmailsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeEmailsCreateMockHandler = ( + overrideResponse?: + | EmailAddress + | ((info: Parameters[1]>[0]) => Promise | EmailAddress), +) => { + return http.post('*/me/emails/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeEmailsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeSocialAccountsListMockHandler = ( + overrideResponse?: + | PaginatedSocialAccountList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedSocialAccountList), +) => { + return http.get('*/me/social-accounts/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeSocialAccountsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeSocialAccountsRetrieveMockHandler = ( + overrideResponse?: + | SocialAccount + | ((info: Parameters[1]>[0]) => Promise | SocialAccount), +) => { + return http.get('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeSocialAccountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + +export const getMeSocialAccountsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) + }) +} +export const getUserTeamOrganizationUsageMock = () => [ + getApiV2AssetUsageListMockHandler(), + getApiV2OrganizationsListMockHandler(), + getApiV2OrganizationsRetrieveMockHandler(), + getApiV2OrganizationsPartialUpdateMockHandler(), + getApiV2OrganizationsAssetUsageListMockHandler(), + getApiV2OrganizationsAssetsRetrieveMockHandler(), + getApiV2OrganizationsAssetsCountsRetrieveMockHandler(), + getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler(), + getApiV2OrganizationsInvitesListMockHandler(), + getApiV2OrganizationsInvitesCreateMockHandler(), + getApiV2OrganizationsInvitesRetrieveMockHandler(), + getApiV2OrganizationsInvitesPartialUpdateMockHandler(), + getApiV2OrganizationsInvitesDestroyMockHandler(), + getApiV2OrganizationsMembersListMockHandler(), + getApiV2OrganizationsMembersRetrieveMockHandler(), + getApiV2OrganizationsMembersPartialUpdateMockHandler(), + getApiV2OrganizationsMembersDestroyMockHandler(), + getApiV2OrganizationsServiceUsageRetrieveMockHandler(), + getApiV2ProjectViewsListMockHandler(), + getApiV2ProjectViewsRetrieveMockHandler(), + getApiV2ProjectViewsExportRetrieveMockHandler(), + getApiV2ProjectViewsExportCreateMockHandler(), + getApiV2ProjectViewsAssetsRetrieveMockHandler(), + getApiV2ProjectViewsAssetsCountsRetrieveMockHandler(), + getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler(), + getApiV2ProjectViewsUsersRetrieveMockHandler(), + getApiV2ServiceUsageListMockHandler(), + getApiV2UsersListMockHandler(), + getApiV2UsersRetrieveMockHandler(), + getMeRetrieveMockHandler(), + getMePartialUpdateMockHandler(), + getMeDestroyMockHandler(), + getMeEmailsListMockHandler(), + getMeEmailsCreateMockHandler(), + getMeSocialAccountsListMockHandler(), + getMeSocialAccountsRetrieveMockHandler(), + getMeSocialAccountsDestroyMockHandler(), +] diff --git a/jsapp/js/api/react-query/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.ts similarity index 52% rename from jsapp/js/api/react-query/user-team-organization-usage.ts rename to jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.ts index 411f880214..f30710d6c3 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.ts @@ -19,123 +19,103 @@ import type { UseQueryResult, } from '@tanstack/react-query' -import type { AssetUsageListParams } from '../models/assetUsageListParams' +import type { AssetListCount } from '../../models/assetListCount' -import type { EmailRequestPayload } from '../models/emailRequestPayload' +import type { AssetUsageListParams } from '../../models/assetUsageListParams' -import type { ErrorDetail } from '../models/errorDetail' +import type { EmailAddress } from '../../models/emailAddress' -import type { ErrorObject } from '../models/errorObject' +import type { EmailRequestPayload } from '../../models/emailRequestPayload' -import type { InviteCreatePayload } from '../models/inviteCreatePayload' +import type { ErrorDetail } from '../../models/errorDetail' -import type { MeEmailsListParams } from '../models/meEmailsListParams' +import type { ErrorObject } from '../../models/errorObject' -import type { MeSocialAccountsListParams } from '../models/meSocialAccountsListParams' +import type { InviteCreatePayload } from '../../models/inviteCreatePayload' -import type { OrganizationsAssetUsageListParams } from '../models/organizationsAssetUsageListParams' +import type { InviteCreateResponse } from '../../models/inviteCreateResponse' -import type { OrganizationsAssetsMinimalListRetrieveParams } from '../models/organizationsAssetsMinimalListRetrieveParams' +import type { InviteResponse } from '../../models/inviteResponse' -import type { OrganizationsInvitesListParams } from '../models/organizationsInvitesListParams' +import type { MeEmailsListParams } from '../../models/meEmailsListParams' -import type { OrganizationsListParams } from '../models/organizationsListParams' +import type { MeListResponse } from '../../models/meListResponse' -import type { OrganizationsMembersListParams } from '../models/organizationsMembersListParams' +import type { MeSocialAccountsListParams } from '../../models/meSocialAccountsListParams' -import type { PatchedCurrentUser } from '../models/patchedCurrentUser' +import type { MemberListResponse } from '../../models/memberListResponse' -import type { PatchedInvitePatchPayload } from '../models/patchedInvitePatchPayload' +import type { OrganizationResponse } from '../../models/organizationResponse' -import type { PatchedMemberPatchRequest } from '../models/patchedMemberPatchRequest' +import type { OrganizationServiceUsageResponse } from '../../models/organizationServiceUsageResponse' -import type { PatchedOrganizationPatchPayload } from '../models/patchedOrganizationPatchPayload' +import type { OrganizationsAssetUsageListParams } from '../../models/organizationsAssetUsageListParams' -import type { ProjectViewsAssetsMinimalListRetrieveParams } from '../models/projectViewsAssetsMinimalListRetrieveParams' +import type { OrganizationsAssetsMinimalListRetrieveParams } from '../../models/organizationsAssetsMinimalListRetrieveParams' -import type { ProjectViewsAssetsRetrieveParams } from '../models/projectViewsAssetsRetrieveParams' +import type { OrganizationsInvitesListParams } from '../../models/organizationsInvitesListParams' -import type { ProjectViewsListParams } from '../models/projectViewsListParams' +import type { OrganizationsListParams } from '../../models/organizationsListParams' -import type { ProjectViewsUsersRetrieveParams } from '../models/projectViewsUsersRetrieveParams' +import type { OrganizationsMembersListParams } from '../../models/organizationsMembersListParams' -import type { UsersListParams } from '../models/usersListParams' +import type { PaginatedAssetList } from '../../models/paginatedAssetList' -import { faker } from '@faker-js/faker' +import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' -import { http, HttpResponse } from 'msw' +import type { PaginatedAssetUsageResponseList } from '../../models/paginatedAssetUsageResponseList' -import { AssetDeploymentStatusEnum } from '../models/assetDeploymentStatusEnum' +import type { PaginatedCustomAssetUsageList } from '../../models/paginatedCustomAssetUsageList' -import type { AssetListCount } from '../models/assetListCount' +import type { PaginatedEmailAddressList } from '../../models/paginatedEmailAddressList' -import { AssetTypeEnum } from '../models/assetTypeEnum' +import type { PaginatedInviteResponseList } from '../../models/paginatedInviteResponseList' -import { CustomAssetUsageDeploymentStatusEnum } from '../models/customAssetUsageDeploymentStatusEnum' +import type { PaginatedMemberListResponseList } from '../../models/paginatedMemberListResponseList' -import type { EmailAddress } from '../models/emailAddress' +import type { PaginatedOrganizationResponseList } from '../../models/paginatedOrganizationResponseList' -import type { InviteCreateResponse } from '../models/inviteCreateResponse' +import type { PaginatedProjectViewAssetResponseList } from '../../models/paginatedProjectViewAssetResponseList' -import type { InviteResponse } from '../models/inviteResponse' +import type { PaginatedProjectViewListResponseList } from '../../models/paginatedProjectViewListResponseList' -import { InviteStatusChoicesEnum } from '../models/inviteStatusChoicesEnum' +import type { PaginatedProjectViewUserResponseList } from '../../models/paginatedProjectViewUserResponseList' -import { InviteeRoleEnum } from '../models/inviteeRoleEnum' +import type { PaginatedSocialAccountList } from '../../models/paginatedSocialAccountList' -import type { MeListResponse } from '../models/meListResponse' +import type { PaginatedUserListResponseList } from '../../models/paginatedUserListResponseList' -import type { MemberListResponse } from '../models/memberListResponse' +import type { PatchedCurrentUser } from '../../models/patchedCurrentUser' -import { MemberRoleEnum } from '../models/memberRoleEnum' +import type { PatchedInvitePatchPayload } from '../../models/patchedInvitePatchPayload' -import type { OrganizationResponse } from '../models/organizationResponse' +import type { PatchedMemberPatchRequest } from '../../models/patchedMemberPatchRequest' -import type { OrganizationServiceUsageResponse } from '../models/organizationServiceUsageResponse' +import type { PatchedOrganizationPatchPayload } from '../../models/patchedOrganizationPatchPayload' -import { OrganizationTypeEnum } from '../models/organizationTypeEnum' +import type { ProjectViewExportCreateResponse } from '../../models/projectViewExportCreateResponse' -import type { PaginatedAssetList } from '../models/paginatedAssetList' +import type { ProjectViewExportResponse } from '../../models/projectViewExportResponse' -import type { PaginatedAssetMinimalListList } from '../models/paginatedAssetMinimalListList' +import type { ProjectViewListResponse } from '../../models/projectViewListResponse' -import type { PaginatedAssetUsageResponseList } from '../models/paginatedAssetUsageResponseList' +import type { ProjectViewsAssetsMinimalListRetrieveParams } from '../../models/projectViewsAssetsMinimalListRetrieveParams' -import type { PaginatedCustomAssetUsageList } from '../models/paginatedCustomAssetUsageList' +import type { ProjectViewsAssetsRetrieveParams } from '../../models/projectViewsAssetsRetrieveParams' -import type { PaginatedEmailAddressList } from '../models/paginatedEmailAddressList' +import type { ProjectViewsListParams } from '../../models/projectViewsListParams' -import type { PaginatedInviteResponseList } from '../models/paginatedInviteResponseList' +import type { ProjectViewsUsersRetrieveParams } from '../../models/projectViewsUsersRetrieveParams' -import type { PaginatedMemberListResponseList } from '../models/paginatedMemberListResponseList' +import type { ServiceUsageResponse } from '../../models/serviceUsageResponse' -import type { PaginatedOrganizationResponseList } from '../models/paginatedOrganizationResponseList' +import type { SocialAccount } from '../../models/socialAccount' -import type { PaginatedProjectViewAssetResponseList } from '../models/paginatedProjectViewAssetResponseList' +import type { UserRetrieveResponse } from '../../models/userRetrieveResponse' -import type { PaginatedProjectViewListResponseList } from '../models/paginatedProjectViewListResponseList' +import type { UsersListParams } from '../../models/usersListParams' -import type { PaginatedProjectViewUserResponseList } from '../models/paginatedProjectViewUserResponseList' - -import type { PaginatedSocialAccountList } from '../models/paginatedSocialAccountList' - -import type { PaginatedUserListResponseList } from '../models/paginatedUserListResponseList' - -import type { ProjectViewExportCreateResponse } from '../models/projectViewExportCreateResponse' - -import type { ProjectViewExportResponse } from '../models/projectViewExportResponse' - -import type { ProjectViewListResponse } from '../models/projectViewListResponse' - -import type { ServiceUsageBalanceData } from '../models/serviceUsageBalanceData' - -import type { ServiceUsageResponse } from '../models/serviceUsageResponse' - -import type { SocialAccount } from '../models/socialAccount' - -import type { UserRetrieveResponse } from '../models/userRetrieveResponse' - -import { fetchWithAuth } from '../orval.mutator' +import { fetchWithAuth } from '../../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B @@ -3680,2206 +3660,3 @@ export const useMeSocialAccountsDestroy = = {}, -): PaginatedAssetUsageResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - asset: faker.internet.url(), - asset__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - nlp_usage_current_period: { - total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - nlp_usage_all_time: { - total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - submission_count_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - submission_count_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedOrganizationResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - website: faker.string.alpha({ length: { min: 10, max: 255 } }), - organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_owner: faker.datatype.boolean(), - is_mmo: faker.datatype.boolean(), - request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - members: faker.internet.url(), - assets: faker.internet.url(), - service_usage: faker.internet.url(), - asset_usage: faker.internet.url(), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): OrganizationResponse => ({ - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - website: faker.string.alpha({ length: { min: 10, max: 255 } }), - organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_owner: faker.datatype.boolean(), - is_mmo: faker.datatype.boolean(), - request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - members: faker.internet.url(), - assets: faker.internet.url(), - service_usage: faker.internet.url(), - asset_usage: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2OrganizationsPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): OrganizationResponse => ({ - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - website: faker.string.alpha({ length: { min: 10, max: 255 } }), - organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_owner: faker.datatype.boolean(), - is_mmo: faker.datatype.boolean(), - request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - members: faker.internet.url(), - assets: faker.internet.url(), - service_usage: faker.internet.url(), - asset_usage: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2OrganizationsAssetUsageListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedCustomAssetUsageList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - asset: faker.internet.url(), - asset__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - nlp_usage_current_period: { - ...{ - total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - nlp_usage_all_time: { - ...{ - total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - submission_count_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - submission_count_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment_status: faker.helpers.arrayElement(Object.values(CustomAssetUsageDeploymentStatusEnum)), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([{}, undefined]), - })), - summary: { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - firsts: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - bad: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - naming_conflicts: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_deployed: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - has_deployment: faker.datatype.boolean(), - deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployed_versions: { - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - }, - deployment__links: {}, - deployment__active: faker.datatype.boolean(), - deployment__data_download_links: { - csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls: faker.string.alpha({ length: { min: 10, max: 20 } }), - zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment__last_submission_time: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - null, - ]), - deployment__encrypted: faker.datatype.boolean(), - deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - report_styles: faker.helpers.arrayElement([ - { - default: faker.helpers.arrayElement([ - { - groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_colors: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translationIndex: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - graphWidth: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - specified: faker.helpers.arrayElement([{}, undefined]), - kuid_names: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([ - { - transcript: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - translation: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - qual: faker.helpers.arrayElement([ - { - qual_survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - scope: faker.string.alpha({ length: { min: 10, max: 20 } }), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - })), - undefined, - ]), - })), - undefined, - ]), - }, - undefined, - ]), - _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_styles: faker.helpers.arrayElement([ - { - colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_custom: faker.helpers.arrayElement([{}, undefined]), - content: faker.helpers.arrayElement([ - { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - hint: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--matrix_list': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-constraint-message': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-items': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--score-choices': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - tags: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - select_from_list_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'body::accept': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - })), - undefined, - ]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'media::image': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_language: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - translations_0: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - 'kobo--locking-profiles': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, - })), - undefined, - ]), - }, - undefined, - ]), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - analysis_form_json: { - additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([ - 'transcript', - 'translation', - 'qualVerification', - 'qualSource', - 'qualInteger', - 'qualTags', - 'qualText', - 'qualNote', - 'qualAutoKeywordCount', - 'qualSelectMultiple', - 'qualSelectOne', - ] as const), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - })), - undefined, - ]), - })), - }, - xform_link: faker.internet.url(), - hooks_link: faker.internet.url(), - tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls_link: faker.internet.url(), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: faker.string.alpha({ length: { min: 10, max: 20 } }), - permission: faker.string.alpha({ length: { min: 10, max: 20 } }), - partial_permissions: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - })), - undefined, - ]), - label: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - undefined, - ]), - })), - effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - exports: faker.internet.url(), - export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - data: faker.internet.url(), - children: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - data_sharing: faker.helpers.arrayElement([{}, undefined]), - paired_data: faker.internet.url(), - project_ownership: { - [faker.string.alphanumeric(5)]: {}, - }, - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsAssetsCountsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetListCount => ({ - deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetMinimalListList => ({ - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 22 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsInvitesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedInviteResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsInvitesCreateResponseMock = (): InviteCreateResponse => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - invited_by: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - invitee_role: faker.helpers.arrayElement(['admin', 'member'] as const), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2OrganizationsInvitesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): InviteResponse => ({ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2OrganizationsInvitesPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): InviteResponse => ({ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2OrganizationsMembersListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedMemberListResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - url: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__email: faker.internet.email(), - user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__has_mfa_enabled: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - user__is_active: faker.datatype.boolean(), - invite: { - ...{ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsMembersRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): MemberListResponse => ({ - role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - url: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__email: faker.internet.email(), - user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__has_mfa_enabled: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - user__is_active: faker.datatype.boolean(), - invite: { - ...{ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2OrganizationsMembersPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): MemberListResponse => ({ - role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - url: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__email: faker.internet.email(), - user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__has_mfa_enabled: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - user__is_active: faker.datatype.boolean(), - invite: { - ...{ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock = ( - overrideResponse: Partial = {}, -): ServiceUsageBalanceData => ({ - ...{ - effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - exceeded: faker.datatype.boolean(), - }, - ...overrideResponse, -}) - -export const getApiV2OrganizationsServiceUsageRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): OrganizationServiceUsageResponse => ({ - total_nlp_usage: { - asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_submission_count: { - all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - balances: { - submission: faker.helpers.arrayElement([ - { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, - null, - ]), - storage_bytes: faker.helpers.arrayElement([ - { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, - null, - ]), - asr_seconds: faker.helpers.arrayElement([ - { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, - null, - ]), - mt_characters: faker.helpers.arrayElement([ - { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, - null, - ]), - llm_requests: faker.helpers.arrayElement([ - { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, - null, - ]), - }, - current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, - current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, - ...overrideResponse, -}) - -export const getApiV2ProjectViewsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedProjectViewListResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 32 } }), - name: faker.internet.url(), - url: faker.internet.url(), - assets: faker.internet.url(), - assets_export: faker.internet.url(), - users: faker.internet.url(), - users_export: faker.internet.url(), - countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ProjectViewListResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 32 } }), - name: faker.internet.url(), - url: faker.internet.url(), - assets: faker.internet.url(), - assets_export: faker.internet.url(), - users: faker.internet.url(), - users_export: faker.internet.url(), - countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsExportRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ProjectViewExportResponse => ({ - status: faker.string.alpha({ length: { min: 10, max: 32 } }), - result: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsExportCreateResponseMock = ( - overrideResponse: Partial = {}, -): ProjectViewExportCreateResponse => ({ - status: faker.string.alpha({ length: { min: 10, max: 32 } }), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsAssetsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedProjectViewAssetResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - owner__email: faker.internet.email(), - owner__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - owner__organization: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - settings: { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - has_deployment: faker.datatype.boolean(), - deployment__active: faker.datatype.boolean(), - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment_status: faker.string.alpha({ length: { min: 10, max: 20 } }), - asset_type: faker.string.alpha({ length: { min: 10, max: 20 } }), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - })), - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsAssetsCountsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetListCount => ({ - deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetMinimalListList => ({ - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 22 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsUsersRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedProjectViewUserResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_superuser: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_active: faker.datatype.boolean(), - email: faker.internet.email(), - asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - metadata: { - city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_website: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - project_view_settings: faker.helpers.arrayElement([ - { - my_project_view_name: faker.helpers.arrayElement([ - { - order: faker.helpers.arrayElement([{}, undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock = ( - overrideResponse: Partial = {}, -): ServiceUsageBalanceData => ({ - ...{ - effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - exceeded: faker.datatype.boolean(), - }, - ...overrideResponse, -}) - -export const getApiV2ServiceUsageListResponseMock = (): ServiceUsageResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - total_nlp_usage: { - asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_submission_count: { - all_time: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - current_period: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - balances: { - submission: faker.helpers.arrayElement([ - { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, - null, - ]), - storage_bytes: faker.helpers.arrayElement([ - { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, - null, - ]), - asr_seconds: faker.helpers.arrayElement([ - { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, - null, - ]), - mt_characters: faker.helpers.arrayElement([ - { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, - null, - ]), - llm_requests: faker.helpers.arrayElement([ - { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, - null, - ]), - }, - current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, - current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, - })) - -export const getApiV2UsersListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedUserListResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_superuser: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_active: faker.datatype.boolean(), - email: faker.internet.email(), - asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - metadata: { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_website: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - project_views_settings: faker.helpers.arrayElement([ - { - kobo_my_project: faker.helpers.arrayElement([ - { - order: faker.helpers.arrayElement([{}, undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2UsersRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): UserRetrieveResponse => ({ - url: faker.internet.url(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - public_collection_subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - public_collections_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getMeRetrieveResponseMock = (overrideResponse: Partial = {}): MeListResponse => ({ - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.internet.email(), - server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - projects_url: faker.internet.url(), - gravatar: faker.internet.url(), - last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - extra_details: { - bio: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - twitter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - linkedin: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - instagram: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_website: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - project_views_settings: faker.helpers.arrayElement([{}, undefined]), - require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - newsletter_subscription: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - git_rev: faker.helpers.arrayElement([ - faker.datatype.boolean(), - { - short: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - long: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - branch: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - tag: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - }, - ]), - social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - email: faker.helpers.arrayElement([faker.internet.email(), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - validated_password: faker.datatype.boolean(), - accepted_tos: faker.datatype.boolean(), - organization: { - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - extra_details__uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getMePartialUpdateResponseMock = (overrideResponse: Partial = {}): MeListResponse => ({ - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.internet.email(), - server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - projects_url: faker.internet.url(), - gravatar: faker.internet.url(), - last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - extra_details: { - bio: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - twitter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - linkedin: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - instagram: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_website: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - project_views_settings: faker.helpers.arrayElement([{}, undefined]), - require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - newsletter_subscription: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - git_rev: faker.helpers.arrayElement([ - faker.datatype.boolean(), - { - short: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - long: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - branch: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - tag: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - }, - ]), - social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - email: faker.helpers.arrayElement([faker.internet.email(), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - validated_password: faker.datatype.boolean(), - accepted_tos: faker.datatype.boolean(), - organization: { - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - extra_details__uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getMeEmailsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedEmailAddressList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getMeEmailsCreateResponseMock = (overrideResponse: Partial = {}): EmailAddress => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - ...overrideResponse, -}) - -export const getMeSocialAccountsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedSocialAccountList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - provider: faker.string.alpha({ length: { min: 10, max: 200 } }), - uid: faker.string.alpha({ length: { min: 10, max: 191 } }), - last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - email: faker.internet.email(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getMeSocialAccountsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): SocialAccount => ({ - provider: faker.string.alpha({ length: { min: 10, max: 200 } }), - uid: faker.string.alpha({ length: { min: 10, max: 191 } }), - last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - email: faker.internet.email(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetUsageListMockHandler = ( - overrideResponse?: - | PaginatedAssetUsageResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetUsageResponseList), -) => { - return http.get('*/api/v2/asset_usage{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetUsageListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsListMockHandler = ( - overrideResponse?: - | PaginatedOrganizationResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedOrganizationResponseList), -) => { - return http.get('*/api/v2/organizations{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsRetrieveMockHandler = ( - overrideResponse?: - | OrganizationResponse - | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), -) => { - return http.get('*/api/v2/organizations/:uidOrganization{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsPartialUpdateMockHandler = ( - overrideResponse?: - | OrganizationResponse - | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), -) => { - return http.patch('*/api/v2/organizations/:uidOrganization{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsAssetUsageListMockHandler = ( - overrideResponse?: - | PaginatedCustomAssetUsageList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedCustomAssetUsageList), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/asset_usage{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsAssetUsageListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsAssetsRetrieveMockHandler = ( - overrideResponse?: - | PaginatedAssetList - | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsAssetsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsAssetsCountsRetrieveMockHandler = ( - overrideResponse?: - | AssetListCount - | ((info: Parameters[1]>[0]) => Promise | AssetListCount), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/counts{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsAssetsCountsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler = ( - overrideResponse?: - | PaginatedAssetMinimalListList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetMinimalListList), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsInvitesListMockHandler = ( - overrideResponse?: - | PaginatedInviteResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedInviteResponseList), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/invites{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsInvitesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsInvitesCreateMockHandler = ( - overrideResponse?: - | InviteCreateResponse - | ((info: Parameters[1]>[0]) => Promise | InviteCreateResponse), -) => { - return http.post('*/api/v2/organizations/:uidOrganization/invites{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsInvitesCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsInvitesRetrieveMockHandler = ( - overrideResponse?: - | InviteResponse - | ((info: Parameters[1]>[0]) => Promise | InviteResponse), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsInvitesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = ( - overrideResponse?: - | InviteResponse - | ((info: Parameters[1]>[0]) => Promise | InviteResponse), -) => { - return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsInvitesPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsInvitesDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2OrganizationsMembersListMockHandler = ( - overrideResponse?: - | PaginatedMemberListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedMemberListResponseList), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/members{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsMembersListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsMembersRetrieveMockHandler = ( - overrideResponse?: - | MemberListResponse - | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsMembersRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsMembersPartialUpdateMockHandler = ( - overrideResponse?: - | MemberListResponse - | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), -) => { - return http.patch('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsMembersPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsMembersDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2OrganizationsServiceUsageRetrieveMockHandler = ( - overrideResponse?: - | OrganizationServiceUsageResponse - | (( - info: Parameters[1]>[0], - ) => Promise | OrganizationServiceUsageResponse), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/service_usage{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsServiceUsageRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsListMockHandler = ( - overrideResponse?: - | PaginatedProjectViewListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedProjectViewListResponseList), -) => { - return http.get('*/api/v2/project-views{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsRetrieveMockHandler = ( - overrideResponse?: - | ProjectViewListResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProjectViewListResponse), -) => { - return http.get('*/api/v2/project-views/:uidProjectView{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsExportRetrieveMockHandler = ( - overrideResponse?: - | ProjectViewExportResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProjectViewExportResponse), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/:objType/export{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsExportRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsExportCreateMockHandler = ( - overrideResponse?: - | ProjectViewExportCreateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProjectViewExportCreateResponse), -) => { - return http.post('*/api/v2/project-views/:uidProjectView/:objType/export{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsExportCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsAssetsRetrieveMockHandler = ( - overrideResponse?: - | PaginatedProjectViewAssetResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedProjectViewAssetResponseList), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsAssetsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsAssetsCountsRetrieveMockHandler = ( - overrideResponse?: - | AssetListCount - | ((info: Parameters[1]>[0]) => Promise | AssetListCount), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/counts{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsAssetsCountsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler = ( - overrideResponse?: - | PaginatedAssetMinimalListList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetMinimalListList), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsUsersRetrieveMockHandler = ( - overrideResponse?: - | PaginatedProjectViewUserResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedProjectViewUserResponseList), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/users{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsUsersRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ServiceUsageListMockHandler = ( - overrideResponse?: - | ServiceUsageResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | ServiceUsageResponse[]), -) => { - return http.get('*/api/v2/service_usage{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ServiceUsageListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2UsersListMockHandler = ( - overrideResponse?: - | PaginatedUserListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedUserListResponseList), -) => { - return http.get('*/api/v2/users{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2UsersListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2UsersRetrieveMockHandler = ( - overrideResponse?: - | UserRetrieveResponse - | ((info: Parameters[1]>[0]) => Promise | UserRetrieveResponse), -) => { - return http.get('*/api/v2/users/:username{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2UsersRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeRetrieveMockHandler = ( - overrideResponse?: - | MeListResponse - | ((info: Parameters[1]>[0]) => Promise | MeListResponse), -) => { - return http.get('*/me{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMeRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMePartialUpdateMockHandler = ( - overrideResponse?: - | MeListResponse - | ((info: Parameters[1]>[0]) => Promise | MeListResponse), -) => { - return http.patch('*/me{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMePartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/me{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getMeEmailsListMockHandler = ( - overrideResponse?: - | PaginatedEmailAddressList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedEmailAddressList), -) => { - return http.get('*/me/emails{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMeEmailsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeEmailsCreateMockHandler = ( - overrideResponse?: - | EmailAddress - | ((info: Parameters[1]>[0]) => Promise | EmailAddress), -) => { - return http.post('*/me/emails{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMeEmailsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeSocialAccountsListMockHandler = ( - overrideResponse?: - | PaginatedSocialAccountList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedSocialAccountList), -) => { - return http.get('*/me/social-accounts{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMeSocialAccountsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeSocialAccountsRetrieveMockHandler = ( - overrideResponse?: - | SocialAccount - | ((info: Parameters[1]>[0]) => Promise | SocialAccount), -) => { - return http.get('*/me/social-accounts/:provider/:uidSocialAccount{/}?', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMeSocialAccountsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeSocialAccountsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/me/social-accounts/:provider/:uidSocialAccount{/}?', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} -export const getUserTeamOrganizationUsageMock = () => [ - getApiV2AssetUsageListMockHandler(), - getApiV2OrganizationsListMockHandler(), - getApiV2OrganizationsRetrieveMockHandler(), - getApiV2OrganizationsPartialUpdateMockHandler(), - getApiV2OrganizationsAssetUsageListMockHandler(), - getApiV2OrganizationsAssetsRetrieveMockHandler(), - getApiV2OrganizationsAssetsCountsRetrieveMockHandler(), - getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler(), - getApiV2OrganizationsInvitesListMockHandler(), - getApiV2OrganizationsInvitesCreateMockHandler(), - getApiV2OrganizationsInvitesRetrieveMockHandler(), - getApiV2OrganizationsInvitesPartialUpdateMockHandler(), - getApiV2OrganizationsInvitesDestroyMockHandler(), - getApiV2OrganizationsMembersListMockHandler(), - getApiV2OrganizationsMembersRetrieveMockHandler(), - getApiV2OrganizationsMembersPartialUpdateMockHandler(), - getApiV2OrganizationsMembersDestroyMockHandler(), - getApiV2OrganizationsServiceUsageRetrieveMockHandler(), - getApiV2ProjectViewsListMockHandler(), - getApiV2ProjectViewsRetrieveMockHandler(), - getApiV2ProjectViewsExportRetrieveMockHandler(), - getApiV2ProjectViewsExportCreateMockHandler(), - getApiV2ProjectViewsAssetsRetrieveMockHandler(), - getApiV2ProjectViewsAssetsCountsRetrieveMockHandler(), - getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler(), - getApiV2ProjectViewsUsersRetrieveMockHandler(), - getApiV2ServiceUsageListMockHandler(), - getApiV2UsersListMockHandler(), - getApiV2UsersRetrieveMockHandler(), - getMeRetrieveMockHandler(), - getMePartialUpdateMockHandler(), - getMeDestroyMockHandler(), - getMeEmailsListMockHandler(), - getMeEmailsCreateMockHandler(), - getMeSocialAccountsListMockHandler(), - getMeSocialAccountsRetrieveMockHandler(), - getMeSocialAccountsDestroyMockHandler(), -] diff --git a/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts b/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts index 1b661cf4da..96433f1f0f 100644 --- a/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts +++ b/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts @@ -1,4 +1,4 @@ -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' import { ANY_ROW_TYPE_NAMES, AssetTypeName } from '#/constants' import type { AssetResponse, SubmissionResponse } from '#/dataInterface' diff --git a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx index 4c7141a412..6534d8d552 100644 --- a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx +++ b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx @@ -1,7 +1,7 @@ import { ModalsProvider } from '@mantine/modals' import type { Meta, StoryObj } from '@storybook/react-webpack5' import { expect, fn, userEvent, waitFor, within } from 'storybook/test' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' import ButtonNew from '#/components/common/ButtonNew' import type { AssetResponse } from '#/dataInterface' import { assetPatchMock } from '#/endpoints/asset.mocks' diff --git a/jsapp/js/components/activity/FormActivity.stories.tsx b/jsapp/js/components/activity/FormActivity.stories.tsx index 5019b1b306..b290bf61eb 100644 --- a/jsapp/js/components/activity/FormActivity.stories.tsx +++ b/jsapp/js/components/activity/FormActivity.stories.tsx @@ -1,7 +1,7 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { reactRouterParameters, withRouter } from 'storybook-addon-remix-react-router' import { expect, userEvent, waitFor, within } from 'storybook/test' -import { getApiV2AssetsHistoryActionsRetrieveMockHandler } from '#/api/react-query/logging' +import { getApiV2AssetsHistoryActionsRetrieveMockHandler } from '#/api/react-query/logging.msw' import assetHistoryMock, { assetHistoryMockWithOngoingBulkProcessing, mockAssetUid, diff --git a/jsapp/js/components/locking/lockingUtils.mocks.ts b/jsapp/js/components/locking/lockingUtils.mocks.ts index b3e2a2f009..33904d85a1 100644 --- a/jsapp/js/components/locking/lockingUtils.mocks.ts +++ b/jsapp/js/components/locking/lockingUtils.mocks.ts @@ -1,6 +1,6 @@ import cloneDeep from 'lodash.clonedeep' import merge from 'lodash.merge' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' import { AssetTypeName, GroupTypeBeginName, diff --git a/jsapp/js/components/map/FormMapWrapper.stories.tsx b/jsapp/js/components/map/FormMapWrapper.stories.tsx index 2eb456f6c3..8ad5eadc8c 100644 --- a/jsapp/js/components/map/FormMapWrapper.stories.tsx +++ b/jsapp/js/components/map/FormMapWrapper.stories.tsx @@ -3,7 +3,7 @@ import { http, HttpResponse } from 'msw' import { reactRouterParameters, withRouter } from 'storybook-addon-remix-react-router' import { expect, waitFor, within } from 'storybook/test' import { endpoints } from '#/api.endpoints' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' import { MetaQuestionTypeName, QuestionTypeName } from '#/constants' import type { AssetResponse, PaginatedResponse, SubmissionResponse } from '#/dataInterface' import assetDataFactory from '#/endpoints/assetData.factory' diff --git a/jsapp/js/components/reports/reports.utils.tests.ts b/jsapp/js/components/reports/reports.utils.tests.ts index 7fb8d32bcf..e5fe04df7b 100644 --- a/jsapp/js/components/reports/reports.utils.tests.ts +++ b/jsapp/js/components/reports/reports.utils.tests.ts @@ -1,5 +1,5 @@ import chai from 'chai' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' import { QuestionTypeName } from '#/constants' import type { AssetResponse } from '#/dataInterface' import { reportStyleFactory, reportsResponseDataFactory } from './reports.factory' diff --git a/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx b/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx index 36eb53896e..b37321d9fa 100644 --- a/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx +++ b/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx @@ -1,6 +1,6 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { withRouter } from 'storybook-addon-remix-react-router' -import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data.msw' import BulkProcessingBanner from './BulkProcessingBanner' import { withBulkProcessingBannerSessionReset } from './BulkProcessingBannerStoriesUtils' diff --git a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx index 73e503e07e..fa35d8aef5 100644 --- a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx +++ b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx @@ -17,8 +17,8 @@ import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseSta import { getApiV2AssetsRetrieveMockHandler, getApiV2AssetsRetrieveResponseMock, -} from '#/api/react-query/manage-projects-and-library-content' -import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' +} from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data.msw' import { QuestionTypeName } from '#/constants' import assetDataFactory from '#/endpoints/assetData.factory' import assetDataMock from '#/endpoints/assetData.mocks' diff --git a/jsapp/js/components/submissions/submissionUtils.mocks.ts b/jsapp/js/components/submissions/submissionUtils.mocks.ts index c68f77062f..d1241af5b0 100644 --- a/jsapp/js/components/submissions/submissionUtils.mocks.ts +++ b/jsapp/js/components/submissions/submissionUtils.mocks.ts @@ -1,4 +1,4 @@ -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' import { AssetTypeName, GroupTypeBeginName, diff --git a/jsapp/js/components/submissions/tableUtils.mocks.ts b/jsapp/js/components/submissions/tableUtils.mocks.ts index 53aa8084e2..b9e1a91b91 100644 --- a/jsapp/js/components/submissions/tableUtils.mocks.ts +++ b/jsapp/js/components/submissions/tableUtils.mocks.ts @@ -1,4 +1,4 @@ -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' import { ANY_ROW_TYPE_NAMES, AssetTypeName } from '#/constants' import type { AssetResponse } from '#/dataInterface' diff --git a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts index d3964fe572..cf091bc941 100644 --- a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts +++ b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts @@ -6,7 +6,7 @@ import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock, getAssetsAdvancedFeaturesBulkActionsListQueryKey, useAssetsAdvancedFeaturesBulkActionsList, -} from '#/api/react-query/survey-data' +} from '#/api/react-query/survey-data.msw' import { useFeatureFlag } from '#/featureFlags' import { useSession } from '#/stores/useSession' import { getBulkActionsPollingIntervalMs, useDataTableBulkActions } from './useDataTableBulkActions' diff --git a/jsapp/js/endpoints/assetHistory.mocks.ts b/jsapp/js/endpoints/assetHistory.mocks.ts index dbb6ad883c..68094191a4 100644 --- a/jsapp/js/endpoints/assetHistory.mocks.ts +++ b/jsapp/js/endpoints/assetHistory.mocks.ts @@ -1,7 +1,7 @@ import { http, HttpResponse, type PathParams } from 'msw' import { endpoints } from '#/api.endpoints' import type { ProjectHistoryLogResponse } from '#/api/models/projectHistoryLogResponse' -import { getApiV2ProjectHistoryLogsListResponseMock } from '#/api/react-query/server-logs-superusers' +import { getApiV2ProjectHistoryLogsListResponseMock } from '#/api/react-query/server-logs-superusers.msw' import { type ActivityLogsItem, AuditActions, diff --git a/jsapp/js/endpoints/assets.mocks.ts b/jsapp/js/endpoints/assets.mocks.ts index 063b2f0e3e..43486118f2 100644 --- a/jsapp/js/endpoints/assets.mocks.ts +++ b/jsapp/js/endpoints/assets.mocks.ts @@ -1,7 +1,7 @@ import { getApiV2AssetsListMockHandler, getApiV2AssetsRetrieveResponseMock, -} from '#/api/react-query/manage-projects-and-library-content' +} from '#/api/react-query/manage-projects-and-library-content.msw' import { AssetTypeName, QuestionTypeName } from '#/constants' import type { AssetResponse, PaginatedResponse } from '#/dataInterface' import { mockTemplates } from './assets.templates' diff --git a/jsapp/js/endpoints/assets.templates.ts b/jsapp/js/endpoints/assets.templates.ts index 145d9928c5..134d12701b 100644 --- a/jsapp/js/endpoints/assets.templates.ts +++ b/jsapp/js/endpoints/assets.templates.ts @@ -1,4 +1,4 @@ -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' import { AssetTypeName, QuestionTypeName } from '#/constants' /** diff --git a/jsapp/js/endpoints/bulkActions.mocks.ts b/jsapp/js/endpoints/bulkActions.mocks.ts index c7fac1d811..ec2827cc14 100644 --- a/jsapp/js/endpoints/bulkActions.mocks.ts +++ b/jsapp/js/endpoints/bulkActions.mocks.ts @@ -5,7 +5,7 @@ import type { BulkActionListResponse } from '#/api/models/bulkActionListResponse import type { BulkActionResponse } from '#/api/models/bulkActionResponse' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' import { BulkActionSubmissionStatusResponseStatusEnum } from '#/api/models/bulkActionSubmissionStatusResponseStatusEnum' -import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data.msw' /** * Mock API for bulk actions list. Use it in Storybook tests in `parameters.msw.handlers.bulkActions`. diff --git a/jsapp/js/endpoints/environment.mocks.ts b/jsapp/js/endpoints/environment.mocks.ts index 6c448f1133..ad7673b540 100644 --- a/jsapp/js/endpoints/environment.mocks.ts +++ b/jsapp/js/endpoints/environment.mocks.ts @@ -1,4 +1,4 @@ -import { getApiV2EnvironmentRetrieveMockHandler } from '#/api/react-query/configuration' +import { getApiV2EnvironmentRetrieveMockHandler } from '#/api/react-query/configuration.msw' /** * Production-like environment configuration for testing. diff --git a/jsapp/js/endpoints/formMedia.mocks.ts b/jsapp/js/endpoints/formMedia.mocks.ts index 0fdda1f4da..371eb0d0dd 100644 --- a/jsapp/js/endpoints/formMedia.mocks.ts +++ b/jsapp/js/endpoints/formMedia.mocks.ts @@ -4,7 +4,7 @@ import { getApiV2AssetsFilesCreateResponseMock, getApiV2AssetsFilesDestroyMockHandler, getApiV2AssetsFilesListMockHandler, -} from '#/api/react-query/survey-data' +} from '#/api/react-query/survey-data.msw' /** * Extended FilesResponse type with redirect_url in metadata. diff --git a/jsapp/js/endpoints/languageDetail.mocks.ts b/jsapp/js/endpoints/languageDetail.mocks.ts index 796e9cd1c4..6b215bd3cd 100644 --- a/jsapp/js/endpoints/languageDetail.mocks.ts +++ b/jsapp/js/endpoints/languageDetail.mocks.ts @@ -1,4 +1,4 @@ -import { getApiV2LanguagesRetrieveMockHandler } from '#/api/react-query/other' +import { getApiV2LanguagesRetrieveMockHandler } from '#/api/react-query/other.msw' /** * Mock API for language detail endpoint using Orval-generated handler. diff --git a/jsapp/js/endpoints/me.mocks.ts b/jsapp/js/endpoints/me.mocks.ts index f45ce83f6f..0db619a373 100644 --- a/jsapp/js/endpoints/me.mocks.ts +++ b/jsapp/js/endpoints/me.mocks.ts @@ -1,5 +1,5 @@ import type { MeListResponse } from '#/api/models/meListResponse' -import { getMeRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage' +import { getMeRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage.msw' /** * Mock response data for /me/ endpoint. diff --git a/jsapp/js/endpoints/organization.mocks.ts b/jsapp/js/endpoints/organization.mocks.ts index 472a4f931e..ab10f14795 100644 --- a/jsapp/js/endpoints/organization.mocks.ts +++ b/jsapp/js/endpoints/organization.mocks.ts @@ -1,5 +1,5 @@ import type { OrganizationResponse } from '#/api/models/organizationResponse' -import { getApiV2OrganizationsRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage' +import { getApiV2OrganizationsRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage.msw' import { meMockResponse } from './me.mocks' /** diff --git a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx index e326b5f034..855b9384b4 100644 --- a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx +++ b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx @@ -3,7 +3,7 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { expect, fn, userEvent, waitFor, within } from 'storybook/test' import type { AssetContentSurveyItem } from '#/api/models/assetContentSurveyItem' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' import ButtonNew from '#/components/common/ButtonNew' import { QuestionTypeName } from '#/constants' import type { AssetResponse } from '#/dataInterface' diff --git a/jsapp/js/project/FormMedia/FormMedia.stories.tsx b/jsapp/js/project/FormMedia/FormMedia.stories.tsx index 9fcb48f7c7..dbbbeb541f 100644 --- a/jsapp/js/project/FormMedia/FormMedia.stories.tsx +++ b/jsapp/js/project/FormMedia/FormMedia.stories.tsx @@ -1,6 +1,6 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { expect, userEvent, waitFor, within } from 'storybook/test' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' import { createFormMediaItem, formMediaHandlers } from '#/endpoints/formMedia.mocks' import { queryClientDecorator } from '#/query/queryClient.mocks' import FormMedia from './index' diff --git a/orval.config.js b/orval.config.js index 69bf6c8c43..8a73a48d99 100644 --- a/orval.config.js +++ b/orval.config.js @@ -3,7 +3,7 @@ const { operationName } = require('./jsapp/js/api/orval.operationName.js') module.exports = { 'kpi-v2': { output: { - mode: 'tags', + mode: 'tags-split', workspace: './jsapp/js/api/', target: './react-query', schemas: './models', @@ -15,9 +15,9 @@ module.exports = { return generatorClients['react-query'] }, httpClient: 'fetch', - mock: { - type: 'msw', - }, + // Generate mocks in separate .msw.ts files to avoid bundling faker/msw in production + // With mode: 'tags-split', mocks are generated separately from runtime code + mock: true, indexFiles: false, biome: true, From 3b9c8ea621dea35e62726fd4f47981a365580a89 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 18:20:31 +0200 Subject: [PATCH 74/86] fix imports --- .../authentication-allauth-headless.msw.ts | 4125 --------- .../authentication-allauth-headless.ts | 8112 ----------------- .../authentication-allauth-headless/index.ts | 7399 +++++++++++++++ .../authentication-allauth-headless/msw.ts | 1114 +++ .../configuration/configuration.msw.ts | 140 - .../{configuration.ts => index.ts} | 113 +- jsapp/js/api/react-query/configuration/msw.ts | 44 + .../form-content/form-content.msw.ts | 548 -- .../react-query/form-content/form-content.ts | 1035 --- .../js/api/react-query/form-content/index.ts | 1038 +++ jsapp/js/api/react-query/form-content/msw.ts | 178 + .../react-query/library-collections/index.ts | 391 + .../library-collections.msw.ts | 130 - .../library-collections.ts | 389 - .../react-query/library-collections/msw.ts | 78 + jsapp/js/api/react-query/logging/index.ts | 751 ++ .../js/api/react-query/logging/logging.msw.ts | 407 - jsapp/js/api/react-query/logging/logging.ts | 709 -- jsapp/js/api/react-query/logging/msw.ts | 123 + .../react-query/manage-permissions/index.ts | 676 ++ .../manage-permissions.msw.ts | 196 - .../manage-permissions/manage-permissions.ts | 753 -- .../api/react-query/manage-permissions/msw.ts | 110 + .../index.ts | 2743 ++++++ ...manage-projects-and-library-content.msw.ts | 5188 ----------- .../manage-projects-and-library-content.ts | 2672 ------ .../msw.ts | 509 ++ jsapp/js/api/react-query/other/index.ts | 1774 ++++ jsapp/js/api/react-query/other/msw.ts | 381 + jsapp/js/api/react-query/other/other.msw.ts | 1051 --- jsapp/js/api/react-query/other/other.ts | 1711 ---- jsapp/js/api/react-query/scim/index.ts | 1407 +++ jsapp/js/api/react-query/scim/msw.ts | 274 + jsapp/js/api/react-query/scim/scim.msw.ts | 487 - jsapp/js/api/react-query/scim/scim.ts | 1408 --- .../{server-logs-superusers.ts => index.ts} | 834 +- .../react-query/server-logs-superusers/msw.ts | 159 + .../server-logs-superusers.msw.ts | 1062 --- .../survey-data-rest-services/index.ts | 968 ++ .../survey-data-rest-services/msw.ts | 167 + .../survey-data-rest-services.msw.ts | 433 - .../survey-data-rest-services.ts | 964 -- jsapp/js/api/react-query/survey-data/index.ts | 5895 ++++++++++++ jsapp/js/api/react-query/survey-data/msw.ts | 1023 +++ .../survey-data/survey-data.msw.ts | 3020 ------ .../react-query/survey-data/survey-data.ts | 6157 ------------- .../user-team-organization-usage/index.ts | 3640 ++++++++ .../user-team-organization-usage/msw.ts | 640 ++ .../user-team-organization-usage.msw.ts | 2287 ----- .../user-team-organization-usage.ts | 3662 -------- .../AttachmentActionsDropdown.mocks.ts | 2 +- .../AssetTagsModal/AssetTagsModal.stories.tsx | 2 +- .../activity/FormActivity.stories.tsx | 2 +- .../components/locking/lockingUtils.mocks.ts | 2 +- .../components/map/FormMapWrapper.stories.tsx | 2 +- .../components/reports/reports.utils.tests.ts | 2 +- .../BulkProcessingBanner.stories.tsx | 2 +- .../submissions/DataTableWrapper.stories.tsx | 4 +- .../submissions/submissionUtils.mocks.ts | 2 +- .../submissions/tableUtils.mocks.ts | 2 +- .../useDataTableBulkActions.tests.ts | 2 +- jsapp/js/endpoints/assetHistory.mocks.ts | 2 +- jsapp/js/endpoints/assets.mocks.ts | 2 +- jsapp/js/endpoints/assets.templates.ts | 2 +- jsapp/js/endpoints/bulkActions.mocks.ts | 2 +- jsapp/js/endpoints/environment.mocks.ts | 2 +- jsapp/js/endpoints/formMedia.mocks.ts | 2 +- jsapp/js/endpoints/languageDetail.mocks.ts | 2 +- jsapp/js/endpoints/me.mocks.ts | 2 +- jsapp/js/endpoints/organization.mocks.ts | 2 +- .../FormLanguagesManager.stories.tsx | 2 +- .../project/FormMedia/FormMedia.stories.tsx | 2 +- 72 files changed, 32026 insertions(+), 47095 deletions(-) delete mode 100644 jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.msw.ts delete mode 100644 jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.ts create mode 100644 jsapp/js/api/react-query/authentication-allauth-headless/index.ts create mode 100644 jsapp/js/api/react-query/authentication-allauth-headless/msw.ts delete mode 100644 jsapp/js/api/react-query/configuration/configuration.msw.ts rename jsapp/js/api/react-query/configuration/{configuration.ts => index.ts} (54%) create mode 100644 jsapp/js/api/react-query/configuration/msw.ts delete mode 100644 jsapp/js/api/react-query/form-content/form-content.msw.ts delete mode 100644 jsapp/js/api/react-query/form-content/form-content.ts create mode 100644 jsapp/js/api/react-query/form-content/index.ts create mode 100644 jsapp/js/api/react-query/form-content/msw.ts create mode 100644 jsapp/js/api/react-query/library-collections/index.ts delete mode 100644 jsapp/js/api/react-query/library-collections/library-collections.msw.ts delete mode 100644 jsapp/js/api/react-query/library-collections/library-collections.ts create mode 100644 jsapp/js/api/react-query/library-collections/msw.ts create mode 100644 jsapp/js/api/react-query/logging/index.ts delete mode 100644 jsapp/js/api/react-query/logging/logging.msw.ts delete mode 100644 jsapp/js/api/react-query/logging/logging.ts create mode 100644 jsapp/js/api/react-query/logging/msw.ts create mode 100644 jsapp/js/api/react-query/manage-permissions/index.ts delete mode 100644 jsapp/js/api/react-query/manage-permissions/manage-permissions.msw.ts delete mode 100644 jsapp/js/api/react-query/manage-permissions/manage-permissions.ts create mode 100644 jsapp/js/api/react-query/manage-permissions/msw.ts create mode 100644 jsapp/js/api/react-query/manage-projects-and-library-content/index.ts delete mode 100644 jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.msw.ts delete mode 100644 jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.ts create mode 100644 jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts create mode 100644 jsapp/js/api/react-query/other/index.ts create mode 100644 jsapp/js/api/react-query/other/msw.ts delete mode 100644 jsapp/js/api/react-query/other/other.msw.ts delete mode 100644 jsapp/js/api/react-query/other/other.ts create mode 100644 jsapp/js/api/react-query/scim/index.ts create mode 100644 jsapp/js/api/react-query/scim/msw.ts delete mode 100644 jsapp/js/api/react-query/scim/scim.msw.ts delete mode 100644 jsapp/js/api/react-query/scim/scim.ts rename jsapp/js/api/react-query/server-logs-superusers/{server-logs-superusers.ts => index.ts} (50%) create mode 100644 jsapp/js/api/react-query/server-logs-superusers/msw.ts delete mode 100644 jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.msw.ts create mode 100644 jsapp/js/api/react-query/survey-data-rest-services/index.ts create mode 100644 jsapp/js/api/react-query/survey-data-rest-services/msw.ts delete mode 100644 jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.msw.ts delete mode 100644 jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.ts create mode 100644 jsapp/js/api/react-query/survey-data/index.ts create mode 100644 jsapp/js/api/react-query/survey-data/msw.ts delete mode 100644 jsapp/js/api/react-query/survey-data/survey-data.msw.ts delete mode 100644 jsapp/js/api/react-query/survey-data/survey-data.ts create mode 100644 jsapp/js/api/react-query/user-team-organization-usage/index.ts create mode 100644 jsapp/js/api/react-query/user-team-organization-usage/msw.ts delete mode 100644 jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.msw.ts delete mode 100644 jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.ts diff --git a/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.msw.ts b/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.msw.ts deleted file mode 100644 index 1360bd115d..0000000000 --- a/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.msw.ts +++ /dev/null @@ -1,4125 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import type { AuthenticatedByCodeResponse } from '../../models/authenticatedByCodeResponse' - -import type { AuthenticatedByPasswordAnd2FAResponse } from '../../models/authenticatedByPasswordAnd2FAResponse' - -import type { AuthenticatedByPasswordResponse } from '../../models/authenticatedByPasswordResponse' - -import type { AuthenticatedResponse } from '../../models/authenticatedResponse' - -import { AuthenticatorType } from '../../models/authenticatorType' - -import type { AuthenticatorsResponse } from '../../models/authenticatorsResponse' - -import type { ConfigurationResponse } from '../../models/configurationResponse' - -import type { EmailAddressesResponse } from '../../models/emailAddressesResponse' - -import type { EmailVerificationInfoResponse } from '../../models/emailVerificationInfoResponse' - -import type { PasswordResetInfoResponse } from '../../models/passwordResetInfoResponse' - -import type { PhoneNumberChangeResponse } from '../../models/phoneNumberChangeResponse' - -import type { PhoneNumbersResponse } from '../../models/phoneNumbersResponse' - -import type { ProviderAccountsResponse } from '../../models/providerAccountsResponse' - -import type { ProviderSignupResponse } from '../../models/providerSignupResponse' - -import type { RecoveryCodesAuthenticator } from '../../models/recoveryCodesAuthenticator' - -import type { RecoveryCodesResponse } from '../../models/recoveryCodesResponse' - -import type { RefreshTokenResponse } from '../../models/refreshTokenResponse' - -import type { SessionsResponse } from '../../models/sessionsResponse' - -import type { StatusOKResponse } from '../../models/statusOKResponse' - -import type { TOTPAuthenticator } from '../../models/tOTPAuthenticator' - -import type { TOTPAuthenticatorResponse } from '../../models/tOTPAuthenticatorResponse' - -import type { WebAuthnAuthenticator } from '../../models/webAuthnAuthenticator' - -export const getApiV2AllauthBrowserV1ConfigGetResponseMock = ( - overrideResponse: Partial = {}, -): ConfigurationResponse => ({ - data: { - account: { - login_methods: faker.helpers.arrayElement([ - faker.helpers.arrayElements(['email', 'username'] as const), - undefined, - ]), - is_open_for_signup: faker.datatype.boolean(), - email_verification_by_code_enabled: faker.datatype.boolean(), - login_by_code_enabled: faker.datatype.boolean(), - password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - socialaccount: faker.helpers.arrayElement([ - { - providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - })), - }, - undefined, - ]), - mfa: faker.helpers.arrayElement([ - { supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType)) }, - undefined, - ]), - usersessions: faker.helpers.arrayElement([{ track_activity: faker.datatype.boolean() }, undefined]), - }, - status: faker.helpers.arrayElement([200] as const), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1ConfigGetResponseMock = ( - overrideResponse: Partial = {}, -): ConfigurationResponse => ({ - data: { - account: { - login_methods: faker.helpers.arrayElement([ - faker.helpers.arrayElements(['email', 'username'] as const), - undefined, - ]), - is_open_for_signup: faker.datatype.boolean(), - email_verification_by_code_enabled: faker.datatype.boolean(), - login_by_code_enabled: faker.datatype.boolean(), - password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - socialaccount: faker.helpers.arrayElement([ - { - providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - })), - }, - undefined, - ]), - mfa: faker.helpers.arrayElement([ - { supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType)) }, - undefined, - ]), - usersessions: faker.helpers.arrayElement([{ track_activity: faker.datatype.boolean() }, undefined]), - }, - status: faker.helpers.arrayElement([200] as const), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthLoginPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthLoginPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthSignupPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthSignupPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock = ( - overrideResponse: Partial = {}, -): EmailVerificationInfoResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - meta: { is_authenticating: faker.datatype.boolean() }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock = ( - overrideResponse: Partial = {}, -): EmailVerificationInfoResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - meta: { is_authenticating: faker.datatype.boolean() }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthReauthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock = ( - overrideResponse: Partial = {}, -): PasswordResetInfoResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: faker.helpers.arrayElement([ - { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthPasswordResetGetResponseMock = ( - overrideResponse: Partial = {}, -): PasswordResetInfoResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: faker.helpers.arrayElement([ - { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthPasswordResetPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthProviderTokenPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock = ( - overrideResponse: Partial = {}, -): ProviderSignupResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - account: { - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - }, - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthProviderSignupGetResponseMock = ( - overrideResponse: Partial = {}, -): ProviderSignupResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - account: { - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - }, - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthProviderSignupPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordAnd2FAResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordAnd2FAResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordAnd2FAResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByPasswordAnd2FAResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByCodeResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedByCodeResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountProvidersGetResponseMock = ( - overrideResponse: Partial = {}, -): ProviderAccountsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock = ( - overrideResponse: Partial = {}, -): ProviderAccountsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountProvidersGetResponseMock = ( - overrideResponse: Partial = {}, -): ProviderAccountsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountProvidersDeleteResponseMock = ( - overrideResponse: Partial = {}, -): ProviderAccountsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider: { - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - openid_configuration_url: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountEmailGetResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountEmailPostResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountEmailPutResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthBrowserV1AccountEmailPatchResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountEmailGetResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountEmailPostResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountEmailPutResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthAppV1AccountEmailPatchResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountEmailDeleteResponseMock = ( - overrideResponse: Partial = {}, -): EmailAddressesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountPhoneGetResponseMock = ( - overrideResponse: Partial = {}, -): PhoneNumbersResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountPhonePostResponseMock = ( - overrideResponse: Partial = {}, -): PhoneNumberChangeResponse => ({ - status: faker.helpers.arrayElement([202] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountPhoneGetResponseMock = ( - overrideResponse: Partial = {}, -): PhoneNumbersResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountPhonePostResponseMock = ( - overrideResponse: Partial = {}, -): PhoneNumberChangeResponse => ({ - status: faker.helpers.arrayElement([202] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = ( - overrideResponse: Partial = {}, -): RecoveryCodesAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['recovery_codes'] as const), - total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = ( - overrideResponse: Partial = {}, -): WebAuthnAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['webauthn'] as const), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatorsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock() }, - { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock() }, - { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock() }, - ]), - ), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = ( - overrideResponse: Partial = {}, -): RecoveryCodesAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['recovery_codes'] as const), - total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = ( - overrideResponse: Partial = {}, -): WebAuthnAuthenticator => ({ - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['webauthn'] as const), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatorsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock() }, - { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock() }, - { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock() }, - ]), - ), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticatorResponse => ({ - status: faker.helpers.arrayElement([200] as const), - meta: faker.helpers.arrayElement([ - { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - data: { - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticatorResponse => ({ - status: faker.helpers.arrayElement([200] as const), - meta: faker.helpers.arrayElement([ - { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - data: { - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticatorResponse => ({ - status: faker.helpers.arrayElement([200] as const), - meta: faker.helpers.arrayElement([ - { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - data: { - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock = ( - overrideResponse: Partial = {}, -): TOTPAuthenticatorResponse => ({ - status: faker.helpers.arrayElement([200] as const), - meta: faker.helpers.arrayElement([ - { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - data: { - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ type: faker.helpers.arrayElement(['totp'] as const) }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock = ( - overrideResponse: Partial = {}, -): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock = ( - overrideResponse: Partial = {}, -): RecoveryCodesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['recovery_codes'] as const), - total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - ...{ - unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock = ( - overrideResponse: Partial = {}, -): RecoveryCodesResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - ...{ - ...{ - last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - }, - ...{ - type: faker.helpers.arrayElement(['recovery_codes'] as const), - total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - ...{ - unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthSessionGetResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthSessionGetResponseMock = ( - overrideResponse: Partial = {}, -): AuthenticatedResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - user: { - id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - display: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - has_usable_password: faker.datatype.boolean(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - { - method: faker.helpers.arrayElement(['password_reset'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['code'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - phone: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['password'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - reauthenticated: faker.datatype.boolean(), - }, - { - method: faker.helpers.arrayElement(['socialaccount'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - { - method: faker.helpers.arrayElement(['mfa'] as const), - at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), - reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ]), - ), - }, - meta: { - ...{ - session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...{ is_authenticated: faker.datatype.boolean() }, - }, - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1TokensRefreshPostResponseMock = ( - overrideResponse: Partial = {}, -): RefreshTokenResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: { - access_token: faker.string.alpha({ length: { min: 10, max: 20 } }), - refresh_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthSessionsGetResponseMock = ( - overrideResponse: Partial = {}, -): SessionsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), - ip: faker.string.alpha({ length: { min: 10, max: 20 } }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - is_current: faker.datatype.boolean(), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - last_seen_at: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock = ( - overrideResponse: Partial = {}, -): SessionsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), - ip: faker.string.alpha({ length: { min: 10, max: 20 } }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - is_current: faker.datatype.boolean(), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - last_seen_at: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthSessionsGetResponseMock = ( - overrideResponse: Partial = {}, -): SessionsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), - ip: faker.string.alpha({ length: { min: 10, max: 20 } }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - is_current: faker.datatype.boolean(), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - last_seen_at: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthAppV1AuthSessionsDeleteResponseMock = ( - overrideResponse: Partial = {}, -): SessionsResponse => ({ - status: faker.helpers.arrayElement([200] as const), - data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), - ip: faker.string.alpha({ length: { min: 10, max: 20 } }), - created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - is_current: faker.datatype.boolean(), - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - last_seen_at: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AllauthBrowserV1ConfigGetMockHandler = ( - overrideResponse?: - | ConfigurationResponse - | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/config', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1ConfigGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1ConfigGetMockHandler = ( - overrideResponse?: - | ConfigurationResponse - | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/config', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1ConfigGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthLoginPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/login', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthLoginPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthLoginPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/login', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthLoginPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthSignupPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthSignupPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthSignupPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthSignupPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler = ( - overrideResponse?: - | EmailVerificationInfoResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailVerificationInfoResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler = ( - overrideResponse?: - | EmailVerificationInfoResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailVerificationInfoResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/email/verify/resend', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/email/verify/resend', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/phone/verify', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify/resend', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/phone/verify/resend', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/reauthenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthReauthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/reauthenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthReauthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/password/request', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/password/request', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler = ( - overrideResponse?: - | PasswordResetInfoResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PasswordResetInfoResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthPasswordResetGetMockHandler = ( - overrideResponse?: - | PasswordResetInfoResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PasswordResetInfoResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthPasswordResetGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthPasswordResetPostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthPasswordResetPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/provider/redirect', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/provider/token', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthProviderTokenPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/provider/token', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthProviderTokenPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler = ( - overrideResponse?: - | ProviderSignupResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderSignupResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthProviderSignupGetMockHandler = ( - overrideResponse?: - | ProviderSignupResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderSignupResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthProviderSignupGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthProviderSignupPostMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthProviderSignupPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordAnd2FAResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordAnd2FAResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/2fa/authenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordAnd2FAResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordAnd2FAResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/2fa/authenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordAnd2FAResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordAnd2FAResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/2fa/reauthenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler = ( - overrideResponse?: - | AuthenticatedByPasswordAnd2FAResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByPasswordAnd2FAResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/2fa/reauthenticate', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler = ( - overrideResponse?: - | AuthenticatedByCodeResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByCodeResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/auth/code/confirm', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler = ( - overrideResponse?: - | AuthenticatedByCodeResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatedByCodeResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/auth/code/confirm', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountProvidersGetMockHandler = ( - overrideResponse?: - | ProviderAccountsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderAccountsResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/providers', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountProvidersGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler = ( - overrideResponse?: - | ProviderAccountsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderAccountsResponse), -) => { - return http.delete('*/api/v2/allauth/browser/v1/account/providers', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountProvidersGetMockHandler = ( - overrideResponse?: - | ProviderAccountsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderAccountsResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/providers', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountProvidersGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountProvidersDeleteMockHandler = ( - overrideResponse?: - | ProviderAccountsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProviderAccountsResponse), -) => { - return http.delete('*/api/v2/allauth/app/v1/account/providers', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountProvidersDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountEmailGetMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountEmailGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountEmailPostMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountEmailPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountEmailPutMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.put('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountEmailPutResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountEmailPatchMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.patch('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountEmailPatchResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.delete('*/api/v2/allauth/browser/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountEmailGetMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountEmailGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountEmailPostMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountEmailPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountEmailPutMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.put('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountEmailPutResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountEmailPatchMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.patch('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountEmailPatchResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountEmailDeleteMockHandler = ( - overrideResponse?: - | EmailAddressesResponse - | (( - info: Parameters[1]>[0], - ) => Promise | EmailAddressesResponse), -) => { - return http.delete('*/api/v2/allauth/app/v1/account/email', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountEmailDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountPhoneGetMockHandler = ( - overrideResponse?: - | PhoneNumbersResponse - | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/phone', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountPhoneGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountPhonePostMockHandler = ( - overrideResponse?: - | PhoneNumberChangeResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PhoneNumberChangeResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/account/phone', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountPhonePostResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountPhoneGetMockHandler = ( - overrideResponse?: - | PhoneNumbersResponse - | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/phone', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountPhoneGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountPhonePostMockHandler = ( - overrideResponse?: - | PhoneNumberChangeResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PhoneNumberChangeResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/account/phone', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountPhonePostResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler = ( - overrideResponse?: - | AuthenticatorsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatorsResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/authenticators', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler = ( - overrideResponse?: - | AuthenticatorsResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AuthenticatorsResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/authenticators', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler = ( - overrideResponse?: - | TOTPAuthenticatorResponse - | (( - info: Parameters[1]>[0], - ) => Promise | TOTPAuthenticatorResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler = ( - overrideResponse?: - | TOTPAuthenticatorResponse - | (( - info: Parameters[1]>[0], - ) => Promise | TOTPAuthenticatorResponse), -) => { - return http.post('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.delete('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler = ( - overrideResponse?: - | TOTPAuthenticatorResponse - | (( - info: Parameters[1]>[0], - ) => Promise | TOTPAuthenticatorResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler = ( - overrideResponse?: - | TOTPAuthenticatorResponse - | (( - info: Parameters[1]>[0], - ) => Promise | TOTPAuthenticatorResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler = ( - overrideResponse?: - | StatusOKResponse - | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), -) => { - return http.delete('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler = ( - overrideResponse?: - | RecoveryCodesResponse - | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.post('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler = ( - overrideResponse?: - | RecoveryCodesResponse - | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.post('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthBrowserV1AuthSessionGetMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/auth/session', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthSessionGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.delete('*/api/v2/allauth/browser/v1/auth/session', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthAppV1AuthSessionGetMockHandler = ( - overrideResponse?: - | AuthenticatedResponse - | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/auth/session', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthSessionGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthSessionDeleteMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.delete('*/api/v2/allauth/app/v1/auth/session', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthAppV1TokensRefreshPostMockHandler = ( - overrideResponse?: - | RefreshTokenResponse - | ((info: Parameters[1]>[0]) => Promise | RefreshTokenResponse), -) => { - return http.post('*/api/v2/allauth/app/v1/tokens/refresh', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1TokensRefreshPostResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.post('*/api/v2/allauth/browser/v1/account/password/change', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthAppV1AccountPasswordChangePostMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.post('*/api/v2/allauth/app/v1/account/password/change', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AllauthBrowserV1AuthSessionsGetMockHandler = ( - overrideResponse?: - | SessionsResponse - | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), -) => { - return http.get('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthSessionsGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler = ( - overrideResponse?: - | SessionsResponse - | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), -) => { - return http.delete('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthSessionsGetMockHandler = ( - overrideResponse?: - | SessionsResponse - | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), -) => { - return http.get('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthSessionsGetResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AllauthAppV1AuthSessionsDeleteMockHandler = ( - overrideResponse?: - | SessionsResponse - | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), -) => { - return http.delete('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AllauthAppV1AuthSessionsDeleteResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getAuthenticationAllauthHeadlessMock = () => [ - getApiV2AllauthBrowserV1ConfigGetMockHandler(), - getApiV2AllauthAppV1ConfigGetMockHandler(), - getApiV2AllauthBrowserV1AuthLoginPostMockHandler(), - getApiV2AllauthAppV1AuthLoginPostMockHandler(), - getApiV2AllauthBrowserV1AuthSignupPostMockHandler(), - getApiV2AllauthAppV1AuthSignupPostMockHandler(), - getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler(), - getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler(), - getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler(), - getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler(), - getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler(), - getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler(), - getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler(), - getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler(), - getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler(), - getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler(), - getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler(), - getApiV2AllauthAppV1AuthReauthenticatePostMockHandler(), - getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler(), - getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler(), - getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler(), - getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler(), - getApiV2AllauthAppV1AuthPasswordResetGetMockHandler(), - getApiV2AllauthAppV1AuthPasswordResetPostMockHandler(), - getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler(), - getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler(), - getApiV2AllauthAppV1AuthProviderTokenPostMockHandler(), - getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler(), - getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler(), - getApiV2AllauthAppV1AuthProviderSignupGetMockHandler(), - getApiV2AllauthAppV1AuthProviderSignupPostMockHandler(), - getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler(), - getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler(), - getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler(), - getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler(), - getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler(), - getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler(), - getApiV2AllauthBrowserV1AccountProvidersGetMockHandler(), - getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler(), - getApiV2AllauthAppV1AccountProvidersGetMockHandler(), - getApiV2AllauthAppV1AccountProvidersDeleteMockHandler(), - getApiV2AllauthBrowserV1AccountEmailGetMockHandler(), - getApiV2AllauthBrowserV1AccountEmailPostMockHandler(), - getApiV2AllauthBrowserV1AccountEmailPutMockHandler(), - getApiV2AllauthBrowserV1AccountEmailPatchMockHandler(), - getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler(), - getApiV2AllauthAppV1AccountEmailGetMockHandler(), - getApiV2AllauthAppV1AccountEmailPostMockHandler(), - getApiV2AllauthAppV1AccountEmailPutMockHandler(), - getApiV2AllauthAppV1AccountEmailPatchMockHandler(), - getApiV2AllauthAppV1AccountEmailDeleteMockHandler(), - getApiV2AllauthBrowserV1AccountPhoneGetMockHandler(), - getApiV2AllauthBrowserV1AccountPhonePostMockHandler(), - getApiV2AllauthAppV1AccountPhoneGetMockHandler(), - getApiV2AllauthAppV1AccountPhonePostMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler(), - getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler(), - getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler(), - getApiV2AllauthBrowserV1AuthSessionGetMockHandler(), - getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler(), - getApiV2AllauthAppV1AuthSessionGetMockHandler(), - getApiV2AllauthAppV1AuthSessionDeleteMockHandler(), - getApiV2AllauthAppV1TokensRefreshPostMockHandler(), - getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler(), - getApiV2AllauthAppV1AccountPasswordChangePostMockHandler(), - getApiV2AllauthBrowserV1AuthSessionsGetMockHandler(), - getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler(), - getApiV2AllauthAppV1AuthSessionsGetMockHandler(), - getApiV2AllauthAppV1AuthSessionsDeleteMockHandler(), -] diff --git a/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.ts b/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.ts deleted file mode 100644 index 042476b18e..0000000000 --- a/jsapp/js/api/react-query/authentication-allauth-headless/authentication-allauth-headless.ts +++ /dev/null @@ -1,8112 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { AddAuthenticatorConflictResponse } from '../../models/addAuthenticatorConflictResponse' - -import type { AuthenticatedByCodeResponse } from '../../models/authenticatedByCodeResponse' - -import type { AuthenticatedByPasswordAnd2FAResponse } from '../../models/authenticatedByPasswordAnd2FAResponse' - -import type { AuthenticatedByPasswordResponse } from '../../models/authenticatedByPasswordResponse' - -import type { AuthenticatedResponse } from '../../models/authenticatedResponse' - -import type { AuthenticationOrReauthenticationResponse } from '../../models/authenticationOrReauthenticationResponse' - -import type { AuthenticationResponse } from '../../models/authenticationResponse' - -import type { AuthenticatorsResponse } from '../../models/authenticatorsResponse' - -import type { ChangePasswordBody } from '../../models/changePasswordBody' - -import type { ConfigurationResponse } from '../../models/configurationResponse' - -import type { ConfirmLoginCodeBody } from '../../models/confirmLoginCodeBody' - -import type { ConflictResponse } from '../../models/conflictResponse' - -import type { EmailAddressesResponse } from '../../models/emailAddressesResponse' - -import type { EmailBody } from '../../models/emailBody' - -import type { EmailVerificationInfoResponse } from '../../models/emailVerificationInfoResponse' - -import type { EndSessionsBody } from '../../models/endSessionsBody' - -import type { ErrorResponse } from '../../models/errorResponse' - -import type { ForbiddenResponse } from '../../models/forbiddenResponse' - -import type { LoginBody } from '../../models/loginBody' - -import type { MFAAuthenticateBody } from '../../models/mFAAuthenticateBody' - -import type { MarkPrimaryEmailBody } from '../../models/markPrimaryEmailBody' - -import type { NotFoundResponse } from '../../models/notFoundResponse' - -import type { PasswordResetInfoResponse } from '../../models/passwordResetInfoResponse' - -import type { PhoneBody } from '../../models/phoneBody' - -import type { PhoneNumberChangeResponse } from '../../models/phoneNumberChangeResponse' - -import type { PhoneNumbersResponse } from '../../models/phoneNumbersResponse' - -import type { ProviderAccountBody } from '../../models/providerAccountBody' - -import type { ProviderAccountsResponse } from '../../models/providerAccountsResponse' - -import type { ProviderRedirectBody } from '../../models/providerRedirectBody' - -import type { ProviderSignupBody } from '../../models/providerSignupBody' - -import type { ProviderSignupResponse } from '../../models/providerSignupResponse' - -import type { ProviderTokenBody } from '../../models/providerTokenBody' - -import type { ReauthenticateBody } from '../../models/reauthenticateBody' - -import type { ReauthenticationRequiredResponse } from '../../models/reauthenticationRequiredResponse' - -import type { RecoveryCodesResponse } from '../../models/recoveryCodesResponse' - -import type { RefreshTokenBody } from '../../models/refreshTokenBody' - -import type { RefreshTokenResponse } from '../../models/refreshTokenResponse' - -import type { RequestPasswordBody } from '../../models/requestPasswordBody' - -import type { ResetPasswordBody } from '../../models/resetPasswordBody' - -import type { SessionGoneResponse } from '../../models/sessionGoneResponse' - -import type { SessionsResponse } from '../../models/sessionsResponse' - -import type { SetupTOTPBody } from '../../models/setupTOTPBody' - -import type { SignupBody } from '../../models/signupBody' - -import type { StatusOKResponse } from '../../models/statusOKResponse' - -import type { TOTPAuthenticatorNotFoundResponse } from '../../models/tOTPAuthenticatorNotFoundResponse' - -import type { TOTPAuthenticatorResponse } from '../../models/tOTPAuthenticatorResponse' - -import type { TooManyRequestsResponse } from '../../models/tooManyRequestsResponse' - -import type { UnauthenticatedResponse } from '../../models/unauthenticatedResponse' - -import type { VerifyEmailBody } from '../../models/verifyEmailBody' - -import type { VerifyPhoneBody } from '../../models/verifyPhoneBody' - -import { fetchWithAuth } from '../../orval.mutator' - -type SecondParameter unknown> = Parameters[1] - -/** - * There are many configuration options that alter the functionality -and behavior of django-allauth, some of which can also impact the -frontend. Therefore, relevant configuration options are exposed via -this endpoint. The data returned is not user/authentication -dependent. Hence, it suffices to only fetch this data once at boot -time of your application. - - * @summary Get configuration - */ -export type allauthBrowserV1ConfigGetResponse200 = { - data: ConfigurationResponse - status: 200 -} - -export type allauthBrowserV1ConfigGetResponseComposite = allauthBrowserV1ConfigGetResponse200 - -export type allauthBrowserV1ConfigGetResponse = allauthBrowserV1ConfigGetResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1ConfigGetUrl = () => { - return `/api/v2/allauth/browser/v1/config` -} - -export const allauthBrowserV1ConfigGet = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAllauthBrowserV1ConfigGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthBrowserV1ConfigGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'config'] as const -} - -export const getAllauthBrowserV1ConfigGetQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1ConfigGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthBrowserV1ConfigGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1ConfigGetQueryResult = NonNullable>> -export type AllauthBrowserV1ConfigGetQueryError = unknown - -/** - * @summary Get configuration - */ - -export function useAllauthBrowserV1ConfigGet< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1ConfigGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * There are many configuration options that alter the functionality -and behavior of django-allauth, some of which can also impact the -frontend. Therefore, relevant configuration options are exposed via -this endpoint. The data returned is not user/authentication -dependent. Hence, it suffices to only fetch this data once at boot -time of your application. - - * @summary Get configuration - */ -export type allauthAppV1ConfigGetResponse200 = { - data: ConfigurationResponse - status: 200 -} - -export type allauthAppV1ConfigGetResponseComposite = allauthAppV1ConfigGetResponse200 - -export type allauthAppV1ConfigGetResponse = allauthAppV1ConfigGetResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1ConfigGetUrl = () => { - return `/api/v2/allauth/app/v1/config` -} - -export const allauthAppV1ConfigGet = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAllauthAppV1ConfigGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthAppV1ConfigGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'config'] as const -} - -export const getAllauthAppV1ConfigGetQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1ConfigGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1ConfigGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1ConfigGetQueryResult = NonNullable>> -export type AllauthAppV1ConfigGetQueryError = unknown - -/** - * @summary Get configuration - */ - -export function useAllauthAppV1ConfigGet< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1ConfigGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Login using a username-password or email-password combination. - - * @summary Login - */ -export type allauthBrowserV1AuthLoginPostResponse200 = { - data: AuthenticatedByPasswordResponse - status: 200 -} - -export type allauthBrowserV1AuthLoginPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthLoginPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AuthLoginPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthLoginPostResponseComposite = - | allauthBrowserV1AuthLoginPostResponse200 - | allauthBrowserV1AuthLoginPostResponse400 - | allauthBrowserV1AuthLoginPostResponse401 - | allauthBrowserV1AuthLoginPostResponse409 - -export type allauthBrowserV1AuthLoginPostResponse = allauthBrowserV1AuthLoginPostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthLoginPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/login` -} - -export const allauthBrowserV1AuthLoginPost = async ( - loginBody: LoginBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthLoginPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(loginBody), - }) -} - -export const getAllauthBrowserV1AuthLoginPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: LoginBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: LoginBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthLoginPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: LoginBody }> = ( - props, - ) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthLoginPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthLoginPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthLoginPostMutationBody = LoginBody -export type AllauthBrowserV1AuthLoginPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - -/** - * @summary Login - */ -export const useAllauthBrowserV1AuthLoginPost = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: LoginBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthLoginPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Login using a username-password or email-password combination. - - * @summary Login - */ -export type allauthAppV1AuthLoginPostResponse200 = { - data: AuthenticatedByPasswordResponse - status: 200 -} - -export type allauthAppV1AuthLoginPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthLoginPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AuthLoginPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthLoginPostResponseComposite = - | allauthAppV1AuthLoginPostResponse200 - | allauthAppV1AuthLoginPostResponse400 - | allauthAppV1AuthLoginPostResponse401 - | allauthAppV1AuthLoginPostResponse409 - -export type allauthAppV1AuthLoginPostResponse = allauthAppV1AuthLoginPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthLoginPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/login` -} - -export const allauthAppV1AuthLoginPost = async ( - loginBody: LoginBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthLoginPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(loginBody), - }) -} - -export const getAllauthAppV1AuthLoginPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: LoginBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: LoginBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthLoginPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: LoginBody }> = ( - props, - ) => { - const { data } = props ?? {} - - return allauthAppV1AuthLoginPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthLoginPostMutationResult = NonNullable>> -export type AllauthAppV1AuthLoginPostMutationBody = LoginBody -export type AllauthAppV1AuthLoginPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - -/** - * @summary Login - */ -export const useAllauthAppV1AuthLoginPost = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: LoginBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthLoginPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Whether or not `username`, `email`, `phone` or combination of those are -required depends on the configuration of django-allauth. Additionally, -if a custom signup form is used there may be other custom properties -required. - - * @summary Signup - */ -export type allauthBrowserV1AuthSignupPostResponse200 = { - data: AuthenticatedByPasswordResponse - status: 200 -} - -export type allauthBrowserV1AuthSignupPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthSignupPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AuthSignupPostResponse403 = { - data: ForbiddenResponse - status: 403 -} - -export type allauthBrowserV1AuthSignupPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthSignupPostResponseComposite = - | allauthBrowserV1AuthSignupPostResponse200 - | allauthBrowserV1AuthSignupPostResponse400 - | allauthBrowserV1AuthSignupPostResponse401 - | allauthBrowserV1AuthSignupPostResponse403 - | allauthBrowserV1AuthSignupPostResponse409 - -export type allauthBrowserV1AuthSignupPostResponse = allauthBrowserV1AuthSignupPostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthSignupPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/signup` -} - -export const allauthBrowserV1AuthSignupPost = async ( - signupBody: SignupBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthSignupPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(signupBody), - }) -} - -export const getAllauthBrowserV1AuthSignupPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: SignupBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: SignupBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthSignupPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: SignupBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthSignupPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthSignupPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthSignupPostMutationBody = SignupBody -export type AllauthBrowserV1AuthSignupPostMutationError = - | ErrorResponse - | AuthenticationResponse - | ForbiddenResponse - | ConflictResponse - -/** - * @summary Signup - */ -export const useAllauthBrowserV1AuthSignupPost = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: SignupBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthSignupPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Whether or not `username`, `email`, `phone` or combination of those are -required depends on the configuration of django-allauth. Additionally, -if a custom signup form is used there may be other custom properties -required. - - * @summary Signup - */ -export type allauthAppV1AuthSignupPostResponse200 = { - data: AuthenticatedByPasswordResponse - status: 200 -} - -export type allauthAppV1AuthSignupPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthSignupPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AuthSignupPostResponse403 = { - data: ForbiddenResponse - status: 403 -} - -export type allauthAppV1AuthSignupPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthSignupPostResponseComposite = - | allauthAppV1AuthSignupPostResponse200 - | allauthAppV1AuthSignupPostResponse400 - | allauthAppV1AuthSignupPostResponse401 - | allauthAppV1AuthSignupPostResponse403 - | allauthAppV1AuthSignupPostResponse409 - -export type allauthAppV1AuthSignupPostResponse = allauthAppV1AuthSignupPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthSignupPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/signup` -} - -export const allauthAppV1AuthSignupPost = async ( - signupBody: SignupBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthSignupPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(signupBody), - }) -} - -export const getAllauthAppV1AuthSignupPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: SignupBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: SignupBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthSignupPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: SignupBody }> = ( - props, - ) => { - const { data } = props ?? {} - - return allauthAppV1AuthSignupPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthSignupPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthSignupPostMutationBody = SignupBody -export type AllauthAppV1AuthSignupPostMutationError = - | ErrorResponse - | AuthenticationResponse - | ForbiddenResponse - | ConflictResponse - -/** - * @summary Signup - */ -export const useAllauthAppV1AuthSignupPost = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: SignupBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthSignupPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Obtain email verification information, given the token that was sent to -the user by email. - - * @summary Get email verification information - */ -export type allauthBrowserV1AuthEmailVerifyGetResponse200 = { - data: EmailVerificationInfoResponse - status: 200 -} - -export type allauthBrowserV1AuthEmailVerifyGetResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthEmailVerifyGetResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthEmailVerifyGetResponseComposite = - | allauthBrowserV1AuthEmailVerifyGetResponse200 - | allauthBrowserV1AuthEmailVerifyGetResponse400 - | allauthBrowserV1AuthEmailVerifyGetResponse409 - -export type allauthBrowserV1AuthEmailVerifyGetResponse = allauthBrowserV1AuthEmailVerifyGetResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthEmailVerifyGetUrl = () => { - return `/api/v2/allauth/browser/v1/auth/email/verify` -} - -export const allauthBrowserV1AuthEmailVerifyGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthEmailVerifyGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthBrowserV1AuthEmailVerifyGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'auth', 'email', 'verify'] as const -} - -export const getAllauthBrowserV1AuthEmailVerifyGetQueryOptions = < - TData = Awaited>, - TError = ErrorResponse | ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthEmailVerifyGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthBrowserV1AuthEmailVerifyGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AuthEmailVerifyGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthEmailVerifyGetQueryError = ErrorResponse | ConflictResponse - -/** - * @summary Get email verification information - */ - -export function useAllauthBrowserV1AuthEmailVerifyGet< - TData = Awaited>, - TError = ErrorResponse | ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AuthEmailVerifyGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Complete the email verification process. Depending on the configuration, -email addresses are either verified by opening a link that is sent to -their email address, or, by inputting a code that is sent. On the API, -both cases are handled identically. Meaning, the required key is either -the one from the link, or, the code itself. - -Note that a status code of 401 does not imply failure. It indicates that -the email verification was successful, yet, the user is still not signed -in. For example, in case `ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION` is set to -`False`, a 401 is returned when verifying as part of login/signup. - - * @summary Verify an email - */ -export type allauthBrowserV1AuthEmailVerifyPostResponse200 = { - data: AuthenticatedResponse - status: 200 -} - -export type allauthBrowserV1AuthEmailVerifyPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthEmailVerifyPostResponse401 = { - data: UnauthenticatedResponse - status: 401 -} - -export type allauthBrowserV1AuthEmailVerifyPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthEmailVerifyPostResponseComposite = - | allauthBrowserV1AuthEmailVerifyPostResponse200 - | allauthBrowserV1AuthEmailVerifyPostResponse400 - | allauthBrowserV1AuthEmailVerifyPostResponse401 - | allauthBrowserV1AuthEmailVerifyPostResponse409 - -export type allauthBrowserV1AuthEmailVerifyPostResponse = allauthBrowserV1AuthEmailVerifyPostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthEmailVerifyPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/email/verify` -} - -export const allauthBrowserV1AuthEmailVerifyPost = async ( - verifyEmailBody: VerifyEmailBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthEmailVerifyPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(verifyEmailBody), - }) -} - -export const getAllauthBrowserV1AuthEmailVerifyPostMutationOptions = < - TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: VerifyEmailBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: VerifyEmailBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthEmailVerifyPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: VerifyEmailBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthEmailVerifyPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthEmailVerifyPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthEmailVerifyPostMutationBody = VerifyEmailBody -export type AllauthBrowserV1AuthEmailVerifyPostMutationError = - | ErrorResponse - | UnauthenticatedResponse - | ConflictResponse - -/** - * @summary Verify an email - */ -export const useAllauthBrowserV1AuthEmailVerifyPost = < - TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: VerifyEmailBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthEmailVerifyPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Obtain email verification information, given the token that was sent to -the user by email. - - * @summary Get email verification information - */ -export type allauthAppV1AuthEmailVerifyGetResponse200 = { - data: EmailVerificationInfoResponse - status: 200 -} - -export type allauthAppV1AuthEmailVerifyGetResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthEmailVerifyGetResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthEmailVerifyGetResponseComposite = - | allauthAppV1AuthEmailVerifyGetResponse200 - | allauthAppV1AuthEmailVerifyGetResponse400 - | allauthAppV1AuthEmailVerifyGetResponse409 - -export type allauthAppV1AuthEmailVerifyGetResponse = allauthAppV1AuthEmailVerifyGetResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthEmailVerifyGetUrl = () => { - return `/api/v2/allauth/app/v1/auth/email/verify` -} - -export const allauthAppV1AuthEmailVerifyGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthEmailVerifyGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthAppV1AuthEmailVerifyGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'auth', 'email', 'verify'] as const -} - -export const getAllauthAppV1AuthEmailVerifyGetQueryOptions = < - TData = Awaited>, - TError = ErrorResponse | ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthEmailVerifyGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1AuthEmailVerifyGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AuthEmailVerifyGetQueryResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthEmailVerifyGetQueryError = ErrorResponse | ConflictResponse - -/** - * @summary Get email verification information - */ - -export function useAllauthAppV1AuthEmailVerifyGet< - TData = Awaited>, - TError = ErrorResponse | ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AuthEmailVerifyGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Complete the email verification process. Depending on the configuration, -email addresses are either verified by opening a link that is sent to -their email address, or, by inputting a code that is sent. On the API, -both cases are handled identically. Meaning, the required key is either -the one from the link, or, the code itself. - -Note that a status code of 401 does not imply failure. It indicates that -the email verification was successful, yet, the user is still not signed -in. For example, in case `ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION` is set to -`False`, a 401 is returned when verifying as part of login/signup. - - * @summary Verify an email - */ -export type allauthAppV1AuthEmailVerifyPostResponse200 = { - data: AuthenticatedResponse - status: 200 -} - -export type allauthAppV1AuthEmailVerifyPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthEmailVerifyPostResponse401 = { - data: UnauthenticatedResponse - status: 401 -} - -export type allauthAppV1AuthEmailVerifyPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthEmailVerifyPostResponseComposite = - | allauthAppV1AuthEmailVerifyPostResponse200 - | allauthAppV1AuthEmailVerifyPostResponse400 - | allauthAppV1AuthEmailVerifyPostResponse401 - | allauthAppV1AuthEmailVerifyPostResponse409 - -export type allauthAppV1AuthEmailVerifyPostResponse = allauthAppV1AuthEmailVerifyPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthEmailVerifyPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/email/verify` -} - -export const allauthAppV1AuthEmailVerifyPost = async ( - verifyEmailBody: VerifyEmailBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthEmailVerifyPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(verifyEmailBody), - }) -} - -export const getAllauthAppV1AuthEmailVerifyPostMutationOptions = < - TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: VerifyEmailBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: VerifyEmailBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthEmailVerifyPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: VerifyEmailBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AuthEmailVerifyPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthEmailVerifyPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthEmailVerifyPostMutationBody = VerifyEmailBody -export type AllauthAppV1AuthEmailVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse - -/** - * @summary Verify an email - */ -export const useAllauthAppV1AuthEmailVerifyPost = < - TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: VerifyEmailBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthEmailVerifyPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Requests a new email verification code. -Requires `ACCOUNT_EMAIL_VERIFICATION_SUPPORTS_RESEND = True`. - - * @summary Resend email verification code - */ -export type allauthBrowserV1AuthEmailVerifyResendPostResponse200 = { - data: StatusOKResponse - status: 200 -} - -export type allauthBrowserV1AuthEmailVerifyResendPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthEmailVerifyResendPostResponse429 = { - data: TooManyRequestsResponse - status: 429 -} - -export type allauthBrowserV1AuthEmailVerifyResendPostResponseComposite = - | allauthBrowserV1AuthEmailVerifyResendPostResponse200 - | allauthBrowserV1AuthEmailVerifyResendPostResponse409 - | allauthBrowserV1AuthEmailVerifyResendPostResponse429 - -export type allauthBrowserV1AuthEmailVerifyResendPostResponse = - allauthBrowserV1AuthEmailVerifyResendPostResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AuthEmailVerifyResendPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/email/verify/resend` -} - -export const allauthBrowserV1AuthEmailVerifyResendPost = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1AuthEmailVerifyResendPostUrl(), - { - ...options, - method: 'POST', - }, - ) -} - -export const getAllauthBrowserV1AuthEmailVerifyResendPostMutationOptions = < - TError = ConflictResponse | TooManyRequestsResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - void, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthEmailVerifyResendPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - void - > = () => { - return allauthBrowserV1AuthEmailVerifyResendPost(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthEmailVerifyResendPostMutationResult = NonNullable< - Awaited> -> - -export type AllauthBrowserV1AuthEmailVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse - -/** - * @summary Resend email verification code - */ -export const useAllauthBrowserV1AuthEmailVerifyResendPost = < - TError = ConflictResponse | TooManyRequestsResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthEmailVerifyResendPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Requests a new email verification code. -Requires `ACCOUNT_EMAIL_VERIFICATION_SUPPORTS_RESEND = True`. - - * @summary Resend email verification code - */ -export type allauthAppV1AuthEmailVerifyResendPostResponse200 = { - data: StatusOKResponse - status: 200 -} - -export type allauthAppV1AuthEmailVerifyResendPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthEmailVerifyResendPostResponse429 = { - data: TooManyRequestsResponse - status: 429 -} - -export type allauthAppV1AuthEmailVerifyResendPostResponseComposite = - | allauthAppV1AuthEmailVerifyResendPostResponse200 - | allauthAppV1AuthEmailVerifyResendPostResponse409 - | allauthAppV1AuthEmailVerifyResendPostResponse429 - -export type allauthAppV1AuthEmailVerifyResendPostResponse = allauthAppV1AuthEmailVerifyResendPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthEmailVerifyResendPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/email/verify/resend` -} - -export const allauthAppV1AuthEmailVerifyResendPost = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthEmailVerifyResendPostUrl(), { - ...options, - method: 'POST', - }) -} - -export const getAllauthAppV1AuthEmailVerifyResendPostMutationOptions = < - TError = ConflictResponse | TooManyRequestsResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['allauthAppV1AuthEmailVerifyResendPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return allauthAppV1AuthEmailVerifyResendPost(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthEmailVerifyResendPostMutationResult = NonNullable< - Awaited> -> - -export type AllauthAppV1AuthEmailVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse - -/** - * @summary Resend email verification code - */ -export const useAllauthAppV1AuthEmailVerifyResendPost = < - TError = ConflictResponse | TooManyRequestsResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthEmailVerifyResendPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Complete the phone number verification process. Note that a status code -of 401 does not imply failure. It merely indicates that the phone number -verification was successful, yet, the user is still not signed in. - - * @summary Verify a phone number - */ -export type allauthBrowserV1AuthPhoneVerifyPostResponse200 = { - data: AuthenticatedResponse - status: 200 -} - -export type allauthBrowserV1AuthPhoneVerifyPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthPhoneVerifyPostResponse401 = { - data: UnauthenticatedResponse - status: 401 -} - -export type allauthBrowserV1AuthPhoneVerifyPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthPhoneVerifyPostResponseComposite = - | allauthBrowserV1AuthPhoneVerifyPostResponse200 - | allauthBrowserV1AuthPhoneVerifyPostResponse400 - | allauthBrowserV1AuthPhoneVerifyPostResponse401 - | allauthBrowserV1AuthPhoneVerifyPostResponse409 - -export type allauthBrowserV1AuthPhoneVerifyPostResponse = allauthBrowserV1AuthPhoneVerifyPostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthPhoneVerifyPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/phone/verify` -} - -export const allauthBrowserV1AuthPhoneVerifyPost = async ( - verifyPhoneBody: VerifyPhoneBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthPhoneVerifyPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(verifyPhoneBody), - }) -} - -export const getAllauthBrowserV1AuthPhoneVerifyPostMutationOptions = < - TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: VerifyPhoneBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: VerifyPhoneBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthPhoneVerifyPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: VerifyPhoneBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthPhoneVerifyPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthPhoneVerifyPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthPhoneVerifyPostMutationBody = VerifyPhoneBody -export type AllauthBrowserV1AuthPhoneVerifyPostMutationError = - | ErrorResponse - | UnauthenticatedResponse - | ConflictResponse - -/** - * @summary Verify a phone number - */ -export const useAllauthBrowserV1AuthPhoneVerifyPost = < - TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: VerifyPhoneBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthPhoneVerifyPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Complete the phone number verification process. Note that a status code -of 401 does not imply failure. It merely indicates that the phone number -verification was successful, yet, the user is still not signed in. - - * @summary Verify a phone number - */ -export type allauthAppV1AuthPhoneVerifyPostResponse200 = { - data: AuthenticatedResponse - status: 200 -} - -export type allauthAppV1AuthPhoneVerifyPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthPhoneVerifyPostResponse401 = { - data: UnauthenticatedResponse - status: 401 -} - -export type allauthAppV1AuthPhoneVerifyPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthPhoneVerifyPostResponseComposite = - | allauthAppV1AuthPhoneVerifyPostResponse200 - | allauthAppV1AuthPhoneVerifyPostResponse400 - | allauthAppV1AuthPhoneVerifyPostResponse401 - | allauthAppV1AuthPhoneVerifyPostResponse409 - -export type allauthAppV1AuthPhoneVerifyPostResponse = allauthAppV1AuthPhoneVerifyPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthPhoneVerifyPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/phone/verify` -} - -export const allauthAppV1AuthPhoneVerifyPost = async ( - verifyPhoneBody: VerifyPhoneBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthPhoneVerifyPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(verifyPhoneBody), - }) -} - -export const getAllauthAppV1AuthPhoneVerifyPostMutationOptions = < - TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: VerifyPhoneBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: VerifyPhoneBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthPhoneVerifyPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: VerifyPhoneBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AuthPhoneVerifyPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthPhoneVerifyPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthPhoneVerifyPostMutationBody = VerifyPhoneBody -export type AllauthAppV1AuthPhoneVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse - -/** - * @summary Verify a phone number - */ -export const useAllauthAppV1AuthPhoneVerifyPost = < - TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: VerifyPhoneBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthPhoneVerifyPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Requests a new phone number verification code. -Requires `ACCOUNT_PHONE_VERIFICATION_SUPPORTS_RESEND = True`. - - * @summary Resend phone number verification code - */ -export type allauthBrowserV1AuthPhoneVerifyResendPostResponse200 = { - data: StatusOKResponse - status: 200 -} - -export type allauthBrowserV1AuthPhoneVerifyResendPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthPhoneVerifyResendPostResponse429 = { - data: TooManyRequestsResponse - status: 429 -} - -export type allauthBrowserV1AuthPhoneVerifyResendPostResponseComposite = - | allauthBrowserV1AuthPhoneVerifyResendPostResponse200 - | allauthBrowserV1AuthPhoneVerifyResendPostResponse409 - | allauthBrowserV1AuthPhoneVerifyResendPostResponse429 - -export type allauthBrowserV1AuthPhoneVerifyResendPostResponse = - allauthBrowserV1AuthPhoneVerifyResendPostResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AuthPhoneVerifyResendPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/phone/verify/resend` -} - -export const allauthBrowserV1AuthPhoneVerifyResendPost = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1AuthPhoneVerifyResendPostUrl(), - { - ...options, - method: 'POST', - }, - ) -} - -export const getAllauthBrowserV1AuthPhoneVerifyResendPostMutationOptions = < - TError = ConflictResponse | TooManyRequestsResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - void, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthPhoneVerifyResendPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - void - > = () => { - return allauthBrowserV1AuthPhoneVerifyResendPost(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthPhoneVerifyResendPostMutationResult = NonNullable< - Awaited> -> - -export type AllauthBrowserV1AuthPhoneVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse - -/** - * @summary Resend phone number verification code - */ -export const useAllauthBrowserV1AuthPhoneVerifyResendPost = < - TError = ConflictResponse | TooManyRequestsResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthPhoneVerifyResendPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Requests a new phone number verification code. -Requires `ACCOUNT_PHONE_VERIFICATION_SUPPORTS_RESEND = True`. - - * @summary Resend phone number verification code - */ -export type allauthAppV1AuthPhoneVerifyResendPostResponse200 = { - data: StatusOKResponse - status: 200 -} - -export type allauthAppV1AuthPhoneVerifyResendPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthPhoneVerifyResendPostResponse429 = { - data: TooManyRequestsResponse - status: 429 -} - -export type allauthAppV1AuthPhoneVerifyResendPostResponseComposite = - | allauthAppV1AuthPhoneVerifyResendPostResponse200 - | allauthAppV1AuthPhoneVerifyResendPostResponse409 - | allauthAppV1AuthPhoneVerifyResendPostResponse429 - -export type allauthAppV1AuthPhoneVerifyResendPostResponse = allauthAppV1AuthPhoneVerifyResendPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthPhoneVerifyResendPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/phone/verify/resend` -} - -export const allauthAppV1AuthPhoneVerifyResendPost = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthPhoneVerifyResendPostUrl(), { - ...options, - method: 'POST', - }) -} - -export const getAllauthAppV1AuthPhoneVerifyResendPostMutationOptions = < - TError = ConflictResponse | TooManyRequestsResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['allauthAppV1AuthPhoneVerifyResendPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return allauthAppV1AuthPhoneVerifyResendPost(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthPhoneVerifyResendPostMutationResult = NonNullable< - Awaited> -> - -export type AllauthAppV1AuthPhoneVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse - -/** - * @summary Resend phone number verification code - */ -export const useAllauthAppV1AuthPhoneVerifyResendPost = < - TError = ConflictResponse | TooManyRequestsResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthPhoneVerifyResendPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * In order to safeguard the account, some actions require the user to be -recently authenticated. If you try to perform such an action without -having been recently authenticated, a `401` status is returned, listing -flows that can be performed to reauthenticate. One such flow is the flow -with ID `reauthenticate`, which allows for the user to input the -password. This is the endpoint related towards that flow. - - * @summary Reauthenticate - */ -export type allauthBrowserV1AuthReauthenticatePostResponse200 = { - data: AuthenticatedByPasswordResponse - status: 200 -} - -export type allauthBrowserV1AuthReauthenticatePostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthReauthenticatePostResponseComposite = - | allauthBrowserV1AuthReauthenticatePostResponse200 - | allauthBrowserV1AuthReauthenticatePostResponse400 - -export type allauthBrowserV1AuthReauthenticatePostResponse = allauthBrowserV1AuthReauthenticatePostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthReauthenticatePostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/reauthenticate` -} - -export const allauthBrowserV1AuthReauthenticatePost = async ( - reauthenticateBody: ReauthenticateBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthReauthenticatePostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(reauthenticateBody), - }) -} - -export const getAllauthBrowserV1AuthReauthenticatePostMutationOptions = < - TError = ErrorResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ReauthenticateBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ReauthenticateBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthReauthenticatePost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ReauthenticateBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthReauthenticatePost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthReauthenticatePostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthReauthenticatePostMutationBody = ReauthenticateBody -export type AllauthBrowserV1AuthReauthenticatePostMutationError = ErrorResponse - -/** - * @summary Reauthenticate - */ -export const useAllauthBrowserV1AuthReauthenticatePost = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ReauthenticateBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthReauthenticatePostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * In order to safeguard the account, some actions require the user to be -recently authenticated. If you try to perform such an action without -having been recently authenticated, a `401` status is returned, listing -flows that can be performed to reauthenticate. One such flow is the flow -with ID `reauthenticate`, which allows for the user to input the -password. This is the endpoint related towards that flow. - - * @summary Reauthenticate - */ -export type allauthAppV1AuthReauthenticatePostResponse200 = { - data: AuthenticatedByPasswordResponse - status: 200 -} - -export type allauthAppV1AuthReauthenticatePostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthReauthenticatePostResponseComposite = - | allauthAppV1AuthReauthenticatePostResponse200 - | allauthAppV1AuthReauthenticatePostResponse400 - -export type allauthAppV1AuthReauthenticatePostResponse = allauthAppV1AuthReauthenticatePostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthReauthenticatePostUrl = () => { - return `/api/v2/allauth/app/v1/auth/reauthenticate` -} - -export const allauthAppV1AuthReauthenticatePost = async ( - reauthenticateBody: ReauthenticateBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthReauthenticatePostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(reauthenticateBody), - }) -} - -export const getAllauthAppV1AuthReauthenticatePostMutationOptions = < - TError = ErrorResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ReauthenticateBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ReauthenticateBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthReauthenticatePost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ReauthenticateBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AuthReauthenticatePost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthReauthenticatePostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthReauthenticatePostMutationBody = ReauthenticateBody -export type AllauthAppV1AuthReauthenticatePostMutationError = ErrorResponse - -/** - * @summary Reauthenticate - */ -export const useAllauthAppV1AuthReauthenticatePost = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ReauthenticateBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthReauthenticatePostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Initiates the password reset procedure. Depending on whether or not -`ACCOUNT_PASSWORD_RESET_BY_CODE_ENABLED` is `True`, the procedure is -either stateless or stateful. - -In case codes are used, it is stateful, and a new -`password_reset_by_code` flow is started. In this case, on a successful -password reset request, you will receive a 401 indicating the pending -status of this flow. - -In case password reset is configured to use (stateless) links, you will -receive a 200 on a successful password reset request. - - * @summary Request password - */ -export type allauthBrowserV1AuthPasswordRequestPostResponse200 = { - data: StatusOKResponse - status: 200 -} - -export type allauthBrowserV1AuthPasswordRequestPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthPasswordRequestPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AuthPasswordRequestPostResponseComposite = - | allauthBrowserV1AuthPasswordRequestPostResponse200 - | allauthBrowserV1AuthPasswordRequestPostResponse400 - | allauthBrowserV1AuthPasswordRequestPostResponse401 - -export type allauthBrowserV1AuthPasswordRequestPostResponse = - allauthBrowserV1AuthPasswordRequestPostResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AuthPasswordRequestPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/password/request` -} - -export const allauthBrowserV1AuthPasswordRequestPost = async ( - requestPasswordBody: RequestPasswordBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1AuthPasswordRequestPostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(requestPasswordBody), - }, - ) -} - -export const getAllauthBrowserV1AuthPasswordRequestPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: RequestPasswordBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: RequestPasswordBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthPasswordRequestPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: RequestPasswordBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthPasswordRequestPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthPasswordRequestPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthPasswordRequestPostMutationBody = RequestPasswordBody -export type AllauthBrowserV1AuthPasswordRequestPostMutationError = ErrorResponse | AuthenticationResponse - -/** - * @summary Request password - */ -export const useAllauthBrowserV1AuthPasswordRequestPost = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: RequestPasswordBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthPasswordRequestPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Initiates the password reset procedure. Depending on whether or not -`ACCOUNT_PASSWORD_RESET_BY_CODE_ENABLED` is `True`, the procedure is -either stateless or stateful. - -In case codes are used, it is stateful, and a new -`password_reset_by_code` flow is started. In this case, on a successful -password reset request, you will receive a 401 indicating the pending -status of this flow. - -In case password reset is configured to use (stateless) links, you will -receive a 200 on a successful password reset request. - - * @summary Request password - */ -export type allauthAppV1AuthPasswordRequestPostResponse200 = { - data: StatusOKResponse - status: 200 -} - -export type allauthAppV1AuthPasswordRequestPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthPasswordRequestPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AuthPasswordRequestPostResponseComposite = - | allauthAppV1AuthPasswordRequestPostResponse200 - | allauthAppV1AuthPasswordRequestPostResponse400 - | allauthAppV1AuthPasswordRequestPostResponse401 - -export type allauthAppV1AuthPasswordRequestPostResponse = allauthAppV1AuthPasswordRequestPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthPasswordRequestPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/password/request` -} - -export const allauthAppV1AuthPasswordRequestPost = async ( - requestPasswordBody: RequestPasswordBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthPasswordRequestPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(requestPasswordBody), - }) -} - -export const getAllauthAppV1AuthPasswordRequestPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: RequestPasswordBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: RequestPasswordBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthPasswordRequestPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: RequestPasswordBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AuthPasswordRequestPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthPasswordRequestPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthPasswordRequestPostMutationBody = RequestPasswordBody -export type AllauthAppV1AuthPasswordRequestPostMutationError = ErrorResponse | AuthenticationResponse - -/** - * @summary Request password - */ -export const useAllauthAppV1AuthPasswordRequestPost = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: RequestPasswordBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthPasswordRequestPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Used to obtain information on and validate a password reset key. The -key passed is either the key encoded in the password reset URL that the -user has received per email, or, the password reset code in case of -`ACCOUNT_PASSWORD_RESET_BY_CODE_ENABLED`. Note that in case of a code, -the number of requests you can make is limited (by -`ACCOUNT_PASSWORD_RESET_BY_CODE_MAX_ATTEMPTS`). - - * @summary Get password reset information - */ -export type allauthBrowserV1AuthPasswordResetGetResponse200 = { - data: PasswordResetInfoResponse - status: 200 -} - -export type allauthBrowserV1AuthPasswordResetGetResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthPasswordResetGetResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthPasswordResetGetResponseComposite = - | allauthBrowserV1AuthPasswordResetGetResponse200 - | allauthBrowserV1AuthPasswordResetGetResponse400 - | allauthBrowserV1AuthPasswordResetGetResponse409 - -export type allauthBrowserV1AuthPasswordResetGetResponse = allauthBrowserV1AuthPasswordResetGetResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthPasswordResetGetUrl = () => { - return `/api/v2/allauth/browser/v1/auth/password/reset` -} - -export const allauthBrowserV1AuthPasswordResetGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthPasswordResetGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthBrowserV1AuthPasswordResetGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'auth', 'password', 'reset'] as const -} - -export const getAllauthBrowserV1AuthPasswordResetGetQueryOptions = < - TData = Awaited>, - TError = ErrorResponse | ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthPasswordResetGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthBrowserV1AuthPasswordResetGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AuthPasswordResetGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthPasswordResetGetQueryError = ErrorResponse | ConflictResponse - -/** - * @summary Get password reset information - */ - -export function useAllauthBrowserV1AuthPasswordResetGet< - TData = Awaited>, - TError = ErrorResponse | ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AuthPasswordResetGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Perform the password reset, by handing over the password reset key and -the new password. After successfully completing the password reset, the -user is either logged in (in case `ACCOUNT_LOGIN_ON_PASSWORD_RESET` is -`True`), or, the user will need to proceed to the login page. In case -of the former, a `200` status code is returned, in case of the latter a -401. - - * @summary Reset password - */ -export type allauthBrowserV1AuthPasswordResetPostResponse200 = { - data: AuthenticatedByPasswordResponse - status: 200 -} - -export type allauthBrowserV1AuthPasswordResetPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthPasswordResetPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AuthPasswordResetPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthPasswordResetPostResponseComposite = - | allauthBrowserV1AuthPasswordResetPostResponse200 - | allauthBrowserV1AuthPasswordResetPostResponse400 - | allauthBrowserV1AuthPasswordResetPostResponse401 - | allauthBrowserV1AuthPasswordResetPostResponse409 - -export type allauthBrowserV1AuthPasswordResetPostResponse = allauthBrowserV1AuthPasswordResetPostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthPasswordResetPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/password/reset` -} - -export const allauthBrowserV1AuthPasswordResetPost = async ( - resetPasswordBody: ResetPasswordBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthPasswordResetPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(resetPasswordBody), - }) -} - -export const getAllauthBrowserV1AuthPasswordResetPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ResetPasswordBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ResetPasswordBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthPasswordResetPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ResetPasswordBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthPasswordResetPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthPasswordResetPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthPasswordResetPostMutationBody = ResetPasswordBody -export type AllauthBrowserV1AuthPasswordResetPostMutationError = - | ErrorResponse - | AuthenticationResponse - | ConflictResponse - -/** - * @summary Reset password - */ -export const useAllauthBrowserV1AuthPasswordResetPost = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ResetPasswordBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthPasswordResetPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Used to obtain information on and validate a password reset key. The -key passed is either the key encoded in the password reset URL that the -user has received per email, or, the password reset code in case of -`ACCOUNT_PASSWORD_RESET_BY_CODE_ENABLED`. Note that in case of a code, -the number of requests you can make is limited (by -`ACCOUNT_PASSWORD_RESET_BY_CODE_MAX_ATTEMPTS`). - - * @summary Get password reset information - */ -export type allauthAppV1AuthPasswordResetGetResponse200 = { - data: PasswordResetInfoResponse - status: 200 -} - -export type allauthAppV1AuthPasswordResetGetResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthPasswordResetGetResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthPasswordResetGetResponseComposite = - | allauthAppV1AuthPasswordResetGetResponse200 - | allauthAppV1AuthPasswordResetGetResponse400 - | allauthAppV1AuthPasswordResetGetResponse409 - -export type allauthAppV1AuthPasswordResetGetResponse = allauthAppV1AuthPasswordResetGetResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthPasswordResetGetUrl = () => { - return `/api/v2/allauth/app/v1/auth/password/reset` -} - -export const allauthAppV1AuthPasswordResetGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthPasswordResetGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthAppV1AuthPasswordResetGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'auth', 'password', 'reset'] as const -} - -export const getAllauthAppV1AuthPasswordResetGetQueryOptions = < - TData = Awaited>, - TError = ErrorResponse | ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthPasswordResetGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1AuthPasswordResetGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AuthPasswordResetGetQueryResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthPasswordResetGetQueryError = ErrorResponse | ConflictResponse - -/** - * @summary Get password reset information - */ - -export function useAllauthAppV1AuthPasswordResetGet< - TData = Awaited>, - TError = ErrorResponse | ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AuthPasswordResetGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Perform the password reset, by handing over the password reset key and -the new password. After successfully completing the password reset, the -user is either logged in (in case `ACCOUNT_LOGIN_ON_PASSWORD_RESET` is -`True`), or, the user will need to proceed to the login page. In case -of the former, a `200` status code is returned, in case of the latter a -401. - - * @summary Reset password - */ -export type allauthAppV1AuthPasswordResetPostResponse200 = { - data: AuthenticatedByPasswordResponse - status: 200 -} - -export type allauthAppV1AuthPasswordResetPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthPasswordResetPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AuthPasswordResetPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthPasswordResetPostResponseComposite = - | allauthAppV1AuthPasswordResetPostResponse200 - | allauthAppV1AuthPasswordResetPostResponse400 - | allauthAppV1AuthPasswordResetPostResponse401 - | allauthAppV1AuthPasswordResetPostResponse409 - -export type allauthAppV1AuthPasswordResetPostResponse = allauthAppV1AuthPasswordResetPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthPasswordResetPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/password/reset` -} - -export const allauthAppV1AuthPasswordResetPost = async ( - resetPasswordBody: ResetPasswordBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthPasswordResetPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(resetPasswordBody), - }) -} - -export const getAllauthAppV1AuthPasswordResetPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ResetPasswordBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ResetPasswordBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthPasswordResetPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ResetPasswordBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AuthPasswordResetPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthPasswordResetPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthPasswordResetPostMutationBody = ResetPasswordBody -export type AllauthAppV1AuthPasswordResetPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - -/** - * @summary Reset password - */ -export const useAllauthAppV1AuthPasswordResetPost = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ResetPasswordBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthPasswordResetPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Initiates the third-party provider authentication redirect flow. As calling -this endpoint results in a user facing redirect (302), this call is only -available in a browser, and must be called in a synchronous (non-XHR) -manner. - - * @summary Provider redirect - */ -export type allauthBrowserV1AuthProviderRedirectPostResponse302 = { - data: void - status: 302 -} - -export type allauthBrowserV1AuthProviderRedirectPostResponseComposite = - allauthBrowserV1AuthProviderRedirectPostResponse302 - -export type allauthBrowserV1AuthProviderRedirectPostResponse = - allauthBrowserV1AuthProviderRedirectPostResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AuthProviderRedirectPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/provider/redirect` -} - -export const allauthBrowserV1AuthProviderRedirectPost = async ( - providerRedirectBody: ProviderRedirectBody, - options?: RequestInit, -): Promise => { - const formUrlEncoded = new URLSearchParams() - formUrlEncoded.append(`provider`, providerRedirectBody.provider) - formUrlEncoded.append(`callback_url`, providerRedirectBody.callback_url) - formUrlEncoded.append(`process`, providerRedirectBody.process) - - return fetchWithAuth( - getAllauthBrowserV1AuthProviderRedirectPostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/x-www-form-urlencoded', ...options?.headers }, - body: formUrlEncoded, - }, - ) -} - -export const getAllauthBrowserV1AuthProviderRedirectPostMutationOptions = < - TError = void, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderRedirectBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ProviderRedirectBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthProviderRedirectPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ProviderRedirectBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthProviderRedirectPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthProviderRedirectPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthProviderRedirectPostMutationBody = ProviderRedirectBody -export type AllauthBrowserV1AuthProviderRedirectPostMutationError = void - -/** - * @summary Provider redirect - */ -export const useAllauthBrowserV1AuthProviderRedirectPost = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderRedirectBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthProviderRedirectPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Authenticates with a third-party provider using provider tokens received -by other means. For example, in case of a mobile app, the authentication -flow runs completely on the device itself, without any interaction with -the API. Then, when the (device) authentication completes and the mobile -app receives an access and/or ID token, it can hand over these tokens -via this endpoint to authenticate on the server. - - * @summary Provider token - */ -export type allauthBrowserV1AuthProviderTokenPostResponse200 = { - data: AuthenticatedResponse - status: 200 -} - -export type allauthBrowserV1AuthProviderTokenPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthProviderTokenPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AuthProviderTokenPostResponse403 = { - data: ForbiddenResponse - status: 403 -} - -export type allauthBrowserV1AuthProviderTokenPostResponseComposite = - | allauthBrowserV1AuthProviderTokenPostResponse200 - | allauthBrowserV1AuthProviderTokenPostResponse400 - | allauthBrowserV1AuthProviderTokenPostResponse401 - | allauthBrowserV1AuthProviderTokenPostResponse403 - -export type allauthBrowserV1AuthProviderTokenPostResponse = allauthBrowserV1AuthProviderTokenPostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthProviderTokenPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/provider/token` -} - -export const allauthBrowserV1AuthProviderTokenPost = async ( - providerTokenBody: ProviderTokenBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthProviderTokenPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(providerTokenBody), - }) -} - -export const getAllauthBrowserV1AuthProviderTokenPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderTokenBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ProviderTokenBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthProviderTokenPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ProviderTokenBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthProviderTokenPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthProviderTokenPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthProviderTokenPostMutationBody = ProviderTokenBody -export type AllauthBrowserV1AuthProviderTokenPostMutationError = - | ErrorResponse - | AuthenticationResponse - | ForbiddenResponse - -/** - * @summary Provider token - */ -export const useAllauthBrowserV1AuthProviderTokenPost = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderTokenBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthProviderTokenPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Authenticates with a third-party provider using provider tokens received -by other means. For example, in case of a mobile app, the authentication -flow runs completely on the device itself, without any interaction with -the API. Then, when the (device) authentication completes and the mobile -app receives an access and/or ID token, it can hand over these tokens -via this endpoint to authenticate on the server. - - * @summary Provider token - */ -export type allauthAppV1AuthProviderTokenPostResponse200 = { - data: AuthenticatedResponse - status: 200 -} - -export type allauthAppV1AuthProviderTokenPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthProviderTokenPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AuthProviderTokenPostResponse403 = { - data: ForbiddenResponse - status: 403 -} - -export type allauthAppV1AuthProviderTokenPostResponseComposite = - | allauthAppV1AuthProviderTokenPostResponse200 - | allauthAppV1AuthProviderTokenPostResponse400 - | allauthAppV1AuthProviderTokenPostResponse401 - | allauthAppV1AuthProviderTokenPostResponse403 - -export type allauthAppV1AuthProviderTokenPostResponse = allauthAppV1AuthProviderTokenPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthProviderTokenPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/provider/token` -} - -export const allauthAppV1AuthProviderTokenPost = async ( - providerTokenBody: ProviderTokenBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthProviderTokenPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(providerTokenBody), - }) -} - -export const getAllauthAppV1AuthProviderTokenPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderTokenBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ProviderTokenBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthProviderTokenPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ProviderTokenBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AuthProviderTokenPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthProviderTokenPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthProviderTokenPostMutationBody = ProviderTokenBody -export type AllauthAppV1AuthProviderTokenPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse - -/** - * @summary Provider token - */ -export const useAllauthAppV1AuthProviderTokenPost = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderTokenBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthProviderTokenPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * If, while signing up using a third-party provider account, there is -insufficient information received from the provider to automatically -complete the signup process, an additional step is needed to complete -the missing data before the user is fully signed up and authenticated. -The information available so far, such as the pending provider account, -can be retrieved via this endpoint. - - * @summary Provider signup information - */ -export type allauthBrowserV1AuthProviderSignupGetResponse200 = { - data: ProviderSignupResponse - status: 200 -} - -export type allauthBrowserV1AuthProviderSignupGetResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthProviderSignupGetResponseComposite = - | allauthBrowserV1AuthProviderSignupGetResponse200 - | allauthBrowserV1AuthProviderSignupGetResponse409 - -export type allauthBrowserV1AuthProviderSignupGetResponse = allauthBrowserV1AuthProviderSignupGetResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthProviderSignupGetUrl = () => { - return `/api/v2/allauth/browser/v1/auth/provider/signup` -} - -export const allauthBrowserV1AuthProviderSignupGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthProviderSignupGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthBrowserV1AuthProviderSignupGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'auth', 'provider', 'signup'] as const -} - -export const getAllauthBrowserV1AuthProviderSignupGetQueryOptions = < - TData = Awaited>, - TError = ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthProviderSignupGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthBrowserV1AuthProviderSignupGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AuthProviderSignupGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthProviderSignupGetQueryError = ConflictResponse - -/** - * @summary Provider signup information - */ - -export function useAllauthBrowserV1AuthProviderSignupGet< - TData = Awaited>, - TError = ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AuthProviderSignupGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * If, while signing up using a third-party provider account, there is -insufficient information received from the provider to automatically -complete the signup process, an additional step is needed to complete -the missing data before the user is fully signed up and authenticated. - - * @summary Provider signup - */ -export type allauthBrowserV1AuthProviderSignupPostResponse200 = { - data: AuthenticatedResponse - status: 200 -} - -export type allauthBrowserV1AuthProviderSignupPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthProviderSignupPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AuthProviderSignupPostResponse403 = { - data: ForbiddenResponse - status: 403 -} - -export type allauthBrowserV1AuthProviderSignupPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthProviderSignupPostResponseComposite = - | allauthBrowserV1AuthProviderSignupPostResponse200 - | allauthBrowserV1AuthProviderSignupPostResponse400 - | allauthBrowserV1AuthProviderSignupPostResponse401 - | allauthBrowserV1AuthProviderSignupPostResponse403 - | allauthBrowserV1AuthProviderSignupPostResponse409 - -export type allauthBrowserV1AuthProviderSignupPostResponse = allauthBrowserV1AuthProviderSignupPostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthProviderSignupPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/provider/signup` -} - -export const allauthBrowserV1AuthProviderSignupPost = async ( - providerSignupBody: ProviderSignupBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthProviderSignupPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(providerSignupBody), - }) -} - -export const getAllauthBrowserV1AuthProviderSignupPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderSignupBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ProviderSignupBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthProviderSignupPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ProviderSignupBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthProviderSignupPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthProviderSignupPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthProviderSignupPostMutationBody = ProviderSignupBody -export type AllauthBrowserV1AuthProviderSignupPostMutationError = - | ErrorResponse - | AuthenticationResponse - | ForbiddenResponse - | ConflictResponse - -/** - * @summary Provider signup - */ -export const useAllauthBrowserV1AuthProviderSignupPost = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderSignupBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthProviderSignupPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * If, while signing up using a third-party provider account, there is -insufficient information received from the provider to automatically -complete the signup process, an additional step is needed to complete -the missing data before the user is fully signed up and authenticated. -The information available so far, such as the pending provider account, -can be retrieved via this endpoint. - - * @summary Provider signup information - */ -export type allauthAppV1AuthProviderSignupGetResponse200 = { - data: ProviderSignupResponse - status: 200 -} - -export type allauthAppV1AuthProviderSignupGetResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthProviderSignupGetResponseComposite = - | allauthAppV1AuthProviderSignupGetResponse200 - | allauthAppV1AuthProviderSignupGetResponse409 - -export type allauthAppV1AuthProviderSignupGetResponse = allauthAppV1AuthProviderSignupGetResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthProviderSignupGetUrl = () => { - return `/api/v2/allauth/app/v1/auth/provider/signup` -} - -export const allauthAppV1AuthProviderSignupGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthProviderSignupGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthAppV1AuthProviderSignupGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'auth', 'provider', 'signup'] as const -} - -export const getAllauthAppV1AuthProviderSignupGetQueryOptions = < - TData = Awaited>, - TError = ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthProviderSignupGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1AuthProviderSignupGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AuthProviderSignupGetQueryResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthProviderSignupGetQueryError = ConflictResponse - -/** - * @summary Provider signup information - */ - -export function useAllauthAppV1AuthProviderSignupGet< - TData = Awaited>, - TError = ConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AuthProviderSignupGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * If, while signing up using a third-party provider account, there is -insufficient information received from the provider to automatically -complete the signup process, an additional step is needed to complete -the missing data before the user is fully signed up and authenticated. - - * @summary Provider signup - */ -export type allauthAppV1AuthProviderSignupPostResponse200 = { - data: AuthenticatedResponse - status: 200 -} - -export type allauthAppV1AuthProviderSignupPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthProviderSignupPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AuthProviderSignupPostResponse403 = { - data: ForbiddenResponse - status: 403 -} - -export type allauthAppV1AuthProviderSignupPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthProviderSignupPostResponseComposite = - | allauthAppV1AuthProviderSignupPostResponse200 - | allauthAppV1AuthProviderSignupPostResponse400 - | allauthAppV1AuthProviderSignupPostResponse401 - | allauthAppV1AuthProviderSignupPostResponse403 - | allauthAppV1AuthProviderSignupPostResponse409 - -export type allauthAppV1AuthProviderSignupPostResponse = allauthAppV1AuthProviderSignupPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthProviderSignupPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/provider/signup` -} - -export const allauthAppV1AuthProviderSignupPost = async ( - providerSignupBody: ProviderSignupBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthProviderSignupPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(providerSignupBody), - }) -} - -export const getAllauthAppV1AuthProviderSignupPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderSignupBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ProviderSignupBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthProviderSignupPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ProviderSignupBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AuthProviderSignupPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthProviderSignupPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthProviderSignupPostMutationBody = ProviderSignupBody -export type AllauthAppV1AuthProviderSignupPostMutationError = - | ErrorResponse - | AuthenticationResponse - | ForbiddenResponse - | ConflictResponse - -/** - * @summary Provider signup - */ -export const useAllauthAppV1AuthProviderSignupPost = < - TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderSignupBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthProviderSignupPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * If, during authentication, a response with status 401 is encountered where one of the pending -flows has ID `mfa_authenticate`, that indicates that the Two-Factor Authentication stage needs to -be completed. - - * @summary Two-factor authentication - */ -export type allauthBrowserV1Auth2faAuthenticatePostResponse200 = { - data: AuthenticatedByPasswordAnd2FAResponse - status: 200 -} - -export type allauthBrowserV1Auth2faAuthenticatePostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1Auth2faAuthenticatePostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1Auth2faAuthenticatePostResponseComposite = - | allauthBrowserV1Auth2faAuthenticatePostResponse200 - | allauthBrowserV1Auth2faAuthenticatePostResponse400 - | allauthBrowserV1Auth2faAuthenticatePostResponse401 - -export type allauthBrowserV1Auth2faAuthenticatePostResponse = - allauthBrowserV1Auth2faAuthenticatePostResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1Auth2faAuthenticatePostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/2fa/authenticate` -} - -export const allauthBrowserV1Auth2faAuthenticatePost = async ( - mFAAuthenticateBody: MFAAuthenticateBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1Auth2faAuthenticatePostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(mFAAuthenticateBody), - }, - ) -} - -export const getAllauthBrowserV1Auth2faAuthenticatePostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1Auth2faAuthenticatePost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: MFAAuthenticateBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1Auth2faAuthenticatePost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1Auth2faAuthenticatePostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1Auth2faAuthenticatePostMutationBody = MFAAuthenticateBody -export type AllauthBrowserV1Auth2faAuthenticatePostMutationError = ErrorResponse | AuthenticationResponse - -/** - * @summary Two-factor authentication - */ -export const useAllauthBrowserV1Auth2faAuthenticatePost = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1Auth2faAuthenticatePostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * If, during authentication, a response with status 401 is encountered where one of the pending -flows has ID `mfa_authenticate`, that indicates that the Two-Factor Authentication stage needs to -be completed. - - * @summary Two-factor authentication - */ -export type allauthAppV1Auth2faAuthenticatePostResponse200 = { - data: AuthenticatedByPasswordAnd2FAResponse - status: 200 -} - -export type allauthAppV1Auth2faAuthenticatePostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1Auth2faAuthenticatePostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1Auth2faAuthenticatePostResponseComposite = - | allauthAppV1Auth2faAuthenticatePostResponse200 - | allauthAppV1Auth2faAuthenticatePostResponse400 - | allauthAppV1Auth2faAuthenticatePostResponse401 - -export type allauthAppV1Auth2faAuthenticatePostResponse = allauthAppV1Auth2faAuthenticatePostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1Auth2faAuthenticatePostUrl = () => { - return `/api/v2/allauth/app/v1/auth/2fa/authenticate` -} - -export const allauthAppV1Auth2faAuthenticatePost = async ( - mFAAuthenticateBody: MFAAuthenticateBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1Auth2faAuthenticatePostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(mFAAuthenticateBody), - }) -} - -export const getAllauthAppV1Auth2faAuthenticatePostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext -> => { - const mutationKey = ['allauthAppV1Auth2faAuthenticatePost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: MFAAuthenticateBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1Auth2faAuthenticatePost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1Auth2faAuthenticatePostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1Auth2faAuthenticatePostMutationBody = MFAAuthenticateBody -export type AllauthAppV1Auth2faAuthenticatePostMutationError = ErrorResponse | AuthenticationResponse - -/** - * @summary Two-factor authentication - */ -export const useAllauthAppV1Auth2faAuthenticatePost = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1Auth2faAuthenticatePostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * In order to safeguard the account, some actions require the user to be -recently authenticated. If you try to perform such an action without -having been recently authenticated, a `401` status is returned, listing -flows that can be performed to reauthenticate. One such flow is the flow -with ID `mfa_reauthenticate`, which allows for the user to input an -authenticator code (e.g. TOTP or recovery code). This is the endpoint -related towards that flow. - - * @summary Reauthenticate using 2FA - */ -export type allauthBrowserV1Auth2faReauthenticatePostResponse200 = { - data: AuthenticatedByPasswordAnd2FAResponse - status: 200 -} - -export type allauthBrowserV1Auth2faReauthenticatePostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1Auth2faReauthenticatePostResponseComposite = - | allauthBrowserV1Auth2faReauthenticatePostResponse200 - | allauthBrowserV1Auth2faReauthenticatePostResponse400 - -export type allauthBrowserV1Auth2faReauthenticatePostResponse = - allauthBrowserV1Auth2faReauthenticatePostResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1Auth2faReauthenticatePostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/2fa/reauthenticate` -} - -export const allauthBrowserV1Auth2faReauthenticatePost = async ( - mFAAuthenticateBody: MFAAuthenticateBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1Auth2faReauthenticatePostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(mFAAuthenticateBody), - }, - ) -} - -export const getAllauthBrowserV1Auth2faReauthenticatePostMutationOptions = < - TError = ErrorResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1Auth2faReauthenticatePost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: MFAAuthenticateBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1Auth2faReauthenticatePost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1Auth2faReauthenticatePostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1Auth2faReauthenticatePostMutationBody = MFAAuthenticateBody -export type AllauthBrowserV1Auth2faReauthenticatePostMutationError = ErrorResponse - -/** - * @summary Reauthenticate using 2FA - */ -export const useAllauthBrowserV1Auth2faReauthenticatePost = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1Auth2faReauthenticatePostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * In order to safeguard the account, some actions require the user to be -recently authenticated. If you try to perform such an action without -having been recently authenticated, a `401` status is returned, listing -flows that can be performed to reauthenticate. One such flow is the flow -with ID `mfa_reauthenticate`, which allows for the user to input an -authenticator code (e.g. TOTP or recovery code). This is the endpoint -related towards that flow. - - * @summary Reauthenticate using 2FA - */ -export type allauthAppV1Auth2faReauthenticatePostResponse200 = { - data: AuthenticatedByPasswordAnd2FAResponse - status: 200 -} - -export type allauthAppV1Auth2faReauthenticatePostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1Auth2faReauthenticatePostResponseComposite = - | allauthAppV1Auth2faReauthenticatePostResponse200 - | allauthAppV1Auth2faReauthenticatePostResponse400 - -export type allauthAppV1Auth2faReauthenticatePostResponse = allauthAppV1Auth2faReauthenticatePostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1Auth2faReauthenticatePostUrl = () => { - return `/api/v2/allauth/app/v1/auth/2fa/reauthenticate` -} - -export const allauthAppV1Auth2faReauthenticatePost = async ( - mFAAuthenticateBody: MFAAuthenticateBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1Auth2faReauthenticatePostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(mFAAuthenticateBody), - }) -} - -export const getAllauthAppV1Auth2faReauthenticatePostMutationOptions = < - TError = ErrorResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext -> => { - const mutationKey = ['allauthAppV1Auth2faReauthenticatePost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: MFAAuthenticateBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1Auth2faReauthenticatePost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1Auth2faReauthenticatePostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1Auth2faReauthenticatePostMutationBody = MFAAuthenticateBody -export type AllauthAppV1Auth2faReauthenticatePostMutationError = ErrorResponse - -/** - * @summary Reauthenticate using 2FA - */ -export const useAllauthAppV1Auth2faReauthenticatePost = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MFAAuthenticateBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1Auth2faReauthenticatePostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Use this endpoint to pass along the received "special" login code. - - * @summary Confirm login code - */ -export type allauthBrowserV1AuthCodeConfirmPostResponse200 = { - data: AuthenticatedByCodeResponse - status: 200 -} - -export type allauthBrowserV1AuthCodeConfirmPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AuthCodeConfirmPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AuthCodeConfirmPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AuthCodeConfirmPostResponseComposite = - | allauthBrowserV1AuthCodeConfirmPostResponse200 - | allauthBrowserV1AuthCodeConfirmPostResponse400 - | allauthBrowserV1AuthCodeConfirmPostResponse401 - | allauthBrowserV1AuthCodeConfirmPostResponse409 - -export type allauthBrowserV1AuthCodeConfirmPostResponse = allauthBrowserV1AuthCodeConfirmPostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthCodeConfirmPostUrl = () => { - return `/api/v2/allauth/browser/v1/auth/code/confirm` -} - -export const allauthBrowserV1AuthCodeConfirmPost = async ( - confirmLoginCodeBody: ConfirmLoginCodeBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthCodeConfirmPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(confirmLoginCodeBody), - }) -} - -export const getAllauthBrowserV1AuthCodeConfirmPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ConfirmLoginCodeBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ConfirmLoginCodeBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthCodeConfirmPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ConfirmLoginCodeBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthCodeConfirmPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthCodeConfirmPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthCodeConfirmPostMutationBody = ConfirmLoginCodeBody -export type AllauthBrowserV1AuthCodeConfirmPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - -/** - * @summary Confirm login code - */ -export const useAllauthBrowserV1AuthCodeConfirmPost = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ConfirmLoginCodeBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthCodeConfirmPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Use this endpoint to pass along the received "special" login code. - - * @summary Confirm login code - */ -export type allauthAppV1AuthCodeConfirmPostResponse200 = { - data: AuthenticatedByCodeResponse - status: 200 -} - -export type allauthAppV1AuthCodeConfirmPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AuthCodeConfirmPostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AuthCodeConfirmPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AuthCodeConfirmPostResponseComposite = - | allauthAppV1AuthCodeConfirmPostResponse200 - | allauthAppV1AuthCodeConfirmPostResponse400 - | allauthAppV1AuthCodeConfirmPostResponse401 - | allauthAppV1AuthCodeConfirmPostResponse409 - -export type allauthAppV1AuthCodeConfirmPostResponse = allauthAppV1AuthCodeConfirmPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthCodeConfirmPostUrl = () => { - return `/api/v2/allauth/app/v1/auth/code/confirm` -} - -export const allauthAppV1AuthCodeConfirmPost = async ( - confirmLoginCodeBody: ConfirmLoginCodeBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthCodeConfirmPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(confirmLoginCodeBody), - }) -} - -export const getAllauthAppV1AuthCodeConfirmPostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ConfirmLoginCodeBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ConfirmLoginCodeBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthCodeConfirmPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ConfirmLoginCodeBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AuthCodeConfirmPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthCodeConfirmPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthCodeConfirmPostMutationBody = ConfirmLoginCodeBody -export type AllauthAppV1AuthCodeConfirmPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - -/** - * @summary Confirm login code - */ -export const useAllauthAppV1AuthCodeConfirmPost = < - TError = ErrorResponse | AuthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ConfirmLoginCodeBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthCodeConfirmPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * @summary List the connected third-party provider accounts - */ -export type allauthBrowserV1AccountProvidersGetResponse200 = { - data: ProviderAccountsResponse - status: 200 -} - -export type allauthBrowserV1AccountProvidersGetResponseComposite = allauthBrowserV1AccountProvidersGetResponse200 - -export type allauthBrowserV1AccountProvidersGetResponse = allauthBrowserV1AccountProvidersGetResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AccountProvidersGetUrl = () => { - return `/api/v2/allauth/browser/v1/account/providers` -} - -export const allauthBrowserV1AccountProvidersGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AccountProvidersGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthBrowserV1AccountProvidersGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'providers'] as const -} - -export const getAllauthBrowserV1AccountProvidersGetQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountProvidersGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthBrowserV1AccountProvidersGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AccountProvidersGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountProvidersGetQueryError = unknown - -/** - * @summary List the connected third-party provider accounts - */ - -export function useAllauthBrowserV1AccountProvidersGet< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AccountProvidersGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Disconnect a third-party provider account, returning the remaining -accounts that are still connected. The disconnect is not allowed if it -would leave the account unusable. For example, if no password was -set up yet. - - * @summary Disconnect a third-party provider account - - */ -export type allauthBrowserV1AccountProvidersDeleteResponse200 = { - data: ProviderAccountsResponse - status: 200 -} - -export type allauthBrowserV1AccountProvidersDeleteResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AccountProvidersDeleteResponseComposite = - | allauthBrowserV1AccountProvidersDeleteResponse200 - | allauthBrowserV1AccountProvidersDeleteResponse400 - -export type allauthBrowserV1AccountProvidersDeleteResponse = allauthBrowserV1AccountProvidersDeleteResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AccountProvidersDeleteUrl = () => { - return `/api/v2/allauth/browser/v1/account/providers` -} - -export const allauthBrowserV1AccountProvidersDelete = async ( - providerAccountBody: ProviderAccountBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AccountProvidersDeleteUrl(), { - ...options, - method: 'DELETE', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(providerAccountBody), - }) -} - -export const getAllauthBrowserV1AccountProvidersDeleteMutationOptions = < - TError = ErrorResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderAccountBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ProviderAccountBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AccountProvidersDelete'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ProviderAccountBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AccountProvidersDelete(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AccountProvidersDeleteMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountProvidersDeleteMutationBody = ProviderAccountBody -export type AllauthBrowserV1AccountProvidersDeleteMutationError = ErrorResponse - -/** - * @summary Disconnect a third-party provider account - - */ -export const useAllauthBrowserV1AccountProvidersDelete = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderAccountBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AccountProvidersDeleteMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * @summary List the connected third-party provider accounts - */ -export type allauthAppV1AccountProvidersGetResponse200 = { - data: ProviderAccountsResponse - status: 200 -} - -export type allauthAppV1AccountProvidersGetResponseComposite = allauthAppV1AccountProvidersGetResponse200 - -export type allauthAppV1AccountProvidersGetResponse = allauthAppV1AccountProvidersGetResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountProvidersGetUrl = () => { - return `/api/v2/allauth/app/v1/account/providers` -} - -export const allauthAppV1AccountProvidersGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountProvidersGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthAppV1AccountProvidersGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'providers'] as const -} - -export const getAllauthAppV1AccountProvidersGetQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountProvidersGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1AccountProvidersGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AccountProvidersGetQueryResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountProvidersGetQueryError = unknown - -/** - * @summary List the connected third-party provider accounts - */ - -export function useAllauthAppV1AccountProvidersGet< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AccountProvidersGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Disconnect a third-party provider account, returning the remaining -accounts that are still connected. The disconnect is not allowed if it -would leave the account unusable. For example, if no password was -set up yet. - - * @summary Disconnect a third-party provider account - - */ -export type allauthAppV1AccountProvidersDeleteResponse200 = { - data: ProviderAccountsResponse - status: 200 -} - -export type allauthAppV1AccountProvidersDeleteResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AccountProvidersDeleteResponseComposite = - | allauthAppV1AccountProvidersDeleteResponse200 - | allauthAppV1AccountProvidersDeleteResponse400 - -export type allauthAppV1AccountProvidersDeleteResponse = allauthAppV1AccountProvidersDeleteResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountProvidersDeleteUrl = () => { - return `/api/v2/allauth/app/v1/account/providers` -} - -export const allauthAppV1AccountProvidersDelete = async ( - providerAccountBody: ProviderAccountBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountProvidersDeleteUrl(), { - ...options, - method: 'DELETE', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(providerAccountBody), - }) -} - -export const getAllauthAppV1AccountProvidersDeleteMutationOptions = < - TError = ErrorResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderAccountBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ProviderAccountBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AccountProvidersDelete'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ProviderAccountBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AccountProvidersDelete(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AccountProvidersDeleteMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountProvidersDeleteMutationBody = ProviderAccountBody -export type AllauthAppV1AccountProvidersDeleteMutationError = ErrorResponse - -/** - * @summary Disconnect a third-party provider account - - */ -export const useAllauthAppV1AccountProvidersDelete = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProviderAccountBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AccountProvidersDeleteMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Retrieves the list of email addresses of the account. - - * @summary List email addresses - */ -export type allauthBrowserV1AccountEmailGetResponse200 = { - data: EmailAddressesResponse - status: 200 -} - -export type allauthBrowserV1AccountEmailGetResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AccountEmailGetResponseComposite = - | allauthBrowserV1AccountEmailGetResponse200 - | allauthBrowserV1AccountEmailGetResponse401 - -export type allauthBrowserV1AccountEmailGetResponse = allauthBrowserV1AccountEmailGetResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AccountEmailGetUrl = () => { - return `/api/v2/allauth/browser/v1/account/email` -} - -export const allauthBrowserV1AccountEmailGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AccountEmailGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthBrowserV1AccountEmailGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'email'] as const -} - -export const getAllauthBrowserV1AccountEmailGetQueryOptions = < - TData = Awaited>, - TError = AuthenticationResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountEmailGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthBrowserV1AccountEmailGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AccountEmailGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountEmailGetQueryError = AuthenticationResponse - -/** - * @summary List email addresses - */ - -export function useAllauthBrowserV1AccountEmailGet< - TData = Awaited>, - TError = AuthenticationResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AccountEmailGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * The following functionality is available: - - - Adding a new email address for an already signed in user (`ACCOUNT_CHANGE_EMAIL = False`). - - Change to a new email address for an already signed in user (`ACCOUNT_CHANGE_EMAIL = True`). - - Change to a new email address during the email verification process at signup (`ACCOUNT_EMAIL_VERIFICATION_SUPPORTS_CHANGE = True`). - -In all cases, an email verification mail will be sent containing a link or code that needs to be verified. - - * @summary Add/Change email address - - */ -export type allauthBrowserV1AccountEmailPostResponse200 = { - data: EmailAddressesResponse - status: 200 -} - -export type allauthBrowserV1AccountEmailPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AccountEmailPostResponse401 = { - data: AuthenticationOrReauthenticationResponse - status: 401 -} - -export type allauthBrowserV1AccountEmailPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AccountEmailPostResponseComposite = - | allauthBrowserV1AccountEmailPostResponse200 - | allauthBrowserV1AccountEmailPostResponse400 - | allauthBrowserV1AccountEmailPostResponse401 - | allauthBrowserV1AccountEmailPostResponse409 - -export type allauthBrowserV1AccountEmailPostResponse = allauthBrowserV1AccountEmailPostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AccountEmailPostUrl = () => { - return `/api/v2/allauth/browser/v1/account/email` -} - -export const allauthBrowserV1AccountEmailPost = async ( - emailBody: EmailBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AccountEmailPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(emailBody), - }) -} - -export const getAllauthBrowserV1AccountEmailPostMutationOptions = < - TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AccountEmailPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: EmailBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AccountEmailPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AccountEmailPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountEmailPostMutationBody = EmailBody -export type AllauthBrowserV1AccountEmailPostMutationError = - | ErrorResponse - | AuthenticationOrReauthenticationResponse - | ConflictResponse - -/** - * @summary Add/Change email address - - */ -export const useAllauthBrowserV1AccountEmailPost = < - TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AccountEmailPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Requests for (another) email verification email to be sent. Note that -sending emails is rate limited, so when you send too many requests the -email will not be sent. - - * @summary Request email verification - */ -export type allauthBrowserV1AccountEmailPutResponse200 = { - data: StatusOKResponse - status: 200 -} - -export type allauthBrowserV1AccountEmailPutResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AccountEmailPutResponse403 = { - data: ForbiddenResponse - status: 403 -} - -export type allauthBrowserV1AccountEmailPutResponseComposite = - | allauthBrowserV1AccountEmailPutResponse200 - | allauthBrowserV1AccountEmailPutResponse400 - | allauthBrowserV1AccountEmailPutResponse403 - -export type allauthBrowserV1AccountEmailPutResponse = allauthBrowserV1AccountEmailPutResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AccountEmailPutUrl = () => { - return `/api/v2/allauth/browser/v1/account/email` -} - -export const allauthBrowserV1AccountEmailPut = async ( - emailBody: EmailBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AccountEmailPutUrl(), { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(emailBody), - }) -} - -export const getAllauthBrowserV1AccountEmailPutMutationOptions = < - TError = ErrorResponse | ForbiddenResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AccountEmailPut'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: EmailBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AccountEmailPut(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AccountEmailPutMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountEmailPutMutationBody = EmailBody -export type AllauthBrowserV1AccountEmailPutMutationError = ErrorResponse | ForbiddenResponse - -/** - * @summary Request email verification - */ -export const useAllauthBrowserV1AccountEmailPut = < - TError = ErrorResponse | ForbiddenResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AccountEmailPutMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Used to change primary email address to a different one. Note that only verified email addresses -can be marked as primary. - - * @summary Change primary email address - */ -export type allauthBrowserV1AccountEmailPatchResponse200 = { - data: EmailAddressesResponse - status: 200 -} - -export type allauthBrowserV1AccountEmailPatchResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AccountEmailPatchResponseComposite = - | allauthBrowserV1AccountEmailPatchResponse200 - | allauthBrowserV1AccountEmailPatchResponse400 - -export type allauthBrowserV1AccountEmailPatchResponse = allauthBrowserV1AccountEmailPatchResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AccountEmailPatchUrl = () => { - return `/api/v2/allauth/browser/v1/account/email` -} - -export const allauthBrowserV1AccountEmailPatch = async ( - markPrimaryEmailBody: MarkPrimaryEmailBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AccountEmailPatchUrl(), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(markPrimaryEmailBody), - }) -} - -export const getAllauthBrowserV1AccountEmailPatchMutationOptions = < - TError = ErrorResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MarkPrimaryEmailBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: MarkPrimaryEmailBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AccountEmailPatch'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: MarkPrimaryEmailBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AccountEmailPatch(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AccountEmailPatchMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountEmailPatchMutationBody = MarkPrimaryEmailBody -export type AllauthBrowserV1AccountEmailPatchMutationError = ErrorResponse - -/** - * @summary Change primary email address - */ -export const useAllauthBrowserV1AccountEmailPatch = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MarkPrimaryEmailBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AccountEmailPatchMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Used to remove an email address. - - * @summary Remove an email address - */ -export type allauthBrowserV1AccountEmailDeleteResponse200 = { - data: EmailAddressesResponse - status: 200 -} - -export type allauthBrowserV1AccountEmailDeleteResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AccountEmailDeleteResponseComposite = - | allauthBrowserV1AccountEmailDeleteResponse200 - | allauthBrowserV1AccountEmailDeleteResponse400 - -export type allauthBrowserV1AccountEmailDeleteResponse = allauthBrowserV1AccountEmailDeleteResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AccountEmailDeleteUrl = () => { - return `/api/v2/allauth/browser/v1/account/email` -} - -export const allauthBrowserV1AccountEmailDelete = async ( - emailBody: EmailBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AccountEmailDeleteUrl(), { - ...options, - method: 'DELETE', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(emailBody), - }) -} - -export const getAllauthBrowserV1AccountEmailDeleteMutationOptions = < - TError = ErrorResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AccountEmailDelete'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: EmailBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AccountEmailDelete(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AccountEmailDeleteMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountEmailDeleteMutationBody = EmailBody -export type AllauthBrowserV1AccountEmailDeleteMutationError = ErrorResponse - -/** - * @summary Remove an email address - */ -export const useAllauthBrowserV1AccountEmailDelete = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AccountEmailDeleteMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Retrieves the list of email addresses of the account. - - * @summary List email addresses - */ -export type allauthAppV1AccountEmailGetResponse200 = { - data: EmailAddressesResponse - status: 200 -} - -export type allauthAppV1AccountEmailGetResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AccountEmailGetResponseComposite = - | allauthAppV1AccountEmailGetResponse200 - | allauthAppV1AccountEmailGetResponse401 - -export type allauthAppV1AccountEmailGetResponse = allauthAppV1AccountEmailGetResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountEmailGetUrl = () => { - return `/api/v2/allauth/app/v1/account/email` -} - -export const allauthAppV1AccountEmailGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountEmailGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthAppV1AccountEmailGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'email'] as const -} - -export const getAllauthAppV1AccountEmailGetQueryOptions = < - TData = Awaited>, - TError = AuthenticationResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountEmailGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1AccountEmailGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AccountEmailGetQueryResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountEmailGetQueryError = AuthenticationResponse - -/** - * @summary List email addresses - */ - -export function useAllauthAppV1AccountEmailGet< - TData = Awaited>, - TError = AuthenticationResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AccountEmailGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * The following functionality is available: - - - Adding a new email address for an already signed in user (`ACCOUNT_CHANGE_EMAIL = False`). - - Change to a new email address for an already signed in user (`ACCOUNT_CHANGE_EMAIL = True`). - - Change to a new email address during the email verification process at signup (`ACCOUNT_EMAIL_VERIFICATION_SUPPORTS_CHANGE = True`). - -In all cases, an email verification mail will be sent containing a link or code that needs to be verified. - - * @summary Add/Change email address - - */ -export type allauthAppV1AccountEmailPostResponse200 = { - data: EmailAddressesResponse - status: 200 -} - -export type allauthAppV1AccountEmailPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AccountEmailPostResponse401 = { - data: AuthenticationOrReauthenticationResponse - status: 401 -} - -export type allauthAppV1AccountEmailPostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AccountEmailPostResponseComposite = - | allauthAppV1AccountEmailPostResponse200 - | allauthAppV1AccountEmailPostResponse400 - | allauthAppV1AccountEmailPostResponse401 - | allauthAppV1AccountEmailPostResponse409 - -export type allauthAppV1AccountEmailPostResponse = allauthAppV1AccountEmailPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountEmailPostUrl = () => { - return `/api/v2/allauth/app/v1/account/email` -} - -export const allauthAppV1AccountEmailPost = async ( - emailBody: EmailBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountEmailPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(emailBody), - }) -} - -export const getAllauthAppV1AccountEmailPostMutationOptions = < - TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AccountEmailPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: EmailBody }> = ( - props, - ) => { - const { data } = props ?? {} - - return allauthAppV1AccountEmailPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AccountEmailPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountEmailPostMutationBody = EmailBody -export type AllauthAppV1AccountEmailPostMutationError = - | ErrorResponse - | AuthenticationOrReauthenticationResponse - | ConflictResponse - -/** - * @summary Add/Change email address - - */ -export const useAllauthAppV1AccountEmailPost = < - TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AccountEmailPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Requests for (another) email verification email to be sent. Note that -sending emails is rate limited, so when you send too many requests the -email will not be sent. - - * @summary Request email verification - */ -export type allauthAppV1AccountEmailPutResponse200 = { - data: StatusOKResponse - status: 200 -} - -export type allauthAppV1AccountEmailPutResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AccountEmailPutResponse403 = { - data: ForbiddenResponse - status: 403 -} - -export type allauthAppV1AccountEmailPutResponseComposite = - | allauthAppV1AccountEmailPutResponse200 - | allauthAppV1AccountEmailPutResponse400 - | allauthAppV1AccountEmailPutResponse403 - -export type allauthAppV1AccountEmailPutResponse = allauthAppV1AccountEmailPutResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountEmailPutUrl = () => { - return `/api/v2/allauth/app/v1/account/email` -} - -export const allauthAppV1AccountEmailPut = async ( - emailBody: EmailBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountEmailPutUrl(), { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(emailBody), - }) -} - -export const getAllauthAppV1AccountEmailPutMutationOptions = < - TError = ErrorResponse | ForbiddenResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AccountEmailPut'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: EmailBody }> = ( - props, - ) => { - const { data } = props ?? {} - - return allauthAppV1AccountEmailPut(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AccountEmailPutMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountEmailPutMutationBody = EmailBody -export type AllauthAppV1AccountEmailPutMutationError = ErrorResponse | ForbiddenResponse - -/** - * @summary Request email verification - */ -export const useAllauthAppV1AccountEmailPut = < - TError = ErrorResponse | ForbiddenResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AccountEmailPutMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Used to change primary email address to a different one. Note that only verified email addresses -can be marked as primary. - - * @summary Change primary email address - */ -export type allauthAppV1AccountEmailPatchResponse200 = { - data: EmailAddressesResponse - status: 200 -} - -export type allauthAppV1AccountEmailPatchResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AccountEmailPatchResponseComposite = - | allauthAppV1AccountEmailPatchResponse200 - | allauthAppV1AccountEmailPatchResponse400 - -export type allauthAppV1AccountEmailPatchResponse = allauthAppV1AccountEmailPatchResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountEmailPatchUrl = () => { - return `/api/v2/allauth/app/v1/account/email` -} - -export const allauthAppV1AccountEmailPatch = async ( - markPrimaryEmailBody: MarkPrimaryEmailBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountEmailPatchUrl(), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(markPrimaryEmailBody), - }) -} - -export const getAllauthAppV1AccountEmailPatchMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MarkPrimaryEmailBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: MarkPrimaryEmailBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AccountEmailPatch'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: MarkPrimaryEmailBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AccountEmailPatch(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AccountEmailPatchMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountEmailPatchMutationBody = MarkPrimaryEmailBody -export type AllauthAppV1AccountEmailPatchMutationError = ErrorResponse - -/** - * @summary Change primary email address - */ -export const useAllauthAppV1AccountEmailPatch = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: MarkPrimaryEmailBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AccountEmailPatchMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Used to remove an email address. - - * @summary Remove an email address - */ -export type allauthAppV1AccountEmailDeleteResponse200 = { - data: EmailAddressesResponse - status: 200 -} - -export type allauthAppV1AccountEmailDeleteResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AccountEmailDeleteResponseComposite = - | allauthAppV1AccountEmailDeleteResponse200 - | allauthAppV1AccountEmailDeleteResponse400 - -export type allauthAppV1AccountEmailDeleteResponse = allauthAppV1AccountEmailDeleteResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountEmailDeleteUrl = () => { - return `/api/v2/allauth/app/v1/account/email` -} - -export const allauthAppV1AccountEmailDelete = async ( - emailBody: EmailBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountEmailDeleteUrl(), { - ...options, - method: 'DELETE', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(emailBody), - }) -} - -export const getAllauthAppV1AccountEmailDeleteMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AccountEmailDelete'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: EmailBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AccountEmailDelete(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AccountEmailDeleteMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountEmailDeleteMutationBody = EmailBody -export type AllauthAppV1AccountEmailDeleteMutationError = ErrorResponse - -/** - * @summary Remove an email address - */ -export const useAllauthAppV1AccountEmailDelete = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AccountEmailDeleteMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Retrieves the phone number of the account, if any. Note that while the -endpoint returns a list of phone numbers, at most one entry is returned. - - * @summary Get the phone number - */ -export type allauthBrowserV1AccountPhoneGetResponse200 = { - data: PhoneNumbersResponse - status: 200 -} - -export type allauthBrowserV1AccountPhoneGetResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AccountPhoneGetResponseComposite = - | allauthBrowserV1AccountPhoneGetResponse200 - | allauthBrowserV1AccountPhoneGetResponse401 - -export type allauthBrowserV1AccountPhoneGetResponse = allauthBrowserV1AccountPhoneGetResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AccountPhoneGetUrl = () => { - return `/api/v2/allauth/browser/v1/account/phone` -} - -export const allauthBrowserV1AccountPhoneGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AccountPhoneGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthBrowserV1AccountPhoneGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'phone'] as const -} - -export const getAllauthBrowserV1AccountPhoneGetQueryOptions = < - TData = Awaited>, - TError = AuthenticationResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountPhoneGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthBrowserV1AccountPhoneGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AccountPhoneGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountPhoneGetQueryError = AuthenticationResponse - -/** - * @summary Get the phone number - */ - -export function useAllauthBrowserV1AccountPhoneGet< - TData = Awaited>, - TError = AuthenticationResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AccountPhoneGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * The following functionality is available: - -- Initiate the phone number change process for signed in users. -- Change to a new phone number during the phone number verification - process at signup for unauthenticated users. Note that this requires: - `ACCOUNT_PHONE_VERIFICATION_SUPPORTS_CHANGE = True`. - -In both cases, after posting a new phone number, proceed with the phone -verification endpoint to confirm the change of the phone number by -posting the verification code. - - * @summary Change the phone number - - */ -export type allauthBrowserV1AccountPhonePostResponse202 = { - data: PhoneNumberChangeResponse - status: 202 -} - -export type allauthBrowserV1AccountPhonePostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AccountPhonePostResponse401 = { - data: AuthenticationOrReauthenticationResponse - status: 401 -} - -export type allauthBrowserV1AccountPhonePostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthBrowserV1AccountPhonePostResponseComposite = - | allauthBrowserV1AccountPhonePostResponse202 - | allauthBrowserV1AccountPhonePostResponse400 - | allauthBrowserV1AccountPhonePostResponse401 - | allauthBrowserV1AccountPhonePostResponse409 - -export type allauthBrowserV1AccountPhonePostResponse = allauthBrowserV1AccountPhonePostResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AccountPhonePostUrl = () => { - return `/api/v2/allauth/browser/v1/account/phone` -} - -export const allauthBrowserV1AccountPhonePost = async ( - phoneBody: PhoneBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AccountPhonePostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(phoneBody), - }) -} - -export const getAllauthBrowserV1AccountPhonePostMutationOptions = < - TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: PhoneBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: PhoneBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AccountPhonePost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: PhoneBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AccountPhonePost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AccountPhonePostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountPhonePostMutationBody = PhoneBody -export type AllauthBrowserV1AccountPhonePostMutationError = - | ErrorResponse - | AuthenticationOrReauthenticationResponse - | ConflictResponse - -/** - * @summary Change the phone number - - */ -export const useAllauthBrowserV1AccountPhonePost = < - TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: PhoneBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AccountPhonePostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Retrieves the phone number of the account, if any. Note that while the -endpoint returns a list of phone numbers, at most one entry is returned. - - * @summary Get the phone number - */ -export type allauthAppV1AccountPhoneGetResponse200 = { - data: PhoneNumbersResponse - status: 200 -} - -export type allauthAppV1AccountPhoneGetResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AccountPhoneGetResponseComposite = - | allauthAppV1AccountPhoneGetResponse200 - | allauthAppV1AccountPhoneGetResponse401 - -export type allauthAppV1AccountPhoneGetResponse = allauthAppV1AccountPhoneGetResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountPhoneGetUrl = () => { - return `/api/v2/allauth/app/v1/account/phone` -} - -export const allauthAppV1AccountPhoneGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountPhoneGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthAppV1AccountPhoneGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'phone'] as const -} - -export const getAllauthAppV1AccountPhoneGetQueryOptions = < - TData = Awaited>, - TError = AuthenticationResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountPhoneGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1AccountPhoneGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AccountPhoneGetQueryResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountPhoneGetQueryError = AuthenticationResponse - -/** - * @summary Get the phone number - */ - -export function useAllauthAppV1AccountPhoneGet< - TData = Awaited>, - TError = AuthenticationResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AccountPhoneGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * The following functionality is available: - -- Initiate the phone number change process for signed in users. -- Change to a new phone number during the phone number verification - process at signup for unauthenticated users. Note that this requires: - `ACCOUNT_PHONE_VERIFICATION_SUPPORTS_CHANGE = True`. - -In both cases, after posting a new phone number, proceed with the phone -verification endpoint to confirm the change of the phone number by -posting the verification code. - - * @summary Change the phone number - - */ -export type allauthAppV1AccountPhonePostResponse202 = { - data: PhoneNumberChangeResponse - status: 202 -} - -export type allauthAppV1AccountPhonePostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AccountPhonePostResponse401 = { - data: AuthenticationOrReauthenticationResponse - status: 401 -} - -export type allauthAppV1AccountPhonePostResponse409 = { - data: ConflictResponse - status: 409 -} - -export type allauthAppV1AccountPhonePostResponseComposite = - | allauthAppV1AccountPhonePostResponse202 - | allauthAppV1AccountPhonePostResponse400 - | allauthAppV1AccountPhonePostResponse401 - | allauthAppV1AccountPhonePostResponse409 - -export type allauthAppV1AccountPhonePostResponse = allauthAppV1AccountPhonePostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountPhonePostUrl = () => { - return `/api/v2/allauth/app/v1/account/phone` -} - -export const allauthAppV1AccountPhonePost = async ( - phoneBody: PhoneBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountPhonePostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(phoneBody), - }) -} - -export const getAllauthAppV1AccountPhonePostMutationOptions = < - TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: PhoneBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: PhoneBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AccountPhonePost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: PhoneBody }> = ( - props, - ) => { - const { data } = props ?? {} - - return allauthAppV1AccountPhonePost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AccountPhonePostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountPhonePostMutationBody = PhoneBody -export type AllauthAppV1AccountPhonePostMutationError = - | ErrorResponse - | AuthenticationOrReauthenticationResponse - | ConflictResponse - -/** - * @summary Change the phone number - - */ -export const useAllauthAppV1AccountPhonePost = < - TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: PhoneBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AccountPhonePostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * @summary List authenticators - */ -export type allauthBrowserV1AccountAuthenticatorsGetResponse200 = { - data: AuthenticatorsResponse - status: 200 -} - -export type allauthBrowserV1AccountAuthenticatorsGetResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AccountAuthenticatorsGetResponse410 = { - data: SessionGoneResponse - status: 410 -} - -export type allauthBrowserV1AccountAuthenticatorsGetResponseComposite = - | allauthBrowserV1AccountAuthenticatorsGetResponse200 - | allauthBrowserV1AccountAuthenticatorsGetResponse401 - | allauthBrowserV1AccountAuthenticatorsGetResponse410 - -export type allauthBrowserV1AccountAuthenticatorsGetResponse = - allauthBrowserV1AccountAuthenticatorsGetResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AccountAuthenticatorsGetUrl = () => { - return `/api/v2/allauth/browser/v1/account/authenticators` -} - -export const allauthBrowserV1AccountAuthenticatorsGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1AccountAuthenticatorsGetUrl(), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAllauthBrowserV1AccountAuthenticatorsGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'authenticators'] as const -} - -export const getAllauthBrowserV1AccountAuthenticatorsGetQueryOptions = < - TData = Awaited>, - TError = AuthenticationResponse | SessionGoneResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthBrowserV1AccountAuthenticatorsGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AccountAuthenticatorsGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountAuthenticatorsGetQueryError = AuthenticationResponse | SessionGoneResponse - -/** - * @summary List authenticators - */ - -export function useAllauthBrowserV1AccountAuthenticatorsGet< - TData = Awaited>, - TError = AuthenticationResponse | SessionGoneResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AccountAuthenticatorsGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * @summary List authenticators - */ -export type allauthAppV1AccountAuthenticatorsGetResponse200 = { - data: AuthenticatorsResponse - status: 200 -} - -export type allauthAppV1AccountAuthenticatorsGetResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AccountAuthenticatorsGetResponse410 = { - data: SessionGoneResponse - status: 410 -} - -export type allauthAppV1AccountAuthenticatorsGetResponseComposite = - | allauthAppV1AccountAuthenticatorsGetResponse200 - | allauthAppV1AccountAuthenticatorsGetResponse401 - | allauthAppV1AccountAuthenticatorsGetResponse410 - -export type allauthAppV1AccountAuthenticatorsGetResponse = allauthAppV1AccountAuthenticatorsGetResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountAuthenticatorsGetUrl = () => { - return `/api/v2/allauth/app/v1/account/authenticators` -} - -export const allauthAppV1AccountAuthenticatorsGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthAppV1AccountAuthenticatorsGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'authenticators'] as const -} - -export const getAllauthAppV1AccountAuthenticatorsGetQueryOptions = < - TData = Awaited>, - TError = AuthenticationResponse | SessionGoneResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1AccountAuthenticatorsGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AccountAuthenticatorsGetQueryResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountAuthenticatorsGetQueryError = AuthenticationResponse | SessionGoneResponse - -/** - * @summary List authenticators - */ - -export function useAllauthAppV1AccountAuthenticatorsGet< - TData = Awaited>, - TError = AuthenticationResponse | SessionGoneResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AccountAuthenticatorsGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Retrieve the information about the current TOTP authenticator, if any. - - * @summary TOTP authenticator status - */ -export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse200 = { - data: TOTPAuthenticatorResponse - status: 200 -} - -export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse404 = { - data: TOTPAuthenticatorNotFoundResponse - status: 404 -} - -export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse409 = { - data: AddAuthenticatorConflictResponse - status: 409 -} - -export type allauthBrowserV1AccountAuthenticatorsTotpGetResponseComposite = - | allauthBrowserV1AccountAuthenticatorsTotpGetResponse200 - | allauthBrowserV1AccountAuthenticatorsTotpGetResponse404 - | allauthBrowserV1AccountAuthenticatorsTotpGetResponse409 - -export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse = - allauthBrowserV1AccountAuthenticatorsTotpGetResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AccountAuthenticatorsTotpGetUrl = () => { - return `/api/v2/allauth/browser/v1/account/authenticators/totp` -} - -export const allauthBrowserV1AccountAuthenticatorsTotpGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1AccountAuthenticatorsTotpGetUrl(), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'authenticators', 'totp'] as const -} - -export const getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryOptions = < - TData = Awaited>, - TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryKey() - - const queryFn: QueryFunction>> = ({ - signal, - }) => allauthBrowserV1AccountAuthenticatorsTotpGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AccountAuthenticatorsTotpGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountAuthenticatorsTotpGetQueryError = - | TOTPAuthenticatorNotFoundResponse - | AddAuthenticatorConflictResponse - -/** - * @summary TOTP authenticator status - */ - -export function useAllauthBrowserV1AccountAuthenticatorsTotpGet< - TData = Awaited>, - TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * The code should be provided from the consuming TOTP authenticator -application which was generated using the TOTP authenticator secret -retrieved from the TOTP authenticator status endpoint. - - * @summary Activate TOTP - */ -export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse200 = { - data: TOTPAuthenticatorResponse - status: 200 -} - -export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse401 = { - data: ReauthenticationRequiredResponse - status: 401 -} - -export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse409 = { - data: AddAuthenticatorConflictResponse - status: 409 -} - -export type allauthBrowserV1AccountAuthenticatorsTotpPostResponseComposite = - | allauthBrowserV1AccountAuthenticatorsTotpPostResponse200 - | allauthBrowserV1AccountAuthenticatorsTotpPostResponse400 - | allauthBrowserV1AccountAuthenticatorsTotpPostResponse401 - | allauthBrowserV1AccountAuthenticatorsTotpPostResponse409 - -export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse = - allauthBrowserV1AccountAuthenticatorsTotpPostResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AccountAuthenticatorsTotpPostUrl = () => { - return `/api/v2/allauth/browser/v1/account/authenticators/totp` -} - -export const allauthBrowserV1AccountAuthenticatorsTotpPost = async ( - setupTOTPBody: SetupTOTPBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1AccountAuthenticatorsTotpPostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(setupTOTPBody), - }, - ) -} - -export const getAllauthBrowserV1AccountAuthenticatorsTotpPostMutationOptions = < - TError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: SetupTOTPBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: SetupTOTPBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AccountAuthenticatorsTotpPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: SetupTOTPBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AccountAuthenticatorsTotpPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationBody = SetupTOTPBody -export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationError = - | ErrorResponse - | ReauthenticationRequiredResponse - | AddAuthenticatorConflictResponse - -/** - * @summary Activate TOTP - */ -export const useAllauthBrowserV1AccountAuthenticatorsTotpPost = < - TError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: SetupTOTPBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsTotpPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Deactivates TOTP authentication. If the user authentication is not -sufficiently recent, a reauthentication flow (`401`) will is presented. - - * @summary Deactivate TOTP - */ -export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse200 = { - data: StatusOKResponse - status: 200 -} - -export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse401 = { - data: ReauthenticationRequiredResponse - status: 401 -} - -export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponseComposite = - | allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse200 - | allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse401 - -export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse = - allauthBrowserV1AccountAuthenticatorsTotpDeleteResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AccountAuthenticatorsTotpDeleteUrl = () => { - return `/api/v2/allauth/browser/v1/account/authenticators/totp` -} - -export const allauthBrowserV1AccountAuthenticatorsTotpDelete = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1AccountAuthenticatorsTotpDeleteUrl(), - { - ...options, - method: 'DELETE', - }, - ) -} - -export const getAllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationOptions = < - TError = ReauthenticationRequiredResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - void, - TContext -> => { - const mutationKey = ['allauthBrowserV1AccountAuthenticatorsTotpDelete'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - void - > = () => { - return allauthBrowserV1AccountAuthenticatorsTotpDelete(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationResult = NonNullable< - Awaited> -> - -export type AllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationError = ReauthenticationRequiredResponse - -/** - * @summary Deactivate TOTP - */ -export const useAllauthBrowserV1AccountAuthenticatorsTotpDelete = < - TError = ReauthenticationRequiredResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Retrieve the information about the current TOTP authenticator, if any. - - * @summary TOTP authenticator status - */ -export type allauthAppV1AccountAuthenticatorsTotpGetResponse200 = { - data: TOTPAuthenticatorResponse - status: 200 -} - -export type allauthAppV1AccountAuthenticatorsTotpGetResponse404 = { - data: TOTPAuthenticatorNotFoundResponse - status: 404 -} - -export type allauthAppV1AccountAuthenticatorsTotpGetResponse409 = { - data: AddAuthenticatorConflictResponse - status: 409 -} - -export type allauthAppV1AccountAuthenticatorsTotpGetResponseComposite = - | allauthAppV1AccountAuthenticatorsTotpGetResponse200 - | allauthAppV1AccountAuthenticatorsTotpGetResponse404 - | allauthAppV1AccountAuthenticatorsTotpGetResponse409 - -export type allauthAppV1AccountAuthenticatorsTotpGetResponse = - allauthAppV1AccountAuthenticatorsTotpGetResponseComposite & { - headers: Headers - } - -export const getAllauthAppV1AccountAuthenticatorsTotpGetUrl = () => { - return `/api/v2/allauth/app/v1/account/authenticators/totp` -} - -export const allauthAppV1AccountAuthenticatorsTotpGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthAppV1AccountAuthenticatorsTotpGetUrl(), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAllauthAppV1AccountAuthenticatorsTotpGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'authenticators', 'totp'] as const -} - -export const getAllauthAppV1AccountAuthenticatorsTotpGetQueryOptions = < - TData = Awaited>, - TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsTotpGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1AccountAuthenticatorsTotpGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AccountAuthenticatorsTotpGetQueryResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountAuthenticatorsTotpGetQueryError = - | TOTPAuthenticatorNotFoundResponse - | AddAuthenticatorConflictResponse - -/** - * @summary TOTP authenticator status - */ - -export function useAllauthAppV1AccountAuthenticatorsTotpGet< - TData = Awaited>, - TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AccountAuthenticatorsTotpGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * The code should be provided from the consuming TOTP authenticator -application which was generated using the TOTP authenticator secret -retrieved from the TOTP authenticator status endpoint. - - * @summary Activate TOTP - */ -export type allauthAppV1AccountAuthenticatorsTotpPostResponse200 = { - data: TOTPAuthenticatorResponse - status: 200 -} - -export type allauthAppV1AccountAuthenticatorsTotpPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AccountAuthenticatorsTotpPostResponse401 = { - data: ReauthenticationRequiredResponse - status: 401 -} - -export type allauthAppV1AccountAuthenticatorsTotpPostResponse409 = { - data: AddAuthenticatorConflictResponse - status: 409 -} - -export type allauthAppV1AccountAuthenticatorsTotpPostResponseComposite = - | allauthAppV1AccountAuthenticatorsTotpPostResponse200 - | allauthAppV1AccountAuthenticatorsTotpPostResponse400 - | allauthAppV1AccountAuthenticatorsTotpPostResponse401 - | allauthAppV1AccountAuthenticatorsTotpPostResponse409 - -export type allauthAppV1AccountAuthenticatorsTotpPostResponse = - allauthAppV1AccountAuthenticatorsTotpPostResponseComposite & { - headers: Headers - } - -export const getAllauthAppV1AccountAuthenticatorsTotpPostUrl = () => { - return `/api/v2/allauth/app/v1/account/authenticators/totp` -} - -export const allauthAppV1AccountAuthenticatorsTotpPost = async ( - setupTOTPBody: SetupTOTPBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthAppV1AccountAuthenticatorsTotpPostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(setupTOTPBody), - }, - ) -} - -export const getAllauthAppV1AccountAuthenticatorsTotpPostMutationOptions = < - TError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: SetupTOTPBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: SetupTOTPBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AccountAuthenticatorsTotpPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: SetupTOTPBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AccountAuthenticatorsTotpPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AccountAuthenticatorsTotpPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountAuthenticatorsTotpPostMutationBody = SetupTOTPBody -export type AllauthAppV1AccountAuthenticatorsTotpPostMutationError = - | ErrorResponse - | ReauthenticationRequiredResponse - | AddAuthenticatorConflictResponse - -/** - * @summary Activate TOTP - */ -export const useAllauthAppV1AccountAuthenticatorsTotpPost = < - TError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: SetupTOTPBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AccountAuthenticatorsTotpPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Deactivates TOTP authentication. If the user authentication is not -sufficiently recent, a reauthentication flow (`401`) will is presented. - - * @summary Deactivate TOTP - */ -export type allauthAppV1AccountAuthenticatorsTotpDeleteResponse200 = { - data: StatusOKResponse - status: 200 -} - -export type allauthAppV1AccountAuthenticatorsTotpDeleteResponse401 = { - data: ReauthenticationRequiredResponse - status: 401 -} - -export type allauthAppV1AccountAuthenticatorsTotpDeleteResponseComposite = - | allauthAppV1AccountAuthenticatorsTotpDeleteResponse200 - | allauthAppV1AccountAuthenticatorsTotpDeleteResponse401 - -export type allauthAppV1AccountAuthenticatorsTotpDeleteResponse = - allauthAppV1AccountAuthenticatorsTotpDeleteResponseComposite & { - headers: Headers - } - -export const getAllauthAppV1AccountAuthenticatorsTotpDeleteUrl = () => { - return `/api/v2/allauth/app/v1/account/authenticators/totp` -} - -export const allauthAppV1AccountAuthenticatorsTotpDelete = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthAppV1AccountAuthenticatorsTotpDeleteUrl(), - { - ...options, - method: 'DELETE', - }, - ) -} - -export const getAllauthAppV1AccountAuthenticatorsTotpDeleteMutationOptions = < - TError = ReauthenticationRequiredResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - void, - TContext -> => { - const mutationKey = ['allauthAppV1AccountAuthenticatorsTotpDelete'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - void - > = () => { - return allauthAppV1AccountAuthenticatorsTotpDelete(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AccountAuthenticatorsTotpDeleteMutationResult = NonNullable< - Awaited> -> - -export type AllauthAppV1AccountAuthenticatorsTotpDeleteMutationError = ReauthenticationRequiredResponse - -/** - * @summary Deactivate TOTP - */ -export const useAllauthAppV1AccountAuthenticatorsTotpDelete = < - TError = ReauthenticationRequiredResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AccountAuthenticatorsTotpDeleteMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * List recovery codes. - - * @summary List recovery codes - */ -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse200 = { - data: RecoveryCodesResponse - status: 200 -} - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse401 = { - data: ReauthenticationRequiredResponse - status: 401 -} - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse404 = { - data: NotFoundResponse - status: 404 -} - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseComposite = - | allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse200 - | allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse401 - | allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse404 - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse = - allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetUrl = () => { - return `/api/v2/allauth/browser/v1/account/authenticators/recovery-codes` -} - -export const allauthBrowserV1AccountAuthenticatorsRecoveryCodesGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetUrl(), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'authenticators', 'recovery-codes'] as const -} - -export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryOptions = < - TData = Awaited>, - TError = ReauthenticationRequiredResponse | NotFoundResponse, ->(options?: { - query?: UseQueryOptions< - Awaited>, - TError, - TData - > - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryKey() - - const queryFn: QueryFunction>> = ({ - signal, - }) => allauthBrowserV1AccountAuthenticatorsRecoveryCodesGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryError = - | ReauthenticationRequiredResponse - | NotFoundResponse - -/** - * @summary List recovery codes - */ - -export function useAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGet< - TData = Awaited>, - TError = ReauthenticationRequiredResponse | NotFoundResponse, ->(options?: { - query?: UseQueryOptions< - Awaited>, - TError, - TData - > - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * @summary Regenerate recovery codes - */ -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse401 = { - data: ReauthenticationRequiredResponse - status: 401 -} - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponseComposite = - | allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse400 - | allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse401 - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse = - allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostUrl = () => { - return `/api/v2/allauth/browser/v1/account/authenticators/recovery-codes` -} - -export const allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostUrl(), - { - ...options, - method: 'POST', - }, - ) -} - -export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationOptions = < - TError = ErrorResponse | ReauthenticationRequiredResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - void, - TContext -> => { - const mutationKey = ['allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - void - > = () => { - return allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationResult = NonNullable< - Awaited> -> - -export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationError = - | ErrorResponse - | ReauthenticationRequiredResponse - -/** - * @summary Regenerate recovery codes - */ -export const useAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPost = < - TError = ErrorResponse | ReauthenticationRequiredResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * List recovery codes. - - * @summary List recovery codes - */ -export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse200 = { - data: RecoveryCodesResponse - status: 200 -} - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse401 = { - data: ReauthenticationRequiredResponse - status: 401 -} - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse404 = { - data: NotFoundResponse - status: 404 -} - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseComposite = - | allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse200 - | allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse401 - | allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse404 - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse = - allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseComposite & { - headers: Headers - } - -export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetUrl = () => { - return `/api/v2/allauth/app/v1/account/authenticators/recovery-codes` -} - -export const allauthAppV1AccountAuthenticatorsRecoveryCodesGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetUrl(), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'authenticators', 'recovery-codes'] as const -} - -export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryOptions = < - TData = Awaited>, - TError = ReauthenticationRequiredResponse | NotFoundResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryKey() - - const queryFn: QueryFunction>> = ({ - signal, - }) => allauthAppV1AccountAuthenticatorsRecoveryCodesGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryError = - | ReauthenticationRequiredResponse - | NotFoundResponse - -/** - * @summary List recovery codes - */ - -export function useAllauthAppV1AccountAuthenticatorsRecoveryCodesGet< - TData = Awaited>, - TError = ReauthenticationRequiredResponse | NotFoundResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * @summary Regenerate recovery codes - */ -export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse401 = { - data: ReauthenticationRequiredResponse - status: 401 -} - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponseComposite = - | allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse400 - | allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse401 - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse = - allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponseComposite & { - headers: Headers - } - -export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostUrl = () => { - return `/api/v2/allauth/app/v1/account/authenticators/recovery-codes` -} - -export const allauthAppV1AccountAuthenticatorsRecoveryCodesPost = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostUrl(), - { - ...options, - method: 'POST', - }, - ) -} - -export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationOptions = < - TError = ErrorResponse | ReauthenticationRequiredResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - void, - TContext -> => { - const mutationKey = ['allauthAppV1AccountAuthenticatorsRecoveryCodesPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - void - > = () => { - return allauthAppV1AccountAuthenticatorsRecoveryCodesPost(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationResult = NonNullable< - Awaited> -> - -export type AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationError = - | ErrorResponse - | ReauthenticationRequiredResponse - -/** - * @summary Regenerate recovery codes - */ -export const useAllauthAppV1AccountAuthenticatorsRecoveryCodesPost = < - TError = ErrorResponse | ReauthenticationRequiredResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - void, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Retrieve information about the authentication status for the current -session. - - * @summary Get authentication status - - */ -export type allauthBrowserV1AuthSessionGetResponse200 = { - data: AuthenticatedResponse - status: 200 -} - -export type allauthBrowserV1AuthSessionGetResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AuthSessionGetResponse410 = { - data: SessionGoneResponse - status: 410 -} - -export type allauthBrowserV1AuthSessionGetResponseComposite = - | allauthBrowserV1AuthSessionGetResponse200 - | allauthBrowserV1AuthSessionGetResponse401 - | allauthBrowserV1AuthSessionGetResponse410 - -export type allauthBrowserV1AuthSessionGetResponse = allauthBrowserV1AuthSessionGetResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthSessionGetUrl = () => { - return `/api/v2/allauth/browser/v1/auth/session` -} - -export const allauthBrowserV1AuthSessionGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthSessionGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthBrowserV1AuthSessionGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'auth', 'session'] as const -} - -export const getAllauthBrowserV1AuthSessionGetQueryOptions = < - TData = Awaited>, - TError = AuthenticationResponse | SessionGoneResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthSessionGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthBrowserV1AuthSessionGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AuthSessionGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthSessionGetQueryError = AuthenticationResponse | SessionGoneResponse - -/** - * @summary Get authentication status - - */ - -export function useAllauthBrowserV1AuthSessionGet< - TData = Awaited>, - TError = AuthenticationResponse | SessionGoneResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AuthSessionGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Logs out the user from the current session. - - * @summary Logout - */ -export type allauthBrowserV1AuthSessionDeleteResponse401 = { - data: UnauthenticatedResponse - status: 401 -} - -export type allauthBrowserV1AuthSessionDeleteResponseComposite = allauthBrowserV1AuthSessionDeleteResponse401 - -export type allauthBrowserV1AuthSessionDeleteResponse = allauthBrowserV1AuthSessionDeleteResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthSessionDeleteUrl = () => { - return `/api/v2/allauth/browser/v1/auth/session` -} - -export const allauthBrowserV1AuthSessionDelete = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthSessionDeleteUrl(), { - ...options, - method: 'DELETE', - }) -} - -export const getAllauthBrowserV1AuthSessionDeleteMutationOptions = < - TError = UnauthenticatedResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['allauthBrowserV1AuthSessionDelete'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return allauthBrowserV1AuthSessionDelete(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthSessionDeleteMutationResult = NonNullable< - Awaited> -> - -export type AllauthBrowserV1AuthSessionDeleteMutationError = UnauthenticatedResponse - -/** - * @summary Logout - */ -export const useAllauthBrowserV1AuthSessionDelete = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthSessionDeleteMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Retrieve information about the authentication status for the current -session. - - * @summary Get authentication status - - */ -export type allauthAppV1AuthSessionGetResponse200 = { - data: AuthenticatedResponse - status: 200 -} - -export type allauthAppV1AuthSessionGetResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AuthSessionGetResponse410 = { - data: SessionGoneResponse - status: 410 -} - -export type allauthAppV1AuthSessionGetResponseComposite = - | allauthAppV1AuthSessionGetResponse200 - | allauthAppV1AuthSessionGetResponse401 - | allauthAppV1AuthSessionGetResponse410 - -export type allauthAppV1AuthSessionGetResponse = allauthAppV1AuthSessionGetResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthSessionGetUrl = () => { - return `/api/v2/allauth/app/v1/auth/session` -} - -export const allauthAppV1AuthSessionGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthSessionGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthAppV1AuthSessionGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'auth', 'session'] as const -} - -export const getAllauthAppV1AuthSessionGetQueryOptions = < - TData = Awaited>, - TError = AuthenticationResponse | SessionGoneResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthSessionGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1AuthSessionGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AuthSessionGetQueryResult = NonNullable>> -export type AllauthAppV1AuthSessionGetQueryError = AuthenticationResponse | SessionGoneResponse - -/** - * @summary Get authentication status - - */ - -export function useAllauthAppV1AuthSessionGet< - TData = Awaited>, - TError = AuthenticationResponse | SessionGoneResponse, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AuthSessionGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Logs out the user from the current session. - - * @summary Logout - */ -export type allauthAppV1AuthSessionDeleteResponse401 = { - data: UnauthenticatedResponse - status: 401 -} - -export type allauthAppV1AuthSessionDeleteResponseComposite = allauthAppV1AuthSessionDeleteResponse401 - -export type allauthAppV1AuthSessionDeleteResponse = allauthAppV1AuthSessionDeleteResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthSessionDeleteUrl = () => { - return `/api/v2/allauth/app/v1/auth/session` -} - -export const allauthAppV1AuthSessionDelete = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthSessionDeleteUrl(), { - ...options, - method: 'DELETE', - }) -} - -export const getAllauthAppV1AuthSessionDeleteMutationOptions = < - TError = UnauthenticatedResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['allauthAppV1AuthSessionDelete'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return allauthAppV1AuthSessionDelete(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthSessionDeleteMutationResult = NonNullable< - Awaited> -> - -export type AllauthAppV1AuthSessionDeleteMutationError = UnauthenticatedResponse - -/** - * @summary Logout - */ -export const useAllauthAppV1AuthSessionDelete = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthSessionDeleteMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Used to retrieve a new access token. Depending on `settings.HEADLESS_JWT_ROTATE_REFRESH_TOKEN`, -a new refresh token is returned as well. - - * @summary Refresh the access token - - */ -export type allauthAppV1TokensRefreshPostResponse200 = { - data: RefreshTokenResponse - status: 200 -} - -export type allauthAppV1TokensRefreshPostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1TokensRefreshPostResponseComposite = - | allauthAppV1TokensRefreshPostResponse200 - | allauthAppV1TokensRefreshPostResponse400 - -export type allauthAppV1TokensRefreshPostResponse = allauthAppV1TokensRefreshPostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1TokensRefreshPostUrl = () => { - return `/api/v2/allauth/app/v1/tokens/refresh` -} - -export const allauthAppV1TokensRefreshPost = async ( - refreshTokenBody: RefreshTokenBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1TokensRefreshPostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(refreshTokenBody), - }) -} - -export const getAllauthAppV1TokensRefreshPostMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: RefreshTokenBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: RefreshTokenBody }, - TContext -> => { - const mutationKey = ['allauthAppV1TokensRefreshPost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: RefreshTokenBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1TokensRefreshPost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1TokensRefreshPostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1TokensRefreshPostMutationBody = RefreshTokenBody -export type AllauthAppV1TokensRefreshPostMutationError = ErrorResponse - -/** - * @summary Refresh the access token - - */ -export const useAllauthAppV1TokensRefreshPost = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: RefreshTokenBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1TokensRefreshPostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * In order to change the password of an account, the current and new -password must be provider. However, accounts that were created by -signing up using a third-party provider do not have a password set. In -that case, the current password is not required. - - * @summary Change password - */ -export type allauthBrowserV1AccountPasswordChangePostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthBrowserV1AccountPasswordChangePostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AccountPasswordChangePostResponseComposite = - | allauthBrowserV1AccountPasswordChangePostResponse400 - | allauthBrowserV1AccountPasswordChangePostResponse401 - -export type allauthBrowserV1AccountPasswordChangePostResponse = - allauthBrowserV1AccountPasswordChangePostResponseComposite & { - headers: Headers - } - -export const getAllauthBrowserV1AccountPasswordChangePostUrl = () => { - return `/api/v2/allauth/browser/v1/account/password/change` -} - -export const allauthBrowserV1AccountPasswordChangePost = async ( - changePasswordBody: ChangePasswordBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAllauthBrowserV1AccountPasswordChangePostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(changePasswordBody), - }, - ) -} - -export const getAllauthBrowserV1AccountPasswordChangePostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ChangePasswordBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ChangePasswordBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AccountPasswordChangePost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ChangePasswordBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AccountPasswordChangePost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AccountPasswordChangePostMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AccountPasswordChangePostMutationBody = ChangePasswordBody -export type AllauthBrowserV1AccountPasswordChangePostMutationError = ErrorResponse | AuthenticationResponse - -/** - * @summary Change password - */ -export const useAllauthBrowserV1AccountPasswordChangePost = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ChangePasswordBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AccountPasswordChangePostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * In order to change the password of an account, the current and new -password must be provider. However, accounts that were created by -signing up using a third-party provider do not have a password set. In -that case, the current password is not required. - - * @summary Change password - */ -export type allauthAppV1AccountPasswordChangePostResponse400 = { - data: ErrorResponse - status: 400 -} - -export type allauthAppV1AccountPasswordChangePostResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AccountPasswordChangePostResponseComposite = - | allauthAppV1AccountPasswordChangePostResponse400 - | allauthAppV1AccountPasswordChangePostResponse401 - -export type allauthAppV1AccountPasswordChangePostResponse = allauthAppV1AccountPasswordChangePostResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AccountPasswordChangePostUrl = () => { - return `/api/v2/allauth/app/v1/account/password/change` -} - -export const allauthAppV1AccountPasswordChangePost = async ( - changePasswordBody: ChangePasswordBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AccountPasswordChangePostUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(changePasswordBody), - }) -} - -export const getAllauthAppV1AccountPasswordChangePostMutationOptions = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ChangePasswordBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ChangePasswordBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AccountPasswordChangePost'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ChangePasswordBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AccountPasswordChangePost(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AccountPasswordChangePostMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AccountPasswordChangePostMutationBody = ChangePasswordBody -export type AllauthAppV1AccountPasswordChangePostMutationError = ErrorResponse | AuthenticationResponse - -/** - * @summary Change password - */ -export const useAllauthAppV1AccountPasswordChangePost = < - TError = ErrorResponse | AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ChangePasswordBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AccountPasswordChangePostMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * @summary List sessions - */ -export type allauthBrowserV1AuthSessionsGetResponse200 = { - data: SessionsResponse - status: 200 -} - -export type allauthBrowserV1AuthSessionsGetResponseComposite = allauthBrowserV1AuthSessionsGetResponse200 - -export type allauthBrowserV1AuthSessionsGetResponse = allauthBrowserV1AuthSessionsGetResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthSessionsGetUrl = () => { - return `/api/v2/allauth/browser/v1/auth/sessions` -} - -export const allauthBrowserV1AuthSessionsGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthSessionsGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthBrowserV1AuthSessionsGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'browser', 'v1', 'auth', 'sessions'] as const -} - -export const getAllauthBrowserV1AuthSessionsGetQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthSessionsGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthBrowserV1AuthSessionsGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthBrowserV1AuthSessionsGetQueryResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthSessionsGetQueryError = unknown - -/** - * @summary List sessions - */ - -export function useAllauthBrowserV1AuthSessionsGet< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthBrowserV1AuthSessionsGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * @summary End one or more sessions - */ -export type allauthBrowserV1AuthSessionsDeleteResponse200 = { - data: SessionsResponse - status: 200 -} - -export type allauthBrowserV1AuthSessionsDeleteResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthBrowserV1AuthSessionsDeleteResponseComposite = - | allauthBrowserV1AuthSessionsDeleteResponse200 - | allauthBrowserV1AuthSessionsDeleteResponse401 - -export type allauthBrowserV1AuthSessionsDeleteResponse = allauthBrowserV1AuthSessionsDeleteResponseComposite & { - headers: Headers -} - -export const getAllauthBrowserV1AuthSessionsDeleteUrl = () => { - return `/api/v2/allauth/browser/v1/auth/sessions` -} - -export const allauthBrowserV1AuthSessionsDelete = async ( - endSessionsBody: EndSessionsBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthBrowserV1AuthSessionsDeleteUrl(), { - ...options, - method: 'DELETE', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(endSessionsBody), - }) -} - -export const getAllauthBrowserV1AuthSessionsDeleteMutationOptions = < - TError = AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EndSessionsBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: EndSessionsBody }, - TContext -> => { - const mutationKey = ['allauthBrowserV1AuthSessionsDelete'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: EndSessionsBody } - > = (props) => { - const { data } = props ?? {} - - return allauthBrowserV1AuthSessionsDelete(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthBrowserV1AuthSessionsDeleteMutationResult = NonNullable< - Awaited> -> -export type AllauthBrowserV1AuthSessionsDeleteMutationBody = EndSessionsBody -export type AllauthBrowserV1AuthSessionsDeleteMutationError = AuthenticationResponse - -/** - * @summary End one or more sessions - */ -export const useAllauthBrowserV1AuthSessionsDelete = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EndSessionsBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthBrowserV1AuthSessionsDeleteMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * @summary List sessions - */ -export type allauthAppV1AuthSessionsGetResponse200 = { - data: SessionsResponse - status: 200 -} - -export type allauthAppV1AuthSessionsGetResponseComposite = allauthAppV1AuthSessionsGetResponse200 - -export type allauthAppV1AuthSessionsGetResponse = allauthAppV1AuthSessionsGetResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthSessionsGetUrl = () => { - return `/api/v2/allauth/app/v1/auth/sessions` -} - -export const allauthAppV1AuthSessionsGet = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthSessionsGetUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAllauthAppV1AuthSessionsGetQueryKey = () => { - return ['api', 'v2', 'allauth', 'app', 'v1', 'auth', 'sessions'] as const -} - -export const getAllauthAppV1AuthSessionsGetQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthSessionsGetQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - allauthAppV1AuthSessionsGet({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AllauthAppV1AuthSessionsGetQueryResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthSessionsGetQueryError = unknown - -/** - * @summary List sessions - */ - -export function useAllauthAppV1AuthSessionsGet< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAllauthAppV1AuthSessionsGetQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * @summary End one or more sessions - */ -export type allauthAppV1AuthSessionsDeleteResponse200 = { - data: SessionsResponse - status: 200 -} - -export type allauthAppV1AuthSessionsDeleteResponse401 = { - data: AuthenticationResponse - status: 401 -} - -export type allauthAppV1AuthSessionsDeleteResponseComposite = - | allauthAppV1AuthSessionsDeleteResponse200 - | allauthAppV1AuthSessionsDeleteResponse401 - -export type allauthAppV1AuthSessionsDeleteResponse = allauthAppV1AuthSessionsDeleteResponseComposite & { - headers: Headers -} - -export const getAllauthAppV1AuthSessionsDeleteUrl = () => { - return `/api/v2/allauth/app/v1/auth/sessions` -} - -export const allauthAppV1AuthSessionsDelete = async ( - endSessionsBody: EndSessionsBody, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAllauthAppV1AuthSessionsDeleteUrl(), { - ...options, - method: 'DELETE', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(endSessionsBody), - }) -} - -export const getAllauthAppV1AuthSessionsDeleteMutationOptions = < - TError = AuthenticationResponse, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EndSessionsBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: EndSessionsBody }, - TContext -> => { - const mutationKey = ['allauthAppV1AuthSessionsDelete'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: EndSessionsBody } - > = (props) => { - const { data } = props ?? {} - - return allauthAppV1AuthSessionsDelete(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AllauthAppV1AuthSessionsDeleteMutationResult = NonNullable< - Awaited> -> -export type AllauthAppV1AuthSessionsDeleteMutationBody = EndSessionsBody -export type AllauthAppV1AuthSessionsDeleteMutationError = AuthenticationResponse - -/** - * @summary End one or more sessions - */ -export const useAllauthAppV1AuthSessionsDelete = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EndSessionsBody }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAllauthAppV1AuthSessionsDeleteMutationOptions(options) - - return useMutation(mutationOptions) -} diff --git a/jsapp/js/api/react-query/authentication-allauth-headless/index.ts b/jsapp/js/api/react-query/authentication-allauth-headless/index.ts new file mode 100644 index 0000000000..f291ac9f14 --- /dev/null +++ b/jsapp/js/api/react-query/authentication-allauth-headless/index.ts @@ -0,0 +1,7399 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + AddAuthenticatorConflictResponse +} from '../../models/addAuthenticatorConflictResponse'; + +import type { + AuthenticatedByCodeResponse +} from '../../models/authenticatedByCodeResponse'; + +import type { + AuthenticatedByPasswordAnd2FAResponse +} from '../../models/authenticatedByPasswordAnd2FAResponse'; + +import type { + AuthenticatedByPasswordResponse +} from '../../models/authenticatedByPasswordResponse'; + +import type { + AuthenticatedResponse +} from '../../models/authenticatedResponse'; + +import type { + AuthenticationOrReauthenticationResponse +} from '../../models/authenticationOrReauthenticationResponse'; + +import type { + AuthenticationResponse +} from '../../models/authenticationResponse'; + +import type { + AuthenticatorsResponse +} from '../../models/authenticatorsResponse'; + +import type { + ChangePasswordBody +} from '../../models/changePasswordBody'; + +import type { + ConfigurationResponse +} from '../../models/configurationResponse'; + +import type { + ConfirmLoginCodeBody +} from '../../models/confirmLoginCodeBody'; + +import type { + ConflictResponse +} from '../../models/conflictResponse'; + +import type { + EmailAddressesResponse +} from '../../models/emailAddressesResponse'; + +import type { + EmailBody +} from '../../models/emailBody'; + +import type { + EmailVerificationInfoResponse +} from '../../models/emailVerificationInfoResponse'; + +import type { + EndSessionsBody +} from '../../models/endSessionsBody'; + +import type { + ErrorResponse +} from '../../models/errorResponse'; + +import type { + ForbiddenResponse +} from '../../models/forbiddenResponse'; + +import type { + LoginBody +} from '../../models/loginBody'; + +import type { + MFAAuthenticateBody +} from '../../models/mFAAuthenticateBody'; + +import type { + MarkPrimaryEmailBody +} from '../../models/markPrimaryEmailBody'; + +import type { + NotFoundResponse +} from '../../models/notFoundResponse'; + +import type { + PasswordResetInfoResponse +} from '../../models/passwordResetInfoResponse'; + +import type { + PhoneBody +} from '../../models/phoneBody'; + +import type { + PhoneNumberChangeResponse +} from '../../models/phoneNumberChangeResponse'; + +import type { + PhoneNumbersResponse +} from '../../models/phoneNumbersResponse'; + +import type { + ProviderAccountBody +} from '../../models/providerAccountBody'; + +import type { + ProviderAccountsResponse +} from '../../models/providerAccountsResponse'; + +import type { + ProviderRedirectBody +} from '../../models/providerRedirectBody'; + +import type { + ProviderSignupBody +} from '../../models/providerSignupBody'; + +import type { + ProviderSignupResponse +} from '../../models/providerSignupResponse'; + +import type { + ProviderTokenBody +} from '../../models/providerTokenBody'; + +import type { + ReauthenticateBody +} from '../../models/reauthenticateBody'; + +import type { + ReauthenticationRequiredResponse +} from '../../models/reauthenticationRequiredResponse'; + +import type { + RecoveryCodesResponse +} from '../../models/recoveryCodesResponse'; + +import type { + RefreshTokenBody +} from '../../models/refreshTokenBody'; + +import type { + RefreshTokenResponse +} from '../../models/refreshTokenResponse'; + +import type { + RequestPasswordBody +} from '../../models/requestPasswordBody'; + +import type { + ResetPasswordBody +} from '../../models/resetPasswordBody'; + +import type { + SessionGoneResponse +} from '../../models/sessionGoneResponse'; + +import type { + SessionsResponse +} from '../../models/sessionsResponse'; + +import type { + SetupTOTPBody +} from '../../models/setupTOTPBody'; + +import type { + SignupBody +} from '../../models/signupBody'; + +import type { + StatusOKResponse +} from '../../models/statusOKResponse'; + +import type { + TOTPAuthenticatorNotFoundResponse +} from '../../models/tOTPAuthenticatorNotFoundResponse'; + +import type { + TOTPAuthenticatorResponse +} from '../../models/tOTPAuthenticatorResponse'; + +import type { + TooManyRequestsResponse +} from '../../models/tooManyRequestsResponse'; + +import type { + UnauthenticatedResponse +} from '../../models/unauthenticatedResponse'; + +import type { + VerifyEmailBody +} from '../../models/verifyEmailBody'; + +import type { + VerifyPhoneBody +} from '../../models/verifyPhoneBody'; + +import { fetchWithAuth } from '../../orval.mutator'; + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * There are many configuration options that alter the functionality +and behavior of django-allauth, some of which can also impact the +frontend. Therefore, relevant configuration options are exposed via +this endpoint. The data returned is not user/authentication +dependent. Hence, it suffices to only fetch this data once at boot +time of your application. + + * @summary Get configuration + */ +export type allauthBrowserV1ConfigGetResponse200 = { + data: ConfigurationResponse + status: 200 +} + +export type allauthBrowserV1ConfigGetResponseComposite = allauthBrowserV1ConfigGetResponse200; + +export type allauthBrowserV1ConfigGetResponse = allauthBrowserV1ConfigGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1ConfigGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/config` +} + +export const allauthBrowserV1ConfigGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1ConfigGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1ConfigGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','config'] as const; + } + + +export const getAllauthBrowserV1ConfigGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1ConfigGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1ConfigGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1ConfigGetQueryResult = NonNullable>> +export type AllauthBrowserV1ConfigGetQueryError = unknown + + +/** + * @summary Get configuration + */ + +export function useAllauthBrowserV1ConfigGet>, TError = unknown>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1ConfigGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * There are many configuration options that alter the functionality +and behavior of django-allauth, some of which can also impact the +frontend. Therefore, relevant configuration options are exposed via +this endpoint. The data returned is not user/authentication +dependent. Hence, it suffices to only fetch this data once at boot +time of your application. + + * @summary Get configuration + */ +export type allauthAppV1ConfigGetResponse200 = { + data: ConfigurationResponse + status: 200 +} + +export type allauthAppV1ConfigGetResponseComposite = allauthAppV1ConfigGetResponse200; + +export type allauthAppV1ConfigGetResponse = allauthAppV1ConfigGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1ConfigGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/config` +} + +export const allauthAppV1ConfigGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1ConfigGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1ConfigGetQueryKey = () => { + return ['api','v2','allauth','app','v1','config'] as const; + } + + +export const getAllauthAppV1ConfigGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1ConfigGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1ConfigGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1ConfigGetQueryResult = NonNullable>> +export type AllauthAppV1ConfigGetQueryError = unknown + + +/** + * @summary Get configuration + */ + +export function useAllauthAppV1ConfigGet>, TError = unknown>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1ConfigGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Login using a username-password or email-password combination. + + * @summary Login + */ +export type allauthBrowserV1AuthLoginPostResponse200 = { + data: AuthenticatedByPasswordResponse + status: 200 +} + +export type allauthBrowserV1AuthLoginPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthLoginPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AuthLoginPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthLoginPostResponseComposite = allauthBrowserV1AuthLoginPostResponse200 | allauthBrowserV1AuthLoginPostResponse400 | allauthBrowserV1AuthLoginPostResponse401 | allauthBrowserV1AuthLoginPostResponse409; + +export type allauthBrowserV1AuthLoginPostResponse = allauthBrowserV1AuthLoginPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthLoginPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/login` +} + +export const allauthBrowserV1AuthLoginPost = async (loginBody: LoginBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthLoginPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + loginBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthLoginPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: LoginBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: LoginBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthLoginPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: LoginBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthLoginPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthLoginPostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthLoginPostMutationBody = LoginBody + export type AllauthBrowserV1AuthLoginPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse + + /** + * @summary Login + */ +export const useAllauthBrowserV1AuthLoginPost = (options?: { mutation?:UseMutationOptions>, TError,{data: LoginBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthLoginPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Login using a username-password or email-password combination. + + * @summary Login + */ +export type allauthAppV1AuthLoginPostResponse200 = { + data: AuthenticatedByPasswordResponse + status: 200 +} + +export type allauthAppV1AuthLoginPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthLoginPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AuthLoginPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthLoginPostResponseComposite = allauthAppV1AuthLoginPostResponse200 | allauthAppV1AuthLoginPostResponse400 | allauthAppV1AuthLoginPostResponse401 | allauthAppV1AuthLoginPostResponse409; + +export type allauthAppV1AuthLoginPostResponse = allauthAppV1AuthLoginPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthLoginPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/login` +} + +export const allauthAppV1AuthLoginPost = async (loginBody: LoginBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthLoginPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + loginBody,) + } +);} + + + + +export const getAllauthAppV1AuthLoginPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: LoginBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: LoginBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthLoginPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: LoginBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthLoginPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthLoginPostMutationResult = NonNullable>> + export type AllauthAppV1AuthLoginPostMutationBody = LoginBody + export type AllauthAppV1AuthLoginPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse + + /** + * @summary Login + */ +export const useAllauthAppV1AuthLoginPost = (options?: { mutation?:UseMutationOptions>, TError,{data: LoginBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthLoginPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Whether or not `username`, `email`, `phone` or combination of those are +required depends on the configuration of django-allauth. Additionally, +if a custom signup form is used there may be other custom properties +required. + + * @summary Signup + */ +export type allauthBrowserV1AuthSignupPostResponse200 = { + data: AuthenticatedByPasswordResponse + status: 200 +} + +export type allauthBrowserV1AuthSignupPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthSignupPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AuthSignupPostResponse403 = { + data: ForbiddenResponse + status: 403 +} + +export type allauthBrowserV1AuthSignupPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthSignupPostResponseComposite = allauthBrowserV1AuthSignupPostResponse200 | allauthBrowserV1AuthSignupPostResponse400 | allauthBrowserV1AuthSignupPostResponse401 | allauthBrowserV1AuthSignupPostResponse403 | allauthBrowserV1AuthSignupPostResponse409; + +export type allauthBrowserV1AuthSignupPostResponse = allauthBrowserV1AuthSignupPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthSignupPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/signup` +} + +export const allauthBrowserV1AuthSignupPost = async (signupBody: SignupBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthSignupPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + signupBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthSignupPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: SignupBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: SignupBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthSignupPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: SignupBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthSignupPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthSignupPostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthSignupPostMutationBody = SignupBody + export type AllauthBrowserV1AuthSignupPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse + + /** + * @summary Signup + */ +export const useAllauthBrowserV1AuthSignupPost = (options?: { mutation?:UseMutationOptions>, TError,{data: SignupBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthSignupPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Whether or not `username`, `email`, `phone` or combination of those are +required depends on the configuration of django-allauth. Additionally, +if a custom signup form is used there may be other custom properties +required. + + * @summary Signup + */ +export type allauthAppV1AuthSignupPostResponse200 = { + data: AuthenticatedByPasswordResponse + status: 200 +} + +export type allauthAppV1AuthSignupPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthSignupPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AuthSignupPostResponse403 = { + data: ForbiddenResponse + status: 403 +} + +export type allauthAppV1AuthSignupPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthSignupPostResponseComposite = allauthAppV1AuthSignupPostResponse200 | allauthAppV1AuthSignupPostResponse400 | allauthAppV1AuthSignupPostResponse401 | allauthAppV1AuthSignupPostResponse403 | allauthAppV1AuthSignupPostResponse409; + +export type allauthAppV1AuthSignupPostResponse = allauthAppV1AuthSignupPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthSignupPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/signup` +} + +export const allauthAppV1AuthSignupPost = async (signupBody: SignupBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthSignupPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + signupBody,) + } +);} + + + + +export const getAllauthAppV1AuthSignupPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: SignupBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: SignupBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthSignupPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: SignupBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthSignupPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthSignupPostMutationResult = NonNullable>> + export type AllauthAppV1AuthSignupPostMutationBody = SignupBody + export type AllauthAppV1AuthSignupPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse + + /** + * @summary Signup + */ +export const useAllauthAppV1AuthSignupPost = (options?: { mutation?:UseMutationOptions>, TError,{data: SignupBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthSignupPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Obtain email verification information, given the token that was sent to +the user by email. + + * @summary Get email verification information + */ +export type allauthBrowserV1AuthEmailVerifyGetResponse200 = { + data: EmailVerificationInfoResponse + status: 200 +} + +export type allauthBrowserV1AuthEmailVerifyGetResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthEmailVerifyGetResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthEmailVerifyGetResponseComposite = allauthBrowserV1AuthEmailVerifyGetResponse200 | allauthBrowserV1AuthEmailVerifyGetResponse400 | allauthBrowserV1AuthEmailVerifyGetResponse409; + +export type allauthBrowserV1AuthEmailVerifyGetResponse = allauthBrowserV1AuthEmailVerifyGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthEmailVerifyGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/email/verify` +} + +export const allauthBrowserV1AuthEmailVerifyGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthEmailVerifyGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AuthEmailVerifyGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','auth','email','verify'] as const; + } + + +export const getAllauthBrowserV1AuthEmailVerifyGetQueryOptions = >, TError = ErrorResponse | ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthEmailVerifyGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AuthEmailVerifyGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AuthEmailVerifyGetQueryResult = NonNullable>> +export type AllauthBrowserV1AuthEmailVerifyGetQueryError = ErrorResponse | ConflictResponse + + +/** + * @summary Get email verification information + */ + +export function useAllauthBrowserV1AuthEmailVerifyGet>, TError = ErrorResponse | ConflictResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AuthEmailVerifyGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Complete the email verification process. Depending on the configuration, +email addresses are either verified by opening a link that is sent to +their email address, or, by inputting a code that is sent. On the API, +both cases are handled identically. Meaning, the required key is either +the one from the link, or, the code itself. + +Note that a status code of 401 does not imply failure. It indicates that +the email verification was successful, yet, the user is still not signed +in. For example, in case `ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION` is set to +`False`, a 401 is returned when verifying as part of login/signup. + + * @summary Verify an email + */ +export type allauthBrowserV1AuthEmailVerifyPostResponse200 = { + data: AuthenticatedResponse + status: 200 +} + +export type allauthBrowserV1AuthEmailVerifyPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthEmailVerifyPostResponse401 = { + data: UnauthenticatedResponse + status: 401 +} + +export type allauthBrowserV1AuthEmailVerifyPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthEmailVerifyPostResponseComposite = allauthBrowserV1AuthEmailVerifyPostResponse200 | allauthBrowserV1AuthEmailVerifyPostResponse400 | allauthBrowserV1AuthEmailVerifyPostResponse401 | allauthBrowserV1AuthEmailVerifyPostResponse409; + +export type allauthBrowserV1AuthEmailVerifyPostResponse = allauthBrowserV1AuthEmailVerifyPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthEmailVerifyPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/email/verify` +} + +export const allauthBrowserV1AuthEmailVerifyPost = async (verifyEmailBody: VerifyEmailBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthEmailVerifyPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + verifyEmailBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthEmailVerifyPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthEmailVerifyPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: VerifyEmailBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthEmailVerifyPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthEmailVerifyPostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthEmailVerifyPostMutationBody = VerifyEmailBody + export type AllauthBrowserV1AuthEmailVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse + + /** + * @summary Verify an email + */ +export const useAllauthBrowserV1AuthEmailVerifyPost = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthEmailVerifyPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Obtain email verification information, given the token that was sent to +the user by email. + + * @summary Get email verification information + */ +export type allauthAppV1AuthEmailVerifyGetResponse200 = { + data: EmailVerificationInfoResponse + status: 200 +} + +export type allauthAppV1AuthEmailVerifyGetResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthEmailVerifyGetResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthEmailVerifyGetResponseComposite = allauthAppV1AuthEmailVerifyGetResponse200 | allauthAppV1AuthEmailVerifyGetResponse400 | allauthAppV1AuthEmailVerifyGetResponse409; + +export type allauthAppV1AuthEmailVerifyGetResponse = allauthAppV1AuthEmailVerifyGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthEmailVerifyGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/email/verify` +} + +export const allauthAppV1AuthEmailVerifyGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthEmailVerifyGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AuthEmailVerifyGetQueryKey = () => { + return ['api','v2','allauth','app','v1','auth','email','verify'] as const; + } + + +export const getAllauthAppV1AuthEmailVerifyGetQueryOptions = >, TError = ErrorResponse | ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthEmailVerifyGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AuthEmailVerifyGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AuthEmailVerifyGetQueryResult = NonNullable>> +export type AllauthAppV1AuthEmailVerifyGetQueryError = ErrorResponse | ConflictResponse + + +/** + * @summary Get email verification information + */ + +export function useAllauthAppV1AuthEmailVerifyGet>, TError = ErrorResponse | ConflictResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AuthEmailVerifyGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Complete the email verification process. Depending on the configuration, +email addresses are either verified by opening a link that is sent to +their email address, or, by inputting a code that is sent. On the API, +both cases are handled identically. Meaning, the required key is either +the one from the link, or, the code itself. + +Note that a status code of 401 does not imply failure. It indicates that +the email verification was successful, yet, the user is still not signed +in. For example, in case `ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION` is set to +`False`, a 401 is returned when verifying as part of login/signup. + + * @summary Verify an email + */ +export type allauthAppV1AuthEmailVerifyPostResponse200 = { + data: AuthenticatedResponse + status: 200 +} + +export type allauthAppV1AuthEmailVerifyPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthEmailVerifyPostResponse401 = { + data: UnauthenticatedResponse + status: 401 +} + +export type allauthAppV1AuthEmailVerifyPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthEmailVerifyPostResponseComposite = allauthAppV1AuthEmailVerifyPostResponse200 | allauthAppV1AuthEmailVerifyPostResponse400 | allauthAppV1AuthEmailVerifyPostResponse401 | allauthAppV1AuthEmailVerifyPostResponse409; + +export type allauthAppV1AuthEmailVerifyPostResponse = allauthAppV1AuthEmailVerifyPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthEmailVerifyPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/email/verify` +} + +export const allauthAppV1AuthEmailVerifyPost = async (verifyEmailBody: VerifyEmailBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthEmailVerifyPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + verifyEmailBody,) + } +);} + + + + +export const getAllauthAppV1AuthEmailVerifyPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthEmailVerifyPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: VerifyEmailBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthEmailVerifyPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthEmailVerifyPostMutationResult = NonNullable>> + export type AllauthAppV1AuthEmailVerifyPostMutationBody = VerifyEmailBody + export type AllauthAppV1AuthEmailVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse + + /** + * @summary Verify an email + */ +export const useAllauthAppV1AuthEmailVerifyPost = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthEmailVerifyPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Requests a new email verification code. +Requires `ACCOUNT_EMAIL_VERIFICATION_SUPPORTS_RESEND = True`. + + * @summary Resend email verification code + */ +export type allauthBrowserV1AuthEmailVerifyResendPostResponse200 = { + data: StatusOKResponse + status: 200 +} + +export type allauthBrowserV1AuthEmailVerifyResendPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthEmailVerifyResendPostResponse429 = { + data: TooManyRequestsResponse + status: 429 +} + +export type allauthBrowserV1AuthEmailVerifyResendPostResponseComposite = allauthBrowserV1AuthEmailVerifyResendPostResponse200 | allauthBrowserV1AuthEmailVerifyResendPostResponse409 | allauthBrowserV1AuthEmailVerifyResendPostResponse429; + +export type allauthBrowserV1AuthEmailVerifyResendPostResponse = allauthBrowserV1AuthEmailVerifyResendPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthEmailVerifyResendPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/email/verify/resend` +} + +export const allauthBrowserV1AuthEmailVerifyResendPost = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthEmailVerifyResendPostUrl(), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getAllauthBrowserV1AuthEmailVerifyResendPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthEmailVerifyResendPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return allauthBrowserV1AuthEmailVerifyResendPost(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthEmailVerifyResendPostMutationResult = NonNullable>> + + export type AllauthBrowserV1AuthEmailVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse + + /** + * @summary Resend email verification code + */ +export const useAllauthBrowserV1AuthEmailVerifyResendPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthEmailVerifyResendPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Requests a new email verification code. +Requires `ACCOUNT_EMAIL_VERIFICATION_SUPPORTS_RESEND = True`. + + * @summary Resend email verification code + */ +export type allauthAppV1AuthEmailVerifyResendPostResponse200 = { + data: StatusOKResponse + status: 200 +} + +export type allauthAppV1AuthEmailVerifyResendPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthEmailVerifyResendPostResponse429 = { + data: TooManyRequestsResponse + status: 429 +} + +export type allauthAppV1AuthEmailVerifyResendPostResponseComposite = allauthAppV1AuthEmailVerifyResendPostResponse200 | allauthAppV1AuthEmailVerifyResendPostResponse409 | allauthAppV1AuthEmailVerifyResendPostResponse429; + +export type allauthAppV1AuthEmailVerifyResendPostResponse = allauthAppV1AuthEmailVerifyResendPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthEmailVerifyResendPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/email/verify/resend` +} + +export const allauthAppV1AuthEmailVerifyResendPost = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthEmailVerifyResendPostUrl(), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getAllauthAppV1AuthEmailVerifyResendPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['allauthAppV1AuthEmailVerifyResendPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return allauthAppV1AuthEmailVerifyResendPost(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthEmailVerifyResendPostMutationResult = NonNullable>> + + export type AllauthAppV1AuthEmailVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse + + /** + * @summary Resend email verification code + */ +export const useAllauthAppV1AuthEmailVerifyResendPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthEmailVerifyResendPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Complete the phone number verification process. Note that a status code +of 401 does not imply failure. It merely indicates that the phone number +verification was successful, yet, the user is still not signed in. + + * @summary Verify a phone number + */ +export type allauthBrowserV1AuthPhoneVerifyPostResponse200 = { + data: AuthenticatedResponse + status: 200 +} + +export type allauthBrowserV1AuthPhoneVerifyPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthPhoneVerifyPostResponse401 = { + data: UnauthenticatedResponse + status: 401 +} + +export type allauthBrowserV1AuthPhoneVerifyPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthPhoneVerifyPostResponseComposite = allauthBrowserV1AuthPhoneVerifyPostResponse200 | allauthBrowserV1AuthPhoneVerifyPostResponse400 | allauthBrowserV1AuthPhoneVerifyPostResponse401 | allauthBrowserV1AuthPhoneVerifyPostResponse409; + +export type allauthBrowserV1AuthPhoneVerifyPostResponse = allauthBrowserV1AuthPhoneVerifyPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthPhoneVerifyPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/phone/verify` +} + +export const allauthBrowserV1AuthPhoneVerifyPost = async (verifyPhoneBody: VerifyPhoneBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthPhoneVerifyPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + verifyPhoneBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthPhoneVerifyPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthPhoneVerifyPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: VerifyPhoneBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthPhoneVerifyPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthPhoneVerifyPostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthPhoneVerifyPostMutationBody = VerifyPhoneBody + export type AllauthBrowserV1AuthPhoneVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse + + /** + * @summary Verify a phone number + */ +export const useAllauthBrowserV1AuthPhoneVerifyPost = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthPhoneVerifyPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Complete the phone number verification process. Note that a status code +of 401 does not imply failure. It merely indicates that the phone number +verification was successful, yet, the user is still not signed in. + + * @summary Verify a phone number + */ +export type allauthAppV1AuthPhoneVerifyPostResponse200 = { + data: AuthenticatedResponse + status: 200 +} + +export type allauthAppV1AuthPhoneVerifyPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthPhoneVerifyPostResponse401 = { + data: UnauthenticatedResponse + status: 401 +} + +export type allauthAppV1AuthPhoneVerifyPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthPhoneVerifyPostResponseComposite = allauthAppV1AuthPhoneVerifyPostResponse200 | allauthAppV1AuthPhoneVerifyPostResponse400 | allauthAppV1AuthPhoneVerifyPostResponse401 | allauthAppV1AuthPhoneVerifyPostResponse409; + +export type allauthAppV1AuthPhoneVerifyPostResponse = allauthAppV1AuthPhoneVerifyPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthPhoneVerifyPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/phone/verify` +} + +export const allauthAppV1AuthPhoneVerifyPost = async (verifyPhoneBody: VerifyPhoneBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthPhoneVerifyPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + verifyPhoneBody,) + } +);} + + + + +export const getAllauthAppV1AuthPhoneVerifyPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthPhoneVerifyPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: VerifyPhoneBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthPhoneVerifyPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthPhoneVerifyPostMutationResult = NonNullable>> + export type AllauthAppV1AuthPhoneVerifyPostMutationBody = VerifyPhoneBody + export type AllauthAppV1AuthPhoneVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse + + /** + * @summary Verify a phone number + */ +export const useAllauthAppV1AuthPhoneVerifyPost = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthPhoneVerifyPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Requests a new phone number verification code. +Requires `ACCOUNT_PHONE_VERIFICATION_SUPPORTS_RESEND = True`. + + * @summary Resend phone number verification code + */ +export type allauthBrowserV1AuthPhoneVerifyResendPostResponse200 = { + data: StatusOKResponse + status: 200 +} + +export type allauthBrowserV1AuthPhoneVerifyResendPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthPhoneVerifyResendPostResponse429 = { + data: TooManyRequestsResponse + status: 429 +} + +export type allauthBrowserV1AuthPhoneVerifyResendPostResponseComposite = allauthBrowserV1AuthPhoneVerifyResendPostResponse200 | allauthBrowserV1AuthPhoneVerifyResendPostResponse409 | allauthBrowserV1AuthPhoneVerifyResendPostResponse429; + +export type allauthBrowserV1AuthPhoneVerifyResendPostResponse = allauthBrowserV1AuthPhoneVerifyResendPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthPhoneVerifyResendPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/phone/verify/resend` +} + +export const allauthBrowserV1AuthPhoneVerifyResendPost = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthPhoneVerifyResendPostUrl(), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getAllauthBrowserV1AuthPhoneVerifyResendPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthPhoneVerifyResendPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return allauthBrowserV1AuthPhoneVerifyResendPost(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthPhoneVerifyResendPostMutationResult = NonNullable>> + + export type AllauthBrowserV1AuthPhoneVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse + + /** + * @summary Resend phone number verification code + */ +export const useAllauthBrowserV1AuthPhoneVerifyResendPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthPhoneVerifyResendPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Requests a new phone number verification code. +Requires `ACCOUNT_PHONE_VERIFICATION_SUPPORTS_RESEND = True`. + + * @summary Resend phone number verification code + */ +export type allauthAppV1AuthPhoneVerifyResendPostResponse200 = { + data: StatusOKResponse + status: 200 +} + +export type allauthAppV1AuthPhoneVerifyResendPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthPhoneVerifyResendPostResponse429 = { + data: TooManyRequestsResponse + status: 429 +} + +export type allauthAppV1AuthPhoneVerifyResendPostResponseComposite = allauthAppV1AuthPhoneVerifyResendPostResponse200 | allauthAppV1AuthPhoneVerifyResendPostResponse409 | allauthAppV1AuthPhoneVerifyResendPostResponse429; + +export type allauthAppV1AuthPhoneVerifyResendPostResponse = allauthAppV1AuthPhoneVerifyResendPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthPhoneVerifyResendPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/phone/verify/resend` +} + +export const allauthAppV1AuthPhoneVerifyResendPost = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthPhoneVerifyResendPostUrl(), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getAllauthAppV1AuthPhoneVerifyResendPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['allauthAppV1AuthPhoneVerifyResendPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return allauthAppV1AuthPhoneVerifyResendPost(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthPhoneVerifyResendPostMutationResult = NonNullable>> + + export type AllauthAppV1AuthPhoneVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse + + /** + * @summary Resend phone number verification code + */ +export const useAllauthAppV1AuthPhoneVerifyResendPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthPhoneVerifyResendPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * In order to safeguard the account, some actions require the user to be +recently authenticated. If you try to perform such an action without +having been recently authenticated, a `401` status is returned, listing +flows that can be performed to reauthenticate. One such flow is the flow +with ID `reauthenticate`, which allows for the user to input the +password. This is the endpoint related towards that flow. + + * @summary Reauthenticate + */ +export type allauthBrowserV1AuthReauthenticatePostResponse200 = { + data: AuthenticatedByPasswordResponse + status: 200 +} + +export type allauthBrowserV1AuthReauthenticatePostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthReauthenticatePostResponseComposite = allauthBrowserV1AuthReauthenticatePostResponse200 | allauthBrowserV1AuthReauthenticatePostResponse400; + +export type allauthBrowserV1AuthReauthenticatePostResponse = allauthBrowserV1AuthReauthenticatePostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthReauthenticatePostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/reauthenticate` +} + +export const allauthBrowserV1AuthReauthenticatePost = async (reauthenticateBody: ReauthenticateBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthReauthenticatePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + reauthenticateBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthReauthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthReauthenticatePost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ReauthenticateBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthReauthenticatePost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthReauthenticatePostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthReauthenticatePostMutationBody = ReauthenticateBody + export type AllauthBrowserV1AuthReauthenticatePostMutationError = ErrorResponse + + /** + * @summary Reauthenticate + */ +export const useAllauthBrowserV1AuthReauthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthReauthenticatePostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * In order to safeguard the account, some actions require the user to be +recently authenticated. If you try to perform such an action without +having been recently authenticated, a `401` status is returned, listing +flows that can be performed to reauthenticate. One such flow is the flow +with ID `reauthenticate`, which allows for the user to input the +password. This is the endpoint related towards that flow. + + * @summary Reauthenticate + */ +export type allauthAppV1AuthReauthenticatePostResponse200 = { + data: AuthenticatedByPasswordResponse + status: 200 +} + +export type allauthAppV1AuthReauthenticatePostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthReauthenticatePostResponseComposite = allauthAppV1AuthReauthenticatePostResponse200 | allauthAppV1AuthReauthenticatePostResponse400; + +export type allauthAppV1AuthReauthenticatePostResponse = allauthAppV1AuthReauthenticatePostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthReauthenticatePostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/reauthenticate` +} + +export const allauthAppV1AuthReauthenticatePost = async (reauthenticateBody: ReauthenticateBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthReauthenticatePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + reauthenticateBody,) + } +);} + + + + +export const getAllauthAppV1AuthReauthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthReauthenticatePost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ReauthenticateBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthReauthenticatePost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthReauthenticatePostMutationResult = NonNullable>> + export type AllauthAppV1AuthReauthenticatePostMutationBody = ReauthenticateBody + export type AllauthAppV1AuthReauthenticatePostMutationError = ErrorResponse + + /** + * @summary Reauthenticate + */ +export const useAllauthAppV1AuthReauthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthReauthenticatePostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Initiates the password reset procedure. Depending on whether or not +`ACCOUNT_PASSWORD_RESET_BY_CODE_ENABLED` is `True`, the procedure is +either stateless or stateful. + +In case codes are used, it is stateful, and a new +`password_reset_by_code` flow is started. In this case, on a successful +password reset request, you will receive a 401 indicating the pending +status of this flow. + +In case password reset is configured to use (stateless) links, you will +receive a 200 on a successful password reset request. + + * @summary Request password + */ +export type allauthBrowserV1AuthPasswordRequestPostResponse200 = { + data: StatusOKResponse + status: 200 +} + +export type allauthBrowserV1AuthPasswordRequestPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthPasswordRequestPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AuthPasswordRequestPostResponseComposite = allauthBrowserV1AuthPasswordRequestPostResponse200 | allauthBrowserV1AuthPasswordRequestPostResponse400 | allauthBrowserV1AuthPasswordRequestPostResponse401; + +export type allauthBrowserV1AuthPasswordRequestPostResponse = allauthBrowserV1AuthPasswordRequestPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthPasswordRequestPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/password/request` +} + +export const allauthBrowserV1AuthPasswordRequestPost = async (requestPasswordBody: RequestPasswordBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthPasswordRequestPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + requestPasswordBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthPasswordRequestPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthPasswordRequestPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: RequestPasswordBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthPasswordRequestPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthPasswordRequestPostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthPasswordRequestPostMutationBody = RequestPasswordBody + export type AllauthBrowserV1AuthPasswordRequestPostMutationError = ErrorResponse | AuthenticationResponse + + /** + * @summary Request password + */ +export const useAllauthBrowserV1AuthPasswordRequestPost = (options?: { mutation?:UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthPasswordRequestPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Initiates the password reset procedure. Depending on whether or not +`ACCOUNT_PASSWORD_RESET_BY_CODE_ENABLED` is `True`, the procedure is +either stateless or stateful. + +In case codes are used, it is stateful, and a new +`password_reset_by_code` flow is started. In this case, on a successful +password reset request, you will receive a 401 indicating the pending +status of this flow. + +In case password reset is configured to use (stateless) links, you will +receive a 200 on a successful password reset request. + + * @summary Request password + */ +export type allauthAppV1AuthPasswordRequestPostResponse200 = { + data: StatusOKResponse + status: 200 +} + +export type allauthAppV1AuthPasswordRequestPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthPasswordRequestPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AuthPasswordRequestPostResponseComposite = allauthAppV1AuthPasswordRequestPostResponse200 | allauthAppV1AuthPasswordRequestPostResponse400 | allauthAppV1AuthPasswordRequestPostResponse401; + +export type allauthAppV1AuthPasswordRequestPostResponse = allauthAppV1AuthPasswordRequestPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthPasswordRequestPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/password/request` +} + +export const allauthAppV1AuthPasswordRequestPost = async (requestPasswordBody: RequestPasswordBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthPasswordRequestPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + requestPasswordBody,) + } +);} + + + + +export const getAllauthAppV1AuthPasswordRequestPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthPasswordRequestPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: RequestPasswordBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthPasswordRequestPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthPasswordRequestPostMutationResult = NonNullable>> + export type AllauthAppV1AuthPasswordRequestPostMutationBody = RequestPasswordBody + export type AllauthAppV1AuthPasswordRequestPostMutationError = ErrorResponse | AuthenticationResponse + + /** + * @summary Request password + */ +export const useAllauthAppV1AuthPasswordRequestPost = (options?: { mutation?:UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthPasswordRequestPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Used to obtain information on and validate a password reset key. The +key passed is either the key encoded in the password reset URL that the +user has received per email, or, the password reset code in case of +`ACCOUNT_PASSWORD_RESET_BY_CODE_ENABLED`. Note that in case of a code, +the number of requests you can make is limited (by +`ACCOUNT_PASSWORD_RESET_BY_CODE_MAX_ATTEMPTS`). + + * @summary Get password reset information + */ +export type allauthBrowserV1AuthPasswordResetGetResponse200 = { + data: PasswordResetInfoResponse + status: 200 +} + +export type allauthBrowserV1AuthPasswordResetGetResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthPasswordResetGetResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthPasswordResetGetResponseComposite = allauthBrowserV1AuthPasswordResetGetResponse200 | allauthBrowserV1AuthPasswordResetGetResponse400 | allauthBrowserV1AuthPasswordResetGetResponse409; + +export type allauthBrowserV1AuthPasswordResetGetResponse = allauthBrowserV1AuthPasswordResetGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthPasswordResetGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/password/reset` +} + +export const allauthBrowserV1AuthPasswordResetGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthPasswordResetGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AuthPasswordResetGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','auth','password','reset'] as const; + } + + +export const getAllauthBrowserV1AuthPasswordResetGetQueryOptions = >, TError = ErrorResponse | ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthPasswordResetGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AuthPasswordResetGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AuthPasswordResetGetQueryResult = NonNullable>> +export type AllauthBrowserV1AuthPasswordResetGetQueryError = ErrorResponse | ConflictResponse + + +/** + * @summary Get password reset information + */ + +export function useAllauthBrowserV1AuthPasswordResetGet>, TError = ErrorResponse | ConflictResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AuthPasswordResetGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Perform the password reset, by handing over the password reset key and +the new password. After successfully completing the password reset, the +user is either logged in (in case `ACCOUNT_LOGIN_ON_PASSWORD_RESET` is +`True`), or, the user will need to proceed to the login page. In case +of the former, a `200` status code is returned, in case of the latter a +401. + + * @summary Reset password + */ +export type allauthBrowserV1AuthPasswordResetPostResponse200 = { + data: AuthenticatedByPasswordResponse + status: 200 +} + +export type allauthBrowserV1AuthPasswordResetPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthPasswordResetPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AuthPasswordResetPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthPasswordResetPostResponseComposite = allauthBrowserV1AuthPasswordResetPostResponse200 | allauthBrowserV1AuthPasswordResetPostResponse400 | allauthBrowserV1AuthPasswordResetPostResponse401 | allauthBrowserV1AuthPasswordResetPostResponse409; + +export type allauthBrowserV1AuthPasswordResetPostResponse = allauthBrowserV1AuthPasswordResetPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthPasswordResetPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/password/reset` +} + +export const allauthBrowserV1AuthPasswordResetPost = async (resetPasswordBody: ResetPasswordBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthPasswordResetPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + resetPasswordBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthPasswordResetPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthPasswordResetPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ResetPasswordBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthPasswordResetPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthPasswordResetPostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthPasswordResetPostMutationBody = ResetPasswordBody + export type AllauthBrowserV1AuthPasswordResetPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse + + /** + * @summary Reset password + */ +export const useAllauthBrowserV1AuthPasswordResetPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthPasswordResetPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Used to obtain information on and validate a password reset key. The +key passed is either the key encoded in the password reset URL that the +user has received per email, or, the password reset code in case of +`ACCOUNT_PASSWORD_RESET_BY_CODE_ENABLED`. Note that in case of a code, +the number of requests you can make is limited (by +`ACCOUNT_PASSWORD_RESET_BY_CODE_MAX_ATTEMPTS`). + + * @summary Get password reset information + */ +export type allauthAppV1AuthPasswordResetGetResponse200 = { + data: PasswordResetInfoResponse + status: 200 +} + +export type allauthAppV1AuthPasswordResetGetResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthPasswordResetGetResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthPasswordResetGetResponseComposite = allauthAppV1AuthPasswordResetGetResponse200 | allauthAppV1AuthPasswordResetGetResponse400 | allauthAppV1AuthPasswordResetGetResponse409; + +export type allauthAppV1AuthPasswordResetGetResponse = allauthAppV1AuthPasswordResetGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthPasswordResetGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/password/reset` +} + +export const allauthAppV1AuthPasswordResetGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthPasswordResetGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AuthPasswordResetGetQueryKey = () => { + return ['api','v2','allauth','app','v1','auth','password','reset'] as const; + } + + +export const getAllauthAppV1AuthPasswordResetGetQueryOptions = >, TError = ErrorResponse | ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthPasswordResetGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AuthPasswordResetGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AuthPasswordResetGetQueryResult = NonNullable>> +export type AllauthAppV1AuthPasswordResetGetQueryError = ErrorResponse | ConflictResponse + + +/** + * @summary Get password reset information + */ + +export function useAllauthAppV1AuthPasswordResetGet>, TError = ErrorResponse | ConflictResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AuthPasswordResetGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Perform the password reset, by handing over the password reset key and +the new password. After successfully completing the password reset, the +user is either logged in (in case `ACCOUNT_LOGIN_ON_PASSWORD_RESET` is +`True`), or, the user will need to proceed to the login page. In case +of the former, a `200` status code is returned, in case of the latter a +401. + + * @summary Reset password + */ +export type allauthAppV1AuthPasswordResetPostResponse200 = { + data: AuthenticatedByPasswordResponse + status: 200 +} + +export type allauthAppV1AuthPasswordResetPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthPasswordResetPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AuthPasswordResetPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthPasswordResetPostResponseComposite = allauthAppV1AuthPasswordResetPostResponse200 | allauthAppV1AuthPasswordResetPostResponse400 | allauthAppV1AuthPasswordResetPostResponse401 | allauthAppV1AuthPasswordResetPostResponse409; + +export type allauthAppV1AuthPasswordResetPostResponse = allauthAppV1AuthPasswordResetPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthPasswordResetPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/password/reset` +} + +export const allauthAppV1AuthPasswordResetPost = async (resetPasswordBody: ResetPasswordBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthPasswordResetPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + resetPasswordBody,) + } +);} + + + + +export const getAllauthAppV1AuthPasswordResetPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthPasswordResetPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ResetPasswordBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthPasswordResetPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthPasswordResetPostMutationResult = NonNullable>> + export type AllauthAppV1AuthPasswordResetPostMutationBody = ResetPasswordBody + export type AllauthAppV1AuthPasswordResetPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse + + /** + * @summary Reset password + */ +export const useAllauthAppV1AuthPasswordResetPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthPasswordResetPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Initiates the third-party provider authentication redirect flow. As calling +this endpoint results in a user facing redirect (302), this call is only +available in a browser, and must be called in a synchronous (non-XHR) +manner. + + * @summary Provider redirect + */ +export type allauthBrowserV1AuthProviderRedirectPostResponse302 = { + data: void + status: 302 +} + +export type allauthBrowserV1AuthProviderRedirectPostResponseComposite = allauthBrowserV1AuthProviderRedirectPostResponse302; + +export type allauthBrowserV1AuthProviderRedirectPostResponse = allauthBrowserV1AuthProviderRedirectPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthProviderRedirectPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/provider/redirect` +} + +export const allauthBrowserV1AuthProviderRedirectPost = async (providerRedirectBody: ProviderRedirectBody, options?: RequestInit): Promise => { + const formUrlEncoded = new URLSearchParams(); +formUrlEncoded.append(`provider`, providerRedirectBody.provider) +formUrlEncoded.append(`callback_url`, providerRedirectBody.callback_url) +formUrlEncoded.append(`process`, providerRedirectBody.process) + + return fetchWithAuth(getAllauthBrowserV1AuthProviderRedirectPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded', ...options?.headers }, + body: + formUrlEncoded, + } +);} + + + + +export const getAllauthBrowserV1AuthProviderRedirectPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderRedirectBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ProviderRedirectBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthProviderRedirectPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ProviderRedirectBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthProviderRedirectPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthProviderRedirectPostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthProviderRedirectPostMutationBody = ProviderRedirectBody + export type AllauthBrowserV1AuthProviderRedirectPostMutationError = void + + /** + * @summary Provider redirect + */ +export const useAllauthBrowserV1AuthProviderRedirectPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderRedirectBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthProviderRedirectPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Authenticates with a third-party provider using provider tokens received +by other means. For example, in case of a mobile app, the authentication +flow runs completely on the device itself, without any interaction with +the API. Then, when the (device) authentication completes and the mobile +app receives an access and/or ID token, it can hand over these tokens +via this endpoint to authenticate on the server. + + * @summary Provider token + */ +export type allauthBrowserV1AuthProviderTokenPostResponse200 = { + data: AuthenticatedResponse + status: 200 +} + +export type allauthBrowserV1AuthProviderTokenPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthProviderTokenPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AuthProviderTokenPostResponse403 = { + data: ForbiddenResponse + status: 403 +} + +export type allauthBrowserV1AuthProviderTokenPostResponseComposite = allauthBrowserV1AuthProviderTokenPostResponse200 | allauthBrowserV1AuthProviderTokenPostResponse400 | allauthBrowserV1AuthProviderTokenPostResponse401 | allauthBrowserV1AuthProviderTokenPostResponse403; + +export type allauthBrowserV1AuthProviderTokenPostResponse = allauthBrowserV1AuthProviderTokenPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthProviderTokenPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/provider/token` +} + +export const allauthBrowserV1AuthProviderTokenPost = async (providerTokenBody: ProviderTokenBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthProviderTokenPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + providerTokenBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthProviderTokenPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthProviderTokenPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ProviderTokenBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthProviderTokenPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthProviderTokenPostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthProviderTokenPostMutationBody = ProviderTokenBody + export type AllauthBrowserV1AuthProviderTokenPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse + + /** + * @summary Provider token + */ +export const useAllauthBrowserV1AuthProviderTokenPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthProviderTokenPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Authenticates with a third-party provider using provider tokens received +by other means. For example, in case of a mobile app, the authentication +flow runs completely on the device itself, without any interaction with +the API. Then, when the (device) authentication completes and the mobile +app receives an access and/or ID token, it can hand over these tokens +via this endpoint to authenticate on the server. + + * @summary Provider token + */ +export type allauthAppV1AuthProviderTokenPostResponse200 = { + data: AuthenticatedResponse + status: 200 +} + +export type allauthAppV1AuthProviderTokenPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthProviderTokenPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AuthProviderTokenPostResponse403 = { + data: ForbiddenResponse + status: 403 +} + +export type allauthAppV1AuthProviderTokenPostResponseComposite = allauthAppV1AuthProviderTokenPostResponse200 | allauthAppV1AuthProviderTokenPostResponse400 | allauthAppV1AuthProviderTokenPostResponse401 | allauthAppV1AuthProviderTokenPostResponse403; + +export type allauthAppV1AuthProviderTokenPostResponse = allauthAppV1AuthProviderTokenPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthProviderTokenPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/provider/token` +} + +export const allauthAppV1AuthProviderTokenPost = async (providerTokenBody: ProviderTokenBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthProviderTokenPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + providerTokenBody,) + } +);} + + + + +export const getAllauthAppV1AuthProviderTokenPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthProviderTokenPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ProviderTokenBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthProviderTokenPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthProviderTokenPostMutationResult = NonNullable>> + export type AllauthAppV1AuthProviderTokenPostMutationBody = ProviderTokenBody + export type AllauthAppV1AuthProviderTokenPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse + + /** + * @summary Provider token + */ +export const useAllauthAppV1AuthProviderTokenPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthProviderTokenPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * If, while signing up using a third-party provider account, there is +insufficient information received from the provider to automatically +complete the signup process, an additional step is needed to complete +the missing data before the user is fully signed up and authenticated. +The information available so far, such as the pending provider account, +can be retrieved via this endpoint. + + * @summary Provider signup information + */ +export type allauthBrowserV1AuthProviderSignupGetResponse200 = { + data: ProviderSignupResponse + status: 200 +} + +export type allauthBrowserV1AuthProviderSignupGetResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthProviderSignupGetResponseComposite = allauthBrowserV1AuthProviderSignupGetResponse200 | allauthBrowserV1AuthProviderSignupGetResponse409; + +export type allauthBrowserV1AuthProviderSignupGetResponse = allauthBrowserV1AuthProviderSignupGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthProviderSignupGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/provider/signup` +} + +export const allauthBrowserV1AuthProviderSignupGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthProviderSignupGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AuthProviderSignupGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','auth','provider','signup'] as const; + } + + +export const getAllauthBrowserV1AuthProviderSignupGetQueryOptions = >, TError = ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthProviderSignupGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AuthProviderSignupGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AuthProviderSignupGetQueryResult = NonNullable>> +export type AllauthBrowserV1AuthProviderSignupGetQueryError = ConflictResponse + + +/** + * @summary Provider signup information + */ + +export function useAllauthBrowserV1AuthProviderSignupGet>, TError = ConflictResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AuthProviderSignupGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * If, while signing up using a third-party provider account, there is +insufficient information received from the provider to automatically +complete the signup process, an additional step is needed to complete +the missing data before the user is fully signed up and authenticated. + + * @summary Provider signup + */ +export type allauthBrowserV1AuthProviderSignupPostResponse200 = { + data: AuthenticatedResponse + status: 200 +} + +export type allauthBrowserV1AuthProviderSignupPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthProviderSignupPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AuthProviderSignupPostResponse403 = { + data: ForbiddenResponse + status: 403 +} + +export type allauthBrowserV1AuthProviderSignupPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthProviderSignupPostResponseComposite = allauthBrowserV1AuthProviderSignupPostResponse200 | allauthBrowserV1AuthProviderSignupPostResponse400 | allauthBrowserV1AuthProviderSignupPostResponse401 | allauthBrowserV1AuthProviderSignupPostResponse403 | allauthBrowserV1AuthProviderSignupPostResponse409; + +export type allauthBrowserV1AuthProviderSignupPostResponse = allauthBrowserV1AuthProviderSignupPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthProviderSignupPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/provider/signup` +} + +export const allauthBrowserV1AuthProviderSignupPost = async (providerSignupBody: ProviderSignupBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthProviderSignupPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + providerSignupBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthProviderSignupPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthProviderSignupPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ProviderSignupBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthProviderSignupPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthProviderSignupPostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthProviderSignupPostMutationBody = ProviderSignupBody + export type AllauthBrowserV1AuthProviderSignupPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse + + /** + * @summary Provider signup + */ +export const useAllauthBrowserV1AuthProviderSignupPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthProviderSignupPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * If, while signing up using a third-party provider account, there is +insufficient information received from the provider to automatically +complete the signup process, an additional step is needed to complete +the missing data before the user is fully signed up and authenticated. +The information available so far, such as the pending provider account, +can be retrieved via this endpoint. + + * @summary Provider signup information + */ +export type allauthAppV1AuthProviderSignupGetResponse200 = { + data: ProviderSignupResponse + status: 200 +} + +export type allauthAppV1AuthProviderSignupGetResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthProviderSignupGetResponseComposite = allauthAppV1AuthProviderSignupGetResponse200 | allauthAppV1AuthProviderSignupGetResponse409; + +export type allauthAppV1AuthProviderSignupGetResponse = allauthAppV1AuthProviderSignupGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthProviderSignupGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/provider/signup` +} + +export const allauthAppV1AuthProviderSignupGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthProviderSignupGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AuthProviderSignupGetQueryKey = () => { + return ['api','v2','allauth','app','v1','auth','provider','signup'] as const; + } + + +export const getAllauthAppV1AuthProviderSignupGetQueryOptions = >, TError = ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthProviderSignupGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AuthProviderSignupGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AuthProviderSignupGetQueryResult = NonNullable>> +export type AllauthAppV1AuthProviderSignupGetQueryError = ConflictResponse + + +/** + * @summary Provider signup information + */ + +export function useAllauthAppV1AuthProviderSignupGet>, TError = ConflictResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AuthProviderSignupGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * If, while signing up using a third-party provider account, there is +insufficient information received from the provider to automatically +complete the signup process, an additional step is needed to complete +the missing data before the user is fully signed up and authenticated. + + * @summary Provider signup + */ +export type allauthAppV1AuthProviderSignupPostResponse200 = { + data: AuthenticatedResponse + status: 200 +} + +export type allauthAppV1AuthProviderSignupPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthProviderSignupPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AuthProviderSignupPostResponse403 = { + data: ForbiddenResponse + status: 403 +} + +export type allauthAppV1AuthProviderSignupPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthProviderSignupPostResponseComposite = allauthAppV1AuthProviderSignupPostResponse200 | allauthAppV1AuthProviderSignupPostResponse400 | allauthAppV1AuthProviderSignupPostResponse401 | allauthAppV1AuthProviderSignupPostResponse403 | allauthAppV1AuthProviderSignupPostResponse409; + +export type allauthAppV1AuthProviderSignupPostResponse = allauthAppV1AuthProviderSignupPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthProviderSignupPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/provider/signup` +} + +export const allauthAppV1AuthProviderSignupPost = async (providerSignupBody: ProviderSignupBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthProviderSignupPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + providerSignupBody,) + } +);} + + + + +export const getAllauthAppV1AuthProviderSignupPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthProviderSignupPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ProviderSignupBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthProviderSignupPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthProviderSignupPostMutationResult = NonNullable>> + export type AllauthAppV1AuthProviderSignupPostMutationBody = ProviderSignupBody + export type AllauthAppV1AuthProviderSignupPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse + + /** + * @summary Provider signup + */ +export const useAllauthAppV1AuthProviderSignupPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthProviderSignupPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * If, during authentication, a response with status 401 is encountered where one of the pending +flows has ID `mfa_authenticate`, that indicates that the Two-Factor Authentication stage needs to +be completed. + + * @summary Two-factor authentication + */ +export type allauthBrowserV1Auth2faAuthenticatePostResponse200 = { + data: AuthenticatedByPasswordAnd2FAResponse + status: 200 +} + +export type allauthBrowserV1Auth2faAuthenticatePostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1Auth2faAuthenticatePostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1Auth2faAuthenticatePostResponseComposite = allauthBrowserV1Auth2faAuthenticatePostResponse200 | allauthBrowserV1Auth2faAuthenticatePostResponse400 | allauthBrowserV1Auth2faAuthenticatePostResponse401; + +export type allauthBrowserV1Auth2faAuthenticatePostResponse = allauthBrowserV1Auth2faAuthenticatePostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1Auth2faAuthenticatePostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/2fa/authenticate` +} + +export const allauthBrowserV1Auth2faAuthenticatePost = async (mFAAuthenticateBody: MFAAuthenticateBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1Auth2faAuthenticatePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + mFAAuthenticateBody,) + } +);} + + + + +export const getAllauthBrowserV1Auth2faAuthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1Auth2faAuthenticatePost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: MFAAuthenticateBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1Auth2faAuthenticatePost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1Auth2faAuthenticatePostMutationResult = NonNullable>> + export type AllauthBrowserV1Auth2faAuthenticatePostMutationBody = MFAAuthenticateBody + export type AllauthBrowserV1Auth2faAuthenticatePostMutationError = ErrorResponse | AuthenticationResponse + + /** + * @summary Two-factor authentication + */ +export const useAllauthBrowserV1Auth2faAuthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1Auth2faAuthenticatePostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * If, during authentication, a response with status 401 is encountered where one of the pending +flows has ID `mfa_authenticate`, that indicates that the Two-Factor Authentication stage needs to +be completed. + + * @summary Two-factor authentication + */ +export type allauthAppV1Auth2faAuthenticatePostResponse200 = { + data: AuthenticatedByPasswordAnd2FAResponse + status: 200 +} + +export type allauthAppV1Auth2faAuthenticatePostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1Auth2faAuthenticatePostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1Auth2faAuthenticatePostResponseComposite = allauthAppV1Auth2faAuthenticatePostResponse200 | allauthAppV1Auth2faAuthenticatePostResponse400 | allauthAppV1Auth2faAuthenticatePostResponse401; + +export type allauthAppV1Auth2faAuthenticatePostResponse = allauthAppV1Auth2faAuthenticatePostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1Auth2faAuthenticatePostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/2fa/authenticate` +} + +export const allauthAppV1Auth2faAuthenticatePost = async (mFAAuthenticateBody: MFAAuthenticateBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1Auth2faAuthenticatePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + mFAAuthenticateBody,) + } +);} + + + + +export const getAllauthAppV1Auth2faAuthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext> => { + +const mutationKey = ['allauthAppV1Auth2faAuthenticatePost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: MFAAuthenticateBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1Auth2faAuthenticatePost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1Auth2faAuthenticatePostMutationResult = NonNullable>> + export type AllauthAppV1Auth2faAuthenticatePostMutationBody = MFAAuthenticateBody + export type AllauthAppV1Auth2faAuthenticatePostMutationError = ErrorResponse | AuthenticationResponse + + /** + * @summary Two-factor authentication + */ +export const useAllauthAppV1Auth2faAuthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1Auth2faAuthenticatePostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * In order to safeguard the account, some actions require the user to be +recently authenticated. If you try to perform such an action without +having been recently authenticated, a `401` status is returned, listing +flows that can be performed to reauthenticate. One such flow is the flow +with ID `mfa_reauthenticate`, which allows for the user to input an +authenticator code (e.g. TOTP or recovery code). This is the endpoint +related towards that flow. + + * @summary Reauthenticate using 2FA + */ +export type allauthBrowserV1Auth2faReauthenticatePostResponse200 = { + data: AuthenticatedByPasswordAnd2FAResponse + status: 200 +} + +export type allauthBrowserV1Auth2faReauthenticatePostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1Auth2faReauthenticatePostResponseComposite = allauthBrowserV1Auth2faReauthenticatePostResponse200 | allauthBrowserV1Auth2faReauthenticatePostResponse400; + +export type allauthBrowserV1Auth2faReauthenticatePostResponse = allauthBrowserV1Auth2faReauthenticatePostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1Auth2faReauthenticatePostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/2fa/reauthenticate` +} + +export const allauthBrowserV1Auth2faReauthenticatePost = async (mFAAuthenticateBody: MFAAuthenticateBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1Auth2faReauthenticatePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + mFAAuthenticateBody,) + } +);} + + + + +export const getAllauthBrowserV1Auth2faReauthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1Auth2faReauthenticatePost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: MFAAuthenticateBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1Auth2faReauthenticatePost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1Auth2faReauthenticatePostMutationResult = NonNullable>> + export type AllauthBrowserV1Auth2faReauthenticatePostMutationBody = MFAAuthenticateBody + export type AllauthBrowserV1Auth2faReauthenticatePostMutationError = ErrorResponse + + /** + * @summary Reauthenticate using 2FA + */ +export const useAllauthBrowserV1Auth2faReauthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1Auth2faReauthenticatePostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * In order to safeguard the account, some actions require the user to be +recently authenticated. If you try to perform such an action without +having been recently authenticated, a `401` status is returned, listing +flows that can be performed to reauthenticate. One such flow is the flow +with ID `mfa_reauthenticate`, which allows for the user to input an +authenticator code (e.g. TOTP or recovery code). This is the endpoint +related towards that flow. + + * @summary Reauthenticate using 2FA + */ +export type allauthAppV1Auth2faReauthenticatePostResponse200 = { + data: AuthenticatedByPasswordAnd2FAResponse + status: 200 +} + +export type allauthAppV1Auth2faReauthenticatePostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1Auth2faReauthenticatePostResponseComposite = allauthAppV1Auth2faReauthenticatePostResponse200 | allauthAppV1Auth2faReauthenticatePostResponse400; + +export type allauthAppV1Auth2faReauthenticatePostResponse = allauthAppV1Auth2faReauthenticatePostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1Auth2faReauthenticatePostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/2fa/reauthenticate` +} + +export const allauthAppV1Auth2faReauthenticatePost = async (mFAAuthenticateBody: MFAAuthenticateBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1Auth2faReauthenticatePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + mFAAuthenticateBody,) + } +);} + + + + +export const getAllauthAppV1Auth2faReauthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext> => { + +const mutationKey = ['allauthAppV1Auth2faReauthenticatePost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: MFAAuthenticateBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1Auth2faReauthenticatePost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1Auth2faReauthenticatePostMutationResult = NonNullable>> + export type AllauthAppV1Auth2faReauthenticatePostMutationBody = MFAAuthenticateBody + export type AllauthAppV1Auth2faReauthenticatePostMutationError = ErrorResponse + + /** + * @summary Reauthenticate using 2FA + */ +export const useAllauthAppV1Auth2faReauthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1Auth2faReauthenticatePostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Use this endpoint to pass along the received "special" login code. + + * @summary Confirm login code + */ +export type allauthBrowserV1AuthCodeConfirmPostResponse200 = { + data: AuthenticatedByCodeResponse + status: 200 +} + +export type allauthBrowserV1AuthCodeConfirmPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AuthCodeConfirmPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AuthCodeConfirmPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AuthCodeConfirmPostResponseComposite = allauthBrowserV1AuthCodeConfirmPostResponse200 | allauthBrowserV1AuthCodeConfirmPostResponse400 | allauthBrowserV1AuthCodeConfirmPostResponse401 | allauthBrowserV1AuthCodeConfirmPostResponse409; + +export type allauthBrowserV1AuthCodeConfirmPostResponse = allauthBrowserV1AuthCodeConfirmPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthCodeConfirmPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/code/confirm` +} + +export const allauthBrowserV1AuthCodeConfirmPost = async (confirmLoginCodeBody: ConfirmLoginCodeBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthCodeConfirmPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + confirmLoginCodeBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthCodeConfirmPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthCodeConfirmPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ConfirmLoginCodeBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthCodeConfirmPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthCodeConfirmPostMutationResult = NonNullable>> + export type AllauthBrowserV1AuthCodeConfirmPostMutationBody = ConfirmLoginCodeBody + export type AllauthBrowserV1AuthCodeConfirmPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse + + /** + * @summary Confirm login code + */ +export const useAllauthBrowserV1AuthCodeConfirmPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthCodeConfirmPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Use this endpoint to pass along the received "special" login code. + + * @summary Confirm login code + */ +export type allauthAppV1AuthCodeConfirmPostResponse200 = { + data: AuthenticatedByCodeResponse + status: 200 +} + +export type allauthAppV1AuthCodeConfirmPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AuthCodeConfirmPostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AuthCodeConfirmPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AuthCodeConfirmPostResponseComposite = allauthAppV1AuthCodeConfirmPostResponse200 | allauthAppV1AuthCodeConfirmPostResponse400 | allauthAppV1AuthCodeConfirmPostResponse401 | allauthAppV1AuthCodeConfirmPostResponse409; + +export type allauthAppV1AuthCodeConfirmPostResponse = allauthAppV1AuthCodeConfirmPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthCodeConfirmPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/code/confirm` +} + +export const allauthAppV1AuthCodeConfirmPost = async (confirmLoginCodeBody: ConfirmLoginCodeBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthCodeConfirmPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + confirmLoginCodeBody,) + } +);} + + + + +export const getAllauthAppV1AuthCodeConfirmPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthCodeConfirmPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ConfirmLoginCodeBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthCodeConfirmPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthCodeConfirmPostMutationResult = NonNullable>> + export type AllauthAppV1AuthCodeConfirmPostMutationBody = ConfirmLoginCodeBody + export type AllauthAppV1AuthCodeConfirmPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse + + /** + * @summary Confirm login code + */ +export const useAllauthAppV1AuthCodeConfirmPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthCodeConfirmPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * @summary List the connected third-party provider accounts + */ +export type allauthBrowserV1AccountProvidersGetResponse200 = { + data: ProviderAccountsResponse + status: 200 +} + +export type allauthBrowserV1AccountProvidersGetResponseComposite = allauthBrowserV1AccountProvidersGetResponse200; + +export type allauthBrowserV1AccountProvidersGetResponse = allauthBrowserV1AccountProvidersGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountProvidersGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/providers` +} + +export const allauthBrowserV1AccountProvidersGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountProvidersGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AccountProvidersGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','account','providers'] as const; + } + + +export const getAllauthBrowserV1AccountProvidersGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountProvidersGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountProvidersGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AccountProvidersGetQueryResult = NonNullable>> +export type AllauthBrowserV1AccountProvidersGetQueryError = unknown + + +/** + * @summary List the connected third-party provider accounts + */ + +export function useAllauthBrowserV1AccountProvidersGet>, TError = unknown>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AccountProvidersGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Disconnect a third-party provider account, returning the remaining +accounts that are still connected. The disconnect is not allowed if it +would leave the account unusable. For example, if no password was +set up yet. + + * @summary Disconnect a third-party provider account + + */ +export type allauthBrowserV1AccountProvidersDeleteResponse200 = { + data: ProviderAccountsResponse + status: 200 +} + +export type allauthBrowserV1AccountProvidersDeleteResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AccountProvidersDeleteResponseComposite = allauthBrowserV1AccountProvidersDeleteResponse200 | allauthBrowserV1AccountProvidersDeleteResponse400; + +export type allauthBrowserV1AccountProvidersDeleteResponse = allauthBrowserV1AccountProvidersDeleteResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountProvidersDeleteUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/providers` +} + +export const allauthBrowserV1AccountProvidersDelete = async (providerAccountBody: ProviderAccountBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountProvidersDeleteUrl(), + { + ...options, + method: 'DELETE', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + providerAccountBody,) + } +);} + + + + +export const getAllauthBrowserV1AccountProvidersDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AccountProvidersDelete']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ProviderAccountBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AccountProvidersDelete(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AccountProvidersDeleteMutationResult = NonNullable>> + export type AllauthBrowserV1AccountProvidersDeleteMutationBody = ProviderAccountBody + export type AllauthBrowserV1AccountProvidersDeleteMutationError = ErrorResponse + + /** + * @summary Disconnect a third-party provider account + + */ +export const useAllauthBrowserV1AccountProvidersDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AccountProvidersDeleteMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * @summary List the connected third-party provider accounts + */ +export type allauthAppV1AccountProvidersGetResponse200 = { + data: ProviderAccountsResponse + status: 200 +} + +export type allauthAppV1AccountProvidersGetResponseComposite = allauthAppV1AccountProvidersGetResponse200; + +export type allauthAppV1AccountProvidersGetResponse = allauthAppV1AccountProvidersGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountProvidersGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/providers` +} + +export const allauthAppV1AccountProvidersGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountProvidersGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AccountProvidersGetQueryKey = () => { + return ['api','v2','allauth','app','v1','account','providers'] as const; + } + + +export const getAllauthAppV1AccountProvidersGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountProvidersGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountProvidersGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AccountProvidersGetQueryResult = NonNullable>> +export type AllauthAppV1AccountProvidersGetQueryError = unknown + + +/** + * @summary List the connected third-party provider accounts + */ + +export function useAllauthAppV1AccountProvidersGet>, TError = unknown>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AccountProvidersGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Disconnect a third-party provider account, returning the remaining +accounts that are still connected. The disconnect is not allowed if it +would leave the account unusable. For example, if no password was +set up yet. + + * @summary Disconnect a third-party provider account + + */ +export type allauthAppV1AccountProvidersDeleteResponse200 = { + data: ProviderAccountsResponse + status: 200 +} + +export type allauthAppV1AccountProvidersDeleteResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AccountProvidersDeleteResponseComposite = allauthAppV1AccountProvidersDeleteResponse200 | allauthAppV1AccountProvidersDeleteResponse400; + +export type allauthAppV1AccountProvidersDeleteResponse = allauthAppV1AccountProvidersDeleteResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountProvidersDeleteUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/providers` +} + +export const allauthAppV1AccountProvidersDelete = async (providerAccountBody: ProviderAccountBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountProvidersDeleteUrl(), + { + ...options, + method: 'DELETE', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + providerAccountBody,) + } +);} + + + + +export const getAllauthAppV1AccountProvidersDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext> => { + +const mutationKey = ['allauthAppV1AccountProvidersDelete']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ProviderAccountBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AccountProvidersDelete(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AccountProvidersDeleteMutationResult = NonNullable>> + export type AllauthAppV1AccountProvidersDeleteMutationBody = ProviderAccountBody + export type AllauthAppV1AccountProvidersDeleteMutationError = ErrorResponse + + /** + * @summary Disconnect a third-party provider account + + */ +export const useAllauthAppV1AccountProvidersDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AccountProvidersDeleteMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Retrieves the list of email addresses of the account. + + * @summary List email addresses + */ +export type allauthBrowserV1AccountEmailGetResponse200 = { + data: EmailAddressesResponse + status: 200 +} + +export type allauthBrowserV1AccountEmailGetResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AccountEmailGetResponseComposite = allauthBrowserV1AccountEmailGetResponse200 | allauthBrowserV1AccountEmailGetResponse401; + +export type allauthBrowserV1AccountEmailGetResponse = allauthBrowserV1AccountEmailGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountEmailGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/email` +} + +export const allauthBrowserV1AccountEmailGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountEmailGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AccountEmailGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','account','email'] as const; + } + + +export const getAllauthBrowserV1AccountEmailGetQueryOptions = >, TError = AuthenticationResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountEmailGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountEmailGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AccountEmailGetQueryResult = NonNullable>> +export type AllauthBrowserV1AccountEmailGetQueryError = AuthenticationResponse + + +/** + * @summary List email addresses + */ + +export function useAllauthBrowserV1AccountEmailGet>, TError = AuthenticationResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AccountEmailGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * The following functionality is available: + + - Adding a new email address for an already signed in user (`ACCOUNT_CHANGE_EMAIL = False`). + - Change to a new email address for an already signed in user (`ACCOUNT_CHANGE_EMAIL = True`). + - Change to a new email address during the email verification process at signup (`ACCOUNT_EMAIL_VERIFICATION_SUPPORTS_CHANGE = True`). + +In all cases, an email verification mail will be sent containing a link or code that needs to be verified. + + * @summary Add/Change email address + + */ +export type allauthBrowserV1AccountEmailPostResponse200 = { + data: EmailAddressesResponse + status: 200 +} + +export type allauthBrowserV1AccountEmailPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AccountEmailPostResponse401 = { + data: AuthenticationOrReauthenticationResponse + status: 401 +} + +export type allauthBrowserV1AccountEmailPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AccountEmailPostResponseComposite = allauthBrowserV1AccountEmailPostResponse200 | allauthBrowserV1AccountEmailPostResponse400 | allauthBrowserV1AccountEmailPostResponse401 | allauthBrowserV1AccountEmailPostResponse409; + +export type allauthBrowserV1AccountEmailPostResponse = allauthBrowserV1AccountEmailPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountEmailPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/email` +} + +export const allauthBrowserV1AccountEmailPost = async (emailBody: EmailBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountEmailPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + emailBody,) + } +);} + + + + +export const getAllauthBrowserV1AccountEmailPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AccountEmailPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AccountEmailPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AccountEmailPostMutationResult = NonNullable>> + export type AllauthBrowserV1AccountEmailPostMutationBody = EmailBody + export type AllauthBrowserV1AccountEmailPostMutationError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse + + /** + * @summary Add/Change email address + + */ +export const useAllauthBrowserV1AccountEmailPost = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AccountEmailPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Requests for (another) email verification email to be sent. Note that +sending emails is rate limited, so when you send too many requests the +email will not be sent. + + * @summary Request email verification + */ +export type allauthBrowserV1AccountEmailPutResponse200 = { + data: StatusOKResponse + status: 200 +} + +export type allauthBrowserV1AccountEmailPutResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AccountEmailPutResponse403 = { + data: ForbiddenResponse + status: 403 +} + +export type allauthBrowserV1AccountEmailPutResponseComposite = allauthBrowserV1AccountEmailPutResponse200 | allauthBrowserV1AccountEmailPutResponse400 | allauthBrowserV1AccountEmailPutResponse403; + +export type allauthBrowserV1AccountEmailPutResponse = allauthBrowserV1AccountEmailPutResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountEmailPutUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/email` +} + +export const allauthBrowserV1AccountEmailPut = async (emailBody: EmailBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountEmailPutUrl(), + { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + emailBody,) + } +);} + + + + +export const getAllauthBrowserV1AccountEmailPutMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AccountEmailPut']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AccountEmailPut(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AccountEmailPutMutationResult = NonNullable>> + export type AllauthBrowserV1AccountEmailPutMutationBody = EmailBody + export type AllauthBrowserV1AccountEmailPutMutationError = ErrorResponse | ForbiddenResponse + + /** + * @summary Request email verification + */ +export const useAllauthBrowserV1AccountEmailPut = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AccountEmailPutMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Used to change primary email address to a different one. Note that only verified email addresses +can be marked as primary. + + * @summary Change primary email address + */ +export type allauthBrowserV1AccountEmailPatchResponse200 = { + data: EmailAddressesResponse + status: 200 +} + +export type allauthBrowserV1AccountEmailPatchResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AccountEmailPatchResponseComposite = allauthBrowserV1AccountEmailPatchResponse200 | allauthBrowserV1AccountEmailPatchResponse400; + +export type allauthBrowserV1AccountEmailPatchResponse = allauthBrowserV1AccountEmailPatchResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountEmailPatchUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/email` +} + +export const allauthBrowserV1AccountEmailPatch = async (markPrimaryEmailBody: MarkPrimaryEmailBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountEmailPatchUrl(), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + markPrimaryEmailBody,) + } +);} + + + + +export const getAllauthBrowserV1AccountEmailPatchMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AccountEmailPatch']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: MarkPrimaryEmailBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AccountEmailPatch(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AccountEmailPatchMutationResult = NonNullable>> + export type AllauthBrowserV1AccountEmailPatchMutationBody = MarkPrimaryEmailBody + export type AllauthBrowserV1AccountEmailPatchMutationError = ErrorResponse + + /** + * @summary Change primary email address + */ +export const useAllauthBrowserV1AccountEmailPatch = (options?: { mutation?:UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AccountEmailPatchMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Used to remove an email address. + + * @summary Remove an email address + */ +export type allauthBrowserV1AccountEmailDeleteResponse200 = { + data: EmailAddressesResponse + status: 200 +} + +export type allauthBrowserV1AccountEmailDeleteResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AccountEmailDeleteResponseComposite = allauthBrowserV1AccountEmailDeleteResponse200 | allauthBrowserV1AccountEmailDeleteResponse400; + +export type allauthBrowserV1AccountEmailDeleteResponse = allauthBrowserV1AccountEmailDeleteResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountEmailDeleteUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/email` +} + +export const allauthBrowserV1AccountEmailDelete = async (emailBody: EmailBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountEmailDeleteUrl(), + { + ...options, + method: 'DELETE', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + emailBody,) + } +);} + + + + +export const getAllauthBrowserV1AccountEmailDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AccountEmailDelete']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AccountEmailDelete(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AccountEmailDeleteMutationResult = NonNullable>> + export type AllauthBrowserV1AccountEmailDeleteMutationBody = EmailBody + export type AllauthBrowserV1AccountEmailDeleteMutationError = ErrorResponse + + /** + * @summary Remove an email address + */ +export const useAllauthBrowserV1AccountEmailDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AccountEmailDeleteMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Retrieves the list of email addresses of the account. + + * @summary List email addresses + */ +export type allauthAppV1AccountEmailGetResponse200 = { + data: EmailAddressesResponse + status: 200 +} + +export type allauthAppV1AccountEmailGetResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AccountEmailGetResponseComposite = allauthAppV1AccountEmailGetResponse200 | allauthAppV1AccountEmailGetResponse401; + +export type allauthAppV1AccountEmailGetResponse = allauthAppV1AccountEmailGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountEmailGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/email` +} + +export const allauthAppV1AccountEmailGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountEmailGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AccountEmailGetQueryKey = () => { + return ['api','v2','allauth','app','v1','account','email'] as const; + } + + +export const getAllauthAppV1AccountEmailGetQueryOptions = >, TError = AuthenticationResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountEmailGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountEmailGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AccountEmailGetQueryResult = NonNullable>> +export type AllauthAppV1AccountEmailGetQueryError = AuthenticationResponse + + +/** + * @summary List email addresses + */ + +export function useAllauthAppV1AccountEmailGet>, TError = AuthenticationResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AccountEmailGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * The following functionality is available: + + - Adding a new email address for an already signed in user (`ACCOUNT_CHANGE_EMAIL = False`). + - Change to a new email address for an already signed in user (`ACCOUNT_CHANGE_EMAIL = True`). + - Change to a new email address during the email verification process at signup (`ACCOUNT_EMAIL_VERIFICATION_SUPPORTS_CHANGE = True`). + +In all cases, an email verification mail will be sent containing a link or code that needs to be verified. + + * @summary Add/Change email address + + */ +export type allauthAppV1AccountEmailPostResponse200 = { + data: EmailAddressesResponse + status: 200 +} + +export type allauthAppV1AccountEmailPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AccountEmailPostResponse401 = { + data: AuthenticationOrReauthenticationResponse + status: 401 +} + +export type allauthAppV1AccountEmailPostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AccountEmailPostResponseComposite = allauthAppV1AccountEmailPostResponse200 | allauthAppV1AccountEmailPostResponse400 | allauthAppV1AccountEmailPostResponse401 | allauthAppV1AccountEmailPostResponse409; + +export type allauthAppV1AccountEmailPostResponse = allauthAppV1AccountEmailPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountEmailPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/email` +} + +export const allauthAppV1AccountEmailPost = async (emailBody: EmailBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountEmailPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + emailBody,) + } +);} + + + + +export const getAllauthAppV1AccountEmailPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { + +const mutationKey = ['allauthAppV1AccountEmailPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AccountEmailPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AccountEmailPostMutationResult = NonNullable>> + export type AllauthAppV1AccountEmailPostMutationBody = EmailBody + export type AllauthAppV1AccountEmailPostMutationError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse + + /** + * @summary Add/Change email address + + */ +export const useAllauthAppV1AccountEmailPost = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AccountEmailPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Requests for (another) email verification email to be sent. Note that +sending emails is rate limited, so when you send too many requests the +email will not be sent. + + * @summary Request email verification + */ +export type allauthAppV1AccountEmailPutResponse200 = { + data: StatusOKResponse + status: 200 +} + +export type allauthAppV1AccountEmailPutResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AccountEmailPutResponse403 = { + data: ForbiddenResponse + status: 403 +} + +export type allauthAppV1AccountEmailPutResponseComposite = allauthAppV1AccountEmailPutResponse200 | allauthAppV1AccountEmailPutResponse400 | allauthAppV1AccountEmailPutResponse403; + +export type allauthAppV1AccountEmailPutResponse = allauthAppV1AccountEmailPutResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountEmailPutUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/email` +} + +export const allauthAppV1AccountEmailPut = async (emailBody: EmailBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountEmailPutUrl(), + { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + emailBody,) + } +);} + + + + +export const getAllauthAppV1AccountEmailPutMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { + +const mutationKey = ['allauthAppV1AccountEmailPut']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AccountEmailPut(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AccountEmailPutMutationResult = NonNullable>> + export type AllauthAppV1AccountEmailPutMutationBody = EmailBody + export type AllauthAppV1AccountEmailPutMutationError = ErrorResponse | ForbiddenResponse + + /** + * @summary Request email verification + */ +export const useAllauthAppV1AccountEmailPut = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AccountEmailPutMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Used to change primary email address to a different one. Note that only verified email addresses +can be marked as primary. + + * @summary Change primary email address + */ +export type allauthAppV1AccountEmailPatchResponse200 = { + data: EmailAddressesResponse + status: 200 +} + +export type allauthAppV1AccountEmailPatchResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AccountEmailPatchResponseComposite = allauthAppV1AccountEmailPatchResponse200 | allauthAppV1AccountEmailPatchResponse400; + +export type allauthAppV1AccountEmailPatchResponse = allauthAppV1AccountEmailPatchResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountEmailPatchUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/email` +} + +export const allauthAppV1AccountEmailPatch = async (markPrimaryEmailBody: MarkPrimaryEmailBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountEmailPatchUrl(), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + markPrimaryEmailBody,) + } +);} + + + + +export const getAllauthAppV1AccountEmailPatchMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext> => { + +const mutationKey = ['allauthAppV1AccountEmailPatch']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: MarkPrimaryEmailBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AccountEmailPatch(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AccountEmailPatchMutationResult = NonNullable>> + export type AllauthAppV1AccountEmailPatchMutationBody = MarkPrimaryEmailBody + export type AllauthAppV1AccountEmailPatchMutationError = ErrorResponse + + /** + * @summary Change primary email address + */ +export const useAllauthAppV1AccountEmailPatch = (options?: { mutation?:UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AccountEmailPatchMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Used to remove an email address. + + * @summary Remove an email address + */ +export type allauthAppV1AccountEmailDeleteResponse200 = { + data: EmailAddressesResponse + status: 200 +} + +export type allauthAppV1AccountEmailDeleteResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AccountEmailDeleteResponseComposite = allauthAppV1AccountEmailDeleteResponse200 | allauthAppV1AccountEmailDeleteResponse400; + +export type allauthAppV1AccountEmailDeleteResponse = allauthAppV1AccountEmailDeleteResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountEmailDeleteUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/email` +} + +export const allauthAppV1AccountEmailDelete = async (emailBody: EmailBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountEmailDeleteUrl(), + { + ...options, + method: 'DELETE', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + emailBody,) + } +);} + + + + +export const getAllauthAppV1AccountEmailDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { + +const mutationKey = ['allauthAppV1AccountEmailDelete']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AccountEmailDelete(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AccountEmailDeleteMutationResult = NonNullable>> + export type AllauthAppV1AccountEmailDeleteMutationBody = EmailBody + export type AllauthAppV1AccountEmailDeleteMutationError = ErrorResponse + + /** + * @summary Remove an email address + */ +export const useAllauthAppV1AccountEmailDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AccountEmailDeleteMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Retrieves the phone number of the account, if any. Note that while the +endpoint returns a list of phone numbers, at most one entry is returned. + + * @summary Get the phone number + */ +export type allauthBrowserV1AccountPhoneGetResponse200 = { + data: PhoneNumbersResponse + status: 200 +} + +export type allauthBrowserV1AccountPhoneGetResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AccountPhoneGetResponseComposite = allauthBrowserV1AccountPhoneGetResponse200 | allauthBrowserV1AccountPhoneGetResponse401; + +export type allauthBrowserV1AccountPhoneGetResponse = allauthBrowserV1AccountPhoneGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountPhoneGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/phone` +} + +export const allauthBrowserV1AccountPhoneGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountPhoneGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AccountPhoneGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','account','phone'] as const; + } + + +export const getAllauthBrowserV1AccountPhoneGetQueryOptions = >, TError = AuthenticationResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountPhoneGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountPhoneGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AccountPhoneGetQueryResult = NonNullable>> +export type AllauthBrowserV1AccountPhoneGetQueryError = AuthenticationResponse + + +/** + * @summary Get the phone number + */ + +export function useAllauthBrowserV1AccountPhoneGet>, TError = AuthenticationResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AccountPhoneGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * The following functionality is available: + +- Initiate the phone number change process for signed in users. +- Change to a new phone number during the phone number verification + process at signup for unauthenticated users. Note that this requires: + `ACCOUNT_PHONE_VERIFICATION_SUPPORTS_CHANGE = True`. + +In both cases, after posting a new phone number, proceed with the phone +verification endpoint to confirm the change of the phone number by +posting the verification code. + + * @summary Change the phone number + + */ +export type allauthBrowserV1AccountPhonePostResponse202 = { + data: PhoneNumberChangeResponse + status: 202 +} + +export type allauthBrowserV1AccountPhonePostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AccountPhonePostResponse401 = { + data: AuthenticationOrReauthenticationResponse + status: 401 +} + +export type allauthBrowserV1AccountPhonePostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthBrowserV1AccountPhonePostResponseComposite = allauthBrowserV1AccountPhonePostResponse202 | allauthBrowserV1AccountPhonePostResponse400 | allauthBrowserV1AccountPhonePostResponse401 | allauthBrowserV1AccountPhonePostResponse409; + +export type allauthBrowserV1AccountPhonePostResponse = allauthBrowserV1AccountPhonePostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountPhonePostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/phone` +} + +export const allauthBrowserV1AccountPhonePost = async (phoneBody: PhoneBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountPhonePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + phoneBody,) + } +);} + + + + +export const getAllauthBrowserV1AccountPhonePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: PhoneBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: PhoneBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AccountPhonePost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: PhoneBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AccountPhonePost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AccountPhonePostMutationResult = NonNullable>> + export type AllauthBrowserV1AccountPhonePostMutationBody = PhoneBody + export type AllauthBrowserV1AccountPhonePostMutationError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse + + /** + * @summary Change the phone number + + */ +export const useAllauthBrowserV1AccountPhonePost = (options?: { mutation?:UseMutationOptions>, TError,{data: PhoneBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AccountPhonePostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Retrieves the phone number of the account, if any. Note that while the +endpoint returns a list of phone numbers, at most one entry is returned. + + * @summary Get the phone number + */ +export type allauthAppV1AccountPhoneGetResponse200 = { + data: PhoneNumbersResponse + status: 200 +} + +export type allauthAppV1AccountPhoneGetResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AccountPhoneGetResponseComposite = allauthAppV1AccountPhoneGetResponse200 | allauthAppV1AccountPhoneGetResponse401; + +export type allauthAppV1AccountPhoneGetResponse = allauthAppV1AccountPhoneGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountPhoneGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/phone` +} + +export const allauthAppV1AccountPhoneGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountPhoneGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AccountPhoneGetQueryKey = () => { + return ['api','v2','allauth','app','v1','account','phone'] as const; + } + + +export const getAllauthAppV1AccountPhoneGetQueryOptions = >, TError = AuthenticationResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountPhoneGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountPhoneGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AccountPhoneGetQueryResult = NonNullable>> +export type AllauthAppV1AccountPhoneGetQueryError = AuthenticationResponse + + +/** + * @summary Get the phone number + */ + +export function useAllauthAppV1AccountPhoneGet>, TError = AuthenticationResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AccountPhoneGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * The following functionality is available: + +- Initiate the phone number change process for signed in users. +- Change to a new phone number during the phone number verification + process at signup for unauthenticated users. Note that this requires: + `ACCOUNT_PHONE_VERIFICATION_SUPPORTS_CHANGE = True`. + +In both cases, after posting a new phone number, proceed with the phone +verification endpoint to confirm the change of the phone number by +posting the verification code. + + * @summary Change the phone number + + */ +export type allauthAppV1AccountPhonePostResponse202 = { + data: PhoneNumberChangeResponse + status: 202 +} + +export type allauthAppV1AccountPhonePostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AccountPhonePostResponse401 = { + data: AuthenticationOrReauthenticationResponse + status: 401 +} + +export type allauthAppV1AccountPhonePostResponse409 = { + data: ConflictResponse + status: 409 +} + +export type allauthAppV1AccountPhonePostResponseComposite = allauthAppV1AccountPhonePostResponse202 | allauthAppV1AccountPhonePostResponse400 | allauthAppV1AccountPhonePostResponse401 | allauthAppV1AccountPhonePostResponse409; + +export type allauthAppV1AccountPhonePostResponse = allauthAppV1AccountPhonePostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountPhonePostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/phone` +} + +export const allauthAppV1AccountPhonePost = async (phoneBody: PhoneBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountPhonePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + phoneBody,) + } +);} + + + + +export const getAllauthAppV1AccountPhonePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: PhoneBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: PhoneBody}, TContext> => { + +const mutationKey = ['allauthAppV1AccountPhonePost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: PhoneBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AccountPhonePost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AccountPhonePostMutationResult = NonNullable>> + export type AllauthAppV1AccountPhonePostMutationBody = PhoneBody + export type AllauthAppV1AccountPhonePostMutationError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse + + /** + * @summary Change the phone number + + */ +export const useAllauthAppV1AccountPhonePost = (options?: { mutation?:UseMutationOptions>, TError,{data: PhoneBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AccountPhonePostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * @summary List authenticators + */ +export type allauthBrowserV1AccountAuthenticatorsGetResponse200 = { + data: AuthenticatorsResponse + status: 200 +} + +export type allauthBrowserV1AccountAuthenticatorsGetResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AccountAuthenticatorsGetResponse410 = { + data: SessionGoneResponse + status: 410 +} + +export type allauthBrowserV1AccountAuthenticatorsGetResponseComposite = allauthBrowserV1AccountAuthenticatorsGetResponse200 | allauthBrowserV1AccountAuthenticatorsGetResponse401 | allauthBrowserV1AccountAuthenticatorsGetResponse410; + +export type allauthBrowserV1AccountAuthenticatorsGetResponse = allauthBrowserV1AccountAuthenticatorsGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountAuthenticatorsGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/authenticators` +} + +export const allauthBrowserV1AccountAuthenticatorsGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AccountAuthenticatorsGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','account','authenticators'] as const; + } + + +export const getAllauthBrowserV1AccountAuthenticatorsGetQueryOptions = >, TError = AuthenticationResponse | SessionGoneResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountAuthenticatorsGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AccountAuthenticatorsGetQueryResult = NonNullable>> +export type AllauthBrowserV1AccountAuthenticatorsGetQueryError = AuthenticationResponse | SessionGoneResponse + + +/** + * @summary List authenticators + */ + +export function useAllauthBrowserV1AccountAuthenticatorsGet>, TError = AuthenticationResponse | SessionGoneResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AccountAuthenticatorsGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * @summary List authenticators + */ +export type allauthAppV1AccountAuthenticatorsGetResponse200 = { + data: AuthenticatorsResponse + status: 200 +} + +export type allauthAppV1AccountAuthenticatorsGetResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AccountAuthenticatorsGetResponse410 = { + data: SessionGoneResponse + status: 410 +} + +export type allauthAppV1AccountAuthenticatorsGetResponseComposite = allauthAppV1AccountAuthenticatorsGetResponse200 | allauthAppV1AccountAuthenticatorsGetResponse401 | allauthAppV1AccountAuthenticatorsGetResponse410; + +export type allauthAppV1AccountAuthenticatorsGetResponse = allauthAppV1AccountAuthenticatorsGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountAuthenticatorsGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/authenticators` +} + +export const allauthAppV1AccountAuthenticatorsGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AccountAuthenticatorsGetQueryKey = () => { + return ['api','v2','allauth','app','v1','account','authenticators'] as const; + } + + +export const getAllauthAppV1AccountAuthenticatorsGetQueryOptions = >, TError = AuthenticationResponse | SessionGoneResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountAuthenticatorsGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AccountAuthenticatorsGetQueryResult = NonNullable>> +export type AllauthAppV1AccountAuthenticatorsGetQueryError = AuthenticationResponse | SessionGoneResponse + + +/** + * @summary List authenticators + */ + +export function useAllauthAppV1AccountAuthenticatorsGet>, TError = AuthenticationResponse | SessionGoneResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AccountAuthenticatorsGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Retrieve the information about the current TOTP authenticator, if any. + + * @summary TOTP authenticator status + */ +export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse200 = { + data: TOTPAuthenticatorResponse + status: 200 +} + +export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse404 = { + data: TOTPAuthenticatorNotFoundResponse + status: 404 +} + +export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse409 = { + data: AddAuthenticatorConflictResponse + status: 409 +} + +export type allauthBrowserV1AccountAuthenticatorsTotpGetResponseComposite = allauthBrowserV1AccountAuthenticatorsTotpGetResponse200 | allauthBrowserV1AccountAuthenticatorsTotpGetResponse404 | allauthBrowserV1AccountAuthenticatorsTotpGetResponse409; + +export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse = allauthBrowserV1AccountAuthenticatorsTotpGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountAuthenticatorsTotpGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/authenticators/totp` +} + +export const allauthBrowserV1AccountAuthenticatorsTotpGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsTotpGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','account','authenticators','totp'] as const; + } + + +export const getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryOptions = >, TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountAuthenticatorsTotpGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AccountAuthenticatorsTotpGetQueryResult = NonNullable>> +export type AllauthBrowserV1AccountAuthenticatorsTotpGetQueryError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse + + +/** + * @summary TOTP authenticator status + */ + +export function useAllauthBrowserV1AccountAuthenticatorsTotpGet>, TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * The code should be provided from the consuming TOTP authenticator +application which was generated using the TOTP authenticator secret +retrieved from the TOTP authenticator status endpoint. + + * @summary Activate TOTP + */ +export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse200 = { + data: TOTPAuthenticatorResponse + status: 200 +} + +export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse401 = { + data: ReauthenticationRequiredResponse + status: 401 +} + +export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse409 = { + data: AddAuthenticatorConflictResponse + status: 409 +} + +export type allauthBrowserV1AccountAuthenticatorsTotpPostResponseComposite = allauthBrowserV1AccountAuthenticatorsTotpPostResponse200 | allauthBrowserV1AccountAuthenticatorsTotpPostResponse400 | allauthBrowserV1AccountAuthenticatorsTotpPostResponse401 | allauthBrowserV1AccountAuthenticatorsTotpPostResponse409; + +export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse = allauthBrowserV1AccountAuthenticatorsTotpPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountAuthenticatorsTotpPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/authenticators/totp` +} + +export const allauthBrowserV1AccountAuthenticatorsTotpPost = async (setupTOTPBody: SetupTOTPBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsTotpPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + setupTOTPBody,) + } +);} + + + + +export const getAllauthBrowserV1AccountAuthenticatorsTotpPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AccountAuthenticatorsTotpPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: SetupTOTPBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AccountAuthenticatorsTotpPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationResult = NonNullable>> + export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationBody = SetupTOTPBody + export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse + + /** + * @summary Activate TOTP + */ +export const useAllauthBrowserV1AccountAuthenticatorsTotpPost = (options?: { mutation?:UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsTotpPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Deactivates TOTP authentication. If the user authentication is not +sufficiently recent, a reauthentication flow (`401`) will is presented. + + * @summary Deactivate TOTP + */ +export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse200 = { + data: StatusOKResponse + status: 200 +} + +export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse401 = { + data: ReauthenticationRequiredResponse + status: 401 +} + +export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponseComposite = allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse200 | allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse401; + +export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse = allauthBrowserV1AccountAuthenticatorsTotpDeleteResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountAuthenticatorsTotpDeleteUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/authenticators/totp` +} + +export const allauthBrowserV1AccountAuthenticatorsTotpDelete = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsTotpDeleteUrl(), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['allauthBrowserV1AccountAuthenticatorsTotpDelete']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return allauthBrowserV1AccountAuthenticatorsTotpDelete(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationResult = NonNullable>> + + export type AllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationError = ReauthenticationRequiredResponse + + /** + * @summary Deactivate TOTP + */ +export const useAllauthBrowserV1AccountAuthenticatorsTotpDelete = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Retrieve the information about the current TOTP authenticator, if any. + + * @summary TOTP authenticator status + */ +export type allauthAppV1AccountAuthenticatorsTotpGetResponse200 = { + data: TOTPAuthenticatorResponse + status: 200 +} + +export type allauthAppV1AccountAuthenticatorsTotpGetResponse404 = { + data: TOTPAuthenticatorNotFoundResponse + status: 404 +} + +export type allauthAppV1AccountAuthenticatorsTotpGetResponse409 = { + data: AddAuthenticatorConflictResponse + status: 409 +} + +export type allauthAppV1AccountAuthenticatorsTotpGetResponseComposite = allauthAppV1AccountAuthenticatorsTotpGetResponse200 | allauthAppV1AccountAuthenticatorsTotpGetResponse404 | allauthAppV1AccountAuthenticatorsTotpGetResponse409; + +export type allauthAppV1AccountAuthenticatorsTotpGetResponse = allauthAppV1AccountAuthenticatorsTotpGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountAuthenticatorsTotpGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/authenticators/totp` +} + +export const allauthAppV1AccountAuthenticatorsTotpGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsTotpGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AccountAuthenticatorsTotpGetQueryKey = () => { + return ['api','v2','allauth','app','v1','account','authenticators','totp'] as const; + } + + +export const getAllauthAppV1AccountAuthenticatorsTotpGetQueryOptions = >, TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsTotpGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountAuthenticatorsTotpGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AccountAuthenticatorsTotpGetQueryResult = NonNullable>> +export type AllauthAppV1AccountAuthenticatorsTotpGetQueryError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse + + +/** + * @summary TOTP authenticator status + */ + +export function useAllauthAppV1AccountAuthenticatorsTotpGet>, TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AccountAuthenticatorsTotpGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * The code should be provided from the consuming TOTP authenticator +application which was generated using the TOTP authenticator secret +retrieved from the TOTP authenticator status endpoint. + + * @summary Activate TOTP + */ +export type allauthAppV1AccountAuthenticatorsTotpPostResponse200 = { + data: TOTPAuthenticatorResponse + status: 200 +} + +export type allauthAppV1AccountAuthenticatorsTotpPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AccountAuthenticatorsTotpPostResponse401 = { + data: ReauthenticationRequiredResponse + status: 401 +} + +export type allauthAppV1AccountAuthenticatorsTotpPostResponse409 = { + data: AddAuthenticatorConflictResponse + status: 409 +} + +export type allauthAppV1AccountAuthenticatorsTotpPostResponseComposite = allauthAppV1AccountAuthenticatorsTotpPostResponse200 | allauthAppV1AccountAuthenticatorsTotpPostResponse400 | allauthAppV1AccountAuthenticatorsTotpPostResponse401 | allauthAppV1AccountAuthenticatorsTotpPostResponse409; + +export type allauthAppV1AccountAuthenticatorsTotpPostResponse = allauthAppV1AccountAuthenticatorsTotpPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountAuthenticatorsTotpPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/authenticators/totp` +} + +export const allauthAppV1AccountAuthenticatorsTotpPost = async (setupTOTPBody: SetupTOTPBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsTotpPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + setupTOTPBody,) + } +);} + + + + +export const getAllauthAppV1AccountAuthenticatorsTotpPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext> => { + +const mutationKey = ['allauthAppV1AccountAuthenticatorsTotpPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: SetupTOTPBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AccountAuthenticatorsTotpPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AccountAuthenticatorsTotpPostMutationResult = NonNullable>> + export type AllauthAppV1AccountAuthenticatorsTotpPostMutationBody = SetupTOTPBody + export type AllauthAppV1AccountAuthenticatorsTotpPostMutationError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse + + /** + * @summary Activate TOTP + */ +export const useAllauthAppV1AccountAuthenticatorsTotpPost = (options?: { mutation?:UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AccountAuthenticatorsTotpPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Deactivates TOTP authentication. If the user authentication is not +sufficiently recent, a reauthentication flow (`401`) will is presented. + + * @summary Deactivate TOTP + */ +export type allauthAppV1AccountAuthenticatorsTotpDeleteResponse200 = { + data: StatusOKResponse + status: 200 +} + +export type allauthAppV1AccountAuthenticatorsTotpDeleteResponse401 = { + data: ReauthenticationRequiredResponse + status: 401 +} + +export type allauthAppV1AccountAuthenticatorsTotpDeleteResponseComposite = allauthAppV1AccountAuthenticatorsTotpDeleteResponse200 | allauthAppV1AccountAuthenticatorsTotpDeleteResponse401; + +export type allauthAppV1AccountAuthenticatorsTotpDeleteResponse = allauthAppV1AccountAuthenticatorsTotpDeleteResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountAuthenticatorsTotpDeleteUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/authenticators/totp` +} + +export const allauthAppV1AccountAuthenticatorsTotpDelete = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsTotpDeleteUrl(), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAllauthAppV1AccountAuthenticatorsTotpDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['allauthAppV1AccountAuthenticatorsTotpDelete']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return allauthAppV1AccountAuthenticatorsTotpDelete(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AccountAuthenticatorsTotpDeleteMutationResult = NonNullable>> + + export type AllauthAppV1AccountAuthenticatorsTotpDeleteMutationError = ReauthenticationRequiredResponse + + /** + * @summary Deactivate TOTP + */ +export const useAllauthAppV1AccountAuthenticatorsTotpDelete = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AccountAuthenticatorsTotpDeleteMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * List recovery codes. + + * @summary List recovery codes + */ +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse200 = { + data: RecoveryCodesResponse + status: 200 +} + +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse401 = { + data: ReauthenticationRequiredResponse + status: 401 +} + +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse404 = { + data: NotFoundResponse + status: 404 +} + +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseComposite = allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse200 | allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse401 | allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse404; + +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse = allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/authenticators/recovery-codes` +} + +export const allauthBrowserV1AccountAuthenticatorsRecoveryCodesGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','account','authenticators','recovery-codes'] as const; + } + + +export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryOptions = >, TError = ReauthenticationRequiredResponse | NotFoundResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountAuthenticatorsRecoveryCodesGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryResult = NonNullable>> +export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryError = ReauthenticationRequiredResponse | NotFoundResponse + + +/** + * @summary List recovery codes + */ + +export function useAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGet>, TError = ReauthenticationRequiredResponse | NotFoundResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * @summary Regenerate recovery codes + */ +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse401 = { + data: ReauthenticationRequiredResponse + status: 401 +} + +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponseComposite = allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse400 | allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse401; + +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse = allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/authenticators/recovery-codes` +} + +export const allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostUrl(), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationResult = NonNullable>> + + export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationError = ErrorResponse | ReauthenticationRequiredResponse + + /** + * @summary Regenerate recovery codes + */ +export const useAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * List recovery codes. + + * @summary List recovery codes + */ +export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse200 = { + data: RecoveryCodesResponse + status: 200 +} + +export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse401 = { + data: ReauthenticationRequiredResponse + status: 401 +} + +export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse404 = { + data: NotFoundResponse + status: 404 +} + +export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseComposite = allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse200 | allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse401 | allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse404; + +export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse = allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/authenticators/recovery-codes` +} + +export const allauthAppV1AccountAuthenticatorsRecoveryCodesGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryKey = () => { + return ['api','v2','allauth','app','v1','account','authenticators','recovery-codes'] as const; + } + + +export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryOptions = >, TError = ReauthenticationRequiredResponse | NotFoundResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountAuthenticatorsRecoveryCodesGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryResult = NonNullable>> +export type AllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryError = ReauthenticationRequiredResponse | NotFoundResponse + + +/** + * @summary List recovery codes + */ + +export function useAllauthAppV1AccountAuthenticatorsRecoveryCodesGet>, TError = ReauthenticationRequiredResponse | NotFoundResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * @summary Regenerate recovery codes + */ +export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse401 = { + data: ReauthenticationRequiredResponse + status: 401 +} + +export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponseComposite = allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse400 | allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse401; + +export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse = allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/authenticators/recovery-codes` +} + +export const allauthAppV1AccountAuthenticatorsRecoveryCodesPost = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostUrl(), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['allauthAppV1AccountAuthenticatorsRecoveryCodesPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return allauthAppV1AccountAuthenticatorsRecoveryCodesPost(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationResult = NonNullable>> + + export type AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationError = ErrorResponse | ReauthenticationRequiredResponse + + /** + * @summary Regenerate recovery codes + */ +export const useAllauthAppV1AccountAuthenticatorsRecoveryCodesPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Retrieve information about the authentication status for the current +session. + + * @summary Get authentication status + + */ +export type allauthBrowserV1AuthSessionGetResponse200 = { + data: AuthenticatedResponse + status: 200 +} + +export type allauthBrowserV1AuthSessionGetResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AuthSessionGetResponse410 = { + data: SessionGoneResponse + status: 410 +} + +export type allauthBrowserV1AuthSessionGetResponseComposite = allauthBrowserV1AuthSessionGetResponse200 | allauthBrowserV1AuthSessionGetResponse401 | allauthBrowserV1AuthSessionGetResponse410; + +export type allauthBrowserV1AuthSessionGetResponse = allauthBrowserV1AuthSessionGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthSessionGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/session` +} + +export const allauthBrowserV1AuthSessionGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthSessionGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AuthSessionGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','auth','session'] as const; + } + + +export const getAllauthBrowserV1AuthSessionGetQueryOptions = >, TError = AuthenticationResponse | SessionGoneResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthSessionGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AuthSessionGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AuthSessionGetQueryResult = NonNullable>> +export type AllauthBrowserV1AuthSessionGetQueryError = AuthenticationResponse | SessionGoneResponse + + +/** + * @summary Get authentication status + + */ + +export function useAllauthBrowserV1AuthSessionGet>, TError = AuthenticationResponse | SessionGoneResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AuthSessionGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Logs out the user from the current session. + + * @summary Logout + */ +export type allauthBrowserV1AuthSessionDeleteResponse401 = { + data: UnauthenticatedResponse + status: 401 +} + +export type allauthBrowserV1AuthSessionDeleteResponseComposite = allauthBrowserV1AuthSessionDeleteResponse401; + +export type allauthBrowserV1AuthSessionDeleteResponse = allauthBrowserV1AuthSessionDeleteResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthSessionDeleteUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/session` +} + +export const allauthBrowserV1AuthSessionDelete = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthSessionDeleteUrl(), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAllauthBrowserV1AuthSessionDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthSessionDelete']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return allauthBrowserV1AuthSessionDelete(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthSessionDeleteMutationResult = NonNullable>> + + export type AllauthBrowserV1AuthSessionDeleteMutationError = UnauthenticatedResponse + + /** + * @summary Logout + */ +export const useAllauthBrowserV1AuthSessionDelete = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthSessionDeleteMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Retrieve information about the authentication status for the current +session. + + * @summary Get authentication status + + */ +export type allauthAppV1AuthSessionGetResponse200 = { + data: AuthenticatedResponse + status: 200 +} + +export type allauthAppV1AuthSessionGetResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AuthSessionGetResponse410 = { + data: SessionGoneResponse + status: 410 +} + +export type allauthAppV1AuthSessionGetResponseComposite = allauthAppV1AuthSessionGetResponse200 | allauthAppV1AuthSessionGetResponse401 | allauthAppV1AuthSessionGetResponse410; + +export type allauthAppV1AuthSessionGetResponse = allauthAppV1AuthSessionGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthSessionGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/session` +} + +export const allauthAppV1AuthSessionGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthSessionGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AuthSessionGetQueryKey = () => { + return ['api','v2','allauth','app','v1','auth','session'] as const; + } + + +export const getAllauthAppV1AuthSessionGetQueryOptions = >, TError = AuthenticationResponse | SessionGoneResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthSessionGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AuthSessionGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AuthSessionGetQueryResult = NonNullable>> +export type AllauthAppV1AuthSessionGetQueryError = AuthenticationResponse | SessionGoneResponse + + +/** + * @summary Get authentication status + + */ + +export function useAllauthAppV1AuthSessionGet>, TError = AuthenticationResponse | SessionGoneResponse>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AuthSessionGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Logs out the user from the current session. + + * @summary Logout + */ +export type allauthAppV1AuthSessionDeleteResponse401 = { + data: UnauthenticatedResponse + status: 401 +} + +export type allauthAppV1AuthSessionDeleteResponseComposite = allauthAppV1AuthSessionDeleteResponse401; + +export type allauthAppV1AuthSessionDeleteResponse = allauthAppV1AuthSessionDeleteResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthSessionDeleteUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/session` +} + +export const allauthAppV1AuthSessionDelete = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthSessionDeleteUrl(), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAllauthAppV1AuthSessionDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['allauthAppV1AuthSessionDelete']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return allauthAppV1AuthSessionDelete(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthSessionDeleteMutationResult = NonNullable>> + + export type AllauthAppV1AuthSessionDeleteMutationError = UnauthenticatedResponse + + /** + * @summary Logout + */ +export const useAllauthAppV1AuthSessionDelete = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthSessionDeleteMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Used to retrieve a new access token. Depending on `settings.HEADLESS_JWT_ROTATE_REFRESH_TOKEN`, +a new refresh token is returned as well. + + * @summary Refresh the access token + + */ +export type allauthAppV1TokensRefreshPostResponse200 = { + data: RefreshTokenResponse + status: 200 +} + +export type allauthAppV1TokensRefreshPostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1TokensRefreshPostResponseComposite = allauthAppV1TokensRefreshPostResponse200 | allauthAppV1TokensRefreshPostResponse400; + +export type allauthAppV1TokensRefreshPostResponse = allauthAppV1TokensRefreshPostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1TokensRefreshPostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/tokens/refresh` +} + +export const allauthAppV1TokensRefreshPost = async (refreshTokenBody: RefreshTokenBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1TokensRefreshPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + refreshTokenBody,) + } +);} + + + + +export const getAllauthAppV1TokensRefreshPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: RefreshTokenBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: RefreshTokenBody}, TContext> => { + +const mutationKey = ['allauthAppV1TokensRefreshPost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: RefreshTokenBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1TokensRefreshPost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1TokensRefreshPostMutationResult = NonNullable>> + export type AllauthAppV1TokensRefreshPostMutationBody = RefreshTokenBody + export type AllauthAppV1TokensRefreshPostMutationError = ErrorResponse + + /** + * @summary Refresh the access token + + */ +export const useAllauthAppV1TokensRefreshPost = (options?: { mutation?:UseMutationOptions>, TError,{data: RefreshTokenBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1TokensRefreshPostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * In order to change the password of an account, the current and new +password must be provider. However, accounts that were created by +signing up using a third-party provider do not have a password set. In +that case, the current password is not required. + + * @summary Change password + */ +export type allauthBrowserV1AccountPasswordChangePostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthBrowserV1AccountPasswordChangePostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AccountPasswordChangePostResponseComposite = allauthBrowserV1AccountPasswordChangePostResponse400 | allauthBrowserV1AccountPasswordChangePostResponse401; + +export type allauthBrowserV1AccountPasswordChangePostResponse = allauthBrowserV1AccountPasswordChangePostResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AccountPasswordChangePostUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/account/password/change` +} + +export const allauthBrowserV1AccountPasswordChangePost = async (changePasswordBody: ChangePasswordBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AccountPasswordChangePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + changePasswordBody,) + } +);} + + + + +export const getAllauthBrowserV1AccountPasswordChangePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AccountPasswordChangePost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ChangePasswordBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AccountPasswordChangePost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AccountPasswordChangePostMutationResult = NonNullable>> + export type AllauthBrowserV1AccountPasswordChangePostMutationBody = ChangePasswordBody + export type AllauthBrowserV1AccountPasswordChangePostMutationError = ErrorResponse | AuthenticationResponse + + /** + * @summary Change password + */ +export const useAllauthBrowserV1AccountPasswordChangePost = (options?: { mutation?:UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AccountPasswordChangePostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * In order to change the password of an account, the current and new +password must be provider. However, accounts that were created by +signing up using a third-party provider do not have a password set. In +that case, the current password is not required. + + * @summary Change password + */ +export type allauthAppV1AccountPasswordChangePostResponse400 = { + data: ErrorResponse + status: 400 +} + +export type allauthAppV1AccountPasswordChangePostResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AccountPasswordChangePostResponseComposite = allauthAppV1AccountPasswordChangePostResponse400 | allauthAppV1AccountPasswordChangePostResponse401; + +export type allauthAppV1AccountPasswordChangePostResponse = allauthAppV1AccountPasswordChangePostResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AccountPasswordChangePostUrl = () => { + + + + + return `/api/v2/allauth/app/v1/account/password/change` +} + +export const allauthAppV1AccountPasswordChangePost = async (changePasswordBody: ChangePasswordBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AccountPasswordChangePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + changePasswordBody,) + } +);} + + + + +export const getAllauthAppV1AccountPasswordChangePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext> => { + +const mutationKey = ['allauthAppV1AccountPasswordChangePost']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ChangePasswordBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AccountPasswordChangePost(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AccountPasswordChangePostMutationResult = NonNullable>> + export type AllauthAppV1AccountPasswordChangePostMutationBody = ChangePasswordBody + export type AllauthAppV1AccountPasswordChangePostMutationError = ErrorResponse | AuthenticationResponse + + /** + * @summary Change password + */ +export const useAllauthAppV1AccountPasswordChangePost = (options?: { mutation?:UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AccountPasswordChangePostMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * @summary List sessions + */ +export type allauthBrowserV1AuthSessionsGetResponse200 = { + data: SessionsResponse + status: 200 +} + +export type allauthBrowserV1AuthSessionsGetResponseComposite = allauthBrowserV1AuthSessionsGetResponse200; + +export type allauthBrowserV1AuthSessionsGetResponse = allauthBrowserV1AuthSessionsGetResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthSessionsGetUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/sessions` +} + +export const allauthBrowserV1AuthSessionsGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthSessionsGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthBrowserV1AuthSessionsGetQueryKey = () => { + return ['api','v2','allauth','browser','v1','auth','sessions'] as const; + } + + +export const getAllauthBrowserV1AuthSessionsGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthSessionsGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AuthSessionsGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AuthSessionsGetQueryResult = NonNullable>> +export type AllauthBrowserV1AuthSessionsGetQueryError = unknown + + +/** + * @summary List sessions + */ + +export function useAllauthBrowserV1AuthSessionsGet>, TError = unknown>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthBrowserV1AuthSessionsGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * @summary End one or more sessions + */ +export type allauthBrowserV1AuthSessionsDeleteResponse200 = { + data: SessionsResponse + status: 200 +} + +export type allauthBrowserV1AuthSessionsDeleteResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthBrowserV1AuthSessionsDeleteResponseComposite = allauthBrowserV1AuthSessionsDeleteResponse200 | allauthBrowserV1AuthSessionsDeleteResponse401; + +export type allauthBrowserV1AuthSessionsDeleteResponse = allauthBrowserV1AuthSessionsDeleteResponseComposite & { + headers: Headers; +} + +export const getAllauthBrowserV1AuthSessionsDeleteUrl = () => { + + + + + return `/api/v2/allauth/browser/v1/auth/sessions` +} + +export const allauthBrowserV1AuthSessionsDelete = async (endSessionsBody: EndSessionsBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthBrowserV1AuthSessionsDeleteUrl(), + { + ...options, + method: 'DELETE', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + endSessionsBody,) + } +);} + + + + +export const getAllauthBrowserV1AuthSessionsDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EndSessionsBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: EndSessionsBody}, TContext> => { + +const mutationKey = ['allauthBrowserV1AuthSessionsDelete']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: EndSessionsBody}> = (props) => { + const {data} = props ?? {}; + + return allauthBrowserV1AuthSessionsDelete(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthBrowserV1AuthSessionsDeleteMutationResult = NonNullable>> + export type AllauthBrowserV1AuthSessionsDeleteMutationBody = EndSessionsBody + export type AllauthBrowserV1AuthSessionsDeleteMutationError = AuthenticationResponse + + /** + * @summary End one or more sessions + */ +export const useAllauthBrowserV1AuthSessionsDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: EndSessionsBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthBrowserV1AuthSessionsDeleteMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * @summary List sessions + */ +export type allauthAppV1AuthSessionsGetResponse200 = { + data: SessionsResponse + status: 200 +} + +export type allauthAppV1AuthSessionsGetResponseComposite = allauthAppV1AuthSessionsGetResponse200; + +export type allauthAppV1AuthSessionsGetResponse = allauthAppV1AuthSessionsGetResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthSessionsGetUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/sessions` +} + +export const allauthAppV1AuthSessionsGet = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthSessionsGetUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAllauthAppV1AuthSessionsGetQueryKey = () => { + return ['api','v2','allauth','app','v1','auth','sessions'] as const; + } + + +export const getAllauthAppV1AuthSessionsGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthSessionsGetQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AuthSessionsGet({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AllauthAppV1AuthSessionsGetQueryResult = NonNullable>> +export type AllauthAppV1AuthSessionsGetQueryError = unknown + + +/** + * @summary List sessions + */ + +export function useAllauthAppV1AuthSessionsGet>, TError = unknown>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAllauthAppV1AuthSessionsGetQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * @summary End one or more sessions + */ +export type allauthAppV1AuthSessionsDeleteResponse200 = { + data: SessionsResponse + status: 200 +} + +export type allauthAppV1AuthSessionsDeleteResponse401 = { + data: AuthenticationResponse + status: 401 +} + +export type allauthAppV1AuthSessionsDeleteResponseComposite = allauthAppV1AuthSessionsDeleteResponse200 | allauthAppV1AuthSessionsDeleteResponse401; + +export type allauthAppV1AuthSessionsDeleteResponse = allauthAppV1AuthSessionsDeleteResponseComposite & { + headers: Headers; +} + +export const getAllauthAppV1AuthSessionsDeleteUrl = () => { + + + + + return `/api/v2/allauth/app/v1/auth/sessions` +} + +export const allauthAppV1AuthSessionsDelete = async (endSessionsBody: EndSessionsBody, options?: RequestInit): Promise => { + + return fetchWithAuth(getAllauthAppV1AuthSessionsDeleteUrl(), + { + ...options, + method: 'DELETE', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + endSessionsBody,) + } +);} + + + + +export const getAllauthAppV1AuthSessionsDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EndSessionsBody}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: EndSessionsBody}, TContext> => { + +const mutationKey = ['allauthAppV1AuthSessionsDelete']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: EndSessionsBody}> = (props) => { + const {data} = props ?? {}; + + return allauthAppV1AuthSessionsDelete(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AllauthAppV1AuthSessionsDeleteMutationResult = NonNullable>> + export type AllauthAppV1AuthSessionsDeleteMutationBody = EndSessionsBody + export type AllauthAppV1AuthSessionsDeleteMutationError = AuthenticationResponse + + /** + * @summary End one or more sessions + */ +export const useAllauthAppV1AuthSessionsDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: EndSessionsBody}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAllauthAppV1AuthSessionsDeleteMutationOptions(options); + + return useMutation(mutationOptions ); + } + \ No newline at end of file diff --git a/jsapp/js/api/react-query/authentication-allauth-headless/msw.ts b/jsapp/js/api/react-query/authentication-allauth-headless/msw.ts new file mode 100644 index 0000000000..aa7dc99c11 --- /dev/null +++ b/jsapp/js/api/react-query/authentication-allauth-headless/msw.ts @@ -0,0 +1,1114 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import type { + AuthenticatedByCodeResponse +} from '../../models/authenticatedByCodeResponse'; + +import type { + AuthenticatedByPasswordAnd2FAResponse +} from '../../models/authenticatedByPasswordAnd2FAResponse'; + +import type { + AuthenticatedByPasswordResponse +} from '../../models/authenticatedByPasswordResponse'; + +import type { + AuthenticatedResponse +} from '../../models/authenticatedResponse'; + +import { + AuthenticatorType +} from '../../models/authenticatorType'; + +import type { + AuthenticatorsResponse +} from '../../models/authenticatorsResponse'; + +import type { + ConfigurationResponse +} from '../../models/configurationResponse'; + +import type { + EmailAddressesResponse +} from '../../models/emailAddressesResponse'; + +import type { + EmailVerificationInfoResponse +} from '../../models/emailVerificationInfoResponse'; + +import type { + PasswordResetInfoResponse +} from '../../models/passwordResetInfoResponse'; + +import type { + PhoneNumberChangeResponse +} from '../../models/phoneNumberChangeResponse'; + +import type { + PhoneNumbersResponse +} from '../../models/phoneNumbersResponse'; + +import type { + ProviderAccountsResponse +} from '../../models/providerAccountsResponse'; + +import type { + ProviderSignupResponse +} from '../../models/providerSignupResponse'; + +import type { + RecoveryCodesAuthenticator +} from '../../models/recoveryCodesAuthenticator'; + +import type { + RecoveryCodesResponse +} from '../../models/recoveryCodesResponse'; + +import type { + RefreshTokenResponse +} from '../../models/refreshTokenResponse'; + +import type { + SessionsResponse +} from '../../models/sessionsResponse'; + +import type { + StatusOKResponse +} from '../../models/statusOKResponse'; + +import type { + TOTPAuthenticator +} from '../../models/tOTPAuthenticator'; + +import type { + TOTPAuthenticatorResponse +} from '../../models/tOTPAuthenticatorResponse'; + +import type { + WebAuthnAuthenticator +} from '../../models/webAuthnAuthenticator'; + + +export const getApiV2AllauthBrowserV1ConfigGetResponseMock = (overrideResponse: Partial< ConfigurationResponse > = {}): ConfigurationResponse => ({data: {account: {login_methods: faker.helpers.arrayElement([faker.helpers.arrayElements(['email','username'] as const), undefined]), is_open_for_signup: faker.datatype.boolean(), email_verification_by_code_enabled: faker.datatype.boolean(), login_by_code_enabled: faker.datatype.boolean(), password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, socialaccount: faker.helpers.arrayElement([{providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}))}, undefined]), mfa: faker.helpers.arrayElement([{supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType))}, undefined]), usersessions: faker.helpers.arrayElement([{track_activity: faker.datatype.boolean()}, undefined])}, status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthAppV1ConfigGetResponseMock = (overrideResponse: Partial< ConfigurationResponse > = {}): ConfigurationResponse => ({data: {account: {login_methods: faker.helpers.arrayElement([faker.helpers.arrayElements(['email','username'] as const), undefined]), is_open_for_signup: faker.datatype.boolean(), email_verification_by_code_enabled: faker.datatype.boolean(), login_by_code_enabled: faker.datatype.boolean(), password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, socialaccount: faker.helpers.arrayElement([{providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}))}, undefined]), mfa: faker.helpers.arrayElement([{supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType))}, undefined]), usersessions: faker.helpers.arrayElement([{track_activity: faker.datatype.boolean()}, undefined])}, status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthLoginPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthLoginPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthSignupPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthSignupPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock = (overrideResponse: Partial< EmailVerificationInfoResponse > = {}): EmailVerificationInfoResponse => ({status: faker.helpers.arrayElement([200] as const), data: {email: faker.string.alpha({length: {min: 10, max: 20}}), user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}}, meta: {is_authenticating: faker.datatype.boolean()}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock = (overrideResponse: Partial< EmailVerificationInfoResponse > = {}): EmailVerificationInfoResponse => ({status: faker.helpers.arrayElement([200] as const), data: {email: faker.string.alpha({length: {min: 10, max: 20}}), user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}}, meta: {is_authenticating: faker.datatype.boolean()}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthReauthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock = (overrideResponse: Partial< PasswordResetInfoResponse > = {}): PasswordResetInfoResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: faker.helpers.arrayElement([{id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, undefined])}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthPasswordResetGetResponseMock = (overrideResponse: Partial< PasswordResetInfoResponse > = {}): PasswordResetInfoResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: faker.helpers.arrayElement([{id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, undefined])}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthPasswordResetPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthProviderTokenPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock = (overrideResponse: Partial< ProviderSignupResponse > = {}): ProviderSignupResponse => ({status: faker.helpers.arrayElement([200] as const), data: {email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), account: {uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}}, user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthProviderSignupGetResponseMock = (overrideResponse: Partial< ProviderSignupResponse > = {}): ProviderSignupResponse => ({status: faker.helpers.arrayElement([200] as const), data: {email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), account: {uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}}, user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthProviderSignupPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordAnd2FAResponse > = {}): AuthenticatedByPasswordAnd2FAResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordAnd2FAResponse > = {}): AuthenticatedByPasswordAnd2FAResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordAnd2FAResponse > = {}): AuthenticatedByPasswordAnd2FAResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordAnd2FAResponse > = {}): AuthenticatedByPasswordAnd2FAResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock = (overrideResponse: Partial< AuthenticatedByCodeResponse > = {}): AuthenticatedByCodeResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock = (overrideResponse: Partial< AuthenticatedByCodeResponse > = {}): AuthenticatedByCodeResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountProvidersGetResponseMock = (overrideResponse: Partial< ProviderAccountsResponse > = {}): ProviderAccountsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}})), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock = (overrideResponse: Partial< ProviderAccountsResponse > = {}): ProviderAccountsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}})), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountProvidersGetResponseMock = (overrideResponse: Partial< ProviderAccountsResponse > = {}): ProviderAccountsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}})), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountProvidersDeleteResponseMock = (overrideResponse: Partial< ProviderAccountsResponse > = {}): ProviderAccountsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}})), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountEmailGetResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountEmailPostResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountEmailPutResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountEmailPatchResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountEmailGetResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountEmailPostResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountEmailPutResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountEmailPatchResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountEmailDeleteResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountPhoneGetResponseMock = (overrideResponse: Partial< PhoneNumbersResponse > = {}): PhoneNumbersResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({phone: faker.string.alpha({length: {min: 10, max: 20}}), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountPhonePostResponseMock = (overrideResponse: Partial< PhoneNumberChangeResponse > = {}): PhoneNumberChangeResponse => ({status: faker.helpers.arrayElement([202] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({phone: faker.string.alpha({length: {min: 10, max: 20}}), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountPhoneGetResponseMock = (overrideResponse: Partial< PhoneNumbersResponse > = {}): PhoneNumbersResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({phone: faker.string.alpha({length: {min: 10, max: 20}}), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountPhonePostResponseMock = (overrideResponse: Partial< PhoneNumberChangeResponse > = {}): PhoneNumberChangeResponse => ({status: faker.helpers.arrayElement([202] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({phone: faker.string.alpha({length: {min: 10, max: 20}}), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = (overrideResponse: Partial = {}): TOTPAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}); + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = (overrideResponse: Partial = {}): RecoveryCodesAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['recovery_codes'] as const), total_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), unused_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},}, ...overrideResponse}); + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = (overrideResponse: Partial = {}): WebAuthnAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['webauthn'] as const), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), name: faker.string.alpha({length: {min: 10, max: 20}}), is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},}, ...overrideResponse}); + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock = (overrideResponse: Partial< AuthenticatorsResponse > = {}): AuthenticatorsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock()},{...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock()},{...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock()},]))), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = (overrideResponse: Partial = {}): TOTPAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}); + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = (overrideResponse: Partial = {}): RecoveryCodesAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['recovery_codes'] as const), total_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), unused_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},}, ...overrideResponse}); + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = (overrideResponse: Partial = {}): WebAuthnAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['webauthn'] as const), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), name: faker.string.alpha({length: {min: 10, max: 20}}), is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},}, ...overrideResponse}); + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock = (overrideResponse: Partial< AuthenticatorsResponse > = {}): AuthenticatorsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock()},{...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock()},{...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock()},]))), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock = (overrideResponse: Partial< TOTPAuthenticatorResponse > = {}): TOTPAuthenticatorResponse => ({status: faker.helpers.arrayElement([200] as const), meta: faker.helpers.arrayElement([{recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), data: {...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock = (overrideResponse: Partial< TOTPAuthenticatorResponse > = {}): TOTPAuthenticatorResponse => ({status: faker.helpers.arrayElement([200] as const), meta: faker.helpers.arrayElement([{recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), data: {...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock = (overrideResponse: Partial< TOTPAuthenticatorResponse > = {}): TOTPAuthenticatorResponse => ({status: faker.helpers.arrayElement([200] as const), meta: faker.helpers.arrayElement([{recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), data: {...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock = (overrideResponse: Partial< TOTPAuthenticatorResponse > = {}): TOTPAuthenticatorResponse => ({status: faker.helpers.arrayElement([200] as const), meta: faker.helpers.arrayElement([{recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), data: {...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock = (overrideResponse: Partial< RecoveryCodesResponse > = {}): RecoveryCodesResponse => ({status: faker.helpers.arrayElement([200] as const), data: {...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['recovery_codes'] as const), total_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), unused_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},},...{unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}})))},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock = (overrideResponse: Partial< RecoveryCodesResponse > = {}): RecoveryCodesResponse => ({status: faker.helpers.arrayElement([200] as const), data: {...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['recovery_codes'] as const), total_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), unused_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},},...{unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}})))},}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthSessionGetResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthSessionGetResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) + +export const getApiV2AllauthAppV1TokensRefreshPostResponseMock = (overrideResponse: Partial< RefreshTokenResponse > = {}): RefreshTokenResponse => ({status: faker.helpers.arrayElement([200] as const), data: {access_token: faker.string.alpha({length: {min: 10, max: 20}}), refresh_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthSessionsGetResponseMock = (overrideResponse: Partial< SessionsResponse > = {}): SessionsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user_agent: faker.string.alpha({length: {min: 10, max: 20}}), ip: faker.string.alpha({length: {min: 10, max: 20}}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), is_current: faker.datatype.boolean(), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), last_seen_at: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined])})), ...overrideResponse}) + +export const getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock = (overrideResponse: Partial< SessionsResponse > = {}): SessionsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user_agent: faker.string.alpha({length: {min: 10, max: 20}}), ip: faker.string.alpha({length: {min: 10, max: 20}}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), is_current: faker.datatype.boolean(), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), last_seen_at: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined])})), ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthSessionsGetResponseMock = (overrideResponse: Partial< SessionsResponse > = {}): SessionsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user_agent: faker.string.alpha({length: {min: 10, max: 20}}), ip: faker.string.alpha({length: {min: 10, max: 20}}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), is_current: faker.datatype.boolean(), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), last_seen_at: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined])})), ...overrideResponse}) + +export const getApiV2AllauthAppV1AuthSessionsDeleteResponseMock = (overrideResponse: Partial< SessionsResponse > = {}): SessionsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user_agent: faker.string.alpha({length: {min: 10, max: 20}}), ip: faker.string.alpha({length: {min: 10, max: 20}}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), is_current: faker.datatype.boolean(), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), last_seen_at: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined])})), ...overrideResponse}) + + +export const getApiV2AllauthBrowserV1ConfigGetMockHandler = (overrideResponse?: ConfigurationResponse | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/config', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1ConfigGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1ConfigGetMockHandler = (overrideResponse?: ConfigurationResponse | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse)) => { + return http.get('*/api/v2/allauth/app/v1/config', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1ConfigGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthLoginPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/login', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthLoginPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthLoginPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/login', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthLoginPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthSignupPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthSignupPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthSignupPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthSignupPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler = (overrideResponse?: EmailVerificationInfoResponse | ((info: Parameters[1]>[0]) => Promise | EmailVerificationInfoResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler = (overrideResponse?: EmailVerificationInfoResponse | ((info: Parameters[1]>[0]) => Promise | EmailVerificationInfoResponse)) => { + return http.get('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/email/verify/resend', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/email/verify/resend', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/phone/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify/resend', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/phone/verify/resend', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/reauthenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthReauthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/reauthenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthReauthenticatePostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/password/request', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/password/request', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler = (overrideResponse?: PasswordResetInfoResponse | ((info: Parameters[1]>[0]) => Promise | PasswordResetInfoResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthPasswordResetGetMockHandler = (overrideResponse?: PasswordResetInfoResponse | ((info: Parameters[1]>[0]) => Promise | PasswordResetInfoResponse)) => { + return http.get('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthPasswordResetGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthPasswordResetPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthPasswordResetPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/redirect', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/token', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthProviderTokenPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/provider/token', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthProviderTokenPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler = (overrideResponse?: ProviderSignupResponse | ((info: Parameters[1]>[0]) => Promise | ProviderSignupResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthProviderSignupGetMockHandler = (overrideResponse?: ProviderSignupResponse | ((info: Parameters[1]>[0]) => Promise | ProviderSignupResponse)) => { + return http.get('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthProviderSignupGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthProviderSignupPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthProviderSignupPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordAnd2FAResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordAnd2FAResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/2fa/authenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordAnd2FAResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordAnd2FAResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/2fa/authenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordAnd2FAResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordAnd2FAResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/2fa/reauthenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordAnd2FAResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordAnd2FAResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/2fa/reauthenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler = (overrideResponse?: AuthenticatedByCodeResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByCodeResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/auth/code/confirm', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler = (overrideResponse?: AuthenticatedByCodeResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByCodeResponse)) => { + return http.post('*/api/v2/allauth/app/v1/auth/code/confirm', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountProvidersGetMockHandler = (overrideResponse?: ProviderAccountsResponse | ((info: Parameters[1]>[0]) => Promise | ProviderAccountsResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/account/providers', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountProvidersGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler = (overrideResponse?: ProviderAccountsResponse | ((info: Parameters[1]>[0]) => Promise | ProviderAccountsResponse)) => { + return http.delete('*/api/v2/allauth/browser/v1/account/providers', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountProvidersGetMockHandler = (overrideResponse?: ProviderAccountsResponse | ((info: Parameters[1]>[0]) => Promise | ProviderAccountsResponse)) => { + return http.get('*/api/v2/allauth/app/v1/account/providers', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountProvidersGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountProvidersDeleteMockHandler = (overrideResponse?: ProviderAccountsResponse | ((info: Parameters[1]>[0]) => Promise | ProviderAccountsResponse)) => { + return http.delete('*/api/v2/allauth/app/v1/account/providers', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountProvidersDeleteResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailGetMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountEmailGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailPostMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountEmailPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailPutMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { + return http.put('*/api/v2/allauth/browser/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountEmailPutResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailPatchMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { + return http.patch('*/api/v2/allauth/browser/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountEmailPatchResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { + return http.delete('*/api/v2/allauth/browser/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountEmailGetMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { + return http.get('*/api/v2/allauth/app/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountEmailGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountEmailPostMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { + return http.post('*/api/v2/allauth/app/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountEmailPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountEmailPutMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { + return http.put('*/api/v2/allauth/app/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountEmailPutResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountEmailPatchMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { + return http.patch('*/api/v2/allauth/app/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountEmailPatchResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountEmailDeleteMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { + return http.delete('*/api/v2/allauth/app/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountEmailDeleteResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountPhoneGetMockHandler = (overrideResponse?: PhoneNumbersResponse | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/account/phone', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountPhoneGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountPhonePostMockHandler = (overrideResponse?: PhoneNumberChangeResponse | ((info: Parameters[1]>[0]) => Promise | PhoneNumberChangeResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/account/phone', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountPhonePostResponseMock()), + { status: 202, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountPhoneGetMockHandler = (overrideResponse?: PhoneNumbersResponse | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse)) => { + return http.get('*/api/v2/allauth/app/v1/account/phone', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountPhoneGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountPhonePostMockHandler = (overrideResponse?: PhoneNumberChangeResponse | ((info: Parameters[1]>[0]) => Promise | PhoneNumberChangeResponse)) => { + return http.post('*/api/v2/allauth/app/v1/account/phone', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountPhonePostResponseMock()), + { status: 202, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler = (overrideResponse?: AuthenticatorsResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatorsResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler = (overrideResponse?: AuthenticatorsResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatorsResponse)) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler = (overrideResponse?: TOTPAuthenticatorResponse | ((info: Parameters[1]>[0]) => Promise | TOTPAuthenticatorResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler = (overrideResponse?: TOTPAuthenticatorResponse | ((info: Parameters[1]>[0]) => Promise | TOTPAuthenticatorResponse)) => { + return http.post('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { + return http.delete('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler = (overrideResponse?: TOTPAuthenticatorResponse | ((info: Parameters[1]>[0]) => Promise | TOTPAuthenticatorResponse)) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler = (overrideResponse?: TOTPAuthenticatorResponse | ((info: Parameters[1]>[0]) => Promise | TOTPAuthenticatorResponse)) => { + return http.post('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { + return http.delete('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler = (overrideResponse?: RecoveryCodesResponse | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { + return http.post('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler = (overrideResponse?: RecoveryCodesResponse | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse)) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { + return http.post('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionGetMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/auth/session', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthSessionGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { + return http.delete('*/api/v2/allauth/browser/v1/auth/session', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AllauthAppV1AuthSessionGetMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { + return http.get('*/api/v2/allauth/app/v1/auth/session', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthSessionGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthSessionDeleteMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { + return http.delete('*/api/v2/allauth/app/v1/auth/session', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AllauthAppV1TokensRefreshPostMockHandler = (overrideResponse?: RefreshTokenResponse | ((info: Parameters[1]>[0]) => Promise | RefreshTokenResponse)) => { + return http.post('*/api/v2/allauth/app/v1/tokens/refresh', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1TokensRefreshPostResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { + return http.post('*/api/v2/allauth/browser/v1/account/password/change', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AllauthAppV1AccountPasswordChangePostMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { + return http.post('*/api/v2/allauth/app/v1/account/password/change', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionsGetMockHandler = (overrideResponse?: SessionsResponse | ((info: Parameters[1]>[0]) => Promise | SessionsResponse)) => { + return http.get('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthSessionsGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler = (overrideResponse?: SessionsResponse | ((info: Parameters[1]>[0]) => Promise | SessionsResponse)) => { + return http.delete('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthSessionsGetMockHandler = (overrideResponse?: SessionsResponse | ((info: Parameters[1]>[0]) => Promise | SessionsResponse)) => { + return http.get('*/api/v2/allauth/app/v1/auth/sessions', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthSessionsGetResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AllauthAppV1AuthSessionsDeleteMockHandler = (overrideResponse?: SessionsResponse | ((info: Parameters[1]>[0]) => Promise | SessionsResponse)) => { + return http.delete('*/api/v2/allauth/app/v1/auth/sessions', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AllauthAppV1AuthSessionsDeleteResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} +export const getAuthenticationAllauthHeadlessMock = () => [ + getApiV2AllauthBrowserV1ConfigGetMockHandler(), + getApiV2AllauthAppV1ConfigGetMockHandler(), + getApiV2AllauthBrowserV1AuthLoginPostMockHandler(), + getApiV2AllauthAppV1AuthLoginPostMockHandler(), + getApiV2AllauthBrowserV1AuthSignupPostMockHandler(), + getApiV2AllauthAppV1AuthSignupPostMockHandler(), + getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler(), + getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler(), + getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler(), + getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler(), + getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler(), + getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler(), + getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler(), + getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler(), + getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler(), + getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler(), + getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler(), + getApiV2AllauthAppV1AuthReauthenticatePostMockHandler(), + getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler(), + getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler(), + getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler(), + getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler(), + getApiV2AllauthAppV1AuthPasswordResetGetMockHandler(), + getApiV2AllauthAppV1AuthPasswordResetPostMockHandler(), + getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler(), + getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler(), + getApiV2AllauthAppV1AuthProviderTokenPostMockHandler(), + getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler(), + getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler(), + getApiV2AllauthAppV1AuthProviderSignupGetMockHandler(), + getApiV2AllauthAppV1AuthProviderSignupPostMockHandler(), + getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler(), + getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler(), + getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler(), + getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler(), + getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler(), + getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler(), + getApiV2AllauthBrowserV1AccountProvidersGetMockHandler(), + getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler(), + getApiV2AllauthAppV1AccountProvidersGetMockHandler(), + getApiV2AllauthAppV1AccountProvidersDeleteMockHandler(), + getApiV2AllauthBrowserV1AccountEmailGetMockHandler(), + getApiV2AllauthBrowserV1AccountEmailPostMockHandler(), + getApiV2AllauthBrowserV1AccountEmailPutMockHandler(), + getApiV2AllauthBrowserV1AccountEmailPatchMockHandler(), + getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler(), + getApiV2AllauthAppV1AccountEmailGetMockHandler(), + getApiV2AllauthAppV1AccountEmailPostMockHandler(), + getApiV2AllauthAppV1AccountEmailPutMockHandler(), + getApiV2AllauthAppV1AccountEmailPatchMockHandler(), + getApiV2AllauthAppV1AccountEmailDeleteMockHandler(), + getApiV2AllauthBrowserV1AccountPhoneGetMockHandler(), + getApiV2AllauthBrowserV1AccountPhonePostMockHandler(), + getApiV2AllauthAppV1AccountPhoneGetMockHandler(), + getApiV2AllauthAppV1AccountPhonePostMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler(), + getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler(), + getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler(), + getApiV2AllauthBrowserV1AuthSessionGetMockHandler(), + getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler(), + getApiV2AllauthAppV1AuthSessionGetMockHandler(), + getApiV2AllauthAppV1AuthSessionDeleteMockHandler(), + getApiV2AllauthAppV1TokensRefreshPostMockHandler(), + getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler(), + getApiV2AllauthAppV1AccountPasswordChangePostMockHandler(), + getApiV2AllauthBrowserV1AuthSessionsGetMockHandler(), + getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler(), + getApiV2AllauthAppV1AuthSessionsGetMockHandler(), + getApiV2AllauthAppV1AuthSessionsDeleteMockHandler() +] diff --git a/jsapp/js/api/react-query/configuration/configuration.msw.ts b/jsapp/js/api/react-query/configuration/configuration.msw.ts deleted file mode 100644 index 7e57ce7fd7..0000000000 --- a/jsapp/js/api/react-query/configuration/configuration.msw.ts +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import type { EnvironmentResponse } from '../../models/environmentResponse' - -export const getApiV2EnvironmentRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnvironmentResponse => ({ - terms_of_service_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - privacy_policy_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - source_code_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - support_email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - support_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - academy_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - community_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - frontend_min_retry_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - frontend_max_retry_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - use_team_label: faker.datatype.boolean(), - usage_limit_enforcement: faker.datatype.boolean(), - allow_self_account_deletion: faker.datatype.boolean(), - project_history_log_lifespan: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - sector_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ), - operational_purpose_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ), - country_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ), - interface_languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ), - mfa_localized_help_text: faker.string.alpha({ length: { min: 10, max: 20 } }), - mfa_enabled: faker.datatype.boolean(), - mfa_code_length: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - superuser_auth_enforcement: faker.datatype.boolean(), - enable_password_entropy_meter: faker.datatype.boolean(), - enable_custom_password_guidance_text: faker.datatype.boolean(), - custom_password_localized_help_text: faker.string.alpha({ length: { min: 10, max: 20 } }), - project_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - options: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - })), - undefined, - ]), - })), - extra_project_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( - () => ({ - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - options: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - })), - undefined, - ]), - }), - ), - user_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - options: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - })), - undefined, - ]), - })), - social_apps: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - provider: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - client_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - provider_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - asr_mt_features_enabled: faker.datatype.boolean(), - submission_placeholder: faker.string.alpha({ length: { min: 10, max: 20 } }), - stripe_public_key: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - terms_of_service__sitewidemessage__exists: faker.datatype.boolean(), - open_rosa_server: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2EnvironmentRetrieveMockHandler = ( - overrideResponse?: - | EnvironmentResponse - | ((info: Parameters[1]>[0]) => Promise | EnvironmentResponse), -) => { - return http.get('*/api/v2/environment/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2EnvironmentRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getConfigurationMock = () => [getApiV2EnvironmentRetrieveMockHandler()] diff --git a/jsapp/js/api/react-query/configuration/configuration.ts b/jsapp/js/api/react-query/configuration/index.ts similarity index 54% rename from jsapp/js/api/react-query/configuration/configuration.ts rename to jsapp/js/api/react-query/configuration/index.ts index c6fac2287d..10005099a0 100644 --- a/jsapp/js/api/react-query/configuration/configuration.ts +++ b/jsapp/js/api/react-query/configuration/index.ts @@ -9,14 +9,26 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { useQuery } from '@tanstack/react-query' -import type { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query' +import { + useQuery +} from '@tanstack/react-query'; +import type { + QueryFunction, + QueryKey, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; -import type { EnvironmentResponse } from '../../models/environmentResponse' +import type { + EnvironmentResponse +} from '../../models/environmentResponse'; + +import { fetchWithAuth } from '../../orval.mutator'; + + +type SecondParameter unknown> = Parameters[1]; -import { fetchWithAuth } from '../../orval.mutator' -type SecondParameter unknown> = Parameters[1] /** * Retrieve Kobo server environment configurations. @@ -34,64 +46,75 @@ export type environmentRetrieveResponse200 = { data: EnvironmentResponse status: 200 } - -export type environmentRetrieveResponseComposite = environmentRetrieveResponse200 - + +export type environmentRetrieveResponseComposite = environmentRetrieveResponse200; + export type environmentRetrieveResponse = environmentRetrieveResponseComposite & { - headers: Headers + headers: Headers; } export const getEnvironmentRetrieveUrl = () => { + + + + return `/api/v2/environment/` } -export const environmentRetrieve = async (options?: RequestInit): Promise => { - return fetchWithAuth(getEnvironmentRetrieveUrl(), { +export const environmentRetrieve = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getEnvironmentRetrieveUrl(), + { ...options, - method: 'GET', - }) -} + method: 'GET' + + + } +);} + + export const getEnvironmentRetrieveQueryKey = () => { - return ['api', 'v2', 'environment'] as const -} + return ['api','v2','environment'] as const; + } + + +export const getEnvironmentRetrieveQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { -export const getEnvironmentRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getEnvironmentRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - environmentRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getEnvironmentRetrieveQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => environmentRetrieve({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } } export type EnvironmentRetrieveQueryResult = NonNullable>> export type EnvironmentRetrieveQueryError = unknown -export function useEnvironmentRetrieve< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { + + +export function useEnvironmentRetrieve>, TError = unknown>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getEnvironmentRetrieveQueryOptions(options) - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - query.queryKey = queryOptions.queryKey + query.queryKey = queryOptions.queryKey ; - return query + return query; } + + + diff --git a/jsapp/js/api/react-query/configuration/msw.ts b/jsapp/js/api/react-query/configuration/msw.ts new file mode 100644 index 0000000000..cc0086b1d8 --- /dev/null +++ b/jsapp/js/api/react-query/configuration/msw.ts @@ -0,0 +1,44 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import type { + EnvironmentResponse +} from '../../models/environmentResponse'; + + +export const getApiV2EnvironmentRetrieveResponseMock = (overrideResponse: Partial< EnvironmentResponse > = {}): EnvironmentResponse => ({terms_of_service_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), privacy_policy_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), source_code_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), support_email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), support_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), academy_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), community_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), frontend_min_retry_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), frontend_max_retry_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), use_team_label: faker.datatype.boolean(), usage_limit_enforcement: faker.datatype.boolean(), allow_self_account_deletion: faker.datatype.boolean(), project_history_log_lifespan: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), sector_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), operational_purpose_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), country_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), interface_languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), mfa_localized_help_text: faker.string.alpha({length: {min: 10, max: 20}}), mfa_enabled: faker.datatype.boolean(), mfa_code_length: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), superuser_auth_enforcement: faker.datatype.boolean(), enable_password_entropy_meter: faker.datatype.boolean(), enable_custom_password_guidance_text: faker.datatype.boolean(), custom_password_localized_help_text: faker.string.alpha({length: {min: 10, max: 20}}), project_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), options: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: { + [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) + }})), undefined])})), extra_project_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), options: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: { + [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) + }})), undefined])})), user_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), options: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: { + [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) + }})), undefined])})), social_apps: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({provider: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.string.alpha({length: {min: 10, max: 20}}), provider_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), asr_mt_features_enabled: faker.datatype.boolean(), submission_placeholder: faker.string.alpha({length: {min: 10, max: 20}}), stripe_public_key: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), terms_of_service__sitewidemessage__exists: faker.datatype.boolean(), open_rosa_server: faker.internet.url(), ...overrideResponse}) + + +export const getApiV2EnvironmentRetrieveMockHandler = (overrideResponse?: EnvironmentResponse | ((info: Parameters[1]>[0]) => Promise | EnvironmentResponse)) => { + return http.get('*/api/v2/environment/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2EnvironmentRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} +export const getConfigurationMock = () => [ + getApiV2EnvironmentRetrieveMockHandler() +] diff --git a/jsapp/js/api/react-query/form-content/form-content.msw.ts b/jsapp/js/api/react-query/form-content/form-content.msw.ts deleted file mode 100644 index 63aa1d2bd5..0000000000 --- a/jsapp/js/api/react-query/form-content/form-content.msw.ts +++ /dev/null @@ -1,548 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import type { AssetSnapshotResponse } from '../../models/assetSnapshotResponse' - -import type { AssetValidContentResponse } from '../../models/assetValidContentResponse' - -import type { ContentResponse } from '../../models/contentResponse' - -import type { OpenRosaXFormResponse } from '../../models/openRosaXFormResponse' - -import type { PaginatedAssetSnapshotResponseList } from '../../models/paginatedAssetSnapshotResponseList' - -export const getApiV2AssetSnapshotsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetSnapshotResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - owner: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - xml: faker.internet.url(), - enketopreviewlink: faker.internet.url(), - asset: faker.internet.url(), - asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - details: { - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - warnings: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - }, - source: { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translation: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AssetSnapshotsCreateResponseMock = ( - overrideResponse: Partial = {}, -): AssetSnapshotResponse => ({ - url: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - owner: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - xml: faker.internet.url(), - enketopreviewlink: faker.internet.url(), - asset: faker.internet.url(), - asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - details: { - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - warnings: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - }, - source: { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translation: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetSnapshotsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetSnapshotResponse => ({ - url: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - owner: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - xml: faker.internet.url(), - enketopreviewlink: faker.internet.url(), - asset: faker.internet.url(), - asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - details: { - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - warnings: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - }, - source: { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translation: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetSnapshotsXformRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): OpenRosaXFormResponse => ({ - html: { - head: faker.helpers.arrayElement([ - { - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - model: faker.helpers.arrayElement([ - { - instance: faker.helpers.arrayElement([ - { - instanceUuid: faker.helpers.arrayElement([ - { - fieldName: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - meta: faker.helpers.arrayElement([ - { - instanceID: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - body: faker.helpers.arrayElement([ - { - input: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - hint: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): OpenRosaXFormResponse => ({ - html: { - head: faker.helpers.arrayElement([ - { - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - model: faker.helpers.arrayElement([ - { - instance: faker.helpers.arrayElement([ - { - instanceUuid: faker.helpers.arrayElement([ - { - fieldName: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - meta: faker.helpers.arrayElement([ - { - instanceID: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - body: faker.helpers.arrayElement([ - { - input: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - hint: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsContentRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ContentResponse => ({ - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - data: { - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - settings: faker.helpers.arrayElement([{}, undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsTableViewRetrieveResponseMock = (): string => faker.word.sample() - -export const getApiV2AssetsValidContentRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetValidContentResponse => ({ - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - data: { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([{}, undefined]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsXlsRetrieveResponseMock = (): string => faker.word.sample() - -export const getApiV2AssetSnapshotsListMockHandler = ( - overrideResponse?: - | PaginatedAssetSnapshotResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetSnapshotResponseList), -) => { - return http.get('*/api/v2/asset_snapshots/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSnapshotsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSnapshotsCreateMockHandler = ( - overrideResponse?: - | AssetSnapshotResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AssetSnapshotResponse), -) => { - return http.post('*/api/v2/asset_snapshots/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSnapshotsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSnapshotsRetrieveMockHandler = ( - overrideResponse?: - | AssetSnapshotResponse - | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse), -) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSnapshotsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSnapshotsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetSnapshotsPreviewRetrieveMockHandler = ( - overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), -) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AssetSnapshotsXformRetrieveMockHandler = ( - overrideResponse?: - | OpenRosaXFormResponse - | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), -) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSnapshotsXformRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler = ( - overrideResponse?: - | OpenRosaXFormResponse - | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), -) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsContentRetrieveMockHandler = ( - overrideResponse?: - | ContentResponse - | ((info: Parameters[1]>[0]) => Promise | ContentResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/content/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsContentRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsTableViewRetrieveMockHandler = ( - overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), -) => { - return http.get('*/api/v2/assets/:uidAsset/table_view/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsTableViewRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsValidContentRetrieveMockHandler = ( - overrideResponse?: - | AssetValidContentResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AssetValidContentResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/valid_content/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsValidContentRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsXlsRetrieveMockHandler = ( - overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), -) => { - return http.get('*/api/v2/assets/:uidAsset/xls/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsXlsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getFormContentMock = () => [ - getApiV2AssetSnapshotsListMockHandler(), - getApiV2AssetSnapshotsCreateMockHandler(), - getApiV2AssetSnapshotsRetrieveMockHandler(), - getApiV2AssetSnapshotsDestroyMockHandler(), - getApiV2AssetSnapshotsPreviewRetrieveMockHandler(), - getApiV2AssetSnapshotsXformRetrieveMockHandler(), - getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler(), - getApiV2AssetsContentRetrieveMockHandler(), - getApiV2AssetsTableViewRetrieveMockHandler(), - getApiV2AssetsValidContentRetrieveMockHandler(), - getApiV2AssetsXlsRetrieveMockHandler(), -] diff --git a/jsapp/js/api/react-query/form-content/form-content.ts b/jsapp/js/api/react-query/form-content/form-content.ts deleted file mode 100644 index 57ce837713..0000000000 --- a/jsapp/js/api/react-query/form-content/form-content.ts +++ /dev/null @@ -1,1035 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { AssetSnapshotCreateRequest } from '../../models/assetSnapshotCreateRequest' - -import type { AssetSnapshotResponse } from '../../models/assetSnapshotResponse' - -import type { AssetSnapshotsListParams } from '../../models/assetSnapshotsListParams' - -import type { AssetSnapshotsRetrieveParams } from '../../models/assetSnapshotsRetrieveParams' - -import type { AssetValidContentResponse } from '../../models/assetValidContentResponse' - -import type { ContentResponse } from '../../models/contentResponse' - -import type { ErrorDetail } from '../../models/errorDetail' - -import type { ErrorObject } from '../../models/errorObject' - -import type { OpenRosaXFormResponse } from '../../models/openRosaXFormResponse' - -import type { PaginatedAssetSnapshotResponseList } from '../../models/paginatedAssetSnapshotResponseList' - -import { fetchWithAuth } from '../../orval.mutator' - -type SecondParameter unknown> = Parameters[1] - -/** - * ## List all snapshots for every asset of a user - - */ -export type assetSnapshotsListResponse200 = { - data: PaginatedAssetSnapshotResponseList - status: 200 -} - -export type assetSnapshotsListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetSnapshotsListResponseComposite = assetSnapshotsListResponse200 | assetSnapshotsListResponse401 - -export type assetSnapshotsListResponse = assetSnapshotsListResponseComposite & { - headers: Headers -} - -export const getAssetSnapshotsListUrl = (params?: AssetSnapshotsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/asset_snapshots/?${stringifiedParams}` : `/api/v2/asset_snapshots/` -} - -export const assetSnapshotsList = async ( - params?: AssetSnapshotsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetSnapshotsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getAssetSnapshotsListQueryKey = (params?: AssetSnapshotsListParams) => { - return ['api', 'v2', 'asset_snapshots', ...(params ? [params] : [])] as const -} - -export const getAssetSnapshotsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: AssetSnapshotsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetSnapshotsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetSnapshotsListQueryResult = NonNullable>> -export type AssetSnapshotsListQueryError = ErrorDetail - -export function useAssetSnapshotsList>, TError = ErrorDetail>( - params?: AssetSnapshotsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetSnapshotsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create an asset snapshot - -When creating an asset snapshot, you must provide either: - -- the asset (as a URI), or -- the source (as a JSON object representing the asset) - -…but not both. - - */ -export type assetSnapshotsCreateResponse201 = { - data: AssetSnapshotResponse - status: 201 -} - -export type assetSnapshotsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetSnapshotsCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetSnapshotsCreateResponseComposite = - | assetSnapshotsCreateResponse201 - | assetSnapshotsCreateResponse400 - | assetSnapshotsCreateResponse401 - -export type assetSnapshotsCreateResponse = assetSnapshotsCreateResponseComposite & { - headers: Headers -} - -export const getAssetSnapshotsCreateUrl = () => { - return `/api/v2/asset_snapshots/` -} - -export const assetSnapshotsCreate = async ( - assetSnapshotCreateRequest: AssetSnapshotCreateRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetSnapshotsCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(assetSnapshotCreateRequest), - }) -} - -export const getAssetSnapshotsCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetSnapshotCreateRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: AssetSnapshotCreateRequest }, - TContext -> => { - const mutationKey = ['assetSnapshotsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: AssetSnapshotCreateRequest } - > = (props) => { - const { data } = props ?? {} - - return assetSnapshotsCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetSnapshotsCreateMutationResult = NonNullable>> -export type AssetSnapshotsCreateMutationBody = AssetSnapshotCreateRequest -export type AssetSnapshotsCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetSnapshotsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetSnapshotCreateRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetSnapshotsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve an asset snapshot - -Note: If the `Content-Type` of the request is set to `application/xml`, the response will -return the XML version of the form, rather than the JSON representation of the asset -snapshot. - - */ -export type assetSnapshotsRetrieveResponse200 = { - data: AssetSnapshotResponse - status: 200 -} - -export type assetSnapshotsRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetSnapshotsRetrieveResponseComposite = - | assetSnapshotsRetrieveResponse200 - | assetSnapshotsRetrieveResponse401 - -export type assetSnapshotsRetrieveResponse = assetSnapshotsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetSnapshotsRetrieveUrl = (uidAssetSnapshot: string, params?: AssetSnapshotsRetrieveParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/asset_snapshots/${uidAssetSnapshot}/?${stringifiedParams}` - : `/api/v2/asset_snapshots/${uidAssetSnapshot}/` -} - -export const assetSnapshotsRetrieve = async ( - uidAssetSnapshot: string, - params?: AssetSnapshotsRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetSnapshotsRetrieveUrl(uidAssetSnapshot, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetSnapshotsRetrieveQueryKey = (uidAssetSnapshot: string, params?: AssetSnapshotsRetrieveParams) => { - return ['api', 'v2', 'asset_snapshots', uidAssetSnapshot, ...(params ? [params] : [])] as const -} - -export const getAssetSnapshotsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAssetSnapshot: string, - params?: AssetSnapshotsRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsRetrieveQueryKey(uidAssetSnapshot, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetSnapshotsRetrieve(uidAssetSnapshot, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAssetSnapshot, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetSnapshotsRetrieveQueryResult = NonNullable>> -export type AssetSnapshotsRetrieveQueryError = ErrorDetail - -export function useAssetSnapshotsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAssetSnapshot: string, - params?: AssetSnapshotsRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetSnapshotsRetrieveQueryOptions(uidAssetSnapshot, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Delete an asset snapshot - - */ -export type assetSnapshotsDestroyResponse204 = { - data: void - status: 204 -} - -export type assetSnapshotsDestroyResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetSnapshotsDestroyResponseComposite = assetSnapshotsDestroyResponse204 | assetSnapshotsDestroyResponse401 - -export type assetSnapshotsDestroyResponse = assetSnapshotsDestroyResponseComposite & { - headers: Headers -} - -export const getAssetSnapshotsDestroyUrl = (uidAssetSnapshot: string) => { - return `/api/v2/asset_snapshots/${uidAssetSnapshot}/` -} - -export const assetSnapshotsDestroy = async ( - uidAssetSnapshot: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetSnapshotsDestroyUrl(uidAssetSnapshot), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetSnapshotsDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAssetSnapshot: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAssetSnapshot: string }, - TContext -> => { - const mutationKey = ['assetSnapshotsDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAssetSnapshot: string } - > = (props) => { - const { uidAssetSnapshot } = props ?? {} - - return assetSnapshotsDestroy(uidAssetSnapshot, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetSnapshotsDestroyMutationResult = NonNullable>> - -export type AssetSnapshotsDestroyMutationError = ErrorDetail - -export const useAssetSnapshotsDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAssetSnapshot: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetSnapshotsDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Asset snapshot preview - -Returns a `302 Found` redirect to the Enketo preview page associated with the asset. - - */ -export type assetSnapshotsPreviewRetrieveResponse302 = { - data: void - status: 302 -} - -export type assetSnapshotsPreviewRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetSnapshotsPreviewRetrieveResponseComposite = - | assetSnapshotsPreviewRetrieveResponse302 - | assetSnapshotsPreviewRetrieveResponse404 - -export type assetSnapshotsPreviewRetrieveResponse = assetSnapshotsPreviewRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetSnapshotsPreviewRetrieveUrl = (uidAssetSnapshot: string) => { - return `/api/v2/asset_snapshots/${uidAssetSnapshot}/preview/` -} - -export const assetSnapshotsPreviewRetrieve = async ( - uidAssetSnapshot: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetSnapshotsPreviewRetrieveUrl(uidAssetSnapshot), { - ...options, - method: 'GET', - }) -} - -export const getAssetSnapshotsPreviewRetrieveQueryKey = (uidAssetSnapshot: string) => { - return ['api', 'v2', 'asset_snapshots', uidAssetSnapshot, 'preview'] as const -} - -export const getAssetSnapshotsPreviewRetrieveQueryOptions = < - TData = Awaited>, - TError = void | ErrorDetail, ->( - uidAssetSnapshot: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsPreviewRetrieveQueryKey(uidAssetSnapshot) - - const queryFn: QueryFunction>> = ({ signal }) => - assetSnapshotsPreviewRetrieve(uidAssetSnapshot, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAssetSnapshot, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetSnapshotsPreviewRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetSnapshotsPreviewRetrieveQueryError = void | ErrorDetail - -export function useAssetSnapshotsPreviewRetrieve< - TData = Awaited>, - TError = void | ErrorDetail, ->( - uidAssetSnapshot: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetSnapshotsPreviewRetrieveQueryOptions(uidAssetSnapshot, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## This route will render the XForm into syntax-highlighted HTML. - -It is useful for debugging pyxform transformations - - */ -export type assetSnapshotsXformRetrieveResponse200 = { - data: OpenRosaXFormResponse - status: 200 -} - -export type assetSnapshotsXformRetrieveResponse404 = { - data: void - status: 404 -} - -export type assetSnapshotsXformRetrieveResponseComposite = - | assetSnapshotsXformRetrieveResponse200 - | assetSnapshotsXformRetrieveResponse404 - -export type assetSnapshotsXformRetrieveResponse = assetSnapshotsXformRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetSnapshotsXformRetrieveUrl = (uidAssetSnapshot: string) => { - return `/api/v2/asset_snapshots/${uidAssetSnapshot}/xform/` -} - -export const assetSnapshotsXformRetrieve = async ( - uidAssetSnapshot: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetSnapshotsXformRetrieveUrl(uidAssetSnapshot), { - ...options, - method: 'GET', - }) -} - -export const getAssetSnapshotsXformRetrieveQueryKey = (uidAssetSnapshot: string) => { - return ['api', 'v2', 'asset_snapshots', uidAssetSnapshot, 'xform'] as const -} - -export const getAssetSnapshotsXformRetrieveQueryOptions = < - TData = Awaited>, - TError = void, ->( - uidAssetSnapshot: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsXformRetrieveQueryKey(uidAssetSnapshot) - - const queryFn: QueryFunction>> = ({ signal }) => - assetSnapshotsXformRetrieve(uidAssetSnapshot, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAssetSnapshot, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetSnapshotsXformRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetSnapshotsXformRetrieveQueryError = void - -export function useAssetSnapshotsXformRetrieve< - TData = Awaited>, - TError = void, ->( - uidAssetSnapshot: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetSnapshotsXformRetrieveQueryOptions(uidAssetSnapshot, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Implement part of the OpenRosa Form List API - -This endpoint is used by Enketo to fetch and return the full XML form. -It behaves like the standard retrieve endpoint but includes an additional `` -node containing the disclaimer, if one exists. - - */ -export type assetSnapshotsXmlWithDisclaimerRetrieveResponse200 = { - data: OpenRosaXFormResponse - status: 200 -} - -export type assetSnapshotsXmlWithDisclaimerRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetSnapshotsXmlWithDisclaimerRetrieveResponseComposite = - | assetSnapshotsXmlWithDisclaimerRetrieveResponse200 - | assetSnapshotsXmlWithDisclaimerRetrieveResponse404 - -export type assetSnapshotsXmlWithDisclaimerRetrieveResponse = - assetSnapshotsXmlWithDisclaimerRetrieveResponseComposite & { - headers: Headers - } - -export const getAssetSnapshotsXmlWithDisclaimerRetrieveUrl = (uidAssetSnapshot: string) => { - return `/api/v2/asset_snapshots/${uidAssetSnapshot}/xml_with_disclaimer/` -} - -export const assetSnapshotsXmlWithDisclaimerRetrieve = async ( - uidAssetSnapshot: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetSnapshotsXmlWithDisclaimerRetrieveUrl(uidAssetSnapshot), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetSnapshotsXmlWithDisclaimerRetrieveQueryKey = (uidAssetSnapshot: string) => { - return ['api', 'v2', 'asset_snapshots', uidAssetSnapshot, 'xml_with_disclaimer'] as const -} - -export const getAssetSnapshotsXmlWithDisclaimerRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAssetSnapshot: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsXmlWithDisclaimerRetrieveQueryKey(uidAssetSnapshot) - - const queryFn: QueryFunction>> = ({ signal }) => - assetSnapshotsXmlWithDisclaimerRetrieve(uidAssetSnapshot, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAssetSnapshot, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetSnapshotsXmlWithDisclaimerRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetSnapshotsXmlWithDisclaimerRetrieveQueryError = ErrorDetail - -export function useAssetSnapshotsXmlWithDisclaimerRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAssetSnapshot: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetSnapshotsXmlWithDisclaimerRetrieveQueryOptions(uidAssetSnapshot, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Return the content of a user's asset. - - */ -export type assetsContentRetrieveResponse200 = { - data: ContentResponse - status: 200 -} - -export type assetsContentRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsContentRetrieveResponseComposite = assetsContentRetrieveResponse200 | assetsContentRetrieveResponse404 - -export type assetsContentRetrieveResponse = assetsContentRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsContentRetrieveUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/content/` -} - -export const assetsContentRetrieve = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsContentRetrieveUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsContentRetrieveQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'content'] as const -} - -export const getAssetsContentRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsContentRetrieveQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsContentRetrieve(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsContentRetrieveQueryResult = NonNullable>> -export type AssetsContentRetrieveQueryError = ErrorDetail - -export function useAssetsContentRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsContentRetrieveQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Return plain HTML of survey in tabular format - - */ -export type assetsTableViewRetrieveResponse200 = { - data: string - status: 200 -} - -export type assetsTableViewRetrieveResponse404 = { - data: void - status: 404 -} - -export type assetsTableViewRetrieveResponseComposite = - | assetsTableViewRetrieveResponse200 - | assetsTableViewRetrieveResponse404 - -export type assetsTableViewRetrieveResponse = assetsTableViewRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsTableViewRetrieveUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/table_view/` -} - -export const assetsTableViewRetrieve = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsTableViewRetrieveUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsTableViewRetrieveQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'table_view'] as const -} - -export const getAssetsTableViewRetrieveQueryOptions = < - TData = Awaited>, - TError = void, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsTableViewRetrieveQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsTableViewRetrieve(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsTableViewRetrieveQueryResult = NonNullable>> -export type AssetsTableViewRetrieveQueryError = void - -export function useAssetsTableViewRetrieve>, TError = void>( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsTableViewRetrieveQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Return valid content for user's asset - - */ -export type assetsValidContentRetrieveResponse200 = { - data: AssetValidContentResponse - status: 200 -} - -export type assetsValidContentRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsValidContentRetrieveResponseComposite = - | assetsValidContentRetrieveResponse200 - | assetsValidContentRetrieveResponse404 - -export type assetsValidContentRetrieveResponse = assetsValidContentRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsValidContentRetrieveUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/valid_content/` -} - -export const assetsValidContentRetrieve = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsValidContentRetrieveUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsValidContentRetrieveQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'valid_content'] as const -} - -export const getAssetsValidContentRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsValidContentRetrieveQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsValidContentRetrieve(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsValidContentRetrieveQueryResult = NonNullable>> -export type AssetsValidContentRetrieveQueryError = ErrorDetail - -export function useAssetsValidContentRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsValidContentRetrieveQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Return plain HTML of survey in tabular format - - */ -export type assetsXlsRetrieveResponse200 = { - data: string - status: 200 -} - -export type assetsXlsRetrieveResponse404 = { - data: void - status: 404 -} - -export type assetsXlsRetrieveResponseComposite = assetsXlsRetrieveResponse200 | assetsXlsRetrieveResponse404 - -export type assetsXlsRetrieveResponse = assetsXlsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsXlsRetrieveUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/xls/` -} - -export const assetsXlsRetrieve = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsXlsRetrieveUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsXlsRetrieveQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'xls'] as const -} - -export const getAssetsXlsRetrieveQueryOptions = >, TError = void>( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsXlsRetrieveQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsXlsRetrieve(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsXlsRetrieveQueryResult = NonNullable>> -export type AssetsXlsRetrieveQueryError = void - -export function useAssetsXlsRetrieve>, TError = void>( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsXlsRetrieveQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} diff --git a/jsapp/js/api/react-query/form-content/index.ts b/jsapp/js/api/react-query/form-content/index.ts new file mode 100644 index 0000000000..a0a4d89921 --- /dev/null +++ b/jsapp/js/api/react-query/form-content/index.ts @@ -0,0 +1,1038 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + AssetSnapshotCreateRequest +} from '../../models/assetSnapshotCreateRequest'; + +import type { + AssetSnapshotResponse +} from '../../models/assetSnapshotResponse'; + +import type { + AssetSnapshotsListParams +} from '../../models/assetSnapshotsListParams'; + +import type { + AssetSnapshotsRetrieveParams +} from '../../models/assetSnapshotsRetrieveParams'; + +import type { + AssetValidContentResponse +} from '../../models/assetValidContentResponse'; + +import type { + ContentResponse +} from '../../models/contentResponse'; + +import type { + ErrorDetail +} from '../../models/errorDetail'; + +import type { + ErrorObject +} from '../../models/errorObject'; + +import type { + OpenRosaXFormResponse +} from '../../models/openRosaXFormResponse'; + +import type { + PaginatedAssetSnapshotResponseList +} from '../../models/paginatedAssetSnapshotResponseList'; + +import { fetchWithAuth } from '../../orval.mutator'; + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * ## List all snapshots for every asset of a user + + */ +export type assetSnapshotsListResponse200 = { + data: PaginatedAssetSnapshotResponseList + status: 200 +} + +export type assetSnapshotsListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetSnapshotsListResponseComposite = assetSnapshotsListResponse200 | assetSnapshotsListResponse401; + +export type assetSnapshotsListResponse = assetSnapshotsListResponseComposite & { + headers: Headers; +} + +export const getAssetSnapshotsListUrl = (params?: AssetSnapshotsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/asset_snapshots/?${stringifiedParams}` : `/api/v2/asset_snapshots/` +} + +export const assetSnapshotsList = async (params?: AssetSnapshotsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSnapshotsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetSnapshotsListQueryKey = (params?: AssetSnapshotsListParams,) => { + return ['api','v2','asset_snapshots', ...(params ? [params]: [])] as const; + } + + +export const getAssetSnapshotsListQueryOptions = >, TError = ErrorDetail>(params?: AssetSnapshotsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetSnapshotsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetSnapshotsListQueryResult = NonNullable>> +export type AssetSnapshotsListQueryError = ErrorDetail + + + +export function useAssetSnapshotsList>, TError = ErrorDetail>( + params?: AssetSnapshotsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetSnapshotsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create an asset snapshot + +When creating an asset snapshot, you must provide either: + +- the asset (as a URI), or +- the source (as a JSON object representing the asset) + +…but not both. + + */ +export type assetSnapshotsCreateResponse201 = { + data: AssetSnapshotResponse + status: 201 +} + +export type assetSnapshotsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetSnapshotsCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetSnapshotsCreateResponseComposite = assetSnapshotsCreateResponse201 | assetSnapshotsCreateResponse400 | assetSnapshotsCreateResponse401; + +export type assetSnapshotsCreateResponse = assetSnapshotsCreateResponseComposite & { + headers: Headers; +} + +export const getAssetSnapshotsCreateUrl = () => { + + + + + return `/api/v2/asset_snapshots/` +} + +export const assetSnapshotsCreate = async (assetSnapshotCreateRequest: AssetSnapshotCreateRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSnapshotsCreateUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + assetSnapshotCreateRequest,) + } +);} + + + + +export const getAssetSnapshotsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetSnapshotCreateRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: AssetSnapshotCreateRequest}, TContext> => { + +const mutationKey = ['assetSnapshotsCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: AssetSnapshotCreateRequest}> = (props) => { + const {data} = props ?? {}; + + return assetSnapshotsCreate(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetSnapshotsCreateMutationResult = NonNullable>> + export type AssetSnapshotsCreateMutationBody = AssetSnapshotCreateRequest + export type AssetSnapshotsCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetSnapshotsCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetSnapshotCreateRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetSnapshotsCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve an asset snapshot + +Note: If the `Content-Type` of the request is set to `application/xml`, the response will +return the XML version of the form, rather than the JSON representation of the asset +snapshot. + + */ +export type assetSnapshotsRetrieveResponse200 = { + data: AssetSnapshotResponse + status: 200 +} + +export type assetSnapshotsRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetSnapshotsRetrieveResponseComposite = assetSnapshotsRetrieveResponse200 | assetSnapshotsRetrieveResponse401; + +export type assetSnapshotsRetrieveResponse = assetSnapshotsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetSnapshotsRetrieveUrl = (uidAssetSnapshot: string, + params?: AssetSnapshotsRetrieveParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/asset_snapshots/${uidAssetSnapshot}/?${stringifiedParams}` : `/api/v2/asset_snapshots/${uidAssetSnapshot}/` +} + +export const assetSnapshotsRetrieve = async (uidAssetSnapshot: string, + params?: AssetSnapshotsRetrieveParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSnapshotsRetrieveUrl(uidAssetSnapshot,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetSnapshotsRetrieveQueryKey = (uidAssetSnapshot: string, + params?: AssetSnapshotsRetrieveParams,) => { + return ['api','v2','asset_snapshots',uidAssetSnapshot, ...(params ? [params]: [])] as const; + } + + +export const getAssetSnapshotsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAssetSnapshot: string, + params?: AssetSnapshotsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsRetrieveQueryKey(uidAssetSnapshot,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetSnapshotsRetrieve(uidAssetSnapshot,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAssetSnapshot), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetSnapshotsRetrieveQueryResult = NonNullable>> +export type AssetSnapshotsRetrieveQueryError = ErrorDetail + + + +export function useAssetSnapshotsRetrieve>, TError = ErrorDetail>( + uidAssetSnapshot: string, + params?: AssetSnapshotsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetSnapshotsRetrieveQueryOptions(uidAssetSnapshot,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Delete an asset snapshot + + */ +export type assetSnapshotsDestroyResponse204 = { + data: void + status: 204 +} + +export type assetSnapshotsDestroyResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetSnapshotsDestroyResponseComposite = assetSnapshotsDestroyResponse204 | assetSnapshotsDestroyResponse401; + +export type assetSnapshotsDestroyResponse = assetSnapshotsDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetSnapshotsDestroyUrl = (uidAssetSnapshot: string,) => { + + + + + return `/api/v2/asset_snapshots/${uidAssetSnapshot}/` +} + +export const assetSnapshotsDestroy = async (uidAssetSnapshot: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSnapshotsDestroyUrl(uidAssetSnapshot), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetSnapshotsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAssetSnapshot: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAssetSnapshot: string}, TContext> => { + +const mutationKey = ['assetSnapshotsDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAssetSnapshot: string}> = (props) => { + const {uidAssetSnapshot} = props ?? {}; + + return assetSnapshotsDestroy(uidAssetSnapshot,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetSnapshotsDestroyMutationResult = NonNullable>> + + export type AssetSnapshotsDestroyMutationError = ErrorDetail + + export const useAssetSnapshotsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAssetSnapshot: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetSnapshotsDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Asset snapshot preview + +Returns a `302 Found` redirect to the Enketo preview page associated with the asset. + + */ +export type assetSnapshotsPreviewRetrieveResponse302 = { + data: void + status: 302 +} + +export type assetSnapshotsPreviewRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetSnapshotsPreviewRetrieveResponseComposite = assetSnapshotsPreviewRetrieveResponse302 | assetSnapshotsPreviewRetrieveResponse404; + +export type assetSnapshotsPreviewRetrieveResponse = assetSnapshotsPreviewRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetSnapshotsPreviewRetrieveUrl = (uidAssetSnapshot: string,) => { + + + + + return `/api/v2/asset_snapshots/${uidAssetSnapshot}/preview/` +} + +export const assetSnapshotsPreviewRetrieve = async (uidAssetSnapshot: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSnapshotsPreviewRetrieveUrl(uidAssetSnapshot), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetSnapshotsPreviewRetrieveQueryKey = (uidAssetSnapshot: string,) => { + return ['api','v2','asset_snapshots',uidAssetSnapshot,'preview'] as const; + } + + +export const getAssetSnapshotsPreviewRetrieveQueryOptions = >, TError = void | ErrorDetail>(uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsPreviewRetrieveQueryKey(uidAssetSnapshot); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetSnapshotsPreviewRetrieve(uidAssetSnapshot, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAssetSnapshot), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetSnapshotsPreviewRetrieveQueryResult = NonNullable>> +export type AssetSnapshotsPreviewRetrieveQueryError = void | ErrorDetail + + + +export function useAssetSnapshotsPreviewRetrieve>, TError = void | ErrorDetail>( + uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetSnapshotsPreviewRetrieveQueryOptions(uidAssetSnapshot,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## This route will render the XForm into syntax-highlighted HTML. + +It is useful for debugging pyxform transformations + + */ +export type assetSnapshotsXformRetrieveResponse200 = { + data: OpenRosaXFormResponse + status: 200 +} + +export type assetSnapshotsXformRetrieveResponse404 = { + data: void + status: 404 +} + +export type assetSnapshotsXformRetrieveResponseComposite = assetSnapshotsXformRetrieveResponse200 | assetSnapshotsXformRetrieveResponse404; + +export type assetSnapshotsXformRetrieveResponse = assetSnapshotsXformRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetSnapshotsXformRetrieveUrl = (uidAssetSnapshot: string,) => { + + + + + return `/api/v2/asset_snapshots/${uidAssetSnapshot}/xform/` +} + +export const assetSnapshotsXformRetrieve = async (uidAssetSnapshot: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSnapshotsXformRetrieveUrl(uidAssetSnapshot), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetSnapshotsXformRetrieveQueryKey = (uidAssetSnapshot: string,) => { + return ['api','v2','asset_snapshots',uidAssetSnapshot,'xform'] as const; + } + + +export const getAssetSnapshotsXformRetrieveQueryOptions = >, TError = void>(uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsXformRetrieveQueryKey(uidAssetSnapshot); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetSnapshotsXformRetrieve(uidAssetSnapshot, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAssetSnapshot), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetSnapshotsXformRetrieveQueryResult = NonNullable>> +export type AssetSnapshotsXformRetrieveQueryError = void + + + +export function useAssetSnapshotsXformRetrieve>, TError = void>( + uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetSnapshotsXformRetrieveQueryOptions(uidAssetSnapshot,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Implement part of the OpenRosa Form List API + +This endpoint is used by Enketo to fetch and return the full XML form. +It behaves like the standard retrieve endpoint but includes an additional `` +node containing the disclaimer, if one exists. + + */ +export type assetSnapshotsXmlWithDisclaimerRetrieveResponse200 = { + data: OpenRosaXFormResponse + status: 200 +} + +export type assetSnapshotsXmlWithDisclaimerRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetSnapshotsXmlWithDisclaimerRetrieveResponseComposite = assetSnapshotsXmlWithDisclaimerRetrieveResponse200 | assetSnapshotsXmlWithDisclaimerRetrieveResponse404; + +export type assetSnapshotsXmlWithDisclaimerRetrieveResponse = assetSnapshotsXmlWithDisclaimerRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetSnapshotsXmlWithDisclaimerRetrieveUrl = (uidAssetSnapshot: string,) => { + + + + + return `/api/v2/asset_snapshots/${uidAssetSnapshot}/xml_with_disclaimer/` +} + +export const assetSnapshotsXmlWithDisclaimerRetrieve = async (uidAssetSnapshot: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSnapshotsXmlWithDisclaimerRetrieveUrl(uidAssetSnapshot), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetSnapshotsXmlWithDisclaimerRetrieveQueryKey = (uidAssetSnapshot: string,) => { + return ['api','v2','asset_snapshots',uidAssetSnapshot,'xml_with_disclaimer'] as const; + } + + +export const getAssetSnapshotsXmlWithDisclaimerRetrieveQueryOptions = >, TError = ErrorDetail>(uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsXmlWithDisclaimerRetrieveQueryKey(uidAssetSnapshot); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetSnapshotsXmlWithDisclaimerRetrieve(uidAssetSnapshot, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAssetSnapshot), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetSnapshotsXmlWithDisclaimerRetrieveQueryResult = NonNullable>> +export type AssetSnapshotsXmlWithDisclaimerRetrieveQueryError = ErrorDetail + + + +export function useAssetSnapshotsXmlWithDisclaimerRetrieve>, TError = ErrorDetail>( + uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetSnapshotsXmlWithDisclaimerRetrieveQueryOptions(uidAssetSnapshot,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Return the content of a user's asset. + + */ +export type assetsContentRetrieveResponse200 = { + data: ContentResponse + status: 200 +} + +export type assetsContentRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsContentRetrieveResponseComposite = assetsContentRetrieveResponse200 | assetsContentRetrieveResponse404; + +export type assetsContentRetrieveResponse = assetsContentRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsContentRetrieveUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/content/` +} + +export const assetsContentRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsContentRetrieveUrl(uidAsset), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsContentRetrieveQueryKey = (uidAsset: string,) => { + return ['api','v2','assets',uidAsset,'content'] as const; + } + + +export const getAssetsContentRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsContentRetrieveQueryKey(uidAsset); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsContentRetrieve(uidAsset, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsContentRetrieveQueryResult = NonNullable>> +export type AssetsContentRetrieveQueryError = ErrorDetail + + + +export function useAssetsContentRetrieve>, TError = ErrorDetail>( + uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsContentRetrieveQueryOptions(uidAsset,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Return plain HTML of survey in tabular format + + */ +export type assetsTableViewRetrieveResponse200 = { + data: string + status: 200 +} + +export type assetsTableViewRetrieveResponse404 = { + data: void + status: 404 +} + +export type assetsTableViewRetrieveResponseComposite = assetsTableViewRetrieveResponse200 | assetsTableViewRetrieveResponse404; + +export type assetsTableViewRetrieveResponse = assetsTableViewRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsTableViewRetrieveUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/table_view/` +} + +export const assetsTableViewRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsTableViewRetrieveUrl(uidAsset), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsTableViewRetrieveQueryKey = (uidAsset: string,) => { + return ['api','v2','assets',uidAsset,'table_view'] as const; + } + + +export const getAssetsTableViewRetrieveQueryOptions = >, TError = void>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsTableViewRetrieveQueryKey(uidAsset); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsTableViewRetrieve(uidAsset, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsTableViewRetrieveQueryResult = NonNullable>> +export type AssetsTableViewRetrieveQueryError = void + + + +export function useAssetsTableViewRetrieve>, TError = void>( + uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsTableViewRetrieveQueryOptions(uidAsset,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Return valid content for user's asset + + */ +export type assetsValidContentRetrieveResponse200 = { + data: AssetValidContentResponse + status: 200 +} + +export type assetsValidContentRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsValidContentRetrieveResponseComposite = assetsValidContentRetrieveResponse200 | assetsValidContentRetrieveResponse404; + +export type assetsValidContentRetrieveResponse = assetsValidContentRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsValidContentRetrieveUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/valid_content/` +} + +export const assetsValidContentRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsValidContentRetrieveUrl(uidAsset), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsValidContentRetrieveQueryKey = (uidAsset: string,) => { + return ['api','v2','assets',uidAsset,'valid_content'] as const; + } + + +export const getAssetsValidContentRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsValidContentRetrieveQueryKey(uidAsset); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsValidContentRetrieve(uidAsset, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsValidContentRetrieveQueryResult = NonNullable>> +export type AssetsValidContentRetrieveQueryError = ErrorDetail + + + +export function useAssetsValidContentRetrieve>, TError = ErrorDetail>( + uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsValidContentRetrieveQueryOptions(uidAsset,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Return plain HTML of survey in tabular format + + */ +export type assetsXlsRetrieveResponse200 = { + data: string + status: 200 +} + +export type assetsXlsRetrieveResponse404 = { + data: void + status: 404 +} + +export type assetsXlsRetrieveResponseComposite = assetsXlsRetrieveResponse200 | assetsXlsRetrieveResponse404; + +export type assetsXlsRetrieveResponse = assetsXlsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsXlsRetrieveUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/xls/` +} + +export const assetsXlsRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsXlsRetrieveUrl(uidAsset), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsXlsRetrieveQueryKey = (uidAsset: string,) => { + return ['api','v2','assets',uidAsset,'xls'] as const; + } + + +export const getAssetsXlsRetrieveQueryOptions = >, TError = void>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsXlsRetrieveQueryKey(uidAsset); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsXlsRetrieve(uidAsset, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsXlsRetrieveQueryResult = NonNullable>> +export type AssetsXlsRetrieveQueryError = void + + + +export function useAssetsXlsRetrieve>, TError = void>( + uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsXlsRetrieveQueryOptions(uidAsset,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + diff --git a/jsapp/js/api/react-query/form-content/msw.ts b/jsapp/js/api/react-query/form-content/msw.ts new file mode 100644 index 0000000000..2e6f11929d --- /dev/null +++ b/jsapp/js/api/react-query/form-content/msw.ts @@ -0,0 +1,178 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import type { + AssetSnapshotResponse +} from '../../models/assetSnapshotResponse'; + +import type { + AssetValidContentResponse +} from '../../models/assetValidContentResponse'; + +import type { + ContentResponse +} from '../../models/contentResponse'; + +import type { + OpenRosaXFormResponse +} from '../../models/openRosaXFormResponse'; + +import type { + PaginatedAssetSnapshotResponseList +} from '../../models/paginatedAssetSnapshotResponseList'; + + +export const getApiV2AssetSnapshotsListResponseMock = (overrideResponse: Partial< PaginatedAssetSnapshotResponseList > = {}): PaginatedAssetSnapshotResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), owner: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, xml: faker.internet.url(), enketopreviewlink: faker.internet.url(), asset: faker.internet.url(), asset_version_id: faker.string.alpha({length: {min: 10, max: 20}}), details: {status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), warnings: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), message: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined])}, source: {schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{form_title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translation: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}})), ...overrideResponse}) + +export const getApiV2AssetSnapshotsCreateResponseMock = (overrideResponse: Partial< AssetSnapshotResponse > = {}): AssetSnapshotResponse => ({url: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), owner: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, xml: faker.internet.url(), enketopreviewlink: faker.internet.url(), asset: faker.internet.url(), asset_version_id: faker.string.alpha({length: {min: 10, max: 20}}), details: {status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), warnings: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), message: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined])}, source: {schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{form_title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translation: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, ...overrideResponse}) + +export const getApiV2AssetSnapshotsRetrieveResponseMock = (overrideResponse: Partial< AssetSnapshotResponse > = {}): AssetSnapshotResponse => ({url: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), owner: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, xml: faker.internet.url(), enketopreviewlink: faker.internet.url(), asset: faker.internet.url(), asset_version_id: faker.string.alpha({length: {min: 10, max: 20}}), details: {status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), warnings: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), message: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined])}, source: {schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{form_title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translation: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, ...overrideResponse}) + +export const getApiV2AssetSnapshotsXformRetrieveResponseMock = (overrideResponse: Partial< OpenRosaXFormResponse > = {}): OpenRosaXFormResponse => ({html: {head: faker.helpers.arrayElement([{title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), model: faker.helpers.arrayElement([{instance: faker.helpers.arrayElement([{instanceUuid: faker.helpers.arrayElement([{fieldName: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), meta: faker.helpers.arrayElement([{instanceID: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined])}, undefined])}, undefined])}, undefined]), body: faker.helpers.arrayElement([{input: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), hint: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined])}, ...overrideResponse}) + +export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock = (overrideResponse: Partial< OpenRosaXFormResponse > = {}): OpenRosaXFormResponse => ({html: {head: faker.helpers.arrayElement([{title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), model: faker.helpers.arrayElement([{instance: faker.helpers.arrayElement([{instanceUuid: faker.helpers.arrayElement([{fieldName: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), meta: faker.helpers.arrayElement([{instanceID: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined])}, undefined])}, undefined])}, undefined]), body: faker.helpers.arrayElement([{input: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), hint: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined])}, ...overrideResponse}) + +export const getApiV2AssetsContentRetrieveResponseMock = (overrideResponse: Partial< ContentResponse > = {}): ContentResponse => ({kind: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), data: {survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined]), settings: faker.helpers.arrayElement([{}, undefined])}, ...overrideResponse}) + +export const getApiV2AssetsTableViewRetrieveResponseMock = (): string => (faker.word.sample()) + +export const getApiV2AssetsValidContentRetrieveResponseMock = (overrideResponse: Partial< AssetValidContentResponse > = {}): AssetValidContentResponse => ({kind: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), data: {schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $kuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, ...overrideResponse}) + +export const getApiV2AssetsXlsRetrieveResponseMock = (): string => (faker.word.sample()) + + +export const getApiV2AssetSnapshotsListMockHandler = (overrideResponse?: PaginatedAssetSnapshotResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetSnapshotResponseList)) => { + return http.get('*/api/v2/asset_snapshots/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetSnapshotsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetSnapshotsCreateMockHandler = (overrideResponse?: AssetSnapshotResponse | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse)) => { + return http.post('*/api/v2/asset_snapshots/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetSnapshotsCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetSnapshotsRetrieveMockHandler = (overrideResponse?: AssetSnapshotResponse | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse)) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetSnapshotsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetSnapshotsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetSnapshotsPreviewRetrieveMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AssetSnapshotsXformRetrieveMockHandler = (overrideResponse?: OpenRosaXFormResponse | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse)) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetSnapshotsXformRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler = (overrideResponse?: OpenRosaXFormResponse | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse)) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsContentRetrieveMockHandler = (overrideResponse?: ContentResponse | ((info: Parameters[1]>[0]) => Promise | ContentResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/content/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsContentRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsTableViewRetrieveMockHandler = (overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string)) => { + return http.get('*/api/v2/assets/:uidAsset/table_view/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsTableViewRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsValidContentRetrieveMockHandler = (overrideResponse?: AssetValidContentResponse | ((info: Parameters[1]>[0]) => Promise | AssetValidContentResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/valid_content/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsValidContentRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsXlsRetrieveMockHandler = (overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string)) => { + return http.get('*/api/v2/assets/:uidAsset/xls/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsXlsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} +export const getFormContentMock = () => [ + getApiV2AssetSnapshotsListMockHandler(), + getApiV2AssetSnapshotsCreateMockHandler(), + getApiV2AssetSnapshotsRetrieveMockHandler(), + getApiV2AssetSnapshotsDestroyMockHandler(), + getApiV2AssetSnapshotsPreviewRetrieveMockHandler(), + getApiV2AssetSnapshotsXformRetrieveMockHandler(), + getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler(), + getApiV2AssetsContentRetrieveMockHandler(), + getApiV2AssetsTableViewRetrieveMockHandler(), + getApiV2AssetsValidContentRetrieveMockHandler(), + getApiV2AssetsXlsRetrieveMockHandler() +] diff --git a/jsapp/js/api/react-query/library-collections/index.ts b/jsapp/js/api/react-query/library-collections/index.ts new file mode 100644 index 0000000000..1d306b0b1b --- /dev/null +++ b/jsapp/js/api/react-query/library-collections/index.ts @@ -0,0 +1,391 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + AssetSubscriptionRequest +} from '../../models/assetSubscriptionRequest'; + +import type { + AssetSubscriptionResponse +} from '../../models/assetSubscriptionResponse'; + +import type { + AssetSubscriptionsListParams +} from '../../models/assetSubscriptionsListParams'; + +import type { + ErrorDetail +} from '../../models/errorDetail'; + +import type { + ErrorObject +} from '../../models/errorObject'; + +import type { + PaginatedAssetSubscriptionResponseList +} from '../../models/paginatedAssetSubscriptionResponseList'; + +import { fetchWithAuth } from '../../orval.mutator'; + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * ## List all asset subscriptions of a user + + */ +export type assetSubscriptionsListResponse200 = { + data: PaginatedAssetSubscriptionResponseList + status: 200 +} + +export type assetSubscriptionsListResponseComposite = assetSubscriptionsListResponse200; + +export type assetSubscriptionsListResponse = assetSubscriptionsListResponseComposite & { + headers: Headers; +} + +export const getAssetSubscriptionsListUrl = (params?: AssetSubscriptionsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/asset_subscriptions/?${stringifiedParams}` : `/api/v2/asset_subscriptions/` +} + +export const assetSubscriptionsList = async (params?: AssetSubscriptionsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSubscriptionsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetSubscriptionsListQueryKey = (params?: AssetSubscriptionsListParams,) => { + return ['api','v2','asset_subscriptions', ...(params ? [params]: [])] as const; + } + + +export const getAssetSubscriptionsListQueryOptions = >, TError = unknown>(params?: AssetSubscriptionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetSubscriptionsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetSubscriptionsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetSubscriptionsListQueryResult = NonNullable>> +export type AssetSubscriptionsListQueryError = unknown + + + +export function useAssetSubscriptionsList>, TError = unknown>( + params?: AssetSubscriptionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetSubscriptionsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create an asset subscription + +Create a subscription to a public collection for the user. + + */ +export type assetSubscriptionsCreateResponse201 = { + data: AssetSubscriptionResponse + status: 201 +} + +export type assetSubscriptionsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetSubscriptionsCreateResponseComposite = assetSubscriptionsCreateResponse201 | assetSubscriptionsCreateResponse400; + +export type assetSubscriptionsCreateResponse = assetSubscriptionsCreateResponseComposite & { + headers: Headers; +} + +export const getAssetSubscriptionsCreateUrl = () => { + + + + + return `/api/v2/asset_subscriptions/` +} + +export const assetSubscriptionsCreate = async (assetSubscriptionRequest: AssetSubscriptionRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSubscriptionsCreateUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + assetSubscriptionRequest,) + } +);} + + + + +export const getAssetSubscriptionsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetSubscriptionRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: AssetSubscriptionRequest}, TContext> => { + +const mutationKey = ['assetSubscriptionsCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: AssetSubscriptionRequest}> = (props) => { + const {data} = props ?? {}; + + return assetSubscriptionsCreate(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetSubscriptionsCreateMutationResult = NonNullable>> + export type AssetSubscriptionsCreateMutationBody = AssetSubscriptionRequest + export type AssetSubscriptionsCreateMutationError = ErrorObject + + export const useAssetSubscriptionsCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetSubscriptionRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetSubscriptionsCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve an asset subscription + + */ +export type assetSubscriptionsRetrieveResponse200 = { + data: AssetSubscriptionResponse + status: 200 +} + +export type assetSubscriptionsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetSubscriptionsRetrieveResponseComposite = assetSubscriptionsRetrieveResponse200 | assetSubscriptionsRetrieveResponse404; + +export type assetSubscriptionsRetrieveResponse = assetSubscriptionsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetSubscriptionsRetrieveUrl = (uidAssetSubscription: string,) => { + + + + + return `/api/v2/asset_subscriptions/${uidAssetSubscription}/` +} + +export const assetSubscriptionsRetrieve = async (uidAssetSubscription: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSubscriptionsRetrieveUrl(uidAssetSubscription), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetSubscriptionsRetrieveQueryKey = (uidAssetSubscription: string,) => { + return ['api','v2','asset_subscriptions',uidAssetSubscription] as const; + } + + +export const getAssetSubscriptionsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAssetSubscription: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetSubscriptionsRetrieveQueryKey(uidAssetSubscription); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetSubscriptionsRetrieve(uidAssetSubscription, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAssetSubscription), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetSubscriptionsRetrieveQueryResult = NonNullable>> +export type AssetSubscriptionsRetrieveQueryError = ErrorDetail + + + +export function useAssetSubscriptionsRetrieve>, TError = ErrorDetail>( + uidAssetSubscription: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetSubscriptionsRetrieveQueryOptions(uidAssetSubscription,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Delete a subscription to an asset + +Unsubscribe from a public asset. + + */ +export type assetSubscriptionsDestroyResponse204 = { + data: void + status: 204 +} + +export type assetSubscriptionsDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetSubscriptionsDestroyResponseComposite = assetSubscriptionsDestroyResponse204 | assetSubscriptionsDestroyResponse404; + +export type assetSubscriptionsDestroyResponse = assetSubscriptionsDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetSubscriptionsDestroyUrl = (uidAssetSubscription: string,) => { + + + + + return `/api/v2/asset_subscriptions/${uidAssetSubscription}/` +} + +export const assetSubscriptionsDestroy = async (uidAssetSubscription: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetSubscriptionsDestroyUrl(uidAssetSubscription), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetSubscriptionsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAssetSubscription: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAssetSubscription: string}, TContext> => { + +const mutationKey = ['assetSubscriptionsDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAssetSubscription: string}> = (props) => { + const {uidAssetSubscription} = props ?? {}; + + return assetSubscriptionsDestroy(uidAssetSubscription,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetSubscriptionsDestroyMutationResult = NonNullable>> + + export type AssetSubscriptionsDestroyMutationError = ErrorDetail + + export const useAssetSubscriptionsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAssetSubscription: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetSubscriptionsDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + \ No newline at end of file diff --git a/jsapp/js/api/react-query/library-collections/library-collections.msw.ts b/jsapp/js/api/react-query/library-collections/library-collections.msw.ts deleted file mode 100644 index bc0298c49d..0000000000 --- a/jsapp/js/api/react-query/library-collections/library-collections.msw.ts +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import type { AssetSubscriptionResponse } from '../../models/assetSubscriptionResponse' - -import type { PaginatedAssetSubscriptionResponseList } from '../../models/paginatedAssetSubscriptionResponseList' - -export const getApiV2AssetSubscriptionsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetSubscriptionResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - asset: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2AssetSubscriptionsCreateResponseMock = ( - overrideResponse: Partial = {}, -): AssetSubscriptionResponse => ({ - url: faker.internet.url(), - asset: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetSubscriptionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetSubscriptionResponse => ({ - url: faker.internet.url(), - asset: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetSubscriptionsListMockHandler = ( - overrideResponse?: - | PaginatedAssetSubscriptionResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetSubscriptionResponseList), -) => { - return http.get('*/api/v2/asset_subscriptions/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSubscriptionsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSubscriptionsCreateMockHandler = ( - overrideResponse?: - | AssetSubscriptionResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AssetSubscriptionResponse), -) => { - return http.post('*/api/v2/asset_subscriptions/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSubscriptionsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSubscriptionsRetrieveMockHandler = ( - overrideResponse?: - | AssetSubscriptionResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AssetSubscriptionResponse), -) => { - return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetSubscriptionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetSubscriptionsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} -export const getLibraryCollectionsMock = () => [ - getApiV2AssetSubscriptionsListMockHandler(), - getApiV2AssetSubscriptionsCreateMockHandler(), - getApiV2AssetSubscriptionsRetrieveMockHandler(), - getApiV2AssetSubscriptionsDestroyMockHandler(), -] diff --git a/jsapp/js/api/react-query/library-collections/library-collections.ts b/jsapp/js/api/react-query/library-collections/library-collections.ts deleted file mode 100644 index 67ac4d8d2f..0000000000 --- a/jsapp/js/api/react-query/library-collections/library-collections.ts +++ /dev/null @@ -1,389 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { AssetSubscriptionRequest } from '../../models/assetSubscriptionRequest' - -import type { AssetSubscriptionResponse } from '../../models/assetSubscriptionResponse' - -import type { AssetSubscriptionsListParams } from '../../models/assetSubscriptionsListParams' - -import type { ErrorDetail } from '../../models/errorDetail' - -import type { ErrorObject } from '../../models/errorObject' - -import type { PaginatedAssetSubscriptionResponseList } from '../../models/paginatedAssetSubscriptionResponseList' - -import { fetchWithAuth } from '../../orval.mutator' - -type SecondParameter unknown> = Parameters[1] - -/** - * ## List all asset subscriptions of a user - - */ -export type assetSubscriptionsListResponse200 = { - data: PaginatedAssetSubscriptionResponseList - status: 200 -} - -export type assetSubscriptionsListResponseComposite = assetSubscriptionsListResponse200 - -export type assetSubscriptionsListResponse = assetSubscriptionsListResponseComposite & { - headers: Headers -} - -export const getAssetSubscriptionsListUrl = (params?: AssetSubscriptionsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/asset_subscriptions/?${stringifiedParams}` - : `/api/v2/asset_subscriptions/` -} - -export const assetSubscriptionsList = async ( - params?: AssetSubscriptionsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetSubscriptionsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getAssetSubscriptionsListQueryKey = (params?: AssetSubscriptionsListParams) => { - return ['api', 'v2', 'asset_subscriptions', ...(params ? [params] : [])] as const -} - -export const getAssetSubscriptionsListQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: AssetSubscriptionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetSubscriptionsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetSubscriptionsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetSubscriptionsListQueryResult = NonNullable>> -export type AssetSubscriptionsListQueryError = unknown - -export function useAssetSubscriptionsList>, TError = unknown>( - params?: AssetSubscriptionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetSubscriptionsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create an asset subscription - -Create a subscription to a public collection for the user. - - */ -export type assetSubscriptionsCreateResponse201 = { - data: AssetSubscriptionResponse - status: 201 -} - -export type assetSubscriptionsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetSubscriptionsCreateResponseComposite = - | assetSubscriptionsCreateResponse201 - | assetSubscriptionsCreateResponse400 - -export type assetSubscriptionsCreateResponse = assetSubscriptionsCreateResponseComposite & { - headers: Headers -} - -export const getAssetSubscriptionsCreateUrl = () => { - return `/api/v2/asset_subscriptions/` -} - -export const assetSubscriptionsCreate = async ( - assetSubscriptionRequest: AssetSubscriptionRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetSubscriptionsCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(assetSubscriptionRequest), - }) -} - -export const getAssetSubscriptionsCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetSubscriptionRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: AssetSubscriptionRequest }, - TContext -> => { - const mutationKey = ['assetSubscriptionsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: AssetSubscriptionRequest } - > = (props) => { - const { data } = props ?? {} - - return assetSubscriptionsCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetSubscriptionsCreateMutationResult = NonNullable>> -export type AssetSubscriptionsCreateMutationBody = AssetSubscriptionRequest -export type AssetSubscriptionsCreateMutationError = ErrorObject - -export const useAssetSubscriptionsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetSubscriptionRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetSubscriptionsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve an asset subscription - - */ -export type assetSubscriptionsRetrieveResponse200 = { - data: AssetSubscriptionResponse - status: 200 -} - -export type assetSubscriptionsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetSubscriptionsRetrieveResponseComposite = - | assetSubscriptionsRetrieveResponse200 - | assetSubscriptionsRetrieveResponse404 - -export type assetSubscriptionsRetrieveResponse = assetSubscriptionsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetSubscriptionsRetrieveUrl = (uidAssetSubscription: string) => { - return `/api/v2/asset_subscriptions/${uidAssetSubscription}/` -} - -export const assetSubscriptionsRetrieve = async ( - uidAssetSubscription: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetSubscriptionsRetrieveUrl(uidAssetSubscription), { - ...options, - method: 'GET', - }) -} - -export const getAssetSubscriptionsRetrieveQueryKey = (uidAssetSubscription: string) => { - return ['api', 'v2', 'asset_subscriptions', uidAssetSubscription] as const -} - -export const getAssetSubscriptionsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAssetSubscription: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetSubscriptionsRetrieveQueryKey(uidAssetSubscription) - - const queryFn: QueryFunction>> = ({ signal }) => - assetSubscriptionsRetrieve(uidAssetSubscription, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAssetSubscription, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetSubscriptionsRetrieveQueryResult = NonNullable>> -export type AssetSubscriptionsRetrieveQueryError = ErrorDetail - -export function useAssetSubscriptionsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAssetSubscription: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetSubscriptionsRetrieveQueryOptions(uidAssetSubscription, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Delete a subscription to an asset - -Unsubscribe from a public asset. - - */ -export type assetSubscriptionsDestroyResponse204 = { - data: void - status: 204 -} - -export type assetSubscriptionsDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetSubscriptionsDestroyResponseComposite = - | assetSubscriptionsDestroyResponse204 - | assetSubscriptionsDestroyResponse404 - -export type assetSubscriptionsDestroyResponse = assetSubscriptionsDestroyResponseComposite & { - headers: Headers -} - -export const getAssetSubscriptionsDestroyUrl = (uidAssetSubscription: string) => { - return `/api/v2/asset_subscriptions/${uidAssetSubscription}/` -} - -export const assetSubscriptionsDestroy = async ( - uidAssetSubscription: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetSubscriptionsDestroyUrl(uidAssetSubscription), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetSubscriptionsDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAssetSubscription: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAssetSubscription: string }, - TContext -> => { - const mutationKey = ['assetSubscriptionsDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAssetSubscription: string } - > = (props) => { - const { uidAssetSubscription } = props ?? {} - - return assetSubscriptionsDestroy(uidAssetSubscription, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetSubscriptionsDestroyMutationResult = NonNullable>> - -export type AssetSubscriptionsDestroyMutationError = ErrorDetail - -export const useAssetSubscriptionsDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAssetSubscription: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetSubscriptionsDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} diff --git a/jsapp/js/api/react-query/library-collections/msw.ts b/jsapp/js/api/react-query/library-collections/msw.ts new file mode 100644 index 0000000000..c3298f01d3 --- /dev/null +++ b/jsapp/js/api/react-query/library-collections/msw.ts @@ -0,0 +1,78 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import type { + AssetSubscriptionResponse +} from '../../models/assetSubscriptionResponse'; + +import type { + PaginatedAssetSubscriptionResponseList +} from '../../models/paginatedAssetSubscriptionResponseList'; + + +export const getApiV2AssetSubscriptionsListResponseMock = (overrideResponse: Partial< PaginatedAssetSubscriptionResponseList > = {}): PaginatedAssetSubscriptionResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), asset: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) + +export const getApiV2AssetSubscriptionsCreateResponseMock = (overrideResponse: Partial< AssetSubscriptionResponse > = {}): AssetSubscriptionResponse => ({url: faker.internet.url(), asset: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetSubscriptionsRetrieveResponseMock = (overrideResponse: Partial< AssetSubscriptionResponse > = {}): AssetSubscriptionResponse => ({url: faker.internet.url(), asset: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + + +export const getApiV2AssetSubscriptionsListMockHandler = (overrideResponse?: PaginatedAssetSubscriptionResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetSubscriptionResponseList)) => { + return http.get('*/api/v2/asset_subscriptions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetSubscriptionsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetSubscriptionsCreateMockHandler = (overrideResponse?: AssetSubscriptionResponse | ((info: Parameters[1]>[0]) => Promise | AssetSubscriptionResponse)) => { + return http.post('*/api/v2/asset_subscriptions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetSubscriptionsCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetSubscriptionsRetrieveMockHandler = (overrideResponse?: AssetSubscriptionResponse | ((info: Parameters[1]>[0]) => Promise | AssetSubscriptionResponse)) => { + return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetSubscriptionsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetSubscriptionsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} +export const getLibraryCollectionsMock = () => [ + getApiV2AssetSubscriptionsListMockHandler(), + getApiV2AssetSubscriptionsCreateMockHandler(), + getApiV2AssetSubscriptionsRetrieveMockHandler(), + getApiV2AssetSubscriptionsDestroyMockHandler() +] diff --git a/jsapp/js/api/react-query/logging/index.ts b/jsapp/js/api/react-query/logging/index.ts new file mode 100644 index 0000000000..51120fbb03 --- /dev/null +++ b/jsapp/js/api/react-query/logging/index.ts @@ -0,0 +1,751 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + AccessLogsMeListParams +} from '../../models/accessLogsMeListParams'; + +import type { + AssetsHistoryListParams +} from '../../models/assetsHistoryListParams'; + +import type { + ErrorDetail +} from '../../models/errorDetail'; + +import type { + ExportCreateResponse +} from '../../models/exportCreateResponse'; + +import type { + ExportListResponse +} from '../../models/exportListResponse'; + +import type { + HistoryActionResponse +} from '../../models/historyActionResponse'; + +import type { + HistoryExportResponse +} from '../../models/historyExportResponse'; + +import type { + PaginatedAccessLogResponseList +} from '../../models/paginatedAccessLogResponseList'; + +import type { + PaginatedHistoryListResponseList +} from '../../models/paginatedHistoryListResponseList'; + +import { fetchWithAuth } from '../../orval.mutator'; + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * ## List all access logs for the authenticated user + +Submissions will be grouped together by hour + +Results from this endpoint can be filtered by a boolean query specified in the `q` parameter. + +**Filterable fields:** + +* date_created +* metadata__source +* metadata__auth_type +* metadata__ip_address + +**Some examples:** + +* All logs from a specific IP address + `api/v2/access-logs/?q=metadata__ip_address:"127.0.0.1"` +* All logs created after Jan, 1 2025 + `api/v2/access-logs/?q=date_created__date__gte:"2025-01-01"` + +*Notes: Do not forget to wrap search terms in double-quotes if they contain spaces +(e.g. date and time "2022-11-15 20:34")* + + */ +export type accessLogsMeListResponse200 = { + data: PaginatedAccessLogResponseList + status: 200 +} + +export type accessLogsMeListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type accessLogsMeListResponseComposite = accessLogsMeListResponse200 | accessLogsMeListResponse401; + +export type accessLogsMeListResponse = accessLogsMeListResponseComposite & { + headers: Headers; +} + +export const getAccessLogsMeListUrl = (params?: AccessLogsMeListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/access-logs/me/?${stringifiedParams}` : `/api/v2/access-logs/me/` +} + +export const accessLogsMeList = async (params?: AccessLogsMeListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAccessLogsMeListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAccessLogsMeListQueryKey = (params?: AccessLogsMeListParams,) => { + return ['api','v2','access-logs','me', ...(params ? [params]: [])] as const; + } + + +export const getAccessLogsMeListQueryOptions = >, TError = ErrorDetail>(params?: AccessLogsMeListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAccessLogsMeListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => accessLogsMeList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AccessLogsMeListQueryResult = NonNullable>> +export type AccessLogsMeListQueryError = ErrorDetail + + + +export function useAccessLogsMeList>, TError = ErrorDetail>( + params?: AccessLogsMeListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAccessLogsMeListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List all access logs export tasks for the authenticated user + + */ +export type accessLogsMeExportListResponse200 = { + data: ExportListResponse[] + status: 200 +} + +export type accessLogsMeExportListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type accessLogsMeExportListResponseComposite = accessLogsMeExportListResponse200 | accessLogsMeExportListResponse401; + +export type accessLogsMeExportListResponse = accessLogsMeExportListResponseComposite & { + headers: Headers; +} + +export const getAccessLogsMeExportListUrl = () => { + + + + + return `/api/v2/access-logs/me/export/` +} + +export const accessLogsMeExportList = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAccessLogsMeExportListUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAccessLogsMeExportListQueryKey = () => { + return ['api','v2','access-logs','me','export'] as const; + } + + +export const getAccessLogsMeExportListQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAccessLogsMeExportListQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => accessLogsMeExportList({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AccessLogsMeExportListQueryResult = NonNullable>> +export type AccessLogsMeExportListQueryError = ErrorDetail + + + +export function useAccessLogsMeExportList>, TError = ErrorDetail>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAccessLogsMeExportListQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create an export task for the authenticated user + + */ +export type accessLogsMeExportCreateResponse202 = { + data: ExportCreateResponse + status: 202 +} + +export type accessLogsMeExportCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type accessLogsMeExportCreateResponseComposite = accessLogsMeExportCreateResponse202 | accessLogsMeExportCreateResponse401; + +export type accessLogsMeExportCreateResponse = accessLogsMeExportCreateResponseComposite & { + headers: Headers; +} + +export const getAccessLogsMeExportCreateUrl = () => { + + + + + return `/api/v2/access-logs/me/export/` +} + +export const accessLogsMeExportCreate = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAccessLogsMeExportCreateUrl(), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getAccessLogsMeExportCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['accessLogsMeExportCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return accessLogsMeExportCreate(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AccessLogsMeExportCreateMutationResult = NonNullable>> + + export type AccessLogsMeExportCreateMutationError = ErrorDetail + + export const useAccessLogsMeExportCreate = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAccessLogsMeExportCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## List project history logs + +Lists all project history logs for a single project. + +⚠️ _Required permissions: `manage_asset` (Manage project)_ + +Results from this endpoint can be filtered by a Boolean query specified in the `q` parameter. + +### Filterable fields for all project history logs: + + - date_created + - user_uid + - user__username + - user__email + - user__is_superuser + - metadata__source + - metadata__ip_address + - metadata__log_subtype + - available subtypes: "project", "permission" + +### action + +available actions: + - add-media + - add-submission + - allow-anonymous-submissions + - archive + - clone-permissions + - connect-project + - delete-media + - delete-service + - delete-submission + - deploy + - disable-sharing + - disallow-anonymous-submissions + - disconnect-project + - enable-sharing + - export + - modify-imported-fields + - modify-qa-data + - modify-service + - modify-sharing + - modify-submission + - modify-user-permissions + - redeploy + - register-service + - replace-form + - share-data-publicly + - share-form-publicly + - transfer + - unarchive + - unshare-data-publicly + - unshare-form-publicly + - update-content + - update-name + - update-settings + - update-qa + +### Filterable fields by action: + + add-media + - metadata__asset-file__uid + - metadata__asset-file__filename + + add-submission + - metadata__submission__submitted_by + - metadata__submission__root_uuid + + archive + - metadata__latest_version_uid + + clone-permissions + - metadata__cloned_from + + connect-project + - metadata__paired-data__source_uid + - metadata__paired-data__source_name + + delete-media + - metadata__asset-file__uid + - metadata__asset-file__filename + + delete-service + - metadata__hook__uid + - metadata__hook__endpoint + - metadata__hook__active + + delete-submission + - metadata__submission__submitted_by + - metadata__submission__root_uuid + + deploy + - metadata__latest_version_uid + - metadata__latest_deployed_version_uid + + disconnect-project + - metadata__paired-data__source_uid + - metadata__paired-data__source_name + + modify-imported-fields + - metadata__paired-data__source_uid + - metadata__paired-data__source_name + + modify-qa-data + - metadata__submission__submitted_by + - metadata__submission__root_uuid + + modify-service + - metadata__hook__uid + - metadata__hook__endpoint + - metadata__hook__active + + modify-submission + - metadata__submission__submitted_by + - metadata__submission__root_uuid + - metadata__submission__status (only present if changed) + + modify-user-permissions + - metadata__permissions__username + + redeploy + - metadata__latest_version_uid + - metadata__latest_deployed_version_uid + + register-service + - metadata__hook__uid + - metadata__hook__endpoint + - metadata__hook__active + + transfer + - metadata__username + + unarchive + - metadata__latest_version_uid + + update-name + - metadata__name__old + - metadata__name__new + + update-settings + - metadata__settings__description__old + - metadata__settings__description__new + +This endpoint can be paginated with 'start' and 'limit' parameters. + + */ +export type assetsHistoryListResponse200 = { + data: PaginatedHistoryListResponseList + status: 200 +} + +export type assetsHistoryListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsHistoryListResponseComposite = assetsHistoryListResponse200 | assetsHistoryListResponse403; + +export type assetsHistoryListResponse = assetsHistoryListResponseComposite & { + headers: Headers; +} + +export const getAssetsHistoryListUrl = (uidAsset: string, + params?: AssetsHistoryListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/history/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/history/` +} + +export const assetsHistoryList = async (uidAsset: string, + params?: AssetsHistoryListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHistoryListUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsHistoryListQueryKey = (uidAsset: string, + params?: AssetsHistoryListParams,) => { + return ['api','v2','assets',uidAsset,'history', ...(params ? [params]: [])] as const; + } + + +export const getAssetsHistoryListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsHistoryListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsHistoryListQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsHistoryList(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsHistoryListQueryResult = NonNullable>> +export type AssetsHistoryListQueryError = ErrorDetail + + + +export function useAssetsHistoryList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsHistoryListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsHistoryListQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve distinct actions performed on the project. + + */ +export type assetsHistoryActionsRetrieveResponse200 = { + data: HistoryActionResponse + status: 200 +} + +export type assetsHistoryActionsRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsHistoryActionsRetrieveResponseComposite = assetsHistoryActionsRetrieveResponse200 | assetsHistoryActionsRetrieveResponse403; + +export type assetsHistoryActionsRetrieveResponse = assetsHistoryActionsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsHistoryActionsRetrieveUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/history/actions/` +} + +export const assetsHistoryActionsRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHistoryActionsRetrieveUrl(uidAsset), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsHistoryActionsRetrieveQueryKey = (uidAsset: string,) => { + return ['api','v2','assets',uidAsset,'history','actions'] as const; + } + + +export const getAssetsHistoryActionsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsHistoryActionsRetrieveQueryKey(uidAsset); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsHistoryActionsRetrieve(uidAsset, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsHistoryActionsRetrieveQueryResult = NonNullable>> +export type AssetsHistoryActionsRetrieveQueryError = ErrorDetail + + + +export function useAssetsHistoryActionsRetrieve>, TError = ErrorDetail>( + uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsHistoryActionsRetrieveQueryOptions(uidAsset,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Export current project's history + +Exports the project's history and sends it by email to the requesting user. + + */ +export type assetsHistoryExportCreateResponse202 = { + data: HistoryExportResponse + status: 202 +} + +export type assetsHistoryExportCreateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsHistoryExportCreateResponseComposite = assetsHistoryExportCreateResponse202 | assetsHistoryExportCreateResponse403; + +export type assetsHistoryExportCreateResponse = assetsHistoryExportCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsHistoryExportCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/history/export/` +} + +export const assetsHistoryExportCreate = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHistoryExportCreateUrl(uidAsset), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getAssetsHistoryExportCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { + +const mutationKey = ['assetsHistoryExportCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { + const {uidAsset} = props ?? {}; + + return assetsHistoryExportCreate(uidAsset,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsHistoryExportCreateMutationResult = NonNullable>> + + export type AssetsHistoryExportCreateMutationError = ErrorDetail + + export const useAssetsHistoryExportCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsHistoryExportCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + \ No newline at end of file diff --git a/jsapp/js/api/react-query/logging/logging.msw.ts b/jsapp/js/api/react-query/logging/logging.msw.ts deleted file mode 100644 index 185e434334..0000000000 --- a/jsapp/js/api/react-query/logging/logging.msw.ts +++ /dev/null @@ -1,407 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import type { ExportCreateResponse } from '../../models/exportCreateResponse' - -import type { ExportListResponse } from '../../models/exportListResponse' - -import type { HistoryActionResponse } from '../../models/historyActionResponse' - -import type { HistoryExportResponse } from '../../models/historyExportResponse' - -import type { PaginatedAccessLogResponseList } from '../../models/paginatedAccessLogResponseList' - -import type { PaginatedHistoryListResponseList } from '../../models/paginatedHistoryListResponseList' - -export const getApiV2AccessLogsMeListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAccessLogResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: { - source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - initial_user_username: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - authorized_app_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - action: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2AccessLogsMeExportListResponseMock = (): ExportListResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 24 } }), - status: faker.string.alpha({ length: { min: 10, max: 32 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - })) - -export const getApiV2AccessLogsMeExportCreateResponseMock = ( - overrideResponse: Partial = {}, -): ExportCreateResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 32 } }), ...overrideResponse }) - -export const getApiV2AssetsHistoryListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedHistoryListResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user: faker.internet.url(), - user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: { - source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - old: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - removed: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - description: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - 'data-table': faker.helpers.arrayElement([ - { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, - undefined, - ]), - }, - undefined, - ]), - asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'asset-files': faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - permissions: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - latest_deployed_version_uid: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - submission: faker.helpers.arrayElement([ - { - root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - hook: faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - undefined, - ]), - bulk_action: faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - params: faker.helpers.arrayElement([{}, undefined]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - total_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - processed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - completed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - failed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - cancelled_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - name: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - shared_fields: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsHistoryActionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): HistoryActionResponse => ({ - actions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2AssetsHistoryExportCreateResponseMock = ( - overrideResponse: Partial = {}, -): HistoryExportResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2AccessLogsMeListMockHandler = ( - overrideResponse?: - | PaginatedAccessLogResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAccessLogResponseList), -) => { - return http.get('*/api/v2/access-logs/me/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AccessLogsMeListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AccessLogsMeExportListMockHandler = ( - overrideResponse?: - | ExportListResponse[] - | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), -) => { - return http.get('*/api/v2/access-logs/me/export/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AccessLogsMeExportListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AccessLogsMeExportCreateMockHandler = ( - overrideResponse?: - | ExportCreateResponse - | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), -) => { - return http.post('*/api/v2/access-logs/me/export/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AccessLogsMeExportCreateResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHistoryListMockHandler = ( - overrideResponse?: - | PaginatedHistoryListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedHistoryListResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/history/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHistoryListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHistoryActionsRetrieveMockHandler = ( - overrideResponse?: - | HistoryActionResponse - | ((info: Parameters[1]>[0]) => Promise | HistoryActionResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/history/actions/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHistoryActionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHistoryExportCreateMockHandler = ( - overrideResponse?: - | HistoryExportResponse - | (( - info: Parameters[1]>[0], - ) => Promise | HistoryExportResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/history/export/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHistoryExportCreateResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getLoggingMock = () => [ - getApiV2AccessLogsMeListMockHandler(), - getApiV2AccessLogsMeExportListMockHandler(), - getApiV2AccessLogsMeExportCreateMockHandler(), - getApiV2AssetsHistoryListMockHandler(), - getApiV2AssetsHistoryActionsRetrieveMockHandler(), - getApiV2AssetsHistoryExportCreateMockHandler(), -] diff --git a/jsapp/js/api/react-query/logging/logging.ts b/jsapp/js/api/react-query/logging/logging.ts deleted file mode 100644 index 9f5370be03..0000000000 --- a/jsapp/js/api/react-query/logging/logging.ts +++ /dev/null @@ -1,709 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { AccessLogsMeListParams } from '../../models/accessLogsMeListParams' - -import type { AssetsHistoryListParams } from '../../models/assetsHistoryListParams' - -import type { ErrorDetail } from '../../models/errorDetail' - -import type { ExportCreateResponse } from '../../models/exportCreateResponse' - -import type { ExportListResponse } from '../../models/exportListResponse' - -import type { HistoryActionResponse } from '../../models/historyActionResponse' - -import type { HistoryExportResponse } from '../../models/historyExportResponse' - -import type { PaginatedAccessLogResponseList } from '../../models/paginatedAccessLogResponseList' - -import type { PaginatedHistoryListResponseList } from '../../models/paginatedHistoryListResponseList' - -import { fetchWithAuth } from '../../orval.mutator' - -type SecondParameter unknown> = Parameters[1] - -/** - * ## List all access logs for the authenticated user - -Submissions will be grouped together by hour - -Results from this endpoint can be filtered by a boolean query specified in the `q` parameter. - -**Filterable fields:** - -* date_created -* metadata__source -* metadata__auth_type -* metadata__ip_address - -**Some examples:** - -* All logs from a specific IP address - `api/v2/access-logs/?q=metadata__ip_address:"127.0.0.1"` -* All logs created after Jan, 1 2025 - `api/v2/access-logs/?q=date_created__date__gte:"2025-01-01"` - -*Notes: Do not forget to wrap search terms in double-quotes if they contain spaces -(e.g. date and time "2022-11-15 20:34")* - - */ -export type accessLogsMeListResponse200 = { - data: PaginatedAccessLogResponseList - status: 200 -} - -export type accessLogsMeListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type accessLogsMeListResponseComposite = accessLogsMeListResponse200 | accessLogsMeListResponse401 - -export type accessLogsMeListResponse = accessLogsMeListResponseComposite & { - headers: Headers -} - -export const getAccessLogsMeListUrl = (params?: AccessLogsMeListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/access-logs/me/?${stringifiedParams}` : `/api/v2/access-logs/me/` -} - -export const accessLogsMeList = async ( - params?: AccessLogsMeListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAccessLogsMeListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getAccessLogsMeListQueryKey = (params?: AccessLogsMeListParams) => { - return ['api', 'v2', 'access-logs', 'me', ...(params ? [params] : [])] as const -} - -export const getAccessLogsMeListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: AccessLogsMeListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAccessLogsMeListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - accessLogsMeList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AccessLogsMeListQueryResult = NonNullable>> -export type AccessLogsMeListQueryError = ErrorDetail - -export function useAccessLogsMeList>, TError = ErrorDetail>( - params?: AccessLogsMeListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAccessLogsMeListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List all access logs export tasks for the authenticated user - - */ -export type accessLogsMeExportListResponse200 = { - data: ExportListResponse[] - status: 200 -} - -export type accessLogsMeExportListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type accessLogsMeExportListResponseComposite = - | accessLogsMeExportListResponse200 - | accessLogsMeExportListResponse401 - -export type accessLogsMeExportListResponse = accessLogsMeExportListResponseComposite & { - headers: Headers -} - -export const getAccessLogsMeExportListUrl = () => { - return `/api/v2/access-logs/me/export/` -} - -export const accessLogsMeExportList = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAccessLogsMeExportListUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAccessLogsMeExportListQueryKey = () => { - return ['api', 'v2', 'access-logs', 'me', 'export'] as const -} - -export const getAccessLogsMeExportListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAccessLogsMeExportListQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - accessLogsMeExportList({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AccessLogsMeExportListQueryResult = NonNullable>> -export type AccessLogsMeExportListQueryError = ErrorDetail - -export function useAccessLogsMeExportList< - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAccessLogsMeExportListQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create an export task for the authenticated user - - */ -export type accessLogsMeExportCreateResponse202 = { - data: ExportCreateResponse - status: 202 -} - -export type accessLogsMeExportCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type accessLogsMeExportCreateResponseComposite = - | accessLogsMeExportCreateResponse202 - | accessLogsMeExportCreateResponse401 - -export type accessLogsMeExportCreateResponse = accessLogsMeExportCreateResponseComposite & { - headers: Headers -} - -export const getAccessLogsMeExportCreateUrl = () => { - return `/api/v2/access-logs/me/export/` -} - -export const accessLogsMeExportCreate = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAccessLogsMeExportCreateUrl(), { - ...options, - method: 'POST', - }) -} - -export const getAccessLogsMeExportCreateMutationOptions = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['accessLogsMeExportCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return accessLogsMeExportCreate(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AccessLogsMeExportCreateMutationResult = NonNullable>> - -export type AccessLogsMeExportCreateMutationError = ErrorDetail - -export const useAccessLogsMeExportCreate = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}) => { - const mutationOptions = getAccessLogsMeExportCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## List project history logs - -Lists all project history logs for a single project. - -⚠️ _Required permissions: `manage_asset` (Manage project)_ - -Results from this endpoint can be filtered by a Boolean query specified in the `q` parameter. - -### Filterable fields for all project history logs: - - - date_created - - user_uid - - user__username - - user__email - - user__is_superuser - - metadata__source - - metadata__ip_address - - metadata__log_subtype - - available subtypes: "project", "permission" - -### action - -available actions: - - add-media - - add-submission - - allow-anonymous-submissions - - archive - - clone-permissions - - connect-project - - delete-media - - delete-service - - delete-submission - - deploy - - disable-sharing - - disallow-anonymous-submissions - - disconnect-project - - enable-sharing - - export - - modify-imported-fields - - modify-qa-data - - modify-service - - modify-sharing - - modify-submission - - modify-user-permissions - - redeploy - - register-service - - replace-form - - share-data-publicly - - share-form-publicly - - transfer - - unarchive - - unshare-data-publicly - - unshare-form-publicly - - update-content - - update-name - - update-settings - - update-qa - -### Filterable fields by action: - - add-media - - metadata__asset-file__uid - - metadata__asset-file__filename - - add-submission - - metadata__submission__submitted_by - - metadata__submission__root_uuid - - archive - - metadata__latest_version_uid - - clone-permissions - - metadata__cloned_from - - connect-project - - metadata__paired-data__source_uid - - metadata__paired-data__source_name - - delete-media - - metadata__asset-file__uid - - metadata__asset-file__filename - - delete-service - - metadata__hook__uid - - metadata__hook__endpoint - - metadata__hook__active - - delete-submission - - metadata__submission__submitted_by - - metadata__submission__root_uuid - - deploy - - metadata__latest_version_uid - - metadata__latest_deployed_version_uid - - disconnect-project - - metadata__paired-data__source_uid - - metadata__paired-data__source_name - - modify-imported-fields - - metadata__paired-data__source_uid - - metadata__paired-data__source_name - - modify-qa-data - - metadata__submission__submitted_by - - metadata__submission__root_uuid - - modify-service - - metadata__hook__uid - - metadata__hook__endpoint - - metadata__hook__active - - modify-submission - - metadata__submission__submitted_by - - metadata__submission__root_uuid - - metadata__submission__status (only present if changed) - - modify-user-permissions - - metadata__permissions__username - - redeploy - - metadata__latest_version_uid - - metadata__latest_deployed_version_uid - - register-service - - metadata__hook__uid - - metadata__hook__endpoint - - metadata__hook__active - - transfer - - metadata__username - - unarchive - - metadata__latest_version_uid - - update-name - - metadata__name__old - - metadata__name__new - - update-settings - - metadata__settings__description__old - - metadata__settings__description__new - -This endpoint can be paginated with 'start' and 'limit' parameters. - - */ -export type assetsHistoryListResponse200 = { - data: PaginatedHistoryListResponseList - status: 200 -} - -export type assetsHistoryListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsHistoryListResponseComposite = assetsHistoryListResponse200 | assetsHistoryListResponse403 - -export type assetsHistoryListResponse = assetsHistoryListResponseComposite & { - headers: Headers -} - -export const getAssetsHistoryListUrl = (uidAsset: string, params?: AssetsHistoryListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/history/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/history/` -} - -export const assetsHistoryList = async ( - uidAsset: string, - params?: AssetsHistoryListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHistoryListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsHistoryListQueryKey = (uidAsset: string, params?: AssetsHistoryListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'history', ...(params ? [params] : [])] as const -} - -export const getAssetsHistoryListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsHistoryListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsHistoryListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsHistoryList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsHistoryListQueryResult = NonNullable>> -export type AssetsHistoryListQueryError = ErrorDetail - -export function useAssetsHistoryList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsHistoryListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsHistoryListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve distinct actions performed on the project. - - */ -export type assetsHistoryActionsRetrieveResponse200 = { - data: HistoryActionResponse - status: 200 -} - -export type assetsHistoryActionsRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsHistoryActionsRetrieveResponseComposite = - | assetsHistoryActionsRetrieveResponse200 - | assetsHistoryActionsRetrieveResponse403 - -export type assetsHistoryActionsRetrieveResponse = assetsHistoryActionsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsHistoryActionsRetrieveUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/history/actions/` -} - -export const assetsHistoryActionsRetrieve = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHistoryActionsRetrieveUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsHistoryActionsRetrieveQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'history', 'actions'] as const -} - -export const getAssetsHistoryActionsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsHistoryActionsRetrieveQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsHistoryActionsRetrieve(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsHistoryActionsRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsHistoryActionsRetrieveQueryError = ErrorDetail - -export function useAssetsHistoryActionsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsHistoryActionsRetrieveQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Export current project's history - -Exports the project's history and sends it by email to the requesting user. - - */ -export type assetsHistoryExportCreateResponse202 = { - data: HistoryExportResponse - status: 202 -} - -export type assetsHistoryExportCreateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsHistoryExportCreateResponseComposite = - | assetsHistoryExportCreateResponse202 - | assetsHistoryExportCreateResponse403 - -export type assetsHistoryExportCreateResponse = assetsHistoryExportCreateResponseComposite & { - headers: Headers -} - -export const getAssetsHistoryExportCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/history/export/` -} - -export const assetsHistoryExportCreate = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHistoryExportCreateUrl(uidAsset), { - ...options, - method: 'POST', - }) -} - -export const getAssetsHistoryExportCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext -> => { - const mutationKey = ['assetsHistoryExportCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { uidAsset: string }> = ( - props, - ) => { - const { uidAsset } = props ?? {} - - return assetsHistoryExportCreate(uidAsset, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsHistoryExportCreateMutationResult = NonNullable>> - -export type AssetsHistoryExportCreateMutationError = ErrorDetail - -export const useAssetsHistoryExportCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsHistoryExportCreateMutationOptions(options) - - return useMutation(mutationOptions) -} diff --git a/jsapp/js/api/react-query/logging/msw.ts b/jsapp/js/api/react-query/logging/msw.ts new file mode 100644 index 0000000000..91f47807d8 --- /dev/null +++ b/jsapp/js/api/react-query/logging/msw.ts @@ -0,0 +1,123 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import type { + ExportCreateResponse +} from '../../models/exportCreateResponse'; + +import type { + ExportListResponse +} from '../../models/exportListResponse'; + +import type { + HistoryActionResponse +} from '../../models/historyActionResponse'; + +import type { + HistoryExportResponse +} from '../../models/historyExportResponse'; + +import type { + PaginatedAccessLogResponseList +} from '../../models/paginatedAccessLogResponseList'; + +import type { + PaginatedHistoryListResponseList +} from '../../models/paginatedHistoryListResponseList'; + + +export const getApiV2AccessLogsMeListResponseMock = (overrideResponse: Partial< PaginatedAccessLogResponseList > = {}): PaginatedAccessLogResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, username: faker.string.alpha({length: {min: 10, max: 20}}), metadata: {source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), auth_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), initial_user_username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), authorized_app_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, user_uid: faker.string.alpha({length: {min: 10, max: 20}}), count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), action: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) + +export const getApiV2AccessLogsMeExportListResponseMock = (): ExportListResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 24}}), status: faker.string.alpha({length: {min: 10, max: 32}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`}))) + +export const getApiV2AccessLogsMeExportCreateResponseMock = (overrideResponse: Partial< ExportCreateResponse > = {}): ExportCreateResponse => ({status: faker.string.alpha({length: {min: 10, max: 32}}), ...overrideResponse}) + +export const getApiV2AssetsHistoryListResponseMock = (overrideResponse: Partial< PaginatedHistoryListResponseList > = {}): PaginatedHistoryListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user: faker.internet.url(), user_uid: faker.string.alpha({length: {min: 10, max: 20}}), username: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.string.alpha({length: {min: 10, max: 20}}), metadata: {source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), old: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), country: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), removed: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), description: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country_codes: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), 'data-table': faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined])}, undefined])}, undefined]), asset_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), log_subtype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_owner: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'asset-files': faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), md5_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), download_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), permissions: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), latest_deployed_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submission: faker.helpers.arrayElement([{root_uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submitted_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), hook: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), bulk_action: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), action_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), question_xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), params: faker.helpers.arrayElement([{}, undefined]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cancelled_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), total_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), processed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), completed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), failed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), cancelled_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), name: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), shared_fields: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) + +export const getApiV2AssetsHistoryActionsRetrieveResponseMock = (overrideResponse: Partial< HistoryActionResponse > = {}): HistoryActionResponse => ({actions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) + +export const getApiV2AssetsHistoryExportCreateResponseMock = (overrideResponse: Partial< HistoryExportResponse > = {}): HistoryExportResponse => ({status: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + + +export const getApiV2AccessLogsMeListMockHandler = (overrideResponse?: PaginatedAccessLogResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAccessLogResponseList)) => { + return http.get('*/api/v2/access-logs/me/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AccessLogsMeListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AccessLogsMeExportListMockHandler = (overrideResponse?: ExportListResponse[] | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[])) => { + return http.get('*/api/v2/access-logs/me/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AccessLogsMeExportListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AccessLogsMeExportCreateMockHandler = (overrideResponse?: ExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse)) => { + return http.post('*/api/v2/access-logs/me/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AccessLogsMeExportCreateResponseMock()), + { status: 202, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHistoryListMockHandler = (overrideResponse?: PaginatedHistoryListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedHistoryListResponseList)) => { + return http.get('*/api/v2/assets/:uidAsset/history/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHistoryListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHistoryActionsRetrieveMockHandler = (overrideResponse?: HistoryActionResponse | ((info: Parameters[1]>[0]) => Promise | HistoryActionResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/history/actions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHistoryActionsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHistoryExportCreateMockHandler = (overrideResponse?: HistoryExportResponse | ((info: Parameters[1]>[0]) => Promise | HistoryExportResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/history/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHistoryExportCreateResponseMock()), + { status: 202, + headers: { 'Content-Type': 'application/json' } + }) + }) +} +export const getLoggingMock = () => [ + getApiV2AccessLogsMeListMockHandler(), + getApiV2AccessLogsMeExportListMockHandler(), + getApiV2AccessLogsMeExportCreateMockHandler(), + getApiV2AssetsHistoryListMockHandler(), + getApiV2AssetsHistoryActionsRetrieveMockHandler(), + getApiV2AssetsHistoryExportCreateMockHandler() +] diff --git a/jsapp/js/api/react-query/manage-permissions/index.ts b/jsapp/js/api/react-query/manage-permissions/index.ts new file mode 100644 index 0000000000..adcba53f8f --- /dev/null +++ b/jsapp/js/api/react-query/manage-permissions/index.ts @@ -0,0 +1,676 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + ErrorDetail +} from '../../models/errorDetail'; + +import type { + ErrorObject +} from '../../models/errorObject'; + +import type { + PatchedPermissionAssignmentCloneRequest +} from '../../models/patchedPermissionAssignmentCloneRequest'; + +import type { + PermissionAssignmentBulkRequest +} from '../../models/permissionAssignmentBulkRequest'; + +import type { + PermissionAssignmentCreateRequest +} from '../../models/permissionAssignmentCreateRequest'; + +import type { + PermissionAssignmentResponse +} from '../../models/permissionAssignmentResponse'; + +import { fetchWithAuth } from '../../orval.mutator'; + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * ## List permission assignments + + */ +export type assetsPermissionAssignmentsListResponse200 = { + data: PermissionAssignmentResponse[] + status: 200 +} + +export type assetsPermissionAssignmentsListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsPermissionAssignmentsListResponseComposite = assetsPermissionAssignmentsListResponse200 | assetsPermissionAssignmentsListResponse403; + +export type assetsPermissionAssignmentsListResponse = assetsPermissionAssignmentsListResponseComposite & { + headers: Headers; +} + +export const getAssetsPermissionAssignmentsListUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/permission-assignments/` +} + +export const assetsPermissionAssignmentsList = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPermissionAssignmentsListUrl(uidAsset), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsPermissionAssignmentsListQueryKey = (uidAsset: string,) => { + return ['api','v2','assets',uidAsset,'permission-assignments'] as const; + } + + +export const getAssetsPermissionAssignmentsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsPermissionAssignmentsListQueryKey(uidAsset); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsPermissionAssignmentsList(uidAsset, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsPermissionAssignmentsListQueryResult = NonNullable>> +export type AssetsPermissionAssignmentsListQueryError = ErrorDetail + + + +export function useAssetsPermissionAssignmentsList>, TError = ErrorDetail>( + uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsPermissionAssignmentsListQueryOptions(uidAsset,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Assign a permission + +N.B.: + - Filters use Mongo Query Engine to narrow down results + - Filters are joined with `OR` operator + - Implied permissions will be also assigned. (e.g. `change_asset` will add `view_asset` too) + + */ +export type assetsPermissionAssignmentsCreateResponse200 = { + data: PermissionAssignmentResponse + status: 200 +} + +export type assetsPermissionAssignmentsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsPermissionAssignmentsCreateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsPermissionAssignmentsCreateResponseComposite = assetsPermissionAssignmentsCreateResponse200 | assetsPermissionAssignmentsCreateResponse400 | assetsPermissionAssignmentsCreateResponse403; + +export type assetsPermissionAssignmentsCreateResponse = assetsPermissionAssignmentsCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsPermissionAssignmentsCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/permission-assignments/` +} + +export const assetsPermissionAssignmentsCreate = async (uidAsset: string, + permissionAssignmentCreateRequest: PermissionAssignmentCreateRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPermissionAssignmentsCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + permissionAssignmentCreateRequest,) + } +);} + + + + +export const getAssetsPermissionAssignmentsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentCreateRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentCreateRequest}, TContext> => { + +const mutationKey = ['assetsPermissionAssignmentsCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: PermissionAssignmentCreateRequest}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsPermissionAssignmentsCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsPermissionAssignmentsCreateMutationResult = NonNullable>> + export type AssetsPermissionAssignmentsCreateMutationBody = PermissionAssignmentCreateRequest + export type AssetsPermissionAssignmentsCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsPermissionAssignmentsCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentCreateRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsPermissionAssignmentsCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve assignments + + */ +export type assetsPermissionAssignmentsRetrieveResponse200 = { + data: PermissionAssignmentResponse + status: 200 +} + +export type assetsPermissionAssignmentsRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsPermissionAssignmentsRetrieveResponseComposite = assetsPermissionAssignmentsRetrieveResponse200 | assetsPermissionAssignmentsRetrieveResponse403; + +export type assetsPermissionAssignmentsRetrieveResponse = assetsPermissionAssignmentsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsPermissionAssignmentsRetrieveUrl = (uidAsset: string, + uidPermissionAssignment: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/permission-assignments/${uidPermissionAssignment}/` +} + +export const assetsPermissionAssignmentsRetrieve = async (uidAsset: string, + uidPermissionAssignment: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPermissionAssignmentsRetrieveUrl(uidAsset,uidPermissionAssignment), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsPermissionAssignmentsRetrieveQueryKey = (uidAsset: string, + uidPermissionAssignment: string,) => { + return ['api','v2','assets',uidAsset,'permission-assignments',uidPermissionAssignment] as const; + } + + +export const getAssetsPermissionAssignmentsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidPermissionAssignment: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsPermissionAssignmentsRetrieveQueryKey(uidAsset,uidPermissionAssignment); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsPermissionAssignmentsRetrieve(uidAsset,uidPermissionAssignment, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidPermissionAssignment), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsPermissionAssignmentsRetrieveQueryResult = NonNullable>> +export type AssetsPermissionAssignmentsRetrieveQueryError = ErrorDetail + + + +export function useAssetsPermissionAssignmentsRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidPermissionAssignment: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsPermissionAssignmentsRetrieveQueryOptions(uidAsset,uidPermissionAssignment,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Remove a permission assignment + + */ +export type assetsPermissionAssignmentsDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsPermissionAssignmentsDestroyResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsPermissionAssignmentsDestroyResponseComposite = assetsPermissionAssignmentsDestroyResponse204 | assetsPermissionAssignmentsDestroyResponse403; + +export type assetsPermissionAssignmentsDestroyResponse = assetsPermissionAssignmentsDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsPermissionAssignmentsDestroyUrl = (uidAsset: string, + uidPermissionAssignment: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/permission-assignments/${uidPermissionAssignment}/` +} + +export const assetsPermissionAssignmentsDestroy = async (uidAsset: string, + uidPermissionAssignment: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPermissionAssignmentsDestroyUrl(uidAsset,uidPermissionAssignment), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsPermissionAssignmentsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPermissionAssignment: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidPermissionAssignment: string}, TContext> => { + +const mutationKey = ['assetsPermissionAssignmentsDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidPermissionAssignment: string}> = (props) => { + const {uidAsset,uidPermissionAssignment} = props ?? {}; + + return assetsPermissionAssignmentsDestroy(uidAsset,uidPermissionAssignment,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsPermissionAssignmentsDestroyMutationResult = NonNullable>> + + export type AssetsPermissionAssignmentsDestroyMutationError = ErrorDetail + + export const useAssetsPermissionAssignmentsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPermissionAssignment: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsPermissionAssignmentsDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Assign multiple permissions at once + +* Can put both regular and partial permission in the payload + + */ +export type assetsPermissionAssignmentsBulkCreateResponse200 = { + data: PermissionAssignmentResponse[] + status: 200 +} + +export type assetsPermissionAssignmentsBulkCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsPermissionAssignmentsBulkCreateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsPermissionAssignmentsBulkCreateResponseComposite = assetsPermissionAssignmentsBulkCreateResponse200 | assetsPermissionAssignmentsBulkCreateResponse400 | assetsPermissionAssignmentsBulkCreateResponse403; + +export type assetsPermissionAssignmentsBulkCreateResponse = assetsPermissionAssignmentsBulkCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsPermissionAssignmentsBulkCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/permission-assignments/bulk/` +} + +export const assetsPermissionAssignmentsBulkCreate = async (uidAsset: string, + permissionAssignmentBulkRequest: PermissionAssignmentBulkRequest[], options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPermissionAssignmentsBulkCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + permissionAssignmentBulkRequest,) + } +);} + + + + +export const getAssetsPermissionAssignmentsBulkCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentBulkRequest[]}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentBulkRequest[]}, TContext> => { + +const mutationKey = ['assetsPermissionAssignmentsBulkCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: PermissionAssignmentBulkRequest[]}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsPermissionAssignmentsBulkCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsPermissionAssignmentsBulkCreateMutationResult = NonNullable>> + export type AssetsPermissionAssignmentsBulkCreateMutationBody = PermissionAssignmentBulkRequest[] + export type AssetsPermissionAssignmentsBulkCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsPermissionAssignmentsBulkCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentBulkRequest[]}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsPermissionAssignmentsBulkCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Remove all permission assignments + +⚠️ **Warning** +This endpoint currently supports deleting **only the user whose username is provided as a parameter**. +Deletion of other accounts is not yet supported. + +**Payload** +```json +{ + "username": "bob" +} +``` + +_Due to limitations with DRF-Spectacular current version, `DELETE` actions do not support showing a request body OR a response body. This is due to the 'vague' nature of the action which generally does *not* recommend the use of a payload. To still document this endpoint, example for the payload and response will be included but it will not be possible to test this endpoint. The HTTP code and the errors example are, for their part, factual and can be considered when working with the endpoint._ + + */ +export type assetsPermissionAssignmentsBulkDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsPermissionAssignmentsBulkDestroyResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsPermissionAssignmentsBulkDestroyResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsPermissionAssignmentsBulkDestroyResponseComposite = assetsPermissionAssignmentsBulkDestroyResponse204 | assetsPermissionAssignmentsBulkDestroyResponse400 | assetsPermissionAssignmentsBulkDestroyResponse403; + +export type assetsPermissionAssignmentsBulkDestroyResponse = assetsPermissionAssignmentsBulkDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsPermissionAssignmentsBulkDestroyUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/permission-assignments/bulk/` +} + +export const assetsPermissionAssignmentsBulkDestroy = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPermissionAssignmentsBulkDestroyUrl(uidAsset), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsPermissionAssignmentsBulkDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { + +const mutationKey = ['assetsPermissionAssignmentsBulkDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { + const {uidAsset} = props ?? {}; + + return assetsPermissionAssignmentsBulkDestroy(uidAsset,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsPermissionAssignmentsBulkDestroyMutationResult = NonNullable>> + + export type AssetsPermissionAssignmentsBulkDestroyMutationError = ErrorObject | ErrorDetail + + export const useAssetsPermissionAssignmentsBulkDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsPermissionAssignmentsBulkDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Clone permission assignments from another asset using uid + +Where `clone_from` is the source uid. + + */ +export type assetsPermissionAssignmentsClonePartialUpdateResponse200 = { + data: PermissionAssignmentResponse[] + status: 200 +} + +export type assetsPermissionAssignmentsClonePartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsPermissionAssignmentsClonePartialUpdateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsPermissionAssignmentsClonePartialUpdateResponseComposite = assetsPermissionAssignmentsClonePartialUpdateResponse200 | assetsPermissionAssignmentsClonePartialUpdateResponse400 | assetsPermissionAssignmentsClonePartialUpdateResponse403; + +export type assetsPermissionAssignmentsClonePartialUpdateResponse = assetsPermissionAssignmentsClonePartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsPermissionAssignmentsClonePartialUpdateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/permission-assignments/clone/` +} + +export const assetsPermissionAssignmentsClonePartialUpdate = async (uidAsset: string, + patchedPermissionAssignmentCloneRequest: PatchedPermissionAssignmentCloneRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPermissionAssignmentsClonePartialUpdateUrl(uidAsset), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedPermissionAssignmentCloneRequest,) + } +);} + + + + +export const getAssetsPermissionAssignmentsClonePartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedPermissionAssignmentCloneRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: PatchedPermissionAssignmentCloneRequest}, TContext> => { + +const mutationKey = ['assetsPermissionAssignmentsClonePartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: PatchedPermissionAssignmentCloneRequest}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsPermissionAssignmentsClonePartialUpdate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsPermissionAssignmentsClonePartialUpdateMutationResult = NonNullable>> + export type AssetsPermissionAssignmentsClonePartialUpdateMutationBody = PatchedPermissionAssignmentCloneRequest + export type AssetsPermissionAssignmentsClonePartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useAssetsPermissionAssignmentsClonePartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedPermissionAssignmentCloneRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsPermissionAssignmentsClonePartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + \ No newline at end of file diff --git a/jsapp/js/api/react-query/manage-permissions/manage-permissions.msw.ts b/jsapp/js/api/react-query/manage-permissions/manage-permissions.msw.ts deleted file mode 100644 index f42da318e1..0000000000 --- a/jsapp/js/api/react-query/manage-permissions/manage-permissions.msw.ts +++ /dev/null @@ -1,196 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import type { PermissionAssignmentResponse } from '../../models/permissionAssignmentResponse' - -export const getApiV2AssetsPermissionAssignmentsListResponseMock = (): PermissionAssignmentResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - user: faker.internet.url(), - permission: faker.internet.url(), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2AssetsPermissionAssignmentsCreateResponseMock = ( - overrideResponse: Partial = {}, -): PermissionAssignmentResponse => ({ - url: faker.internet.url(), - user: faker.internet.url(), - permission: faker.internet.url(), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsPermissionAssignmentsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PermissionAssignmentResponse => ({ - url: faker.internet.url(), - user: faker.internet.url(), - permission: faker.internet.url(), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock = (): PermissionAssignmentResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - user: faker.internet.url(), - permission: faker.internet.url(), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock = (): PermissionAssignmentResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - user: faker.internet.url(), - permission: faker.internet.url(), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2AssetsPermissionAssignmentsListMockHandler = ( - overrideResponse?: - | PermissionAssignmentResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | PermissionAssignmentResponse[]), -) => { - return http.get('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPermissionAssignmentsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPermissionAssignmentsCreateMockHandler = ( - overrideResponse?: - | PermissionAssignmentResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PermissionAssignmentResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPermissionAssignmentsCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = ( - overrideResponse?: - | PermissionAssignmentResponse - | (( - info: Parameters[1]>[0], - ) => Promise | PermissionAssignmentResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPermissionAssignmentsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPermissionAssignmentsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = ( - overrideResponse?: - | PermissionAssignmentResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | PermissionAssignmentResponse[]), -) => { - return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler = ( - overrideResponse?: - | PermissionAssignmentResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | PermissionAssignmentResponse[]), -) => { - return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getManagePermissionsMock = () => [ - getApiV2AssetsPermissionAssignmentsListMockHandler(), - getApiV2AssetsPermissionAssignmentsCreateMockHandler(), - getApiV2AssetsPermissionAssignmentsRetrieveMockHandler(), - getApiV2AssetsPermissionAssignmentsDestroyMockHandler(), - getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler(), - getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler(), - getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler(), -] diff --git a/jsapp/js/api/react-query/manage-permissions/manage-permissions.ts b/jsapp/js/api/react-query/manage-permissions/manage-permissions.ts deleted file mode 100644 index 82b8f5bd55..0000000000 --- a/jsapp/js/api/react-query/manage-permissions/manage-permissions.ts +++ /dev/null @@ -1,753 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { ErrorDetail } from '../../models/errorDetail' - -import type { ErrorObject } from '../../models/errorObject' - -import type { PatchedPermissionAssignmentCloneRequest } from '../../models/patchedPermissionAssignmentCloneRequest' - -import type { PermissionAssignmentBulkRequest } from '../../models/permissionAssignmentBulkRequest' - -import type { PermissionAssignmentCreateRequest } from '../../models/permissionAssignmentCreateRequest' - -import type { PermissionAssignmentResponse } from '../../models/permissionAssignmentResponse' - -import { fetchWithAuth } from '../../orval.mutator' - -type SecondParameter unknown> = Parameters[1] - -/** - * ## List permission assignments - - */ -export type assetsPermissionAssignmentsListResponse200 = { - data: PermissionAssignmentResponse[] - status: 200 -} - -export type assetsPermissionAssignmentsListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsPermissionAssignmentsListResponseComposite = - | assetsPermissionAssignmentsListResponse200 - | assetsPermissionAssignmentsListResponse403 - -export type assetsPermissionAssignmentsListResponse = assetsPermissionAssignmentsListResponseComposite & { - headers: Headers -} - -export const getAssetsPermissionAssignmentsListUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/permission-assignments/` -} - -export const assetsPermissionAssignmentsList = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsPermissionAssignmentsListUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsPermissionAssignmentsListQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'permission-assignments'] as const -} - -export const getAssetsPermissionAssignmentsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsPermissionAssignmentsListQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsPermissionAssignmentsList(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsPermissionAssignmentsListQueryResult = NonNullable< - Awaited> -> -export type AssetsPermissionAssignmentsListQueryError = ErrorDetail - -export function useAssetsPermissionAssignmentsList< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsPermissionAssignmentsListQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Assign a permission - -N.B.: - - Filters use Mongo Query Engine to narrow down results - - Filters are joined with `OR` operator - - Implied permissions will be also assigned. (e.g. `change_asset` will add `view_asset` too) - - */ -export type assetsPermissionAssignmentsCreateResponse200 = { - data: PermissionAssignmentResponse - status: 200 -} - -export type assetsPermissionAssignmentsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsPermissionAssignmentsCreateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsPermissionAssignmentsCreateResponseComposite = - | assetsPermissionAssignmentsCreateResponse200 - | assetsPermissionAssignmentsCreateResponse400 - | assetsPermissionAssignmentsCreateResponse403 - -export type assetsPermissionAssignmentsCreateResponse = assetsPermissionAssignmentsCreateResponseComposite & { - headers: Headers -} - -export const getAssetsPermissionAssignmentsCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/permission-assignments/` -} - -export const assetsPermissionAssignmentsCreate = async ( - uidAsset: string, - permissionAssignmentCreateRequest: PermissionAssignmentCreateRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsPermissionAssignmentsCreateUrl(uidAsset), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(permissionAssignmentCreateRequest), - }) -} - -export const getAssetsPermissionAssignmentsCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PermissionAssignmentCreateRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PermissionAssignmentCreateRequest }, - TContext -> => { - const mutationKey = ['assetsPermissionAssignmentsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: PermissionAssignmentCreateRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsPermissionAssignmentsCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsPermissionAssignmentsCreateMutationResult = NonNullable< - Awaited> -> -export type AssetsPermissionAssignmentsCreateMutationBody = PermissionAssignmentCreateRequest -export type AssetsPermissionAssignmentsCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsPermissionAssignmentsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PermissionAssignmentCreateRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsPermissionAssignmentsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve assignments - - */ -export type assetsPermissionAssignmentsRetrieveResponse200 = { - data: PermissionAssignmentResponse - status: 200 -} - -export type assetsPermissionAssignmentsRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsPermissionAssignmentsRetrieveResponseComposite = - | assetsPermissionAssignmentsRetrieveResponse200 - | assetsPermissionAssignmentsRetrieveResponse403 - -export type assetsPermissionAssignmentsRetrieveResponse = assetsPermissionAssignmentsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsPermissionAssignmentsRetrieveUrl = (uidAsset: string, uidPermissionAssignment: string) => { - return `/api/v2/assets/${uidAsset}/permission-assignments/${uidPermissionAssignment}/` -} - -export const assetsPermissionAssignmentsRetrieve = async ( - uidAsset: string, - uidPermissionAssignment: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsPermissionAssignmentsRetrieveUrl(uidAsset, uidPermissionAssignment), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetsPermissionAssignmentsRetrieveQueryKey = (uidAsset: string, uidPermissionAssignment: string) => { - return ['api', 'v2', 'assets', uidAsset, 'permission-assignments', uidPermissionAssignment] as const -} - -export const getAssetsPermissionAssignmentsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidPermissionAssignment: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = - queryOptions?.queryKey ?? getAssetsPermissionAssignmentsRetrieveQueryKey(uidAsset, uidPermissionAssignment) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsPermissionAssignmentsRetrieve(uidAsset, uidPermissionAssignment, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidPermissionAssignment), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsPermissionAssignmentsRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsPermissionAssignmentsRetrieveQueryError = ErrorDetail - -export function useAssetsPermissionAssignmentsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidPermissionAssignment: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsPermissionAssignmentsRetrieveQueryOptions(uidAsset, uidPermissionAssignment, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Remove a permission assignment - - */ -export type assetsPermissionAssignmentsDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsPermissionAssignmentsDestroyResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsPermissionAssignmentsDestroyResponseComposite = - | assetsPermissionAssignmentsDestroyResponse204 - | assetsPermissionAssignmentsDestroyResponse403 - -export type assetsPermissionAssignmentsDestroyResponse = assetsPermissionAssignmentsDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsPermissionAssignmentsDestroyUrl = (uidAsset: string, uidPermissionAssignment: string) => { - return `/api/v2/assets/${uidAsset}/permission-assignments/${uidPermissionAssignment}/` -} - -export const assetsPermissionAssignmentsDestroy = async ( - uidAsset: string, - uidPermissionAssignment: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsPermissionAssignmentsDestroyUrl(uidAsset, uidPermissionAssignment), - { - ...options, - method: 'DELETE', - }, - ) -} - -export const getAssetsPermissionAssignmentsDestroyMutationOptions = < - TError = ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidPermissionAssignment: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidPermissionAssignment: string }, - TContext -> => { - const mutationKey = ['assetsPermissionAssignmentsDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidPermissionAssignment: string } - > = (props) => { - const { uidAsset, uidPermissionAssignment } = props ?? {} - - return assetsPermissionAssignmentsDestroy(uidAsset, uidPermissionAssignment, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsPermissionAssignmentsDestroyMutationResult = NonNullable< - Awaited> -> - -export type AssetsPermissionAssignmentsDestroyMutationError = ErrorDetail - -export const useAssetsPermissionAssignmentsDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidPermissionAssignment: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsPermissionAssignmentsDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Assign multiple permissions at once - -* Can put both regular and partial permission in the payload - - */ -export type assetsPermissionAssignmentsBulkCreateResponse200 = { - data: PermissionAssignmentResponse[] - status: 200 -} - -export type assetsPermissionAssignmentsBulkCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsPermissionAssignmentsBulkCreateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsPermissionAssignmentsBulkCreateResponseComposite = - | assetsPermissionAssignmentsBulkCreateResponse200 - | assetsPermissionAssignmentsBulkCreateResponse400 - | assetsPermissionAssignmentsBulkCreateResponse403 - -export type assetsPermissionAssignmentsBulkCreateResponse = assetsPermissionAssignmentsBulkCreateResponseComposite & { - headers: Headers -} - -export const getAssetsPermissionAssignmentsBulkCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/permission-assignments/bulk/` -} - -export const assetsPermissionAssignmentsBulkCreate = async ( - uidAsset: string, - permissionAssignmentBulkRequest: PermissionAssignmentBulkRequest[], - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsPermissionAssignmentsBulkCreateUrl(uidAsset), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(permissionAssignmentBulkRequest), - }, - ) -} - -export const getAssetsPermissionAssignmentsBulkCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PermissionAssignmentBulkRequest[] }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PermissionAssignmentBulkRequest[] }, - TContext -> => { - const mutationKey = ['assetsPermissionAssignmentsBulkCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: PermissionAssignmentBulkRequest[] } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsPermissionAssignmentsBulkCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsPermissionAssignmentsBulkCreateMutationResult = NonNullable< - Awaited> -> -export type AssetsPermissionAssignmentsBulkCreateMutationBody = PermissionAssignmentBulkRequest[] -export type AssetsPermissionAssignmentsBulkCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsPermissionAssignmentsBulkCreate = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PermissionAssignmentBulkRequest[] }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsPermissionAssignmentsBulkCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Remove all permission assignments - -⚠️ **Warning** -This endpoint currently supports deleting **only the user whose username is provided as a parameter**. -Deletion of other accounts is not yet supported. - -**Payload** -```json -{ - "username": "bob" -} -``` - -_Due to limitations with DRF-Spectacular current version, `DELETE` actions do not support showing a request body OR a response body. This is due to the 'vague' nature of the action which generally does *not* recommend the use of a payload. To still document this endpoint, example for the payload and response will be included but it will not be possible to test this endpoint. The HTTP code and the errors example are, for their part, factual and can be considered when working with the endpoint._ - - */ -export type assetsPermissionAssignmentsBulkDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsPermissionAssignmentsBulkDestroyResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsPermissionAssignmentsBulkDestroyResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsPermissionAssignmentsBulkDestroyResponseComposite = - | assetsPermissionAssignmentsBulkDestroyResponse204 - | assetsPermissionAssignmentsBulkDestroyResponse400 - | assetsPermissionAssignmentsBulkDestroyResponse403 - -export type assetsPermissionAssignmentsBulkDestroyResponse = assetsPermissionAssignmentsBulkDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsPermissionAssignmentsBulkDestroyUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/permission-assignments/bulk/` -} - -export const assetsPermissionAssignmentsBulkDestroy = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsPermissionAssignmentsBulkDestroyUrl(uidAsset), - { - ...options, - method: 'DELETE', - }, - ) -} - -export const getAssetsPermissionAssignmentsBulkDestroyMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext -> => { - const mutationKey = ['assetsPermissionAssignmentsBulkDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string } - > = (props) => { - const { uidAsset } = props ?? {} - - return assetsPermissionAssignmentsBulkDestroy(uidAsset, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsPermissionAssignmentsBulkDestroyMutationResult = NonNullable< - Awaited> -> - -export type AssetsPermissionAssignmentsBulkDestroyMutationError = ErrorObject | ErrorDetail - -export const useAssetsPermissionAssignmentsBulkDestroy = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsPermissionAssignmentsBulkDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Clone permission assignments from another asset using uid - -Where `clone_from` is the source uid. - - */ -export type assetsPermissionAssignmentsClonePartialUpdateResponse200 = { - data: PermissionAssignmentResponse[] - status: 200 -} - -export type assetsPermissionAssignmentsClonePartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsPermissionAssignmentsClonePartialUpdateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsPermissionAssignmentsClonePartialUpdateResponseComposite = - | assetsPermissionAssignmentsClonePartialUpdateResponse200 - | assetsPermissionAssignmentsClonePartialUpdateResponse400 - | assetsPermissionAssignmentsClonePartialUpdateResponse403 - -export type assetsPermissionAssignmentsClonePartialUpdateResponse = - assetsPermissionAssignmentsClonePartialUpdateResponseComposite & { - headers: Headers - } - -export const getAssetsPermissionAssignmentsClonePartialUpdateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/permission-assignments/clone/` -} - -export const assetsPermissionAssignmentsClonePartialUpdate = async ( - uidAsset: string, - patchedPermissionAssignmentCloneRequest: PatchedPermissionAssignmentCloneRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsPermissionAssignmentsClonePartialUpdateUrl(uidAsset), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedPermissionAssignmentCloneRequest), - }, - ) -} - -export const getAssetsPermissionAssignmentsClonePartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedPermissionAssignmentCloneRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedPermissionAssignmentCloneRequest }, - TContext -> => { - const mutationKey = ['assetsPermissionAssignmentsClonePartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: PatchedPermissionAssignmentCloneRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsPermissionAssignmentsClonePartialUpdate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsPermissionAssignmentsClonePartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsPermissionAssignmentsClonePartialUpdateMutationBody = PatchedPermissionAssignmentCloneRequest -export type AssetsPermissionAssignmentsClonePartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useAssetsPermissionAssignmentsClonePartialUpdate = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedPermissionAssignmentCloneRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsPermissionAssignmentsClonePartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} diff --git a/jsapp/js/api/react-query/manage-permissions/msw.ts b/jsapp/js/api/react-query/manage-permissions/msw.ts new file mode 100644 index 0000000000..106e8875ab --- /dev/null +++ b/jsapp/js/api/react-query/manage-permissions/msw.ts @@ -0,0 +1,110 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import type { + PermissionAssignmentResponse +} from '../../models/permissionAssignmentResponse'; + + +export const getApiV2AssetsPermissionAssignmentsListResponseMock = (): PermissionAssignmentResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), user: faker.internet.url(), permission: faker.internet.url(), label: faker.string.alpha({length: {min: 10, max: 20}})}))) + +export const getApiV2AssetsPermissionAssignmentsCreateResponseMock = (overrideResponse: Partial< PermissionAssignmentResponse > = {}): PermissionAssignmentResponse => ({url: faker.internet.url(), user: faker.internet.url(), permission: faker.internet.url(), label: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsPermissionAssignmentsRetrieveResponseMock = (overrideResponse: Partial< PermissionAssignmentResponse > = {}): PermissionAssignmentResponse => ({url: faker.internet.url(), user: faker.internet.url(), permission: faker.internet.url(), label: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock = (): PermissionAssignmentResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), user: faker.internet.url(), permission: faker.internet.url(), label: faker.string.alpha({length: {min: 10, max: 20}})}))) + +export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock = (): PermissionAssignmentResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), user: faker.internet.url(), permission: faker.internet.url(), label: faker.string.alpha({length: {min: 10, max: 20}})}))) + + +export const getApiV2AssetsPermissionAssignmentsListMockHandler = (overrideResponse?: PermissionAssignmentResponse[] | ((info: Parameters[1]>[0]) => Promise | PermissionAssignmentResponse[])) => { + return http.get('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPermissionAssignmentsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsPermissionAssignmentsCreateMockHandler = (overrideResponse?: PermissionAssignmentResponse | ((info: Parameters[1]>[0]) => Promise | PermissionAssignmentResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPermissionAssignmentsCreateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = (overrideResponse?: PermissionAssignmentResponse | ((info: Parameters[1]>[0]) => Promise | PermissionAssignmentResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPermissionAssignmentsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsPermissionAssignmentsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = (overrideResponse?: PermissionAssignmentResponse[] | ((info: Parameters[1]>[0]) => Promise | PermissionAssignmentResponse[])) => { + return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler = (overrideResponse?: PermissionAssignmentResponse[] | ((info: Parameters[1]>[0]) => Promise | PermissionAssignmentResponse[])) => { + return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} +export const getManagePermissionsMock = () => [ + getApiV2AssetsPermissionAssignmentsListMockHandler(), + getApiV2AssetsPermissionAssignmentsCreateMockHandler(), + getApiV2AssetsPermissionAssignmentsRetrieveMockHandler(), + getApiV2AssetsPermissionAssignmentsDestroyMockHandler(), + getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler(), + getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler(), + getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler() +] diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content/index.ts b/jsapp/js/api/react-query/manage-projects-and-library-content/index.ts new file mode 100644 index 0000000000..2fa90001ed --- /dev/null +++ b/jsapp/js/api/react-query/manage-projects-and-library-content/index.ts @@ -0,0 +1,2743 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + Asset +} from '../../models/asset'; + +import type { + AssetBulkRequest +} from '../../models/assetBulkRequest'; + +import type { + AssetBulkResponse +} from '../../models/assetBulkResponse'; + +import type { + AssetCreateRequest +} from '../../models/assetCreateRequest'; + +import type { + AssetListCount +} from '../../models/assetListCount'; + +import type { + AssetMetadataResponse +} from '../../models/assetMetadataResponse'; + +import type { + AssetsCountsListParams +} from '../../models/assetsCountsListParams'; + +import type { + AssetsListParams +} from '../../models/assetsListParams'; + +import type { + AssetsMinimalListRetrieveParams +} from '../../models/assetsMinimalListRetrieveParams'; + +import type { + AssetsRetrieveParams +} from '../../models/assetsRetrieveParams'; + +import type { + AssetsVersionsListParams +} from '../../models/assetsVersionsListParams'; + +import type { + DeploymentCreateRequest +} from '../../models/deploymentCreateRequest'; + +import type { + DeploymentResponse +} from '../../models/deploymentResponse'; + +import type { + ErrorDetail +} from '../../models/errorDetail'; + +import type { + ErrorObject +} from '../../models/errorObject'; + +import type { + HashResponse +} from '../../models/hashResponse'; + +import type { + ImportCreateRequest +} from '../../models/importCreateRequest'; + +import type { + ImportCreateResponse +} from '../../models/importCreateResponse'; + +import type { + ImportResponse +} from '../../models/importResponse'; + +import type { + ImportsListParams +} from '../../models/importsListParams'; + +import type { + PaginatedAssetCountResponseList +} from '../../models/paginatedAssetCountResponseList'; + +import type { + PaginatedAssetList +} from '../../models/paginatedAssetList'; + +import type { + PaginatedAssetMinimalListList +} from '../../models/paginatedAssetMinimalListList'; + +import type { + PaginatedImportResponseList +} from '../../models/paginatedImportResponseList'; + +import type { + PaginatedProjectInviteResponseList +} from '../../models/paginatedProjectInviteResponseList'; + +import type { + PaginatedTagListResponseList +} from '../../models/paginatedTagListResponseList'; + +import type { + PaginatedVersionListResponseList +} from '../../models/paginatedVersionListResponseList'; + +import type { + PatchedAssetPatchRequest +} from '../../models/patchedAssetPatchRequest'; + +import type { + PatchedDeploymentPatchRequest +} from '../../models/patchedDeploymentPatchRequest'; + +import type { + PatchedInviteUpdatePayload +} from '../../models/patchedInviteUpdatePayload'; + +import type { + ProjectInviteCreatePayload +} from '../../models/projectInviteCreatePayload'; + +import type { + ProjectInviteResponse +} from '../../models/projectInviteResponse'; + +import type { + ProjectOwnershipInvitesListParams +} from '../../models/projectOwnershipInvitesListParams'; + +import type { + TagRetrieveResponse +} from '../../models/tagRetrieveResponse'; + +import type { + TagsListParams +} from '../../models/tagsListParams'; + +import type { + TransferListResponse +} from '../../models/transferListResponse'; + +import type { + VersionRetrieveResponse +} from '../../models/versionRetrieveResponse'; + +import { fetchWithAuth } from '../../orval.mutator'; + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * ## Get user's assets + + +Search can be made with `q` parameter. +Search filters can be returned with results by passing `metadata=on` to querystring. + + +Results can be sorted with `ordering` parameter, e.g.: + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/?ordering=-name +``` + + +Allowed fields are: + +- `asset_type` +- `date_modified` +- `date_deployed` +- `date_modified__date` +- `date_deployed__date` +- `name` +- `settings__sector` +- `settings__sector__value` +- `settings__description` +- `owner__username` +- `owner__extra_details__data__name` +- `owner__extra_details__data__organization` +- `owner__email` +- `_deployment_status` +- `subscribers_count` + + +Note: Collections can be displayed first with parameter `collections_first`, e.g.: + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/?collections_first=true&ordering=-name +``` + + */ +export type assetsListResponse200 = { + data: PaginatedAssetList + status: 200 +} + +export type assetsListResponseComposite = assetsListResponse200; + +export type assetsListResponse = assetsListResponseComposite & { + headers: Headers; +} + +export const getAssetsListUrl = (params?: AssetsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/?${stringifiedParams}` : `/api/v2/assets/` +} + +export const assetsList = async (params?: AssetsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsListQueryKey = (params?: AssetsListParams,) => { + return ['api','v2','assets', ...(params ? [params]: [])] as const; + } + + +export const getAssetsListQueryOptions = >, TError = unknown>(params?: AssetsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsListQueryResult = NonNullable>> +export type AssetsListQueryError = unknown + + + +export function useAssetsList>, TError = unknown>( + params?: AssetsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create or clone an asset + +When cloning an asset, you must provide: + +- the name (as a string), +- the `clone_from` (the uid representing the asset), +- the asset_type + +Where `asset_type` must be one of these values: + +* block (can be cloned to `block`, `question`, `survey`, `template`) +* question (can be cloned to `question`, `survey`, `template`) +* survey (can be cloned to `block`, `question`, `survey`, `template`) +* template (can be cloned to `survey`, `template`) + +Settings are cloned only when type of assets are `survey` or `template`. +In that case, `share-metadata` is not preserved. + +When creating a new `block` or `question` asset, settings are not saved either. + + */ +export type assetsCreateResponse201 = { + data: Asset + status: 201 +} + +export type assetsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsCreateResponseComposite = assetsCreateResponse201 | assetsCreateResponse400 | assetsCreateResponse401; + +export type assetsCreateResponse = assetsCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsCreateUrl = () => { + + + + + return `/api/v2/assets/` +} + +export const assetsCreate = async (assetCreateRequest: AssetCreateRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsCreateUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + assetCreateRequest,) + } +);} + + + + +export const getAssetsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetCreateRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: AssetCreateRequest}, TContext> => { + +const mutationKey = ['assetsCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: AssetCreateRequest}> = (props) => { + const {data} = props ?? {}; + + return assetsCreate(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsCreateMutationResult = NonNullable>> + export type AssetsCreateMutationBody = AssetCreateRequest + export type AssetsCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetCreateRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Get a user's current asset + + */ +export type assetsRetrieveResponse200 = { + data: Asset + status: 200 +} + +export type assetsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsRetrieveResponseComposite = assetsRetrieveResponse200 | assetsRetrieveResponse404; + +export type assetsRetrieveResponse = assetsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsRetrieveUrl = (uidAsset: string, + params?: AssetsRetrieveParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/` +} + +export const assetsRetrieve = async (uidAsset: string, + params?: AssetsRetrieveParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsRetrieveUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsRetrieveQueryKey = (uidAsset: string, + params?: AssetsRetrieveParams,) => { + return ['api','v2','assets',uidAsset, ...(params ? [params]: [])] as const; + } + + +export const getAssetsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsRetrieveQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsRetrieve(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsRetrieveQueryResult = NonNullable>> +export type AssetsRetrieveQueryError = ErrorDetail + + + +export function useAssetsRetrieve>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsRetrieveQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update or connect a user's asset + +Updates a project or connect project's data from this project to other projects + +When `Data sharing`: + +`fields`: Optional. List of questions whose responses will be shared. If +missing or empty, all responses will be shared. Questions must be +identified by full group path separated by slashes, e.g. +`group/subgroup/question_name`. + + */ +export type assetsPartialUpdateResponse200 = { + data: Asset + status: 200 +} + +export type assetsPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsPartialUpdateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsPartialUpdateResponseComposite = assetsPartialUpdateResponse200 | assetsPartialUpdateResponse400 | assetsPartialUpdateResponse401; + +export type assetsPartialUpdateResponse = assetsPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsPartialUpdateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/` +} + +export const assetsPartialUpdate = async (uidAsset: string, + patchedAssetPatchRequest: PatchedAssetPatchRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPartialUpdateUrl(uidAsset), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedAssetPatchRequest,) + } +);} + + + + +export const getAssetsPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedAssetPatchRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: PatchedAssetPatchRequest}, TContext> => { + +const mutationKey = ['assetsPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: PatchedAssetPatchRequest}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsPartialUpdate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsPartialUpdateMutationResult = NonNullable>> + export type AssetsPartialUpdateMutationBody = PatchedAssetPatchRequest + export type AssetsPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useAssetsPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedAssetPatchRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Delete a user's asset + + */ +export type assetsDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsDestroyResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsDestroyResponseComposite = assetsDestroyResponse204 | assetsDestroyResponse401; + +export type assetsDestroyResponse = assetsDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsDestroyUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/` +} + +export const assetsDestroy = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDestroyUrl(uidAsset), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { + +const mutationKey = ['assetsDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { + const {uidAsset} = props ?? {}; + + return assetsDestroy(uidAsset,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDestroyMutationResult = NonNullable>> + + export type AssetsDestroyMutationError = ErrorDetail + + export const useAssetsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Count the daily amount of submissions + +Returns up to the last 31 days of daily counts and total counts of submissions to a survey. + + +Use the `days` query to get the daily counts from the last x amount of days. +Default amount is 30 days + + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/counts/?days=7 +``` + + */ +export type assetsCountsListResponse200 = { + data: PaginatedAssetCountResponseList + status: 200 +} + +export type assetsCountsListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsCountsListResponseComposite = assetsCountsListResponse200 | assetsCountsListResponse401; + +export type assetsCountsListResponse = assetsCountsListResponseComposite & { + headers: Headers; +} + +export const getAssetsCountsListUrl = (uidAsset: string, + params?: AssetsCountsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/counts/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/counts/` +} + +export const assetsCountsList = async (uidAsset: string, + params?: AssetsCountsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsCountsListUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsCountsListQueryKey = (uidAsset: string, + params?: AssetsCountsListParams,) => { + return ['api','v2','assets',uidAsset,'counts', ...(params ? [params]: [])] as const; + } + + +export const getAssetsCountsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsCountsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsCountsListQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsCountsList(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsCountsListQueryResult = NonNullable>> +export type AssetsCountsListQueryError = ErrorDetail + + + +export function useAssetsCountsList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsCountsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsCountsListQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve the existing deployment (if any) + + */ +export type assetsDeploymentRetrieveResponse200 = { + data: DeploymentResponse + status: 200 +} + +export type assetsDeploymentRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDeploymentRetrieveResponseComposite = assetsDeploymentRetrieveResponse200 | assetsDeploymentRetrieveResponse404; + +export type assetsDeploymentRetrieveResponse = assetsDeploymentRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsDeploymentRetrieveUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/deployment/` +} + +export const assetsDeploymentRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDeploymentRetrieveUrl(uidAsset), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDeploymentRetrieveQueryKey = (uidAsset: string,) => { + return ['api','v2','assets',uidAsset,'deployment'] as const; + } + + +export const getAssetsDeploymentRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDeploymentRetrieveQueryKey(uidAsset); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDeploymentRetrieve(uidAsset, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDeploymentRetrieveQueryResult = NonNullable>> +export type AssetsDeploymentRetrieveQueryError = ErrorDetail + + + +export function useAssetsDeploymentRetrieve>, TError = ErrorDetail>( + uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDeploymentRetrieveQueryOptions(uidAsset,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## (Re)Deploy a form + +Deploy a new form or re-deploy an existing one. + + */ +export type assetsDeploymentCreateResponse200 = { + data: DeploymentResponse + status: 200 +} + +export type assetsDeploymentCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsDeploymentCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsDeploymentCreateResponseComposite = assetsDeploymentCreateResponse200 | assetsDeploymentCreateResponse400 | assetsDeploymentCreateResponse401; + +export type assetsDeploymentCreateResponse = assetsDeploymentCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsDeploymentCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/deployment/` +} + +export const assetsDeploymentCreate = async (uidAsset: string, + deploymentCreateRequest: DeploymentCreateRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDeploymentCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + deploymentCreateRequest,) + } +);} + + + + +export const getAssetsDeploymentCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: DeploymentCreateRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: DeploymentCreateRequest}, TContext> => { + +const mutationKey = ['assetsDeploymentCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: DeploymentCreateRequest}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsDeploymentCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDeploymentCreateMutationResult = NonNullable>> + export type AssetsDeploymentCreateMutationBody = DeploymentCreateRequest + export type AssetsDeploymentCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsDeploymentCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: DeploymentCreateRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDeploymentCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## (Un)Archive the existing deployment. + +Update the `active` field of the existing deployment. + +To overwrite the entire deployment (including the form contents), use a PUT request. + + */ +export type assetsDeploymentPartialUpdateResponse200 = { + data: DeploymentResponse + status: 200 +} + +export type assetsDeploymentPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsDeploymentPartialUpdateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsDeploymentPartialUpdateResponseComposite = assetsDeploymentPartialUpdateResponse200 | assetsDeploymentPartialUpdateResponse400 | assetsDeploymentPartialUpdateResponse401; + +export type assetsDeploymentPartialUpdateResponse = assetsDeploymentPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsDeploymentPartialUpdateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/deployment/` +} + +export const assetsDeploymentPartialUpdate = async (uidAsset: string, + patchedDeploymentPatchRequest: PatchedDeploymentPatchRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDeploymentPartialUpdateUrl(uidAsset), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedDeploymentPatchRequest,) + } +);} + + + + +export const getAssetsDeploymentPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDeploymentPatchRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: PatchedDeploymentPatchRequest}, TContext> => { + +const mutationKey = ['assetsDeploymentPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: PatchedDeploymentPatchRequest}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsDeploymentPartialUpdate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDeploymentPartialUpdateMutationResult = NonNullable>> + export type AssetsDeploymentPartialUpdateMutationBody = PatchedDeploymentPatchRequest + export type AssetsDeploymentPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useAssetsDeploymentPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDeploymentPatchRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDeploymentPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## List the versions of forms + + */ +export type assetsVersionsListResponse200 = { + data: PaginatedVersionListResponseList + status: 200 +} + +export type assetsVersionsListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsVersionsListResponseComposite = assetsVersionsListResponse200 | assetsVersionsListResponse404; + +export type assetsVersionsListResponse = assetsVersionsListResponseComposite & { + headers: Headers; +} + +export const getAssetsVersionsListUrl = (uidAsset: string, + params?: AssetsVersionsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/versions/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/versions/` +} + +export const assetsVersionsList = async (uidAsset: string, + params?: AssetsVersionsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsVersionsListUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsVersionsListQueryKey = (uidAsset: string, + params?: AssetsVersionsListParams,) => { + return ['api','v2','assets',uidAsset,'versions', ...(params ? [params]: [])] as const; + } + + +export const getAssetsVersionsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsVersionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsVersionsListQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsVersionsList(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsVersionsListQueryResult = NonNullable>> +export type AssetsVersionsListQueryError = ErrorDetail + + + +export function useAssetsVersionsList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsVersionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsVersionsListQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve asset versions + +Returns the details of an asset version + + */ +export type assetsVersionsRetrieveResponse200 = { + data: VersionRetrieveResponse + status: 200 +} + +export type assetsVersionsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsVersionsRetrieveResponseComposite = assetsVersionsRetrieveResponse200 | assetsVersionsRetrieveResponse404; + +export type assetsVersionsRetrieveResponse = assetsVersionsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsVersionsRetrieveUrl = (uidAsset: string, + uidVersion: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/versions/${uidVersion}/` +} + +export const assetsVersionsRetrieve = async (uidAsset: string, + uidVersion: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsVersionsRetrieveUrl(uidAsset,uidVersion), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsVersionsRetrieveQueryKey = (uidAsset: string, + uidVersion: string,) => { + return ['api','v2','assets',uidAsset,'versions',uidVersion] as const; + } + + +export const getAssetsVersionsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidVersion: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsVersionsRetrieveQueryKey(uidAsset,uidVersion); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsVersionsRetrieve(uidAsset,uidVersion, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidVersion), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsVersionsRetrieveQueryResult = NonNullable>> +export type AssetsVersionsRetrieveQueryError = ErrorDetail + + + +export function useAssetsVersionsRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidVersion: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsVersionsRetrieveQueryOptions(uidAsset,uidVersion,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## This route will render the XForm into syntax-highlighted HTML. + +It is useful for debugging pyxform transformations + + */ +export type assetsXformRetrieveResponse200 = { + data: string + status: 200 +} + +export type assetsXformRetrieveResponse404 = { + data: void + status: 404 +} + +export type assetsXformRetrieveResponseComposite = assetsXformRetrieveResponse200 | assetsXformRetrieveResponse404; + +export type assetsXformRetrieveResponse = assetsXformRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsXformRetrieveUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/xform/` +} + +export const assetsXformRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsXformRetrieveUrl(uidAsset), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsXformRetrieveQueryKey = (uidAsset: string,) => { + return ['api','v2','assets',uidAsset,'xform'] as const; + } + + +export const getAssetsXformRetrieveQueryOptions = >, TError = void>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsXformRetrieveQueryKey(uidAsset); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsXformRetrieve(uidAsset, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsXformRetrieveQueryResult = NonNullable>> +export type AssetsXformRetrieveQueryError = void + + + +export function useAssetsXformRetrieve>, TError = void>( + uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsXformRetrieveQueryOptions(uidAsset,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Perform bulk actions on assets + +Actions available: + +- `archive` +- `delete` +- `unarchive` +- `undelete` (superusers only) + + */ +export type assetsBulkCreateResponse200 = { + data: AssetBulkResponse + status: 200 +} + +export type assetsBulkCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsBulkCreateResponseComposite = assetsBulkCreateResponse200 | assetsBulkCreateResponse404; + +export type assetsBulkCreateResponse = assetsBulkCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsBulkCreateUrl = () => { + + + + + return `/api/v2/assets/bulk/` +} + +export const assetsBulkCreate = async (assetBulkRequest: AssetBulkRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsBulkCreateUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + assetBulkRequest,) + } +);} + + + + +export const getAssetsBulkCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetBulkRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: AssetBulkRequest}, TContext> => { + +const mutationKey = ['assetsBulkCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: AssetBulkRequest}> = (props) => { + const {data} = props ?? {}; + + return assetsBulkCreate(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsBulkCreateMutationResult = NonNullable>> + export type AssetsBulkCreateMutationBody = AssetBulkRequest + export type AssetsBulkCreateMutationError = ErrorDetail + + export const useAssetsBulkCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetBulkRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsBulkCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Return counts of deployed, archived, and draft assets + + */ +export type assetsCountsRetrieveResponse200 = { + data: AssetListCount + status: 200 +} + +export type assetsCountsRetrieveResponseComposite = assetsCountsRetrieveResponse200; + +export type assetsCountsRetrieveResponse = assetsCountsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsCountsRetrieveUrl = () => { + + + + + return `/api/v2/assets/counts/` +} + +export const assetsCountsRetrieve = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsCountsRetrieveUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsCountsRetrieveQueryKey = () => { + return ['api','v2','assets','counts'] as const; + } + + +export const getAssetsCountsRetrieveQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsCountsRetrieveQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsCountsRetrieve({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsCountsRetrieveQueryResult = NonNullable>> +export type AssetsCountsRetrieveQueryError = unknown + + + +export function useAssetsCountsRetrieve>, TError = unknown>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsCountsRetrieveQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Get a hash of all `version_id`s of all accessible assets by the current user. + +Useful to detect any changes in assets with only one call to `API` + + */ +export type assetsHashRetrieveResponse200 = { + data: HashResponse + status: 200 +} + +export type assetsHashRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsHashRetrieveResponseComposite = assetsHashRetrieveResponse200 | assetsHashRetrieveResponse401; + +export type assetsHashRetrieveResponse = assetsHashRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsHashRetrieveUrl = () => { + + + + + return `/api/v2/assets/hash/` +} + +export const assetsHashRetrieve = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHashRetrieveUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsHashRetrieveQueryKey = () => { + return ['api','v2','assets','hash'] as const; + } + + +export const getAssetsHashRetrieveQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsHashRetrieveQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsHashRetrieve({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsHashRetrieveQueryResult = NonNullable>> +export type AssetsHashRetrieveQueryError = ErrorDetail + + + +export function useAssetsHashRetrieve>, TError = ErrorDetail>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsHashRetrieveQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Get metadata for all authenticated user' assets + + */ +export type assetsMetadataRetrieveResponse200 = { + data: AssetMetadataResponse + status: 200 +} + +export type assetsMetadataRetrieveResponseComposite = assetsMetadataRetrieveResponse200; + +export type assetsMetadataRetrieveResponse = assetsMetadataRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsMetadataRetrieveUrl = () => { + + + + + return `/api/v2/assets/metadata/` +} + +export const assetsMetadataRetrieve = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsMetadataRetrieveUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsMetadataRetrieveQueryKey = () => { + return ['api','v2','assets','metadata'] as const; + } + + +export const getAssetsMetadataRetrieveQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsMetadataRetrieveQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsMetadataRetrieve({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsMetadataRetrieveQueryResult = NonNullable>> +export type AssetsMetadataRetrieveQueryError = unknown + + + +export function useAssetsMetadataRetrieve>, TError = unknown>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsMetadataRetrieveQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Return a minimal listing of assets with their deployment status + +Returns a paginated list of assets visible to the current user, including only `uid`, `name`, and `deployment_status` (`draft`, `deployed`, or `archived`). + +Use the `q` query parameter to filter by asset type (e.g. `?q=asset_type:survey`). + +Responses do not include a `count` field. Use the `next` and `previous` links to paginate through results. + + */ +export type assetsMinimalListRetrieveResponse200 = { + data: PaginatedAssetMinimalListList + status: 200 +} + +export type assetsMinimalListRetrieveResponseComposite = assetsMinimalListRetrieveResponse200; + +export type assetsMinimalListRetrieveResponse = assetsMinimalListRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsMinimalListRetrieveUrl = (params?: AssetsMinimalListRetrieveParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/minimal-list/?${stringifiedParams}` : `/api/v2/assets/minimal-list/` +} + +export const assetsMinimalListRetrieve = async (params?: AssetsMinimalListRetrieveParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsMinimalListRetrieveUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsMinimalListRetrieveQueryKey = (params?: AssetsMinimalListRetrieveParams,) => { + return ['api','v2','assets','minimal-list', ...(params ? [params]: [])] as const; + } + + +export const getAssetsMinimalListRetrieveQueryOptions = >, TError = unknown>(params?: AssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsMinimalListRetrieveQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsMinimalListRetrieve(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsMinimalListRetrieveQueryResult = NonNullable>> +export type AssetsMinimalListRetrieveQueryError = unknown + + + +export function useAssetsMinimalListRetrieve>, TError = unknown>( + params?: AssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsMinimalListRetrieveQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List imported files + + */ +export type importsListResponse200 = { + data: PaginatedImportResponseList + status: 200 +} + +export type importsListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type importsListResponseComposite = importsListResponse200 | importsListResponse401; + +export type importsListResponse = importsListResponseComposite & { + headers: Headers; +} + +export const getImportsListUrl = (params?: ImportsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/imports/?${stringifiedParams}` : `/api/v2/imports/` +} + +export const importsList = async (params?: ImportsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getImportsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getImportsListQueryKey = (params?: ImportsListParams,) => { + return ['api','v2','imports', ...(params ? [params]: [])] as const; + } + + +export const getImportsListQueryOptions = >, TError = ErrorDetail>(params?: ImportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getImportsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => importsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ImportsListQueryResult = NonNullable>> +export type ImportsListQueryError = ErrorDetail + + + +export function useImportsList>, TError = ErrorDetail>( + params?: ImportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getImportsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Import file + +_**Note**: this endpoint is expecting a multipart/form-data_ + + */ +export type importsCreateResponse201 = { + data: ImportCreateResponse + status: 201 +} + +export type importsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type importsCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type importsCreateResponseComposite = importsCreateResponse201 | importsCreateResponse400 | importsCreateResponse401; + +export type importsCreateResponse = importsCreateResponseComposite & { + headers: Headers; +} + +export const getImportsCreateUrl = () => { + + + + + return `/api/v2/imports/` +} + +export const importsCreate = async (importCreateRequest: ImportCreateRequest, options?: RequestInit): Promise => { + const formData = new FormData(); +formData.append(`destination`, importCreateRequest.destination) +formData.append(`url`, importCreateRequest.url) +if(importCreateRequest.name !== undefined) { + formData.append(`name`, importCreateRequest.name) + } +formData.append(`assetUid`, importCreateRequest.assetUid) + + return fetchWithAuth(getImportsCreateUrl(), + { + ...options, + method: 'POST' + , + body: + formData, + } +);} + + + + +export const getImportsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ImportCreateRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ImportCreateRequest}, TContext> => { + +const mutationKey = ['importsCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ImportCreateRequest}> = (props) => { + const {data} = props ?? {}; + + return importsCreate(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ImportsCreateMutationResult = NonNullable>> + export type ImportsCreateMutationBody = ImportCreateRequest + export type ImportsCreateMutationError = ErrorObject | ErrorDetail + + export const useImportsCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: ImportCreateRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getImportsCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve imported files + + */ +export type importsRetrieveResponse200 = { + data: ImportResponse + status: 200 +} + +export type importsRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type importsRetrieveResponseComposite = importsRetrieveResponse200 | importsRetrieveResponse401; + +export type importsRetrieveResponse = importsRetrieveResponseComposite & { + headers: Headers; +} + +export const getImportsRetrieveUrl = (uidImport: string,) => { + + + + + return `/api/v2/imports/${uidImport}/` +} + +export const importsRetrieve = async (uidImport: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getImportsRetrieveUrl(uidImport), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getImportsRetrieveQueryKey = (uidImport: string,) => { + return ['api','v2','imports',uidImport] as const; + } + + +export const getImportsRetrieveQueryOptions = >, TError = ErrorDetail>(uidImport: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getImportsRetrieveQueryKey(uidImport); + + + + const queryFn: QueryFunction>> = ({ signal }) => importsRetrieve(uidImport, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidImport), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ImportsRetrieveQueryResult = NonNullable>> +export type ImportsRetrieveQueryError = ErrorDetail + + + +export function useImportsRetrieve>, TError = ErrorDetail>( + uidImport: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getImportsRetrieveQueryOptions(uidImport,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List of invites + +Invites sent or received by current user about transferring project ownership. + +List can be filtered with `mode` parameter, e.g.: display only received invites. + +Possible values for `mode`: +- `sender` +- `recipient` + + + */ +export type projectOwnershipInvitesListResponse200 = { + data: PaginatedProjectInviteResponseList + status: 200 +} + +export type projectOwnershipInvitesListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectOwnershipInvitesListResponseComposite = projectOwnershipInvitesListResponse200 | projectOwnershipInvitesListResponse403; + +export type projectOwnershipInvitesListResponse = projectOwnershipInvitesListResponseComposite & { + headers: Headers; +} + +export const getProjectOwnershipInvitesListUrl = (params?: ProjectOwnershipInvitesListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/project-ownership/invites/?${stringifiedParams}` : `/api/v2/project-ownership/invites/` +} + +export const projectOwnershipInvitesList = async (params?: ProjectOwnershipInvitesListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectOwnershipInvitesListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getProjectOwnershipInvitesListQueryKey = (params?: ProjectOwnershipInvitesListParams,) => { + return ['api','v2','project-ownership','invites', ...(params ? [params]: [])] as const; + } + + +export const getProjectOwnershipInvitesListQueryOptions = >, TError = ErrorDetail>(params?: ProjectOwnershipInvitesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => projectOwnershipInvitesList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ProjectOwnershipInvitesListQueryResult = NonNullable>> +export type ProjectOwnershipInvitesListQueryError = ErrorDetail + + + +export function useProjectOwnershipInvitesList>, TError = ErrorDetail>( + params?: ProjectOwnershipInvitesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectOwnershipInvitesListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create (send) an invite + +Where the assets `uid` are given in the payload's list + + + + */ +export type projectOwnershipInvitesCreateResponse201 = { + data: ProjectInviteResponse + status: 201 +} + +export type projectOwnershipInvitesCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type projectOwnershipInvitesCreateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectOwnershipInvitesCreateResponseComposite = projectOwnershipInvitesCreateResponse201 | projectOwnershipInvitesCreateResponse400 | projectOwnershipInvitesCreateResponse403; + +export type projectOwnershipInvitesCreateResponse = projectOwnershipInvitesCreateResponseComposite & { + headers: Headers; +} + +export const getProjectOwnershipInvitesCreateUrl = () => { + + + + + return `/api/v2/project-ownership/invites/` +} + +export const projectOwnershipInvitesCreate = async (projectInviteCreatePayload: ProjectInviteCreatePayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectOwnershipInvitesCreateUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + projectInviteCreatePayload,) + } +);} + + + + +export const getProjectOwnershipInvitesCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProjectInviteCreatePayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: ProjectInviteCreatePayload}, TContext> => { + +const mutationKey = ['projectOwnershipInvitesCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: ProjectInviteCreatePayload}> = (props) => { + const {data} = props ?? {}; + + return projectOwnershipInvitesCreate(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ProjectOwnershipInvitesCreateMutationResult = NonNullable>> + export type ProjectOwnershipInvitesCreateMutationBody = ProjectInviteCreatePayload + export type ProjectOwnershipInvitesCreateMutationError = ErrorObject | ErrorDetail + + export const useProjectOwnershipInvitesCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: ProjectInviteCreatePayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getProjectOwnershipInvitesCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Invite detail + +It can be useful to monitor the invite status while the transfer is being processed + + */ +export type projectOwnershipInvitesRetrieveResponse200 = { + data: ProjectInviteResponse + status: 200 +} + +export type projectOwnershipInvitesRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectOwnershipInvitesRetrieveResponseComposite = projectOwnershipInvitesRetrieveResponse200 | projectOwnershipInvitesRetrieveResponse403; + +export type projectOwnershipInvitesRetrieveResponse = projectOwnershipInvitesRetrieveResponseComposite & { + headers: Headers; +} + +export const getProjectOwnershipInvitesRetrieveUrl = (uidInvite: string,) => { + + + + + return `/api/v2/project-ownership/invites/${uidInvite}/` +} + +export const projectOwnershipInvitesRetrieve = async (uidInvite: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectOwnershipInvitesRetrieveUrl(uidInvite), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getProjectOwnershipInvitesRetrieveQueryKey = (uidInvite: string,) => { + return ['api','v2','project-ownership','invites',uidInvite] as const; + } + + +export const getProjectOwnershipInvitesRetrieveQueryOptions = >, TError = ErrorDetail>(uidInvite: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesRetrieveQueryKey(uidInvite); + + + + const queryFn: QueryFunction>> = ({ signal }) => projectOwnershipInvitesRetrieve(uidInvite, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidInvite), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ProjectOwnershipInvitesRetrieveQueryResult = NonNullable>> +export type ProjectOwnershipInvitesRetrieveQueryError = ErrorDetail + + + +export function useProjectOwnershipInvitesRetrieve>, TError = ErrorDetail>( + uidInvite: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectOwnershipInvitesRetrieveQueryOptions(uidInvite,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update an invite status + +Update the status of an invite. +Status accepted: +- `cancelled` +- `accepted` +- `declined` + +**Notes**: +- _When submitting `accepted` the invite status becomes automatically `in_progress`_ +- _Only the sender can cancel an invite, and **if only if** the invite is still pending._ +- _Only the recipient can accept or decline, **if and only if** the invite is still pending._ + + + */ +export type projectOwnershipInvitesPartialUpdateResponse200 = { + data: ProjectInviteResponse + status: 200 +} + +export type projectOwnershipInvitesPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type projectOwnershipInvitesPartialUpdateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectOwnershipInvitesPartialUpdateResponseComposite = projectOwnershipInvitesPartialUpdateResponse200 | projectOwnershipInvitesPartialUpdateResponse400 | projectOwnershipInvitesPartialUpdateResponse403; + +export type projectOwnershipInvitesPartialUpdateResponse = projectOwnershipInvitesPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getProjectOwnershipInvitesPartialUpdateUrl = (uidInvite: string,) => { + + + + + return `/api/v2/project-ownership/invites/${uidInvite}/` +} + +export const projectOwnershipInvitesPartialUpdate = async (uidInvite: string, + patchedInviteUpdatePayload: PatchedInviteUpdatePayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectOwnershipInvitesPartialUpdateUrl(uidInvite), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedInviteUpdatePayload,) + } +);} + + + + +export const getProjectOwnershipInvitesPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidInvite: string;data: PatchedInviteUpdatePayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidInvite: string;data: PatchedInviteUpdatePayload}, TContext> => { + +const mutationKey = ['projectOwnershipInvitesPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidInvite: string;data: PatchedInviteUpdatePayload}> = (props) => { + const {uidInvite,data} = props ?? {}; + + return projectOwnershipInvitesPartialUpdate(uidInvite,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ProjectOwnershipInvitesPartialUpdateMutationResult = NonNullable>> + export type ProjectOwnershipInvitesPartialUpdateMutationBody = PatchedInviteUpdatePayload + export type ProjectOwnershipInvitesPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useProjectOwnershipInvitesPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidInvite: string;data: PatchedInviteUpdatePayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getProjectOwnershipInvitesPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Delete invite + + */ +export type projectOwnershipInvitesDestroyResponse204 = { + data: void + status: 204 +} + +export type projectOwnershipInvitesDestroyResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectOwnershipInvitesDestroyResponseComposite = projectOwnershipInvitesDestroyResponse204 | projectOwnershipInvitesDestroyResponse403; + +export type projectOwnershipInvitesDestroyResponse = projectOwnershipInvitesDestroyResponseComposite & { + headers: Headers; +} + +export const getProjectOwnershipInvitesDestroyUrl = (uidInvite: string,) => { + + + + + return `/api/v2/project-ownership/invites/${uidInvite}/` +} + +export const projectOwnershipInvitesDestroy = async (uidInvite: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectOwnershipInvitesDestroyUrl(uidInvite), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getProjectOwnershipInvitesDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidInvite: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidInvite: string}, TContext> => { + +const mutationKey = ['projectOwnershipInvitesDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidInvite: string}> = (props) => { + const {uidInvite} = props ?? {}; + + return projectOwnershipInvitesDestroy(uidInvite,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ProjectOwnershipInvitesDestroyMutationResult = NonNullable>> + + export type ProjectOwnershipInvitesDestroyMutationError = ErrorDetail + + export const useProjectOwnershipInvitesDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidInvite: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getProjectOwnershipInvitesDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve transfer details + + */ +export type projectOwnershipInvitesTransfersRetrieveResponse200 = { + data: TransferListResponse + status: 200 +} + +export type projectOwnershipInvitesTransfersRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type projectOwnershipInvitesTransfersRetrieveResponseComposite = projectOwnershipInvitesTransfersRetrieveResponse200 | projectOwnershipInvitesTransfersRetrieveResponse401; + +export type projectOwnershipInvitesTransfersRetrieveResponse = projectOwnershipInvitesTransfersRetrieveResponseComposite & { + headers: Headers; +} + +export const getProjectOwnershipInvitesTransfersRetrieveUrl = (uidInvite: string, + uidTransfer: string,) => { + + + + + return `/api/v2/project-ownership/invites/${uidInvite}/transfers/${uidTransfer}/` +} + +export const projectOwnershipInvitesTransfersRetrieve = async (uidInvite: string, + uidTransfer: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectOwnershipInvitesTransfersRetrieveUrl(uidInvite,uidTransfer), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getProjectOwnershipInvitesTransfersRetrieveQueryKey = (uidInvite: string, + uidTransfer: string,) => { + return ['api','v2','project-ownership','invites',uidInvite,'transfers',uidTransfer] as const; + } + + +export const getProjectOwnershipInvitesTransfersRetrieveQueryOptions = >, TError = ErrorDetail>(uidInvite: string, + uidTransfer: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesTransfersRetrieveQueryKey(uidInvite,uidTransfer); + + + + const queryFn: QueryFunction>> = ({ signal }) => projectOwnershipInvitesTransfersRetrieve(uidInvite,uidTransfer, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidInvite && uidTransfer), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ProjectOwnershipInvitesTransfersRetrieveQueryResult = NonNullable>> +export type ProjectOwnershipInvitesTransfersRetrieveQueryError = ErrorDetail + + + +export function useProjectOwnershipInvitesTransfersRetrieve>, TError = ErrorDetail>( + uidInvite: string, + uidTransfer: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectOwnershipInvitesTransfersRetrieveQueryOptions(uidInvite,uidTransfer,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List current user's assets' tags + + */ +export type tagsListResponse200 = { + data: PaginatedTagListResponseList + status: 200 +} + +export type tagsListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type tagsListResponseComposite = tagsListResponse200 | tagsListResponse401; + +export type tagsListResponse = tagsListResponseComposite & { + headers: Headers; +} + +export const getTagsListUrl = (params?: TagsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/tags/?${stringifiedParams}` : `/api/v2/tags/` +} + +export const tagsList = async (params?: TagsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getTagsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getTagsListQueryKey = (params?: TagsListParams,) => { + return ['api','v2','tags', ...(params ? [params]: [])] as const; + } + + +export const getTagsListQueryOptions = >, TError = ErrorDetail>(params?: TagsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getTagsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => tagsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type TagsListQueryResult = NonNullable>> +export type TagsListQueryError = ErrorDetail + + + +export function useTagsList>, TError = ErrorDetail>( + params?: TagsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getTagsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve a tag's data + + */ +export type tagsRetrieveResponse200 = { + data: TagRetrieveResponse + status: 200 +} + +export type tagsRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type tagsRetrieveResponseComposite = tagsRetrieveResponse200 | tagsRetrieveResponse401; + +export type tagsRetrieveResponse = tagsRetrieveResponseComposite & { + headers: Headers; +} + +export const getTagsRetrieveUrl = (taguidUid: string,) => { + + + + + return `/api/v2/tags/${taguidUid}/` +} + +export const tagsRetrieve = async (taguidUid: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getTagsRetrieveUrl(taguidUid), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getTagsRetrieveQueryKey = (taguidUid: string,) => { + return ['api','v2','tags',taguidUid] as const; + } + + +export const getTagsRetrieveQueryOptions = >, TError = ErrorDetail>(taguidUid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getTagsRetrieveQueryKey(taguidUid); + + + + const queryFn: QueryFunction>> = ({ signal }) => tagsRetrieve(taguidUid, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(taguidUid), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type TagsRetrieveQueryResult = NonNullable>> +export type TagsRetrieveQueryError = ErrorDetail + + + +export function useTagsRetrieve>, TError = ErrorDetail>( + taguidUid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getTagsRetrieveQueryOptions(taguidUid,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.msw.ts b/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.msw.ts deleted file mode 100644 index 9027cb565d..0000000000 --- a/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.msw.ts +++ /dev/null @@ -1,5188 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import type { Asset } from '../../models/asset' - -import type { AssetBulkResponse } from '../../models/assetBulkResponse' - -import { AssetDeploymentStatusEnum } from '../../models/assetDeploymentStatusEnum' - -import type { AssetListCount } from '../../models/assetListCount' - -import type { AssetMetadataResponse } from '../../models/assetMetadataResponse' - -import { AssetTypeEnum } from '../../models/assetTypeEnum' - -import type { DeploymentResponse } from '../../models/deploymentResponse' - -import type { HashResponse } from '../../models/hashResponse' - -import type { ImportCreateResponse } from '../../models/importCreateResponse' - -import type { ImportResponse } from '../../models/importResponse' - -import { InviteStatusChoicesEnum } from '../../models/inviteStatusChoicesEnum' - -import type { PaginatedAssetCountResponseList } from '../../models/paginatedAssetCountResponseList' - -import type { PaginatedAssetList } from '../../models/paginatedAssetList' - -import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' - -import type { PaginatedImportResponseList } from '../../models/paginatedImportResponseList' - -import type { PaginatedProjectInviteResponseList } from '../../models/paginatedProjectInviteResponseList' - -import type { PaginatedTagListResponseList } from '../../models/paginatedTagListResponseList' - -import type { PaginatedVersionListResponseList } from '../../models/paginatedVersionListResponseList' - -import type { ProjectInviteResponse } from '../../models/projectInviteResponse' - -import type { TagRetrieveResponse } from '../../models/tagRetrieveResponse' - -import type { TransferListResponse } from '../../models/transferListResponse' - -import type { VersionRetrieveResponse } from '../../models/versionRetrieveResponse' - -export const getApiV2AssetsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([{}, undefined]), - })), - summary: { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - firsts: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - bad: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - naming_conflicts: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_deployed: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - has_deployment: faker.datatype.boolean(), - deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployed_versions: { - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - }, - deployment__links: {}, - deployment__active: faker.datatype.boolean(), - deployment__data_download_links: { - csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls: faker.string.alpha({ length: { min: 10, max: 20 } }), - zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment__last_submission_time: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - null, - ]), - deployment__encrypted: faker.datatype.boolean(), - deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - report_styles: faker.helpers.arrayElement([ - { - default: faker.helpers.arrayElement([ - { - groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_colors: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translationIndex: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - graphWidth: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - specified: faker.helpers.arrayElement([{}, undefined]), - kuid_names: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([ - { - transcript: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - translation: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - qual: faker.helpers.arrayElement([ - { - qual_survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - scope: faker.string.alpha({ length: { min: 10, max: 20 } }), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - })), - undefined, - ]), - })), - undefined, - ]), - }, - undefined, - ]), - _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_styles: faker.helpers.arrayElement([ - { - colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_custom: faker.helpers.arrayElement([{}, undefined]), - content: faker.helpers.arrayElement([ - { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - hint: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--matrix_list': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-constraint-message': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-items': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--score-choices': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - tags: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - select_from_list_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'body::accept': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - })), - undefined, - ]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'media::image': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_language: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - translations_0: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - 'kobo--locking-profiles': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, - })), - undefined, - ]), - }, - undefined, - ]), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - analysis_form_json: { - additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([ - 'transcript', - 'translation', - 'qualVerification', - 'qualSource', - 'qualInteger', - 'qualTags', - 'qualText', - 'qualNote', - 'qualAutoKeywordCount', - 'qualSelectMultiple', - 'qualSelectOne', - ] as const), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - })), - undefined, - ]), - })), - }, - xform_link: faker.internet.url(), - hooks_link: faker.internet.url(), - tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls_link: faker.internet.url(), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: faker.string.alpha({ length: { min: 10, max: 20 } }), - permission: faker.string.alpha({ length: { min: 10, max: 20 } }), - partial_permissions: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - })), - undefined, - ]), - label: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - undefined, - ]), - })), - effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - exports: faker.internet.url(), - export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - data: faker.internet.url(), - children: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - data_sharing: faker.helpers.arrayElement([{}, undefined]), - paired_data: faker.internet.url(), - project_ownership: { - [faker.string.alphanumeric(5)]: {}, - }, - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial = {}): Asset => ({ - url: faker.internet.url(), - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([{}, undefined]), - })), - summary: { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - firsts: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - bad: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - naming_conflicts: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_deployed: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - has_deployment: faker.datatype.boolean(), - deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployed_versions: { - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - }, - deployment__links: {}, - deployment__active: faker.datatype.boolean(), - deployment__data_download_links: { - csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls: faker.string.alpha({ length: { min: 10, max: 20 } }), - zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment__last_submission_time: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - null, - ]), - deployment__encrypted: faker.datatype.boolean(), - deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - report_styles: faker.helpers.arrayElement([ - { - default: faker.helpers.arrayElement([ - { - groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_colors: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translationIndex: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - graphWidth: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - specified: faker.helpers.arrayElement([{}, undefined]), - kuid_names: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([ - { - transcript: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - translation: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - qual: faker.helpers.arrayElement([ - { - qual_survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - scope: faker.string.alpha({ length: { min: 10, max: 20 } }), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - })), - undefined, - ]), - })), - undefined, - ]), - }, - undefined, - ]), - _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_styles: faker.helpers.arrayElement([ - { - colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_custom: faker.helpers.arrayElement([{}, undefined]), - content: faker.helpers.arrayElement([ - { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - hint: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--matrix_list': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-constraint-message': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-items': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--score-choices': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - tags: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - select_from_list_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'body::accept': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'media::image': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_language: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - translations_0: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - 'kobo--locking-profiles': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, - })), - undefined, - ]), - }, - undefined, - ]), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - analysis_form_json: { - additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([ - 'transcript', - 'translation', - 'qualVerification', - 'qualSource', - 'qualInteger', - 'qualTags', - 'qualText', - 'qualNote', - 'qualAutoKeywordCount', - 'qualSelectMultiple', - 'qualSelectOne', - ] as const), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - })), - undefined, - ]), - })), - }, - xform_link: faker.internet.url(), - hooks_link: faker.internet.url(), - tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls_link: faker.internet.url(), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: faker.string.alpha({ length: { min: 10, max: 20 } }), - permission: faker.string.alpha({ length: { min: 10, max: 20 } }), - partial_permissions: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - })), - undefined, - ]), - label: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - undefined, - ]), - })), - effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - exports: faker.internet.url(), - export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - data: faker.internet.url(), - children: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - data_sharing: faker.helpers.arrayElement([{}, undefined]), - paired_data: faker.internet.url(), - project_ownership: { - [faker.string.alphanumeric(5)]: {}, - }, - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ...overrideResponse, -}) - -export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial = {}): Asset => ({ - url: faker.internet.url(), - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([{}, undefined]), - })), - summary: { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - firsts: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - bad: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - naming_conflicts: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_deployed: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - has_deployment: faker.datatype.boolean(), - deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployed_versions: { - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - }, - deployment__links: {}, - deployment__active: faker.datatype.boolean(), - deployment__data_download_links: { - csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls: faker.string.alpha({ length: { min: 10, max: 20 } }), - zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment__last_submission_time: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - null, - ]), - deployment__encrypted: faker.datatype.boolean(), - deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - report_styles: faker.helpers.arrayElement([ - { - default: faker.helpers.arrayElement([ - { - groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_colors: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translationIndex: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - graphWidth: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - specified: faker.helpers.arrayElement([{}, undefined]), - kuid_names: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([ - { - transcript: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - translation: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - qual: faker.helpers.arrayElement([ - { - qual_survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - scope: faker.string.alpha({ length: { min: 10, max: 20 } }), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - })), - undefined, - ]), - })), - undefined, - ]), - }, - undefined, - ]), - _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_styles: faker.helpers.arrayElement([ - { - colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_custom: faker.helpers.arrayElement([{}, undefined]), - content: faker.helpers.arrayElement([ - { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - hint: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--matrix_list': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-constraint-message': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-items': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--score-choices': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - tags: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - select_from_list_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'body::accept': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'media::image': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_language: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - translations_0: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - 'kobo--locking-profiles': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, - })), - undefined, - ]), - }, - undefined, - ]), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - analysis_form_json: { - additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([ - 'transcript', - 'translation', - 'qualVerification', - 'qualSource', - 'qualInteger', - 'qualTags', - 'qualText', - 'qualNote', - 'qualAutoKeywordCount', - 'qualSelectMultiple', - 'qualSelectOne', - ] as const), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - })), - undefined, - ]), - })), - }, - xform_link: faker.internet.url(), - hooks_link: faker.internet.url(), - tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls_link: faker.internet.url(), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: faker.string.alpha({ length: { min: 10, max: 20 } }), - permission: faker.string.alpha({ length: { min: 10, max: 20 } }), - partial_permissions: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - })), - undefined, - ]), - label: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - undefined, - ]), - })), - effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - exports: faker.internet.url(), - export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - data: faker.internet.url(), - children: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - data_sharing: faker.helpers.arrayElement([{}, undefined]), - paired_data: faker.internet.url(), - project_ownership: { - [faker.string.alphanumeric(5)]: {}, - }, - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ...overrideResponse, -}) - -export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partial = {}): Asset => ({ - url: faker.internet.url(), - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([{}, undefined]), - })), - summary: { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - firsts: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - bad: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - naming_conflicts: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_deployed: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - has_deployment: faker.datatype.boolean(), - deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployed_versions: { - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - }, - deployment__links: {}, - deployment__active: faker.datatype.boolean(), - deployment__data_download_links: { - csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls: faker.string.alpha({ length: { min: 10, max: 20 } }), - zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment__last_submission_time: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - null, - ]), - deployment__encrypted: faker.datatype.boolean(), - deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - report_styles: faker.helpers.arrayElement([ - { - default: faker.helpers.arrayElement([ - { - groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_colors: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translationIndex: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - graphWidth: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - specified: faker.helpers.arrayElement([{}, undefined]), - kuid_names: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([ - { - transcript: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - translation: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - qual: faker.helpers.arrayElement([ - { - qual_survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - scope: faker.string.alpha({ length: { min: 10, max: 20 } }), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - })), - undefined, - ]), - })), - undefined, - ]), - }, - undefined, - ]), - _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_styles: faker.helpers.arrayElement([ - { - colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_custom: faker.helpers.arrayElement([{}, undefined]), - content: faker.helpers.arrayElement([ - { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - hint: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--matrix_list': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-constraint-message': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-items': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--score-choices': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - tags: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - select_from_list_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'body::accept': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'media::image': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_language: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - translations_0: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - 'kobo--locking-profiles': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, - })), - undefined, - ]), - }, - undefined, - ]), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - analysis_form_json: { - additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([ - 'transcript', - 'translation', - 'qualVerification', - 'qualSource', - 'qualInteger', - 'qualTags', - 'qualText', - 'qualNote', - 'qualAutoKeywordCount', - 'qualSelectMultiple', - 'qualSelectOne', - ] as const), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - })), - undefined, - ]), - })), - }, - xform_link: faker.internet.url(), - hooks_link: faker.internet.url(), - tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls_link: faker.internet.url(), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: faker.string.alpha({ length: { min: 10, max: 20 } }), - permission: faker.string.alpha({ length: { min: 10, max: 20 } }), - partial_permissions: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - })), - undefined, - ]), - label: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - undefined, - ]), - })), - effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - exports: faker.internet.url(), - export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - data: faker.internet.url(), - children: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - data_sharing: faker.helpers.arrayElement([{}, undefined]), - paired_data: faker.internet.url(), - project_ownership: { - [faker.string.alphanumeric(5)]: {}, - }, - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ...overrideResponse, -}) - -export const getApiV2AssetsCountsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetCountResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - daily_submission_count: { - '2020-10-20': faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - total_submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsDeploymentRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): DeploymentResponse => ({ - backend: faker.string.alpha({ length: { min: 10, max: 20 } }), - active: faker.datatype.boolean(), - version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - asset: { - url: faker.internet.url(), - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([{}, undefined]), - })), - summary: { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - firsts: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - bad: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - naming_conflicts: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_deployed: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - has_deployment: faker.datatype.boolean(), - deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployed_versions: { - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - }, - deployment__links: {}, - deployment__active: faker.datatype.boolean(), - deployment__data_download_links: { - csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls: faker.string.alpha({ length: { min: 10, max: 20 } }), - zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment__last_submission_time: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - null, - ]), - deployment__encrypted: faker.datatype.boolean(), - deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - report_styles: faker.helpers.arrayElement([ - { - default: faker.helpers.arrayElement([ - { - groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_colors: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translationIndex: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - graphWidth: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - specified: faker.helpers.arrayElement([{}, undefined]), - kuid_names: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([ - { - transcript: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - translation: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - qual: faker.helpers.arrayElement([ - { - qual_survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - scope: faker.string.alpha({ length: { min: 10, max: 20 } }), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - })), - undefined, - ]), - })), - undefined, - ]), - }, - undefined, - ]), - _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_styles: faker.helpers.arrayElement([ - { - colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_custom: faker.helpers.arrayElement([{}, undefined]), - content: faker.helpers.arrayElement([ - { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - hint: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--matrix_list': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-constraint-message': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-items': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--score-choices': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - tags: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - select_from_list_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'body::accept': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - })), - undefined, - ]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'media::image': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_language: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - translations_0: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - 'kobo--locking-profiles': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, - })), - undefined, - ]), - }, - undefined, - ]), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - analysis_form_json: { - additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([ - 'transcript', - 'translation', - 'qualVerification', - 'qualSource', - 'qualInteger', - 'qualTags', - 'qualText', - 'qualNote', - 'qualAutoKeywordCount', - 'qualSelectMultiple', - 'qualSelectOne', - ] as const), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - })), - undefined, - ]), - })), - }, - xform_link: faker.internet.url(), - hooks_link: faker.internet.url(), - tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls_link: faker.internet.url(), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: faker.string.alpha({ length: { min: 10, max: 20 } }), - permission: faker.string.alpha({ length: { min: 10, max: 20 } }), - partial_permissions: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - })), - undefined, - ]), - label: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - undefined, - ]), - })), - effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - exports: faker.internet.url(), - export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - data: faker.internet.url(), - children: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - data_sharing: faker.helpers.arrayElement([{}, undefined]), - paired_data: faker.internet.url(), - project_ownership: { - [faker.string.alphanumeric(5)]: {}, - }, - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDeploymentCreateResponseMock = ( - overrideResponse: Partial = {}, -): DeploymentResponse => ({ - backend: faker.string.alpha({ length: { min: 10, max: 20 } }), - active: faker.datatype.boolean(), - version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - asset: { - url: faker.internet.url(), - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([{}, undefined]), - })), - summary: { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - firsts: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - bad: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - naming_conflicts: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_deployed: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - has_deployment: faker.datatype.boolean(), - deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployed_versions: { - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - }, - deployment__links: {}, - deployment__active: faker.datatype.boolean(), - deployment__data_download_links: { - csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls: faker.string.alpha({ length: { min: 10, max: 20 } }), - zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment__last_submission_time: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - null, - ]), - deployment__encrypted: faker.datatype.boolean(), - deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - report_styles: faker.helpers.arrayElement([ - { - default: faker.helpers.arrayElement([ - { - groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_colors: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translationIndex: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - graphWidth: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - specified: faker.helpers.arrayElement([{}, undefined]), - kuid_names: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([ - { - transcript: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - translation: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - qual: faker.helpers.arrayElement([ - { - qual_survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - scope: faker.string.alpha({ length: { min: 10, max: 20 } }), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - })), - undefined, - ]), - })), - undefined, - ]), - }, - undefined, - ]), - _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_styles: faker.helpers.arrayElement([ - { - colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_custom: faker.helpers.arrayElement([{}, undefined]), - content: faker.helpers.arrayElement([ - { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - hint: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--matrix_list': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-constraint-message': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-items': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--score-choices': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - tags: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - select_from_list_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'body::accept': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - })), - undefined, - ]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'media::image': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_language: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - translations_0: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - 'kobo--locking-profiles': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, - })), - undefined, - ]), - }, - undefined, - ]), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - analysis_form_json: { - additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([ - 'transcript', - 'translation', - 'qualVerification', - 'qualSource', - 'qualInteger', - 'qualTags', - 'qualText', - 'qualNote', - 'qualAutoKeywordCount', - 'qualSelectMultiple', - 'qualSelectOne', - ] as const), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - })), - undefined, - ]), - })), - }, - xform_link: faker.internet.url(), - hooks_link: faker.internet.url(), - tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls_link: faker.internet.url(), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: faker.string.alpha({ length: { min: 10, max: 20 } }), - permission: faker.string.alpha({ length: { min: 10, max: 20 } }), - partial_permissions: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - })), - undefined, - ]), - label: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - undefined, - ]), - })), - effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - exports: faker.internet.url(), - export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - data: faker.internet.url(), - children: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - data_sharing: faker.helpers.arrayElement([{}, undefined]), - paired_data: faker.internet.url(), - project_ownership: { - [faker.string.alphanumeric(5)]: {}, - }, - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): DeploymentResponse => ({ - backend: faker.string.alpha({ length: { min: 10, max: 20 } }), - active: faker.datatype.boolean(), - version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - asset: { - url: faker.internet.url(), - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([{}, undefined]), - })), - summary: { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - firsts: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - bad: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - naming_conflicts: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_deployed: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - has_deployment: faker.datatype.boolean(), - deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployed_versions: { - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - }, - deployment__links: {}, - deployment__active: faker.datatype.boolean(), - deployment__data_download_links: { - csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls: faker.string.alpha({ length: { min: 10, max: 20 } }), - zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment__last_submission_time: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - null, - ]), - deployment__encrypted: faker.datatype.boolean(), - deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - report_styles: faker.helpers.arrayElement([ - { - default: faker.helpers.arrayElement([ - { - groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_colors: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translationIndex: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - graphWidth: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - specified: faker.helpers.arrayElement([{}, undefined]), - kuid_names: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([ - { - transcript: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - translation: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - qual: faker.helpers.arrayElement([ - { - qual_survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - scope: faker.string.alpha({ length: { min: 10, max: 20 } }), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - })), - undefined, - ]), - })), - undefined, - ]), - }, - undefined, - ]), - _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_styles: faker.helpers.arrayElement([ - { - colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_custom: faker.helpers.arrayElement([{}, undefined]), - content: faker.helpers.arrayElement([ - { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - hint: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--matrix_list': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-constraint-message': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-items': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--score-choices': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - tags: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - select_from_list_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'body::accept': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - })), - undefined, - ]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'media::image': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_language: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - translations_0: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - 'kobo--locking-profiles': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, - })), - undefined, - ]), - }, - undefined, - ]), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - analysis_form_json: { - additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([ - 'transcript', - 'translation', - 'qualVerification', - 'qualSource', - 'qualInteger', - 'qualTags', - 'qualText', - 'qualNote', - 'qualAutoKeywordCount', - 'qualSelectMultiple', - 'qualSelectOne', - ] as const), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - })), - undefined, - ]), - })), - }, - xform_link: faker.internet.url(), - hooks_link: faker.internet.url(), - tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls_link: faker.internet.url(), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: faker.string.alpha({ length: { min: 10, max: 20 } }), - permission: faker.string.alpha({ length: { min: 10, max: 20 } }), - partial_permissions: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - })), - undefined, - ]), - label: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - undefined, - ]), - })), - effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - exports: faker.internet.url(), - export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - data: faker.internet.url(), - children: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - data_sharing: faker.helpers.arrayElement([{}, undefined]), - paired_data: faker.internet.url(), - project_ownership: { - [faker.string.alphanumeric(5)]: {}, - }, - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsVersionsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedVersionListResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsVersionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): VersionRetrieveResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - content: { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - hint: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { - default_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translation: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsXformRetrieveResponseMock = (): string => faker.word.sample() - -export const getApiV2AssetsBulkCreateResponseMock = ( - overrideResponse: Partial = {}, -): AssetBulkResponse => ({ detail: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2AssetsCountsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetListCount => ({ - deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getApiV2AssetsHashRetrieveResponseMock = (overrideResponse: Partial = {}): HashResponse => ({ - hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsMetadataRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetMetadataResponse => ({ - languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ), - sectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ), - organizations: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2AssetsMinimalListRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetMinimalListList => ({ - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 22 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - })), - ...overrideResponse, -}) - -export const getApiV2ImportsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedImportResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - messages: { - updated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kind: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - summary: faker.helpers.arrayElement([ - { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - language: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - first: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - undefined, - ]), - owner__username: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - })), - undefined, - ]), - 'audit-logs': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset_id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - new_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - old_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - latest_version_uid: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - })), - undefined, - ]), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - error_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - ...overrideResponse, -}) - -export const getApiV2ImportsCreateResponseMock = ( - overrideResponse: Partial = {}, -): ImportCreateResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2ImportsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ImportResponse => ({ - url: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - messages: { - updated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kind: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - summary: faker.helpers.arrayElement([ - { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - language: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - first: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - undefined, - ]), - owner__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - 'audit-logs': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset_id: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - new_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - old_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - latest_version_uid: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - })), - undefined, - ]), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - error_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - ...overrideResponse, -}) - -export const getApiV2ProjectOwnershipInvitesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedProjectInviteResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - 'sender | recipient': faker.internet.url(), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectOwnershipInvitesCreateResponseMock = ( - overrideResponse: Partial = {}, -): ProjectInviteResponse => ({ - url: faker.internet.url(), - 'sender | recipient': faker.internet.url(), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectOwnershipInvitesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ProjectInviteResponse => ({ - url: faker.internet.url(), - 'sender | recipient': faker.internet.url(), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectOwnershipInvitesPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): ProjectInviteResponse => ({ - url: faker.internet.url(), - 'sender | recipient': faker.internet.url(), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectOwnershipInvitesTransfersRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): TransferListResponse => ({ - url: faker.internet.url(), - asset: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - error: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - ...overrideResponse, -}) - -export const getApiV2TagsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedTagListResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - })), - ...overrideResponse, -}) - -export const getApiV2TagsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): TagRetrieveResponse => ({ - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - assets: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.internet.url(), - ), - parent: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsListMockHandler = ( - overrideResponse?: - | PaginatedAssetList - | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), -) => { - return http.get('*/api/v2/assets/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsCreateMockHandler = ( - overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), -) => { - return http.post('*/api/v2/assets/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsRetrieveMockHandler = ( - overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), -) => { - return http.get('*/api/v2/assets/:uidAsset/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPartialUpdateMockHandler = ( - overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), -) => { - return http.patch('*/api/v2/assets/:uidAsset/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsCountsListMockHandler = ( - overrideResponse?: - | PaginatedAssetCountResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetCountResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/counts/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsCountsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDeploymentRetrieveMockHandler = ( - overrideResponse?: - | DeploymentResponse - | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/deployment/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDeploymentRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDeploymentCreateMockHandler = ( - overrideResponse?: - | DeploymentResponse - | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/deployment/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDeploymentCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDeploymentPartialUpdateMockHandler = ( - overrideResponse?: - | DeploymentResponse - | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/deployment/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDeploymentPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsVersionsListMockHandler = ( - overrideResponse?: - | PaginatedVersionListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedVersionListResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/versions/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsVersionsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsVersionsRetrieveMockHandler = ( - overrideResponse?: - | VersionRetrieveResponse - | (( - info: Parameters[1]>[0], - ) => Promise | VersionRetrieveResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsVersionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsXformRetrieveMockHandler = ( - overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), -) => { - return http.get('*/api/v2/assets/:uidAsset/xform/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsXformRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsBulkCreateMockHandler = ( - overrideResponse?: - | AssetBulkResponse - | ((info: Parameters[1]>[0]) => Promise | AssetBulkResponse), -) => { - return http.post('*/api/v2/assets/bulk/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsBulkCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsCountsRetrieveMockHandler = ( - overrideResponse?: - | AssetListCount - | ((info: Parameters[1]>[0]) => Promise | AssetListCount), -) => { - return http.get('*/api/v2/assets/counts/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsCountsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHashRetrieveMockHandler = ( - overrideResponse?: - | HashResponse - | ((info: Parameters[1]>[0]) => Promise | HashResponse), -) => { - return http.get('*/api/v2/assets/hash/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHashRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsMetadataRetrieveMockHandler = ( - overrideResponse?: - | AssetMetadataResponse - | ((info: Parameters[1]>[0]) => Promise | AssetMetadataResponse), -) => { - return http.get('*/api/v2/assets/metadata/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsMetadataRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsMinimalListRetrieveMockHandler = ( - overrideResponse?: - | PaginatedAssetMinimalListList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetMinimalListList), -) => { - return http.get('*/api/v2/assets/minimal-list/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsMinimalListRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ImportsListMockHandler = ( - overrideResponse?: - | PaginatedImportResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedImportResponseList), -) => { - return http.get('*/api/v2/imports/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ImportsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ImportsCreateMockHandler = ( - overrideResponse?: - | ImportCreateResponse - | ((info: Parameters[1]>[0]) => Promise | ImportCreateResponse), -) => { - return http.post('*/api/v2/imports/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ImportsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ImportsRetrieveMockHandler = ( - overrideResponse?: - | ImportResponse - | ((info: Parameters[1]>[0]) => Promise | ImportResponse), -) => { - return http.get('*/api/v2/imports/:uidImport/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ImportsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectOwnershipInvitesListMockHandler = ( - overrideResponse?: - | PaginatedProjectInviteResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedProjectInviteResponseList), -) => { - return http.get('*/api/v2/project-ownership/invites/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectOwnershipInvitesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectOwnershipInvitesCreateMockHandler = ( - overrideResponse?: - | ProjectInviteResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProjectInviteResponse), -) => { - return http.post('*/api/v2/project-ownership/invites/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectOwnershipInvitesCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectOwnershipInvitesRetrieveMockHandler = ( - overrideResponse?: - | ProjectInviteResponse - | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse), -) => { - return http.get('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectOwnershipInvitesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = ( - overrideResponse?: - | ProjectInviteResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProjectInviteResponse), -) => { - return http.patch('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectOwnershipInvitesPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectOwnershipInvitesDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler = ( - overrideResponse?: - | TransferListResponse - | ((info: Parameters[1]>[0]) => Promise | TransferListResponse), -) => { - return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectOwnershipInvitesTransfersRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TagsListMockHandler = ( - overrideResponse?: - | PaginatedTagListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedTagListResponseList), -) => { - return http.get('*/api/v2/tags/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TagsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TagsRetrieveMockHandler = ( - overrideResponse?: - | TagRetrieveResponse - | ((info: Parameters[1]>[0]) => Promise | TagRetrieveResponse), -) => { - return http.get('*/api/v2/tags/:taguidUid/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TagsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getManageProjectsAndLibraryContentMock = () => [ - getApiV2AssetsListMockHandler(), - getApiV2AssetsCreateMockHandler(), - getApiV2AssetsRetrieveMockHandler(), - getApiV2AssetsPartialUpdateMockHandler(), - getApiV2AssetsDestroyMockHandler(), - getApiV2AssetsCountsListMockHandler(), - getApiV2AssetsDeploymentRetrieveMockHandler(), - getApiV2AssetsDeploymentCreateMockHandler(), - getApiV2AssetsDeploymentPartialUpdateMockHandler(), - getApiV2AssetsVersionsListMockHandler(), - getApiV2AssetsVersionsRetrieveMockHandler(), - getApiV2AssetsXformRetrieveMockHandler(), - getApiV2AssetsBulkCreateMockHandler(), - getApiV2AssetsCountsRetrieveMockHandler(), - getApiV2AssetsHashRetrieveMockHandler(), - getApiV2AssetsMetadataRetrieveMockHandler(), - getApiV2AssetsMinimalListRetrieveMockHandler(), - getApiV2ImportsListMockHandler(), - getApiV2ImportsCreateMockHandler(), - getApiV2ImportsRetrieveMockHandler(), - getApiV2ProjectOwnershipInvitesListMockHandler(), - getApiV2ProjectOwnershipInvitesCreateMockHandler(), - getApiV2ProjectOwnershipInvitesRetrieveMockHandler(), - getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler(), - getApiV2ProjectOwnershipInvitesDestroyMockHandler(), - getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler(), - getApiV2TagsListMockHandler(), - getApiV2TagsRetrieveMockHandler(), -] diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.ts b/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.ts deleted file mode 100644 index 9a964a2818..0000000000 --- a/jsapp/js/api/react-query/manage-projects-and-library-content/manage-projects-and-library-content.ts +++ /dev/null @@ -1,2672 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { Asset } from '../../models/asset' - -import type { AssetBulkRequest } from '../../models/assetBulkRequest' - -import type { AssetBulkResponse } from '../../models/assetBulkResponse' - -import type { AssetCreateRequest } from '../../models/assetCreateRequest' - -import type { AssetListCount } from '../../models/assetListCount' - -import type { AssetMetadataResponse } from '../../models/assetMetadataResponse' - -import type { AssetsCountsListParams } from '../../models/assetsCountsListParams' - -import type { AssetsListParams } from '../../models/assetsListParams' - -import type { AssetsMinimalListRetrieveParams } from '../../models/assetsMinimalListRetrieveParams' - -import type { AssetsRetrieveParams } from '../../models/assetsRetrieveParams' - -import type { AssetsVersionsListParams } from '../../models/assetsVersionsListParams' - -import type { DeploymentCreateRequest } from '../../models/deploymentCreateRequest' - -import type { DeploymentResponse } from '../../models/deploymentResponse' - -import type { ErrorDetail } from '../../models/errorDetail' - -import type { ErrorObject } from '../../models/errorObject' - -import type { HashResponse } from '../../models/hashResponse' - -import type { ImportCreateRequest } from '../../models/importCreateRequest' - -import type { ImportCreateResponse } from '../../models/importCreateResponse' - -import type { ImportResponse } from '../../models/importResponse' - -import type { ImportsListParams } from '../../models/importsListParams' - -import type { PaginatedAssetCountResponseList } from '../../models/paginatedAssetCountResponseList' - -import type { PaginatedAssetList } from '../../models/paginatedAssetList' - -import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' - -import type { PaginatedImportResponseList } from '../../models/paginatedImportResponseList' - -import type { PaginatedProjectInviteResponseList } from '../../models/paginatedProjectInviteResponseList' - -import type { PaginatedTagListResponseList } from '../../models/paginatedTagListResponseList' - -import type { PaginatedVersionListResponseList } from '../../models/paginatedVersionListResponseList' - -import type { PatchedAssetPatchRequest } from '../../models/patchedAssetPatchRequest' - -import type { PatchedDeploymentPatchRequest } from '../../models/patchedDeploymentPatchRequest' - -import type { PatchedInviteUpdatePayload } from '../../models/patchedInviteUpdatePayload' - -import type { ProjectInviteCreatePayload } from '../../models/projectInviteCreatePayload' - -import type { ProjectInviteResponse } from '../../models/projectInviteResponse' - -import type { ProjectOwnershipInvitesListParams } from '../../models/projectOwnershipInvitesListParams' - -import type { TagRetrieveResponse } from '../../models/tagRetrieveResponse' - -import type { TagsListParams } from '../../models/tagsListParams' - -import type { TransferListResponse } from '../../models/transferListResponse' - -import type { VersionRetrieveResponse } from '../../models/versionRetrieveResponse' - -import { fetchWithAuth } from '../../orval.mutator' - -type SecondParameter unknown> = Parameters[1] - -/** - * ## Get user's assets - - -Search can be made with `q` parameter. -Search filters can be returned with results by passing `metadata=on` to querystring. - - -Results can be sorted with `ordering` parameter, e.g.: - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/?ordering=-name -``` - - -Allowed fields are: - -- `asset_type` -- `date_modified` -- `date_deployed` -- `date_modified__date` -- `date_deployed__date` -- `name` -- `settings__sector` -- `settings__sector__value` -- `settings__description` -- `owner__username` -- `owner__extra_details__data__name` -- `owner__extra_details__data__organization` -- `owner__email` -- `_deployment_status` -- `subscribers_count` - - -Note: Collections can be displayed first with parameter `collections_first`, e.g.: - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/?collections_first=true&ordering=-name -``` - - */ -export type assetsListResponse200 = { - data: PaginatedAssetList - status: 200 -} - -export type assetsListResponseComposite = assetsListResponse200 - -export type assetsListResponse = assetsListResponseComposite & { - headers: Headers -} - -export const getAssetsListUrl = (params?: AssetsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/assets/?${stringifiedParams}` : `/api/v2/assets/` -} - -export const assetsList = async (params?: AssetsListParams, options?: RequestInit): Promise => { - return fetchWithAuth(getAssetsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsListQueryKey = (params?: AssetsListParams) => { - return ['api', 'v2', 'assets', ...(params ? [params] : [])] as const -} - -export const getAssetsListQueryOptions = >, TError = unknown>( - params?: AssetsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsListQueryResult = NonNullable>> -export type AssetsListQueryError = unknown - -export function useAssetsList>, TError = unknown>( - params?: AssetsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create or clone an asset - -When cloning an asset, you must provide: - -- the name (as a string), -- the `clone_from` (the uid representing the asset), -- the asset_type - -Where `asset_type` must be one of these values: - -* block (can be cloned to `block`, `question`, `survey`, `template`) -* question (can be cloned to `question`, `survey`, `template`) -* survey (can be cloned to `block`, `question`, `survey`, `template`) -* template (can be cloned to `survey`, `template`) - -Settings are cloned only when type of assets are `survey` or `template`. -In that case, `share-metadata` is not preserved. - -When creating a new `block` or `question` asset, settings are not saved either. - - */ -export type assetsCreateResponse201 = { - data: Asset - status: 201 -} - -export type assetsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsCreateResponseComposite = assetsCreateResponse201 | assetsCreateResponse400 | assetsCreateResponse401 - -export type assetsCreateResponse = assetsCreateResponseComposite & { - headers: Headers -} - -export const getAssetsCreateUrl = () => { - return `/api/v2/assets/` -} - -export const assetsCreate = async ( - assetCreateRequest: AssetCreateRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(assetCreateRequest), - }) -} - -export const getAssetsCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetCreateRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions>, TError, { data: AssetCreateRequest }, TContext> => { - const mutationKey = ['assetsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: AssetCreateRequest }> = ( - props, - ) => { - const { data } = props ?? {} - - return assetsCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsCreateMutationResult = NonNullable>> -export type AssetsCreateMutationBody = AssetCreateRequest -export type AssetsCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetCreateRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Get a user's current asset - - */ -export type assetsRetrieveResponse200 = { - data: Asset - status: 200 -} - -export type assetsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsRetrieveResponseComposite = assetsRetrieveResponse200 | assetsRetrieveResponse404 - -export type assetsRetrieveResponse = assetsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsRetrieveUrl = (uidAsset: string, params?: AssetsRetrieveParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/` -} - -export const assetsRetrieve = async ( - uidAsset: string, - params?: AssetsRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsRetrieveUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsRetrieveQueryKey = (uidAsset: string, params?: AssetsRetrieveParams) => { - return ['api', 'v2', 'assets', uidAsset, ...(params ? [params] : [])] as const -} - -export const getAssetsRetrieveQueryOptions = >, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsRetrieveQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsRetrieve(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsRetrieveQueryResult = NonNullable>> -export type AssetsRetrieveQueryError = ErrorDetail - -export function useAssetsRetrieve>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsRetrieveQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update or connect a user's asset - -Updates a project or connect project's data from this project to other projects - -When `Data sharing`: - -`fields`: Optional. List of questions whose responses will be shared. If -missing or empty, all responses will be shared. Questions must be -identified by full group path separated by slashes, e.g. -`group/subgroup/question_name`. - - */ -export type assetsPartialUpdateResponse200 = { - data: Asset - status: 200 -} - -export type assetsPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsPartialUpdateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsPartialUpdateResponseComposite = - | assetsPartialUpdateResponse200 - | assetsPartialUpdateResponse400 - | assetsPartialUpdateResponse401 - -export type assetsPartialUpdateResponse = assetsPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsPartialUpdateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/` -} - -export const assetsPartialUpdate = async ( - uidAsset: string, - patchedAssetPatchRequest: PatchedAssetPatchRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsPartialUpdateUrl(uidAsset), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedAssetPatchRequest), - }) -} - -export const getAssetsPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedAssetPatchRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedAssetPatchRequest }, - TContext -> => { - const mutationKey = ['assetsPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: PatchedAssetPatchRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsPartialUpdate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsPartialUpdateMutationResult = NonNullable>> -export type AssetsPartialUpdateMutationBody = PatchedAssetPatchRequest -export type AssetsPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useAssetsPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedAssetPatchRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete a user's asset - - */ -export type assetsDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsDestroyResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsDestroyResponseComposite = assetsDestroyResponse204 | assetsDestroyResponse401 - -export type assetsDestroyResponse = assetsDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsDestroyUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/` -} - -export const assetsDestroy = async (uidAsset: string, options?: RequestInit): Promise => { - return fetchWithAuth(getAssetsDestroyUrl(uidAsset), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetsDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions>, TError, { uidAsset: string }, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, { uidAsset: string }, TContext> => { - const mutationKey = ['assetsDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { uidAsset: string }> = (props) => { - const { uidAsset } = props ?? {} - - return assetsDestroy(uidAsset, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDestroyMutationResult = NonNullable>> - -export type AssetsDestroyMutationError = ErrorDetail - -export const useAssetsDestroy = (options?: { - mutation?: UseMutationOptions>, TError, { uidAsset: string }, TContext> - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Count the daily amount of submissions - -Returns up to the last 31 days of daily counts and total counts of submissions to a survey. - - -Use the `days` query to get the daily counts from the last x amount of days. -Default amount is 30 days - - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/counts/?days=7 -``` - - */ -export type assetsCountsListResponse200 = { - data: PaginatedAssetCountResponseList - status: 200 -} - -export type assetsCountsListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsCountsListResponseComposite = assetsCountsListResponse200 | assetsCountsListResponse401 - -export type assetsCountsListResponse = assetsCountsListResponseComposite & { - headers: Headers -} - -export const getAssetsCountsListUrl = (uidAsset: string, params?: AssetsCountsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/counts/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/counts/` -} - -export const assetsCountsList = async ( - uidAsset: string, - params?: AssetsCountsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsCountsListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsCountsListQueryKey = (uidAsset: string, params?: AssetsCountsListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'counts', ...(params ? [params] : [])] as const -} - -export const getAssetsCountsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsCountsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsCountsListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsCountsList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsCountsListQueryResult = NonNullable>> -export type AssetsCountsListQueryError = ErrorDetail - -export function useAssetsCountsList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsCountsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsCountsListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve the existing deployment (if any) - - */ -export type assetsDeploymentRetrieveResponse200 = { - data: DeploymentResponse - status: 200 -} - -export type assetsDeploymentRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDeploymentRetrieveResponseComposite = - | assetsDeploymentRetrieveResponse200 - | assetsDeploymentRetrieveResponse404 - -export type assetsDeploymentRetrieveResponse = assetsDeploymentRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsDeploymentRetrieveUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/deployment/` -} - -export const assetsDeploymentRetrieve = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDeploymentRetrieveUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsDeploymentRetrieveQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'deployment'] as const -} - -export const getAssetsDeploymentRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDeploymentRetrieveQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDeploymentRetrieve(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDeploymentRetrieveQueryResult = NonNullable>> -export type AssetsDeploymentRetrieveQueryError = ErrorDetail - -export function useAssetsDeploymentRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDeploymentRetrieveQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## (Re)Deploy a form - -Deploy a new form or re-deploy an existing one. - - */ -export type assetsDeploymentCreateResponse200 = { - data: DeploymentResponse - status: 200 -} - -export type assetsDeploymentCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsDeploymentCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsDeploymentCreateResponseComposite = - | assetsDeploymentCreateResponse200 - | assetsDeploymentCreateResponse400 - | assetsDeploymentCreateResponse401 - -export type assetsDeploymentCreateResponse = assetsDeploymentCreateResponseComposite & { - headers: Headers -} - -export const getAssetsDeploymentCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/deployment/` -} - -export const assetsDeploymentCreate = async ( - uidAsset: string, - deploymentCreateRequest: DeploymentCreateRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDeploymentCreateUrl(uidAsset), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(deploymentCreateRequest), - }) -} - -export const getAssetsDeploymentCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: DeploymentCreateRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: DeploymentCreateRequest }, - TContext -> => { - const mutationKey = ['assetsDeploymentCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: DeploymentCreateRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsDeploymentCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDeploymentCreateMutationResult = NonNullable>> -export type AssetsDeploymentCreateMutationBody = DeploymentCreateRequest -export type AssetsDeploymentCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsDeploymentCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: DeploymentCreateRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDeploymentCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## (Un)Archive the existing deployment. - -Update the `active` field of the existing deployment. - -To overwrite the entire deployment (including the form contents), use a PUT request. - - */ -export type assetsDeploymentPartialUpdateResponse200 = { - data: DeploymentResponse - status: 200 -} - -export type assetsDeploymentPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsDeploymentPartialUpdateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsDeploymentPartialUpdateResponseComposite = - | assetsDeploymentPartialUpdateResponse200 - | assetsDeploymentPartialUpdateResponse400 - | assetsDeploymentPartialUpdateResponse401 - -export type assetsDeploymentPartialUpdateResponse = assetsDeploymentPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsDeploymentPartialUpdateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/deployment/` -} - -export const assetsDeploymentPartialUpdate = async ( - uidAsset: string, - patchedDeploymentPatchRequest: PatchedDeploymentPatchRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDeploymentPartialUpdateUrl(uidAsset), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedDeploymentPatchRequest), - }) -} - -export const getAssetsDeploymentPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDeploymentPatchRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDeploymentPatchRequest }, - TContext -> => { - const mutationKey = ['assetsDeploymentPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: PatchedDeploymentPatchRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsDeploymentPartialUpdate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDeploymentPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsDeploymentPartialUpdateMutationBody = PatchedDeploymentPatchRequest -export type AssetsDeploymentPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useAssetsDeploymentPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDeploymentPatchRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDeploymentPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## List the versions of forms - - */ -export type assetsVersionsListResponse200 = { - data: PaginatedVersionListResponseList - status: 200 -} - -export type assetsVersionsListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsVersionsListResponseComposite = assetsVersionsListResponse200 | assetsVersionsListResponse404 - -export type assetsVersionsListResponse = assetsVersionsListResponseComposite & { - headers: Headers -} - -export const getAssetsVersionsListUrl = (uidAsset: string, params?: AssetsVersionsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/versions/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/versions/` -} - -export const assetsVersionsList = async ( - uidAsset: string, - params?: AssetsVersionsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsVersionsListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsVersionsListQueryKey = (uidAsset: string, params?: AssetsVersionsListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'versions', ...(params ? [params] : [])] as const -} - -export const getAssetsVersionsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsVersionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsVersionsListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsVersionsList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsVersionsListQueryResult = NonNullable>> -export type AssetsVersionsListQueryError = ErrorDetail - -export function useAssetsVersionsList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsVersionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsVersionsListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve asset versions - -Returns the details of an asset version - - */ -export type assetsVersionsRetrieveResponse200 = { - data: VersionRetrieveResponse - status: 200 -} - -export type assetsVersionsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsVersionsRetrieveResponseComposite = - | assetsVersionsRetrieveResponse200 - | assetsVersionsRetrieveResponse404 - -export type assetsVersionsRetrieveResponse = assetsVersionsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsVersionsRetrieveUrl = (uidAsset: string, uidVersion: string) => { - return `/api/v2/assets/${uidAsset}/versions/${uidVersion}/` -} - -export const assetsVersionsRetrieve = async ( - uidAsset: string, - uidVersion: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsVersionsRetrieveUrl(uidAsset, uidVersion), { - ...options, - method: 'GET', - }) -} - -export const getAssetsVersionsRetrieveQueryKey = (uidAsset: string, uidVersion: string) => { - return ['api', 'v2', 'assets', uidAsset, 'versions', uidVersion] as const -} - -export const getAssetsVersionsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidVersion: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsVersionsRetrieveQueryKey(uidAsset, uidVersion) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsVersionsRetrieve(uidAsset, uidVersion, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidVersion), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsVersionsRetrieveQueryResult = NonNullable>> -export type AssetsVersionsRetrieveQueryError = ErrorDetail - -export function useAssetsVersionsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidVersion: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsVersionsRetrieveQueryOptions(uidAsset, uidVersion, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## This route will render the XForm into syntax-highlighted HTML. - -It is useful for debugging pyxform transformations - - */ -export type assetsXformRetrieveResponse200 = { - data: string - status: 200 -} - -export type assetsXformRetrieveResponse404 = { - data: void - status: 404 -} - -export type assetsXformRetrieveResponseComposite = assetsXformRetrieveResponse200 | assetsXformRetrieveResponse404 - -export type assetsXformRetrieveResponse = assetsXformRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsXformRetrieveUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/xform/` -} - -export const assetsXformRetrieve = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsXformRetrieveUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsXformRetrieveQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'xform'] as const -} - -export const getAssetsXformRetrieveQueryOptions = < - TData = Awaited>, - TError = void, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsXformRetrieveQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsXformRetrieve(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsXformRetrieveQueryResult = NonNullable>> -export type AssetsXformRetrieveQueryError = void - -export function useAssetsXformRetrieve>, TError = void>( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsXformRetrieveQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Perform bulk actions on assets - -Actions available: - -- `archive` -- `delete` -- `unarchive` -- `undelete` (superusers only) - - */ -export type assetsBulkCreateResponse200 = { - data: AssetBulkResponse - status: 200 -} - -export type assetsBulkCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsBulkCreateResponseComposite = assetsBulkCreateResponse200 | assetsBulkCreateResponse404 - -export type assetsBulkCreateResponse = assetsBulkCreateResponseComposite & { - headers: Headers -} - -export const getAssetsBulkCreateUrl = () => { - return `/api/v2/assets/bulk/` -} - -export const assetsBulkCreate = async ( - assetBulkRequest: AssetBulkRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsBulkCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(assetBulkRequest), - }) -} - -export const getAssetsBulkCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetBulkRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions>, TError, { data: AssetBulkRequest }, TContext> => { - const mutationKey = ['assetsBulkCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: AssetBulkRequest }> = ( - props, - ) => { - const { data } = props ?? {} - - return assetsBulkCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsBulkCreateMutationResult = NonNullable>> -export type AssetsBulkCreateMutationBody = AssetBulkRequest -export type AssetsBulkCreateMutationError = ErrorDetail - -export const useAssetsBulkCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: AssetBulkRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsBulkCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Return counts of deployed, archived, and draft assets - - */ -export type assetsCountsRetrieveResponse200 = { - data: AssetListCount - status: 200 -} - -export type assetsCountsRetrieveResponseComposite = assetsCountsRetrieveResponse200 - -export type assetsCountsRetrieveResponse = assetsCountsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsCountsRetrieveUrl = () => { - return `/api/v2/assets/counts/` -} - -export const assetsCountsRetrieve = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAssetsCountsRetrieveUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAssetsCountsRetrieveQueryKey = () => { - return ['api', 'v2', 'assets', 'counts'] as const -} - -export const getAssetsCountsRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsCountsRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - assetsCountsRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsCountsRetrieveQueryResult = NonNullable>> -export type AssetsCountsRetrieveQueryError = unknown - -export function useAssetsCountsRetrieve< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsCountsRetrieveQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get a hash of all `version_id`s of all accessible assets by the current user. - -Useful to detect any changes in assets with only one call to `API` - - */ -export type assetsHashRetrieveResponse200 = { - data: HashResponse - status: 200 -} - -export type assetsHashRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsHashRetrieveResponseComposite = assetsHashRetrieveResponse200 | assetsHashRetrieveResponse401 - -export type assetsHashRetrieveResponse = assetsHashRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsHashRetrieveUrl = () => { - return `/api/v2/assets/hash/` -} - -export const assetsHashRetrieve = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAssetsHashRetrieveUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAssetsHashRetrieveQueryKey = () => { - return ['api', 'v2', 'assets', 'hash'] as const -} - -export const getAssetsHashRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsHashRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - assetsHashRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsHashRetrieveQueryResult = NonNullable>> -export type AssetsHashRetrieveQueryError = ErrorDetail - -export function useAssetsHashRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsHashRetrieveQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get metadata for all authenticated user' assets - - */ -export type assetsMetadataRetrieveResponse200 = { - data: AssetMetadataResponse - status: 200 -} - -export type assetsMetadataRetrieveResponseComposite = assetsMetadataRetrieveResponse200 - -export type assetsMetadataRetrieveResponse = assetsMetadataRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsMetadataRetrieveUrl = () => { - return `/api/v2/assets/metadata/` -} - -export const assetsMetadataRetrieve = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAssetsMetadataRetrieveUrl(), { - ...options, - method: 'GET', - }) -} - -export const getAssetsMetadataRetrieveQueryKey = () => { - return ['api', 'v2', 'assets', 'metadata'] as const -} - -export const getAssetsMetadataRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsMetadataRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - assetsMetadataRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsMetadataRetrieveQueryResult = NonNullable>> -export type AssetsMetadataRetrieveQueryError = unknown - -export function useAssetsMetadataRetrieve< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsMetadataRetrieveQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Return a minimal listing of assets with their deployment status - -Returns a paginated list of assets visible to the current user, including only `uid`, `name`, and `deployment_status` (`draft`, `deployed`, or `archived`). - -Use the `q` query parameter to filter by asset type (e.g. `?q=asset_type:survey`). - -Responses do not include a `count` field. Use the `next` and `previous` links to paginate through results. - - */ -export type assetsMinimalListRetrieveResponse200 = { - data: PaginatedAssetMinimalListList - status: 200 -} - -export type assetsMinimalListRetrieveResponseComposite = assetsMinimalListRetrieveResponse200 - -export type assetsMinimalListRetrieveResponse = assetsMinimalListRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsMinimalListRetrieveUrl = (params?: AssetsMinimalListRetrieveParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/minimal-list/?${stringifiedParams}` - : `/api/v2/assets/minimal-list/` -} - -export const assetsMinimalListRetrieve = async ( - params?: AssetsMinimalListRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsMinimalListRetrieveUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsMinimalListRetrieveQueryKey = (params?: AssetsMinimalListRetrieveParams) => { - return ['api', 'v2', 'assets', 'minimal-list', ...(params ? [params] : [])] as const -} - -export const getAssetsMinimalListRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: AssetsMinimalListRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsMinimalListRetrieveQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsMinimalListRetrieve(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsMinimalListRetrieveQueryResult = NonNullable>> -export type AssetsMinimalListRetrieveQueryError = unknown - -export function useAssetsMinimalListRetrieve< - TData = Awaited>, - TError = unknown, ->( - params?: AssetsMinimalListRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsMinimalListRetrieveQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List imported files - - */ -export type importsListResponse200 = { - data: PaginatedImportResponseList - status: 200 -} - -export type importsListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type importsListResponseComposite = importsListResponse200 | importsListResponse401 - -export type importsListResponse = importsListResponseComposite & { - headers: Headers -} - -export const getImportsListUrl = (params?: ImportsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/imports/?${stringifiedParams}` : `/api/v2/imports/` -} - -export const importsList = async (params?: ImportsListParams, options?: RequestInit): Promise => { - return fetchWithAuth(getImportsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getImportsListQueryKey = (params?: ImportsListParams) => { - return ['api', 'v2', 'imports', ...(params ? [params] : [])] as const -} - -export const getImportsListQueryOptions = >, TError = ErrorDetail>( - params?: ImportsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getImportsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - importsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ImportsListQueryResult = NonNullable>> -export type ImportsListQueryError = ErrorDetail - -export function useImportsList>, TError = ErrorDetail>( - params?: ImportsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getImportsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Import file - -_**Note**: this endpoint is expecting a multipart/form-data_ - - */ -export type importsCreateResponse201 = { - data: ImportCreateResponse - status: 201 -} - -export type importsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type importsCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type importsCreateResponseComposite = - | importsCreateResponse201 - | importsCreateResponse400 - | importsCreateResponse401 - -export type importsCreateResponse = importsCreateResponseComposite & { - headers: Headers -} - -export const getImportsCreateUrl = () => { - return `/api/v2/imports/` -} - -export const importsCreate = async ( - importCreateRequest: ImportCreateRequest, - options?: RequestInit, -): Promise => { - const formData = new FormData() - formData.append(`destination`, importCreateRequest.destination) - formData.append(`url`, importCreateRequest.url) - if (importCreateRequest.name !== undefined) { - formData.append(`name`, importCreateRequest.name) - } - formData.append(`assetUid`, importCreateRequest.assetUid) - - return fetchWithAuth(getImportsCreateUrl(), { - ...options, - method: 'POST', - body: formData, - }) -} - -export const getImportsCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ImportCreateRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions>, TError, { data: ImportCreateRequest }, TContext> => { - const mutationKey = ['importsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: ImportCreateRequest }> = ( - props, - ) => { - const { data } = props ?? {} - - return importsCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ImportsCreateMutationResult = NonNullable>> -export type ImportsCreateMutationBody = ImportCreateRequest -export type ImportsCreateMutationError = ErrorObject | ErrorDetail - -export const useImportsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ImportCreateRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getImportsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve imported files - - */ -export type importsRetrieveResponse200 = { - data: ImportResponse - status: 200 -} - -export type importsRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type importsRetrieveResponseComposite = importsRetrieveResponse200 | importsRetrieveResponse401 - -export type importsRetrieveResponse = importsRetrieveResponseComposite & { - headers: Headers -} - -export const getImportsRetrieveUrl = (uidImport: string) => { - return `/api/v2/imports/${uidImport}/` -} - -export const importsRetrieve = async (uidImport: string, options?: RequestInit): Promise => { - return fetchWithAuth(getImportsRetrieveUrl(uidImport), { - ...options, - method: 'GET', - }) -} - -export const getImportsRetrieveQueryKey = (uidImport: string) => { - return ['api', 'v2', 'imports', uidImport] as const -} - -export const getImportsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidImport: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getImportsRetrieveQueryKey(uidImport) - - const queryFn: QueryFunction>> = ({ signal }) => - importsRetrieve(uidImport, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidImport, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ImportsRetrieveQueryResult = NonNullable>> -export type ImportsRetrieveQueryError = ErrorDetail - -export function useImportsRetrieve>, TError = ErrorDetail>( - uidImport: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getImportsRetrieveQueryOptions(uidImport, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List of invites - -Invites sent or received by current user about transferring project ownership. - -List can be filtered with `mode` parameter, e.g.: display only received invites. - -Possible values for `mode`: -- `sender` -- `recipient` - - - */ -export type projectOwnershipInvitesListResponse200 = { - data: PaginatedProjectInviteResponseList - status: 200 -} - -export type projectOwnershipInvitesListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectOwnershipInvitesListResponseComposite = - | projectOwnershipInvitesListResponse200 - | projectOwnershipInvitesListResponse403 - -export type projectOwnershipInvitesListResponse = projectOwnershipInvitesListResponseComposite & { - headers: Headers -} - -export const getProjectOwnershipInvitesListUrl = (params?: ProjectOwnershipInvitesListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/project-ownership/invites/?${stringifiedParams}` - : `/api/v2/project-ownership/invites/` -} - -export const projectOwnershipInvitesList = async ( - params?: ProjectOwnershipInvitesListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectOwnershipInvitesListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getProjectOwnershipInvitesListQueryKey = (params?: ProjectOwnershipInvitesListParams) => { - return ['api', 'v2', 'project-ownership', 'invites', ...(params ? [params] : [])] as const -} - -export const getProjectOwnershipInvitesListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: ProjectOwnershipInvitesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - projectOwnershipInvitesList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectOwnershipInvitesListQueryResult = NonNullable< - Awaited> -> -export type ProjectOwnershipInvitesListQueryError = ErrorDetail - -export function useProjectOwnershipInvitesList< - TData = Awaited>, - TError = ErrorDetail, ->( - params?: ProjectOwnershipInvitesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectOwnershipInvitesListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create (send) an invite - -Where the assets `uid` are given in the payload's list - - - - */ -export type projectOwnershipInvitesCreateResponse201 = { - data: ProjectInviteResponse - status: 201 -} - -export type projectOwnershipInvitesCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type projectOwnershipInvitesCreateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectOwnershipInvitesCreateResponseComposite = - | projectOwnershipInvitesCreateResponse201 - | projectOwnershipInvitesCreateResponse400 - | projectOwnershipInvitesCreateResponse403 - -export type projectOwnershipInvitesCreateResponse = projectOwnershipInvitesCreateResponseComposite & { - headers: Headers -} - -export const getProjectOwnershipInvitesCreateUrl = () => { - return `/api/v2/project-ownership/invites/` -} - -export const projectOwnershipInvitesCreate = async ( - projectInviteCreatePayload: ProjectInviteCreatePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectOwnershipInvitesCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(projectInviteCreatePayload), - }) -} - -export const getProjectOwnershipInvitesCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProjectInviteCreatePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ProjectInviteCreatePayload }, - TContext -> => { - const mutationKey = ['projectOwnershipInvitesCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ProjectInviteCreatePayload } - > = (props) => { - const { data } = props ?? {} - - return projectOwnershipInvitesCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ProjectOwnershipInvitesCreateMutationResult = NonNullable< - Awaited> -> -export type ProjectOwnershipInvitesCreateMutationBody = ProjectInviteCreatePayload -export type ProjectOwnershipInvitesCreateMutationError = ErrorObject | ErrorDetail - -export const useProjectOwnershipInvitesCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ProjectInviteCreatePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getProjectOwnershipInvitesCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Invite detail - -It can be useful to monitor the invite status while the transfer is being processed - - */ -export type projectOwnershipInvitesRetrieveResponse200 = { - data: ProjectInviteResponse - status: 200 -} - -export type projectOwnershipInvitesRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectOwnershipInvitesRetrieveResponseComposite = - | projectOwnershipInvitesRetrieveResponse200 - | projectOwnershipInvitesRetrieveResponse403 - -export type projectOwnershipInvitesRetrieveResponse = projectOwnershipInvitesRetrieveResponseComposite & { - headers: Headers -} - -export const getProjectOwnershipInvitesRetrieveUrl = (uidInvite: string) => { - return `/api/v2/project-ownership/invites/${uidInvite}/` -} - -export const projectOwnershipInvitesRetrieve = async ( - uidInvite: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectOwnershipInvitesRetrieveUrl(uidInvite), { - ...options, - method: 'GET', - }) -} - -export const getProjectOwnershipInvitesRetrieveQueryKey = (uidInvite: string) => { - return ['api', 'v2', 'project-ownership', 'invites', uidInvite] as const -} - -export const getProjectOwnershipInvitesRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidInvite: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesRetrieveQueryKey(uidInvite) - - const queryFn: QueryFunction>> = ({ signal }) => - projectOwnershipInvitesRetrieve(uidInvite, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidInvite, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectOwnershipInvitesRetrieveQueryResult = NonNullable< - Awaited> -> -export type ProjectOwnershipInvitesRetrieveQueryError = ErrorDetail - -export function useProjectOwnershipInvitesRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidInvite: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectOwnershipInvitesRetrieveQueryOptions(uidInvite, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update an invite status - -Update the status of an invite. -Status accepted: -- `cancelled` -- `accepted` -- `declined` - -**Notes**: -- _When submitting `accepted` the invite status becomes automatically `in_progress`_ -- _Only the sender can cancel an invite, and **if only if** the invite is still pending._ -- _Only the recipient can accept or decline, **if and only if** the invite is still pending._ - - - */ -export type projectOwnershipInvitesPartialUpdateResponse200 = { - data: ProjectInviteResponse - status: 200 -} - -export type projectOwnershipInvitesPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type projectOwnershipInvitesPartialUpdateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectOwnershipInvitesPartialUpdateResponseComposite = - | projectOwnershipInvitesPartialUpdateResponse200 - | projectOwnershipInvitesPartialUpdateResponse400 - | projectOwnershipInvitesPartialUpdateResponse403 - -export type projectOwnershipInvitesPartialUpdateResponse = projectOwnershipInvitesPartialUpdateResponseComposite & { - headers: Headers -} - -export const getProjectOwnershipInvitesPartialUpdateUrl = (uidInvite: string) => { - return `/api/v2/project-ownership/invites/${uidInvite}/` -} - -export const projectOwnershipInvitesPartialUpdate = async ( - uidInvite: string, - patchedInviteUpdatePayload: PatchedInviteUpdatePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getProjectOwnershipInvitesPartialUpdateUrl(uidInvite), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedInviteUpdatePayload), - }, - ) -} - -export const getProjectOwnershipInvitesPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidInvite: string; data: PatchedInviteUpdatePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidInvite: string; data: PatchedInviteUpdatePayload }, - TContext -> => { - const mutationKey = ['projectOwnershipInvitesPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidInvite: string; data: PatchedInviteUpdatePayload } - > = (props) => { - const { uidInvite, data } = props ?? {} - - return projectOwnershipInvitesPartialUpdate(uidInvite, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ProjectOwnershipInvitesPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type ProjectOwnershipInvitesPartialUpdateMutationBody = PatchedInviteUpdatePayload -export type ProjectOwnershipInvitesPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useProjectOwnershipInvitesPartialUpdate = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidInvite: string; data: PatchedInviteUpdatePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getProjectOwnershipInvitesPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete invite - - */ -export type projectOwnershipInvitesDestroyResponse204 = { - data: void - status: 204 -} - -export type projectOwnershipInvitesDestroyResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectOwnershipInvitesDestroyResponseComposite = - | projectOwnershipInvitesDestroyResponse204 - | projectOwnershipInvitesDestroyResponse403 - -export type projectOwnershipInvitesDestroyResponse = projectOwnershipInvitesDestroyResponseComposite & { - headers: Headers -} - -export const getProjectOwnershipInvitesDestroyUrl = (uidInvite: string) => { - return `/api/v2/project-ownership/invites/${uidInvite}/` -} - -export const projectOwnershipInvitesDestroy = async ( - uidInvite: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectOwnershipInvitesDestroyUrl(uidInvite), { - ...options, - method: 'DELETE', - }) -} - -export const getProjectOwnershipInvitesDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidInvite: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidInvite: string }, - TContext -> => { - const mutationKey = ['projectOwnershipInvitesDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidInvite: string } - > = (props) => { - const { uidInvite } = props ?? {} - - return projectOwnershipInvitesDestroy(uidInvite, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ProjectOwnershipInvitesDestroyMutationResult = NonNullable< - Awaited> -> - -export type ProjectOwnershipInvitesDestroyMutationError = ErrorDetail - -export const useProjectOwnershipInvitesDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidInvite: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getProjectOwnershipInvitesDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve transfer details - - */ -export type projectOwnershipInvitesTransfersRetrieveResponse200 = { - data: TransferListResponse - status: 200 -} - -export type projectOwnershipInvitesTransfersRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type projectOwnershipInvitesTransfersRetrieveResponseComposite = - | projectOwnershipInvitesTransfersRetrieveResponse200 - | projectOwnershipInvitesTransfersRetrieveResponse401 - -export type projectOwnershipInvitesTransfersRetrieveResponse = - projectOwnershipInvitesTransfersRetrieveResponseComposite & { - headers: Headers - } - -export const getProjectOwnershipInvitesTransfersRetrieveUrl = (uidInvite: string, uidTransfer: string) => { - return `/api/v2/project-ownership/invites/${uidInvite}/transfers/${uidTransfer}/` -} - -export const projectOwnershipInvitesTransfersRetrieve = async ( - uidInvite: string, - uidTransfer: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getProjectOwnershipInvitesTransfersRetrieveUrl(uidInvite, uidTransfer), - { - ...options, - method: 'GET', - }, - ) -} - -export const getProjectOwnershipInvitesTransfersRetrieveQueryKey = (uidInvite: string, uidTransfer: string) => { - return ['api', 'v2', 'project-ownership', 'invites', uidInvite, 'transfers', uidTransfer] as const -} - -export const getProjectOwnershipInvitesTransfersRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidInvite: string, - uidTransfer: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesTransfersRetrieveQueryKey(uidInvite, uidTransfer) - - const queryFn: QueryFunction>> = ({ signal }) => - projectOwnershipInvitesTransfersRetrieve(uidInvite, uidTransfer, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidInvite && uidTransfer), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectOwnershipInvitesTransfersRetrieveQueryResult = NonNullable< - Awaited> -> -export type ProjectOwnershipInvitesTransfersRetrieveQueryError = ErrorDetail - -export function useProjectOwnershipInvitesTransfersRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidInvite: string, - uidTransfer: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectOwnershipInvitesTransfersRetrieveQueryOptions(uidInvite, uidTransfer, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List current user's assets' tags - - */ -export type tagsListResponse200 = { - data: PaginatedTagListResponseList - status: 200 -} - -export type tagsListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type tagsListResponseComposite = tagsListResponse200 | tagsListResponse401 - -export type tagsListResponse = tagsListResponseComposite & { - headers: Headers -} - -export const getTagsListUrl = (params?: TagsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/tags/?${stringifiedParams}` : `/api/v2/tags/` -} - -export const tagsList = async (params?: TagsListParams, options?: RequestInit): Promise => { - return fetchWithAuth(getTagsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getTagsListQueryKey = (params?: TagsListParams) => { - return ['api', 'v2', 'tags', ...(params ? [params] : [])] as const -} - -export const getTagsListQueryOptions = >, TError = ErrorDetail>( - params?: TagsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getTagsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - tagsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type TagsListQueryResult = NonNullable>> -export type TagsListQueryError = ErrorDetail - -export function useTagsList>, TError = ErrorDetail>( - params?: TagsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getTagsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve a tag's data - - */ -export type tagsRetrieveResponse200 = { - data: TagRetrieveResponse - status: 200 -} - -export type tagsRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type tagsRetrieveResponseComposite = tagsRetrieveResponse200 | tagsRetrieveResponse401 - -export type tagsRetrieveResponse = tagsRetrieveResponseComposite & { - headers: Headers -} - -export const getTagsRetrieveUrl = (taguidUid: string) => { - return `/api/v2/tags/${taguidUid}/` -} - -export const tagsRetrieve = async (taguidUid: string, options?: RequestInit): Promise => { - return fetchWithAuth(getTagsRetrieveUrl(taguidUid), { - ...options, - method: 'GET', - }) -} - -export const getTagsRetrieveQueryKey = (taguidUid: string) => { - return ['api', 'v2', 'tags', taguidUid] as const -} - -export const getTagsRetrieveQueryOptions = >, TError = ErrorDetail>( - taguidUid: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getTagsRetrieveQueryKey(taguidUid) - - const queryFn: QueryFunction>> = ({ signal }) => - tagsRetrieve(taguidUid, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!taguidUid, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type TagsRetrieveQueryResult = NonNullable>> -export type TagsRetrieveQueryError = ErrorDetail - -export function useTagsRetrieve>, TError = ErrorDetail>( - taguidUid: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getTagsRetrieveQueryOptions(taguidUid, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts b/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts new file mode 100644 index 0000000000..71eeec3c38 --- /dev/null +++ b/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts @@ -0,0 +1,509 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import type { + Asset +} from '../../models/asset'; + +import type { + AssetBulkResponse +} from '../../models/assetBulkResponse'; + +import { + AssetDeploymentStatusEnum +} from '../../models/assetDeploymentStatusEnum'; + +import type { + AssetListCount +} from '../../models/assetListCount'; + +import type { + AssetMetadataResponse +} from '../../models/assetMetadataResponse'; + +import { + AssetTypeEnum +} from '../../models/assetTypeEnum'; + +import type { + DeploymentResponse +} from '../../models/deploymentResponse'; + +import type { + HashResponse +} from '../../models/hashResponse'; + +import type { + ImportCreateResponse +} from '../../models/importCreateResponse'; + +import type { + ImportResponse +} from '../../models/importResponse'; + +import { + InviteStatusChoicesEnum +} from '../../models/inviteStatusChoicesEnum'; + +import type { + PaginatedAssetCountResponseList +} from '../../models/paginatedAssetCountResponseList'; + +import type { + PaginatedAssetList +} from '../../models/paginatedAssetList'; + +import type { + PaginatedAssetMinimalListList +} from '../../models/paginatedAssetMinimalListList'; + +import type { + PaginatedImportResponseList +} from '../../models/paginatedImportResponseList'; + +import type { + PaginatedProjectInviteResponseList +} from '../../models/paginatedProjectInviteResponseList'; + +import type { + PaginatedTagListResponseList +} from '../../models/paginatedTagListResponseList'; + +import type { + PaginatedVersionListResponseList +} from '../../models/paginatedVersionListResponseList'; + +import type { + ProjectInviteResponse +} from '../../models/projectInviteResponse'; + +import type { + TagRetrieveResponse +} from '../../models/tagRetrieveResponse'; + +import type { + TransferListResponse +} from '../../models/transferListResponse'; + +import type { + VersionRetrieveResponse +} from '../../models/versionRetrieveResponse'; + + +export const getApiV2AssetsListResponseMock = (overrideResponse: Partial< PaginatedAssetList > = {}): PaginatedAssetList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {} + })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { + [faker.string.alphanumeric(5)]: {} + }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { + [faker.string.alphanumeric(5)]: {} + }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), ...overrideResponse}) + +export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial< Asset > = {}): Asset => ({url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {} + })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { + [faker.string.alphanumeric(5)]: {} + }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { + [faker.string.alphanumeric(5)]: {} + }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), ...overrideResponse}) + +export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial< Asset > = {}): Asset => ({url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {} + })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { + [faker.string.alphanumeric(5)]: {} + }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { + [faker.string.alphanumeric(5)]: {} + }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), ...overrideResponse}) + +export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partial< Asset > = {}): Asset => ({url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {} + })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { + [faker.string.alphanumeric(5)]: {} + }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { + [faker.string.alphanumeric(5)]: {} + }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), ...overrideResponse}) + +export const getApiV2AssetsCountsListResponseMock = (overrideResponse: Partial< PaginatedAssetCountResponseList > = {}): PaginatedAssetCountResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({daily_submission_count: {'2020-10-20': faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, total_submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})})), ...overrideResponse}) + +export const getApiV2AssetsDeploymentRetrieveResponseMock = (overrideResponse: Partial< DeploymentResponse > = {}): DeploymentResponse => ({backend: faker.string.alpha({length: {min: 10, max: 20}}), active: faker.datatype.boolean(), version_id: faker.string.alpha({length: {min: 10, max: 20}}), asset: {url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {} + })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { + [faker.string.alphanumeric(5)]: {} + }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { + [faker.string.alphanumeric(5)]: {} + }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}, ...overrideResponse}) + +export const getApiV2AssetsDeploymentCreateResponseMock = (overrideResponse: Partial< DeploymentResponse > = {}): DeploymentResponse => ({backend: faker.string.alpha({length: {min: 10, max: 20}}), active: faker.datatype.boolean(), version_id: faker.string.alpha({length: {min: 10, max: 20}}), asset: {url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {} + })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { + [faker.string.alphanumeric(5)]: {} + }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { + [faker.string.alphanumeric(5)]: {} + }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}, ...overrideResponse}) + +export const getApiV2AssetsDeploymentPartialUpdateResponseMock = (overrideResponse: Partial< DeploymentResponse > = {}): DeploymentResponse => ({backend: faker.string.alpha({length: {min: 10, max: 20}}), active: faker.datatype.boolean(), version_id: faker.string.alpha({length: {min: 10, max: 20}}), asset: {url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {} + })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { + [faker.string.alphanumeric(5)]: {} + }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { + [faker.string.alphanumeric(5)]: {} + }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}, ...overrideResponse}) + +export const getApiV2AssetsVersionsListResponseMock = (overrideResponse: Partial< PaginatedVersionListResponseList > = {}): PaginatedVersionListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) + +export const getApiV2AssetsVersionsRetrieveResponseMock = (overrideResponse: Partial< VersionRetrieveResponse > = {}): VersionRetrieveResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, content: {schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $kuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{default_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translation: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, ...overrideResponse}) + +export const getApiV2AssetsXformRetrieveResponseMock = (): string => (faker.word.sample()) + +export const getApiV2AssetsBulkCreateResponseMock = (overrideResponse: Partial< AssetBulkResponse > = {}): AssetBulkResponse => ({detail: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsCountsRetrieveResponseMock = (overrideResponse: Partial< AssetListCount > = {}): AssetListCount => ({deployed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), archived_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), draft_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), ...overrideResponse}) + +export const getApiV2AssetsHashRetrieveResponseMock = (overrideResponse: Partial< HashResponse > = {}): HashResponse => ({hash: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsMetadataRetrieveResponseMock = (overrideResponse: Partial< AssetMetadataResponse > = {}): AssetMetadataResponse => ({languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), sectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), organizations: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) + +export const getApiV2AssetsMinimalListRetrieveResponseMock = (overrideResponse: Partial< PaginatedAssetMinimalListList > = {}): PaginatedAssetMinimalListList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 22}}), name: faker.string.alpha({length: {min: 10, max: 20}}), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum))})), ...overrideResponse}) + +export const getApiV2ImportsListResponseMock = (overrideResponse: Partial< PaginatedImportResponseList > = {}): PaginatedImportResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), messages: {updated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kind: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), summary: faker.helpers.arrayElement([{geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), language: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), first: faker.helpers.arrayElement([{}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), owner__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), 'audit-logs': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset_id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), new_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_owner: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, uid: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) + +export const getApiV2ImportsCreateResponseMock = (overrideResponse: Partial< ImportCreateResponse > = {}): ImportCreateResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2ImportsRetrieveResponseMock = (overrideResponse: Partial< ImportResponse > = {}): ImportResponse => ({url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), messages: {updated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kind: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), summary: faker.helpers.arrayElement([{geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), language: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), first: faker.helpers.arrayElement([{}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), owner__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), 'audit-logs': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset_id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), new_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_owner: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, uid: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, ...overrideResponse}) + +export const getApiV2ProjectOwnershipInvitesListResponseMock = (overrideResponse: Partial< PaginatedProjectInviteResponseList > = {}): PaginatedProjectInviteResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), 'sender | recipient': faker.internet.url(), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.internet.url(), undefined]), asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined])}))})), ...overrideResponse}) + +export const getApiV2ProjectOwnershipInvitesCreateResponseMock = (overrideResponse: Partial< ProjectInviteResponse > = {}): ProjectInviteResponse => ({url: faker.internet.url(), 'sender | recipient': faker.internet.url(), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.internet.url(), undefined]), asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined])})), ...overrideResponse}) + +export const getApiV2ProjectOwnershipInvitesRetrieveResponseMock = (overrideResponse: Partial< ProjectInviteResponse > = {}): ProjectInviteResponse => ({url: faker.internet.url(), 'sender | recipient': faker.internet.url(), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.internet.url(), undefined]), asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined])})), ...overrideResponse}) + +export const getApiV2ProjectOwnershipInvitesPartialUpdateResponseMock = (overrideResponse: Partial< ProjectInviteResponse > = {}): ProjectInviteResponse => ({url: faker.internet.url(), 'sender | recipient': faker.internet.url(), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.internet.url(), undefined]), asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined])})), ...overrideResponse}) + +export const getApiV2ProjectOwnershipInvitesTransfersRetrieveResponseMock = (overrideResponse: Partial< TransferListResponse > = {}): TransferListResponse => ({url: faker.internet.url(), asset: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), error: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), ...overrideResponse}) + +export const getApiV2TagsListResponseMock = (overrideResponse: Partial< PaginatedTagListResponseList > = {}): PaginatedTagListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url()})), ...overrideResponse}) + +export const getApiV2TagsRetrieveResponseMock = (overrideResponse: Partial< TagRetrieveResponse > = {}): TagRetrieveResponse => ({name: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), assets: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.internet.url())), parent: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + + +export const getApiV2AssetsListMockHandler = (overrideResponse?: PaginatedAssetList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList)) => { + return http.get('*/api/v2/assets/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsCreateMockHandler = (overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset)) => { + return http.post('*/api/v2/assets/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsRetrieveMockHandler = (overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset)) => { + return http.get('*/api/v2/assets/:uidAsset/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsPartialUpdateMockHandler = (overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset)) => { + return http.patch('*/api/v2/assets/:uidAsset/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsCountsListMockHandler = (overrideResponse?: PaginatedAssetCountResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetCountResponseList)) => { + return http.get('*/api/v2/assets/:uidAsset/counts/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsCountsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDeploymentRetrieveMockHandler = (overrideResponse?: DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/deployment/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDeploymentRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDeploymentCreateMockHandler = (overrideResponse?: DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/deployment/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDeploymentCreateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDeploymentPartialUpdateMockHandler = (overrideResponse?: DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse)) => { + return http.patch('*/api/v2/assets/:uidAsset/deployment/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDeploymentPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsVersionsListMockHandler = (overrideResponse?: PaginatedVersionListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedVersionListResponseList)) => { + return http.get('*/api/v2/assets/:uidAsset/versions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsVersionsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsVersionsRetrieveMockHandler = (overrideResponse?: VersionRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | VersionRetrieveResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsVersionsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsXformRetrieveMockHandler = (overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string)) => { + return http.get('*/api/v2/assets/:uidAsset/xform/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsXformRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsBulkCreateMockHandler = (overrideResponse?: AssetBulkResponse | ((info: Parameters[1]>[0]) => Promise | AssetBulkResponse)) => { + return http.post('*/api/v2/assets/bulk/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsBulkCreateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsCountsRetrieveMockHandler = (overrideResponse?: AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount)) => { + return http.get('*/api/v2/assets/counts/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsCountsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHashRetrieveMockHandler = (overrideResponse?: HashResponse | ((info: Parameters[1]>[0]) => Promise | HashResponse)) => { + return http.get('*/api/v2/assets/hash/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHashRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsMetadataRetrieveMockHandler = (overrideResponse?: AssetMetadataResponse | ((info: Parameters[1]>[0]) => Promise | AssetMetadataResponse)) => { + return http.get('*/api/v2/assets/metadata/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsMetadataRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsMinimalListRetrieveMockHandler = (overrideResponse?: PaginatedAssetMinimalListList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetMinimalListList)) => { + return http.get('*/api/v2/assets/minimal-list/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsMinimalListRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ImportsListMockHandler = (overrideResponse?: PaginatedImportResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedImportResponseList)) => { + return http.get('*/api/v2/imports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ImportsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ImportsCreateMockHandler = (overrideResponse?: ImportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ImportCreateResponse)) => { + return http.post('*/api/v2/imports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ImportsCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ImportsRetrieveMockHandler = (overrideResponse?: ImportResponse | ((info: Parameters[1]>[0]) => Promise | ImportResponse)) => { + return http.get('*/api/v2/imports/:uidImport/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ImportsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectOwnershipInvitesListMockHandler = (overrideResponse?: PaginatedProjectInviteResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedProjectInviteResponseList)) => { + return http.get('*/api/v2/project-ownership/invites/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectOwnershipInvitesListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectOwnershipInvitesCreateMockHandler = (overrideResponse?: ProjectInviteResponse | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse)) => { + return http.post('*/api/v2/project-ownership/invites/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectOwnershipInvitesCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectOwnershipInvitesRetrieveMockHandler = (overrideResponse?: ProjectInviteResponse | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse)) => { + return http.get('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectOwnershipInvitesRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = (overrideResponse?: ProjectInviteResponse | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse)) => { + return http.patch('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectOwnershipInvitesPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectOwnershipInvitesDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler = (overrideResponse?: TransferListResponse | ((info: Parameters[1]>[0]) => Promise | TransferListResponse)) => { + return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectOwnershipInvitesTransfersRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2TagsListMockHandler = (overrideResponse?: PaginatedTagListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedTagListResponseList)) => { + return http.get('*/api/v2/tags/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2TagsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2TagsRetrieveMockHandler = (overrideResponse?: TagRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | TagRetrieveResponse)) => { + return http.get('*/api/v2/tags/:taguidUid/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2TagsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} +export const getManageProjectsAndLibraryContentMock = () => [ + getApiV2AssetsListMockHandler(), + getApiV2AssetsCreateMockHandler(), + getApiV2AssetsRetrieveMockHandler(), + getApiV2AssetsPartialUpdateMockHandler(), + getApiV2AssetsDestroyMockHandler(), + getApiV2AssetsCountsListMockHandler(), + getApiV2AssetsDeploymentRetrieveMockHandler(), + getApiV2AssetsDeploymentCreateMockHandler(), + getApiV2AssetsDeploymentPartialUpdateMockHandler(), + getApiV2AssetsVersionsListMockHandler(), + getApiV2AssetsVersionsRetrieveMockHandler(), + getApiV2AssetsXformRetrieveMockHandler(), + getApiV2AssetsBulkCreateMockHandler(), + getApiV2AssetsCountsRetrieveMockHandler(), + getApiV2AssetsHashRetrieveMockHandler(), + getApiV2AssetsMetadataRetrieveMockHandler(), + getApiV2AssetsMinimalListRetrieveMockHandler(), + getApiV2ImportsListMockHandler(), + getApiV2ImportsCreateMockHandler(), + getApiV2ImportsRetrieveMockHandler(), + getApiV2ProjectOwnershipInvitesListMockHandler(), + getApiV2ProjectOwnershipInvitesCreateMockHandler(), + getApiV2ProjectOwnershipInvitesRetrieveMockHandler(), + getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler(), + getApiV2ProjectOwnershipInvitesDestroyMockHandler(), + getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler(), + getApiV2TagsListMockHandler(), + getApiV2TagsRetrieveMockHandler() +] diff --git a/jsapp/js/api/react-query/other/index.ts b/jsapp/js/api/react-query/other/index.ts new file mode 100644 index 0000000000..6dd906a653 --- /dev/null +++ b/jsapp/js/api/react-query/other/index.ts @@ -0,0 +1,1774 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + ChangePlan +} from '../../models/changePlan'; + +import type { + CheckoutLink +} from '../../models/checkoutLink'; + +import type { + CustomerPortal +} from '../../models/customerPortal'; + +import type { + CustomerPortalPostResponse +} from '../../models/customerPortalPostResponse'; + +import type { + ErrorDetail +} from '../../models/errorDetail'; + +import type { + ErrorObject +} from '../../models/errorObject'; + +import type { + Language +} from '../../models/language'; + +import type { + LanguagesListParams +} from '../../models/languagesListParams'; + +import type { + OneTimeAddOn +} from '../../models/oneTimeAddOn'; + +import type { + PaginatedLanguageListList +} from '../../models/paginatedLanguageListList'; + +import type { + PaginatedOneTimeAddOnList +} from '../../models/paginatedOneTimeAddOnList'; + +import type { + PaginatedPermissionResponseList +} from '../../models/paginatedPermissionResponseList'; + +import type { + PaginatedProductList +} from '../../models/paginatedProductList'; + +import type { + PaginatedSubscriptionList +} from '../../models/paginatedSubscriptionList'; + +import type { + PaginatedTranscriptionServiceList +} from '../../models/paginatedTranscriptionServiceList'; + +import type { + PaginatedTranslationServiceList +} from '../../models/paginatedTranslationServiceList'; + +import type { + PermissionResponse +} from '../../models/permissionResponse'; + +import type { + PermissionsListParams +} from '../../models/permissionsListParams'; + +import type { + StripeAddonsListParams +} from '../../models/stripeAddonsListParams'; + +import type { + StripeProductsListParams +} from '../../models/stripeProductsListParams'; + +import type { + StripeSubscriptionsListParams +} from '../../models/stripeSubscriptionsListParams'; + +import type { + Subscription +} from '../../models/subscription'; + +import type { + TermsOfServiceResponse +} from '../../models/termsOfServiceResponse'; + +import type { + TranscriptionService +} from '../../models/transcriptionService'; + +import type { + TranscriptionServicesListParams +} from '../../models/transcriptionServicesListParams'; + +import type { + TranslationService +} from '../../models/translationService'; + +import type { + TranslationServicesListParams +} from '../../models/translationServicesListParams'; + +import { fetchWithAuth } from '../../orval.mutator'; + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * ## List the languages accessible to requesting (authenticated) user. + +Search can be made with `q` parameter. By default, search for the term in language names or language codes. + +Examples: +```shell + curl -X GET https://kf.kobotoolbox.org/api/v2/languages/?q=fr +``` + +Complex searches can be done on other fields, such as `transcription_services` and `translation_services`. + +Examples: +```shell + curl -X GET https://kf.kobotoolbox.org/api/v2/languages/?q=transcription_services__code:goog AND translation_services__code:goog +``` + +Results are order by `featured` first (descending order), then by their name. + + */ +export type languagesListResponse200 = { + data: PaginatedLanguageListList + status: 200 +} + +export type languagesListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type languagesListResponseComposite = languagesListResponse200 | languagesListResponse401; + +export type languagesListResponse = languagesListResponseComposite & { + headers: Headers; +} + +export const getLanguagesListUrl = (params?: LanguagesListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/languages/?${stringifiedParams}` : `/api/v2/languages/` +} + +export const languagesList = async (params?: LanguagesListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getLanguagesListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getLanguagesListQueryKey = (params?: LanguagesListParams,) => { + return ['api','v2','languages', ...(params ? [params]: [])] as const; + } + + +export const getLanguagesListQueryOptions = >, TError = ErrorDetail>(params?: LanguagesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getLanguagesListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => languagesList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type LanguagesListQueryResult = NonNullable>> +export type LanguagesListQueryError = ErrorDetail + + + +export function useLanguagesList>, TError = ErrorDetail>( + params?: LanguagesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getLanguagesListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve one language + +* `code` - is the unique identifier of a specific language + + */ +export type languagesRetrieveResponse200 = { + data: Language + status: 200 +} + +export type languagesRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type languagesRetrieveResponseComposite = languagesRetrieveResponse200 | languagesRetrieveResponse401; + +export type languagesRetrieveResponse = languagesRetrieveResponseComposite & { + headers: Headers; +} + +export const getLanguagesRetrieveUrl = (code: string,) => { + + + + + return `/api/v2/languages/${code}/` +} + +export const languagesRetrieve = async (code: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getLanguagesRetrieveUrl(code), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getLanguagesRetrieveQueryKey = (code: string,) => { + return ['api','v2','languages',code] as const; + } + + +export const getLanguagesRetrieveQueryOptions = >, TError = ErrorDetail>(code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getLanguagesRetrieveQueryKey(code); + + + + const queryFn: QueryFunction>> = ({ signal }) => languagesRetrieve(code, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(code), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type LanguagesRetrieveQueryResult = NonNullable>> +export type LanguagesRetrieveQueryError = ErrorDetail + + + +export function useLanguagesRetrieve>, TError = ErrorDetail>( + code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getLanguagesRetrieveQueryOptions(code,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List all assignable permissions for `Asset` + +The `implied` property of a given permission shows which additional +permissions are automatically granted when assigning that particular +permission. + +The `contradictory` property shows which permissions are removed when +assigning that particular permission. + + */ +export type permissionsListResponse200 = { + data: PaginatedPermissionResponseList + status: 200 +} + +export type permissionsListResponseComposite = permissionsListResponse200; + +export type permissionsListResponse = permissionsListResponseComposite & { + headers: Headers; +} + +export const getPermissionsListUrl = (params?: PermissionsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/permissions/?${stringifiedParams}` : `/api/v2/permissions/` +} + +export const permissionsList = async (params?: PermissionsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getPermissionsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getPermissionsListQueryKey = (params?: PermissionsListParams,) => { + return ['api','v2','permissions', ...(params ? [params]: [])] as const; + } + + +export const getPermissionsListQueryOptions = >, TError = unknown>(params?: PermissionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getPermissionsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => permissionsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type PermissionsListQueryResult = NonNullable>> +export type PermissionsListQueryError = unknown + + + +export function usePermissionsList>, TError = unknown>( + params?: PermissionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getPermissionsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve a codename's permissions + + */ +export type permissionsRetrieveResponse200 = { + data: PermissionResponse + status: 200 +} + +export type permissionsRetrieveResponseComposite = permissionsRetrieveResponse200; + +export type permissionsRetrieveResponse = permissionsRetrieveResponseComposite & { + headers: Headers; +} + +export const getPermissionsRetrieveUrl = (codename: string,) => { + + + + + return `/api/v2/permissions/${codename}/` +} + +export const permissionsRetrieve = async (codename: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getPermissionsRetrieveUrl(codename), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getPermissionsRetrieveQueryKey = (codename: string,) => { + return ['api','v2','permissions',codename] as const; + } + + +export const getPermissionsRetrieveQueryOptions = >, TError = unknown>(codename: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getPermissionsRetrieveQueryKey(codename); + + + + const queryFn: QueryFunction>> = ({ signal }) => permissionsRetrieve(codename, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(codename), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type PermissionsRetrieveQueryResult = NonNullable>> +export type PermissionsRetrieveQueryError = unknown + + + +export function usePermissionsRetrieve>, TError = unknown>( + codename: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getPermissionsRetrieveQueryOptions(codename,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Lists the one-time add-ons for the authenticated user's organization. + */ +export type stripeAddonsListResponse200 = { + data: PaginatedOneTimeAddOnList + status: 200 +} + +export type stripeAddonsListResponseComposite = stripeAddonsListResponse200; + +export type stripeAddonsListResponse = stripeAddonsListResponseComposite & { + headers: Headers; +} + +export const getStripeAddonsListUrl = (params?: StripeAddonsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/stripe/addons/?${stringifiedParams}` : `/api/v2/stripe/addons/` +} + +export const stripeAddonsList = async (params?: StripeAddonsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getStripeAddonsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getStripeAddonsListQueryKey = (params?: StripeAddonsListParams,) => { + return ['api','v2','stripe','addons', ...(params ? [params]: [])] as const; + } + + +export const getStripeAddonsListQueryOptions = >, TError = unknown>(params?: StripeAddonsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getStripeAddonsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => stripeAddonsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type StripeAddonsListQueryResult = NonNullable>> +export type StripeAddonsListQueryError = unknown + + + +export function useStripeAddonsList>, TError = unknown>( + params?: StripeAddonsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getStripeAddonsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Lists the one-time add-ons for the authenticated user's organization. + */ +export type stripeAddonsRetrieveResponse200 = { + data: OneTimeAddOn + status: 200 +} + +export type stripeAddonsRetrieveResponseComposite = stripeAddonsRetrieveResponse200; + +export type stripeAddonsRetrieveResponse = stripeAddonsRetrieveResponseComposite & { + headers: Headers; +} + +export const getStripeAddonsRetrieveUrl = (id: string,) => { + + + + + return `/api/v2/stripe/addons/${id}/` +} + +export const stripeAddonsRetrieve = async (id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getStripeAddonsRetrieveUrl(id), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getStripeAddonsRetrieveQueryKey = (id: string,) => { + return ['api','v2','stripe','addons',id] as const; + } + + +export const getStripeAddonsRetrieveQueryOptions = >, TError = unknown>(id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getStripeAddonsRetrieveQueryKey(id); + + + + const queryFn: QueryFunction>> = ({ signal }) => stripeAddonsRetrieve(id, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type StripeAddonsRetrieveQueryResult = NonNullable>> +export type StripeAddonsRetrieveQueryError = unknown + + + +export function useStripeAddonsRetrieve>, TError = unknown>( + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getStripeAddonsRetrieveQueryOptions(id,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Change an existing subscription to a new price. + +This will immediately change their subscription to the new plan if upgrading, prorating the charge. +If the user is downgrading to a lower price, it will schedule the change at the end of the current billing period. + +
+GET /api/v2/stripe/change-plan/?subscription_id={subscription_id}&price_id={price_id}
+
+ +> Example +> +> curl -X GET https://[kpi]/api/v2/stripe/change-plan/ + +> **Payload** +> +> { +> "price_id": "price_A34cds8fmske3tf", +> "subscription_id": "sub_s9aNFrd2fsmld4gz", +> "quantity": 100000 +> } + +where: + +* "price_id" (required) is the Stripe Price ID for the plan the user is changing to. +* "quantity" is the quantity for the new subscription price (default: 1). +* "subscription_id" (required) is a Stripe Subscription ID for the subscription being changed. + */ +export type stripeChangePlanRetrieveResponse200 = { + data: ChangePlan + status: 200 +} + +export type stripeChangePlanRetrieveResponseComposite = stripeChangePlanRetrieveResponse200; + +export type stripeChangePlanRetrieveResponse = stripeChangePlanRetrieveResponseComposite & { + headers: Headers; +} + +export const getStripeChangePlanRetrieveUrl = () => { + + + + + return `/api/v2/stripe/change-plan` +} + +export const stripeChangePlanRetrieve = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getStripeChangePlanRetrieveUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getStripeChangePlanRetrieveQueryKey = () => { + return ['api','v2','stripe','change-plan'] as const; + } + + +export const getStripeChangePlanRetrieveQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getStripeChangePlanRetrieveQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => stripeChangePlanRetrieve({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type StripeChangePlanRetrieveQueryResult = NonNullable>> +export type StripeChangePlanRetrieveQueryError = unknown + + + +export function useStripeChangePlanRetrieve>, TError = unknown>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getStripeChangePlanRetrieveQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +export type stripeCheckoutLinkCreateResponse200 = { + data: CheckoutLink + status: 200 +} + +export type stripeCheckoutLinkCreateResponseComposite = stripeCheckoutLinkCreateResponse200; + +export type stripeCheckoutLinkCreateResponse = stripeCheckoutLinkCreateResponseComposite & { + headers: Headers; +} + +export const getStripeCheckoutLinkCreateUrl = () => { + + + + + return `/api/v2/stripe/checkout-link` +} + +export const stripeCheckoutLinkCreate = async (checkoutLink: CheckoutLink, options?: RequestInit): Promise => { + + return fetchWithAuth(getStripeCheckoutLinkCreateUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + checkoutLink,) + } +);} + + + + +export const getStripeCheckoutLinkCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: CheckoutLink}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: CheckoutLink}, TContext> => { + +const mutationKey = ['stripeCheckoutLinkCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: CheckoutLink}> = (props) => { + const {data} = props ?? {}; + + return stripeCheckoutLinkCreate(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type StripeCheckoutLinkCreateMutationResult = NonNullable>> + export type StripeCheckoutLinkCreateMutationBody = CheckoutLink + export type StripeCheckoutLinkCreateMutationError = unknown + + export const useStripeCheckoutLinkCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: CheckoutLink}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getStripeCheckoutLinkCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + export type stripeCustomerPortalCreateResponse200 = { + data: CustomerPortalPostResponse + status: 200 +} + +export type stripeCustomerPortalCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type stripeCustomerPortalCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type stripeCustomerPortalCreateResponseComposite = stripeCustomerPortalCreateResponse200 | stripeCustomerPortalCreateResponse400 | stripeCustomerPortalCreateResponse401; + +export type stripeCustomerPortalCreateResponse = stripeCustomerPortalCreateResponseComposite & { + headers: Headers; +} + +export const getStripeCustomerPortalCreateUrl = () => { + + + + + return `/api/v2/stripe/customer-portal` +} + +export const stripeCustomerPortalCreate = async (customerPortal: CustomerPortal, options?: RequestInit): Promise => { + + return fetchWithAuth(getStripeCustomerPortalCreateUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + customerPortal,) + } +);} + + + + +export const getStripeCustomerPortalCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: CustomerPortal}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: CustomerPortal}, TContext> => { + +const mutationKey = ['stripeCustomerPortalCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: CustomerPortal}> = (props) => { + const {data} = props ?? {}; + + return stripeCustomerPortalCreate(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type StripeCustomerPortalCreateMutationResult = NonNullable>> + export type StripeCustomerPortalCreateMutationBody = CustomerPortal + export type StripeCustomerPortalCreateMutationError = ErrorObject | ErrorDetail + + export const useStripeCustomerPortalCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: CustomerPortal}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getStripeCustomerPortalCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Returns Product and Price Lists, sorted from the product with the lowest price to highest +This endpoint is cached for an amount of time determined by ENDPOINT_CACHE_DURATION + +
+GET /api/v2/stripe/products/
+
+ +> Example +> +> curl -X GET https://[kpi]/api/v2/stripe/products/ + +> Response +> +> HTTP 200 Ok +> { +> "count": ... +> "next": ... +> "previous": ... +> "results": [ +> { +> "id": string, +> "name": string, +> "type": string, +> "prices": [ +> { +> "id": string, +> "nickname": string, +> "currency": string, +> "type": string, +> "recurring": { +> "aggregate_usage": string ('sum', 'last_during_period`, `last_ever`, `max`) +> "interval": string ('month', 'year', 'week', 'day') +> "interval_count": int, +> "usage_type": string ('metered', 'licensed') +> }, +> "unit_amount": int (cents), +> "human_readable_price": string, +> "metadata": {}, +> "active": bool, +> "product": string, +> "transform_quantity": null | {'round': 'up'|'down', 'divide_by': int} +> }, +> ... +> ], +> "metadata": {}, +> }, +> ... +> ] +> } +> + +### Note: unit_amount is price in cents (assuming currency is USD/AUD/CAD/etc.) + +## Current Endpoint + */ +export type stripeProductsListResponse200 = { + data: PaginatedProductList + status: 200 +} + +export type stripeProductsListResponseComposite = stripeProductsListResponse200; + +export type stripeProductsListResponse = stripeProductsListResponseComposite & { + headers: Headers; +} + +export const getStripeProductsListUrl = (params?: StripeProductsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/stripe/products/?${stringifiedParams}` : `/api/v2/stripe/products/` +} + +export const stripeProductsList = async (params?: StripeProductsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getStripeProductsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getStripeProductsListQueryKey = (params?: StripeProductsListParams,) => { + return ['api','v2','stripe','products', ...(params ? [params]: [])] as const; + } + + +export const getStripeProductsListQueryOptions = >, TError = unknown>(params?: StripeProductsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getStripeProductsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => stripeProductsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type StripeProductsListQueryResult = NonNullable>> +export type StripeProductsListQueryError = unknown + + + +export function useStripeProductsList>, TError = unknown>( + params?: StripeProductsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getStripeProductsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +export type stripeSubscriptionsListResponse200 = { + data: PaginatedSubscriptionList + status: 200 +} + +export type stripeSubscriptionsListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type stripeSubscriptionsListResponseComposite = stripeSubscriptionsListResponse200 | stripeSubscriptionsListResponse401; + +export type stripeSubscriptionsListResponse = stripeSubscriptionsListResponseComposite & { + headers: Headers; +} + +export const getStripeSubscriptionsListUrl = (params?: StripeSubscriptionsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/stripe/subscriptions/?${stringifiedParams}` : `/api/v2/stripe/subscriptions/` +} + +export const stripeSubscriptionsList = async (params?: StripeSubscriptionsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getStripeSubscriptionsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getStripeSubscriptionsListQueryKey = (params?: StripeSubscriptionsListParams,) => { + return ['api','v2','stripe','subscriptions', ...(params ? [params]: [])] as const; + } + + +export const getStripeSubscriptionsListQueryOptions = >, TError = ErrorDetail>(params?: StripeSubscriptionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getStripeSubscriptionsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => stripeSubscriptionsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type StripeSubscriptionsListQueryResult = NonNullable>> +export type StripeSubscriptionsListQueryError = ErrorDetail + + + +export function useStripeSubscriptionsList>, TError = ErrorDetail>( + params?: StripeSubscriptionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getStripeSubscriptionsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +export type stripeSubscriptionsRetrieveResponse200 = { + data: Subscription + status: 200 +} + +export type stripeSubscriptionsRetrieveResponseComposite = stripeSubscriptionsRetrieveResponse200; + +export type stripeSubscriptionsRetrieveResponse = stripeSubscriptionsRetrieveResponseComposite & { + headers: Headers; +} + +export const getStripeSubscriptionsRetrieveUrl = (id: string,) => { + + + + + return `/api/v2/stripe/subscriptions/${id}/` +} + +export const stripeSubscriptionsRetrieve = async (id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getStripeSubscriptionsRetrieveUrl(id), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getStripeSubscriptionsRetrieveQueryKey = (id: string,) => { + return ['api','v2','stripe','subscriptions',id] as const; + } + + +export const getStripeSubscriptionsRetrieveQueryOptions = >, TError = unknown>(id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getStripeSubscriptionsRetrieveQueryKey(id); + + + + const queryFn: QueryFunction>> = ({ signal }) => stripeSubscriptionsRetrieve(id, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type StripeSubscriptionsRetrieveQueryResult = NonNullable>> +export type StripeSubscriptionsRetrieveQueryError = unknown + + + +export function useStripeSubscriptionsRetrieve>, TError = unknown>( + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getStripeSubscriptionsRetrieveQueryOptions(id,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List the different terms of service + + */ +export type termsOfServiceListResponse200 = { + data: TermsOfServiceResponse[] + status: 200 +} + +export type termsOfServiceListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type termsOfServiceListResponseComposite = termsOfServiceListResponse200 | termsOfServiceListResponse401; + +export type termsOfServiceListResponse = termsOfServiceListResponseComposite & { + headers: Headers; +} + +export const getTermsOfServiceListUrl = () => { + + + + + return `/api/v2/terms-of-service/` +} + +export const termsOfServiceList = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getTermsOfServiceListUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getTermsOfServiceListQueryKey = () => { + return ['api','v2','terms-of-service'] as const; + } + + +export const getTermsOfServiceListQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getTermsOfServiceListQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => termsOfServiceList({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type TermsOfServiceListQueryResult = NonNullable>> +export type TermsOfServiceListQueryError = ErrorDetail + + + +export function useTermsOfServiceList>, TError = ErrorDetail>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getTermsOfServiceListQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve a specific terms of service + + */ +export type termsOfServiceRetrieveResponse200 = { + data: TermsOfServiceResponse + status: 200 +} + +export type termsOfServiceRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type termsOfServiceRetrieveResponseComposite = termsOfServiceRetrieveResponse200 | termsOfServiceRetrieveResponse401; + +export type termsOfServiceRetrieveResponse = termsOfServiceRetrieveResponseComposite & { + headers: Headers; +} + +export const getTermsOfServiceRetrieveUrl = (slug: string,) => { + + + + + return `/api/v2/terms-of-service/${slug}/` +} + +export const termsOfServiceRetrieve = async (slug: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getTermsOfServiceRetrieveUrl(slug), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getTermsOfServiceRetrieveQueryKey = (slug: string,) => { + return ['api','v2','terms-of-service',slug] as const; + } + + +export const getTermsOfServiceRetrieveQueryOptions = >, TError = ErrorDetail>(slug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getTermsOfServiceRetrieveQueryKey(slug); + + + + const queryFn: QueryFunction>> = ({ signal }) => termsOfServiceRetrieve(slug, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(slug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type TermsOfServiceRetrieveQueryResult = NonNullable>> +export type TermsOfServiceRetrieveQueryError = ErrorDetail + + + +export function useTermsOfServiceRetrieve>, TError = ErrorDetail>( + slug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getTermsOfServiceRetrieveQueryOptions(slug,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List the transcription services accessible to requesting user. + +Search can be made with `q` parameter to search for the term in names and codes. + +Results are order by name. + + */ +export type transcriptionServicesListResponse200 = { + data: PaginatedTranscriptionServiceList + status: 200 +} + +export type transcriptionServicesListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type transcriptionServicesListResponseComposite = transcriptionServicesListResponse200 | transcriptionServicesListResponse401; + +export type transcriptionServicesListResponse = transcriptionServicesListResponseComposite & { + headers: Headers; +} + +export const getTranscriptionServicesListUrl = (params?: TranscriptionServicesListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/transcription-services/?${stringifiedParams}` : `/api/v2/transcription-services/` +} + +export const transcriptionServicesList = async (params?: TranscriptionServicesListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getTranscriptionServicesListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getTranscriptionServicesListQueryKey = (params?: TranscriptionServicesListParams,) => { + return ['api','v2','transcription-services', ...(params ? [params]: [])] as const; + } + + +export const getTranscriptionServicesListQueryOptions = >, TError = ErrorDetail>(params?: TranscriptionServicesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getTranscriptionServicesListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => transcriptionServicesList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type TranscriptionServicesListQueryResult = NonNullable>> +export type TranscriptionServicesListQueryError = ErrorDetail + + + +export function useTranscriptionServicesList>, TError = ErrorDetail>( + params?: TranscriptionServicesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getTranscriptionServicesListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## retrieve a transcription service + +* `code` - is the unique identifier of a specific language + + */ +export type transcriptionServicesRetrieveResponse200 = { + data: TranscriptionService + status: 200 +} + +export type transcriptionServicesRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type transcriptionServicesRetrieveResponseComposite = transcriptionServicesRetrieveResponse200 | transcriptionServicesRetrieveResponse401; + +export type transcriptionServicesRetrieveResponse = transcriptionServicesRetrieveResponseComposite & { + headers: Headers; +} + +export const getTranscriptionServicesRetrieveUrl = (code: string,) => { + + + + + return `/api/v2/transcription-services/${code}/` +} + +export const transcriptionServicesRetrieve = async (code: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getTranscriptionServicesRetrieveUrl(code), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getTranscriptionServicesRetrieveQueryKey = (code: string,) => { + return ['api','v2','transcription-services',code] as const; + } + + +export const getTranscriptionServicesRetrieveQueryOptions = >, TError = ErrorDetail>(code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getTranscriptionServicesRetrieveQueryKey(code); + + + + const queryFn: QueryFunction>> = ({ signal }) => transcriptionServicesRetrieve(code, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(code), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type TranscriptionServicesRetrieveQueryResult = NonNullable>> +export type TranscriptionServicesRetrieveQueryError = ErrorDetail + + + +export function useTranscriptionServicesRetrieve>, TError = ErrorDetail>( + code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getTranscriptionServicesRetrieveQueryOptions(code,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List the translation services accessible to requesting (authenticated) user. + +Search can be made with `q` parameter to search for the term in names and codes. + +Results are ordered by name. + + + */ +export type translationServicesListResponse200 = { + data: PaginatedTranslationServiceList + status: 200 +} + +export type translationServicesListResponse400 = { + data: ErrorObject + status: 400 +} + +export type translationServicesListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type translationServicesListResponseComposite = translationServicesListResponse200 | translationServicesListResponse400 | translationServicesListResponse401; + +export type translationServicesListResponse = translationServicesListResponseComposite & { + headers: Headers; +} + +export const getTranslationServicesListUrl = (params?: TranslationServicesListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/translation-services/?${stringifiedParams}` : `/api/v2/translation-services/` +} + +export const translationServicesList = async (params?: TranslationServicesListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getTranslationServicesListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getTranslationServicesListQueryKey = (params?: TranslationServicesListParams,) => { + return ['api','v2','translation-services', ...(params ? [params]: [])] as const; + } + + +export const getTranslationServicesListQueryOptions = >, TError = ErrorObject | ErrorDetail>(params?: TranslationServicesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getTranslationServicesListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => translationServicesList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type TranslationServicesListQueryResult = NonNullable>> +export type TranslationServicesListQueryError = ErrorObject | ErrorDetail + + + +export function useTranslationServicesList>, TError = ErrorObject | ErrorDetail>( + params?: TranslationServicesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getTranslationServicesListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve a translation service + +* `code` - is the unique identifier of a specific language + + */ +export type translationServicesRetrieveResponse200 = { + data: TranslationService + status: 200 +} + +export type translationServicesRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type translationServicesRetrieveResponseComposite = translationServicesRetrieveResponse200 | translationServicesRetrieveResponse401; + +export type translationServicesRetrieveResponse = translationServicesRetrieveResponseComposite & { + headers: Headers; +} + +export const getTranslationServicesRetrieveUrl = (code: string,) => { + + + + + return `/api/v2/translation-services/${code}/` +} + +export const translationServicesRetrieve = async (code: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getTranslationServicesRetrieveUrl(code), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getTranslationServicesRetrieveQueryKey = (code: string,) => { + return ['api','v2','translation-services',code] as const; + } + + +export const getTranslationServicesRetrieveQueryOptions = >, TError = ErrorDetail>(code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getTranslationServicesRetrieveQueryKey(code); + + + + const queryFn: QueryFunction>> = ({ signal }) => translationServicesRetrieve(code, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(code), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type TranslationServicesRetrieveQueryResult = NonNullable>> +export type TranslationServicesRetrieveQueryError = ErrorDetail + + + +export function useTranslationServicesRetrieve>, TError = ErrorDetail>( + code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getTranslationServicesRetrieveQueryOptions(code,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + diff --git a/jsapp/js/api/react-query/other/msw.ts b/jsapp/js/api/react-query/other/msw.ts new file mode 100644 index 0000000000..a9a53458d3 --- /dev/null +++ b/jsapp/js/api/react-query/other/msw.ts @@ -0,0 +1,381 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import { + BlankEnum +} from '../../models/blankEnum'; + +import type { + ChangePlan +} from '../../models/changePlan'; + +import type { + CheckoutLink +} from '../../models/checkoutLink'; + +import { + CollectionMethodEnum +} from '../../models/collectionMethodEnum'; + +import type { + CustomerPortalPostResponse +} from '../../models/customerPortalPostResponse'; + +import type { + Language +} from '../../models/language'; + +import type { + OneTimeAddOn +} from '../../models/oneTimeAddOn'; + +import type { + PaginatedLanguageListList +} from '../../models/paginatedLanguageListList'; + +import type { + PaginatedOneTimeAddOnList +} from '../../models/paginatedOneTimeAddOnList'; + +import type { + PaginatedPermissionResponseList +} from '../../models/paginatedPermissionResponseList'; + +import type { + PaginatedProductList +} from '../../models/paginatedProductList'; + +import type { + PaginatedSubscriptionList +} from '../../models/paginatedSubscriptionList'; + +import type { + PaginatedTranscriptionServiceList +} from '../../models/paginatedTranscriptionServiceList'; + +import type { + PaginatedTranslationServiceList +} from '../../models/paginatedTranslationServiceList'; + +import type { + PermissionResponse +} from '../../models/permissionResponse'; + +import { + ProrationBehaviorEnum +} from '../../models/prorationBehaviorEnum'; + +import { + StripeIntervalEnum +} from '../../models/stripeIntervalEnum'; + +import { + StripePriceType +} from '../../models/stripePriceType'; + +import { + StripeProductType +} from '../../models/stripeProductType'; + +import { + StripeUsageType +} from '../../models/stripeUsageType'; + +import type { + Subscription +} from '../../models/subscription'; + +import { + SubscriptionScheduleStatusEnum +} from '../../models/subscriptionScheduleStatusEnum'; + +import { + SubscriptionStatusEnum +} from '../../models/subscriptionStatusEnum'; + +import type { + TermsOfServiceResponse +} from '../../models/termsOfServiceResponse'; + +import type { + TranscriptionService +} from '../../models/transcriptionService'; + +import type { + TranslationService +} from '../../models/translationService'; + + +export const getApiV2LanguagesListResponseMock = (overrideResponse: Partial< PaginatedLanguageListList > = {}): PaginatedLanguageListList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 200}}), code: faker.string.alpha({length: {min: 10, max: 10}}), featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), transcription_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), translation_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), url: faker.internet.url()})), ...overrideResponse}) + +export const getApiV2LanguagesRetrieveResponseMock = (overrideResponse: Partial< Language > = {}): Language => ({name: faker.string.alpha({length: {min: 10, max: 200}}), code: faker.string.alpha({length: {min: 10, max: 10}}), featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), transcription_services: { + [faker.string.alphanumeric(5)]: { + [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) + } + }, translation_services: { + [faker.string.alphanumeric(5)]: { + [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) + } + }, regions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 200}})})), ...overrideResponse}) + +export const getApiV2PermissionsListResponseMock = (overrideResponse: Partial< PaginatedPermissionResponseList > = {}): PaginatedPermissionResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), codename: faker.string.alpha({length: {min: 10, max: 20}}), implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.internet.url())), contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.internet.url())), name: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) + +export const getApiV2PermissionsRetrieveResponseMock = (overrideResponse: Partial< PermissionResponse > = {}): PermissionResponse => ({url: faker.internet.url(), codename: faker.string.alpha({length: {min: 10, max: 20}}), implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.internet.url())), contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.internet.url())), name: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2StripeAddonsListResponseMock = (overrideResponse: Partial< PaginatedOneTimeAddOnList > = {}): PaginatedOneTimeAddOnList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 27}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, is_available: faker.datatype.boolean(), usage_limits: faker.helpers.arrayElement([{}, undefined]), total_usage_limits: { + [faker.string.alphanumeric(5)]: {} + }, limits_remaining: faker.helpers.arrayElement([{}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), product: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])})), ...overrideResponse}) + +export const getApiV2StripeAddonsRetrieveResponseMock = (overrideResponse: Partial< OneTimeAddOn > = {}): OneTimeAddOn => ({id: faker.string.alpha({length: {min: 10, max: 27}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, is_available: faker.datatype.boolean(), usage_limits: faker.helpers.arrayElement([{}, undefined]), total_usage_limits: { + [faker.string.alphanumeric(5)]: {} + }, limits_remaining: faker.helpers.arrayElement([{}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), product: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), ...overrideResponse}) + +export const getApiV2StripeChangePlanRetrieveResponseMock = (overrideResponse: Partial< ChangePlan > = {}): ChangePlan => ({price_id: faker.string.alpha({length: {min: 10, max: 20}}), subscription_id: faker.string.alpha({length: {min: 10, max: 20}}), quantity: faker.helpers.arrayElement([faker.number.int({min: 1, max: undefined, multipleOf: undefined}), undefined]), ...overrideResponse}) + +export const getApiV2StripeCheckoutLinkCreateResponseMock = (overrideResponse: Partial< CheckoutLink > = {}): CheckoutLink => ({price_id: faker.string.alpha({length: {min: 10, max: 20}}), organization_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), quantity: faker.helpers.arrayElement([faker.number.int({min: 1, max: undefined, multipleOf: undefined}), undefined]), ...overrideResponse}) + +export const getApiV2StripeCustomerPortalCreateResponseMock = (overrideResponse: Partial< CustomerPortalPostResponse > = {}): CustomerPortalPostResponse => ({url: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2StripeProductsListResponseMock = (overrideResponse: Partial< PaginatedProductList > = {}): PaginatedProductList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 255}}), name: faker.string.alpha({length: {min: 10, max: 5000}}), description: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), type: faker.helpers.arrayElement(Object.values(StripeProductType)), prices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 255}}), nickname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 250}}), undefined]), currency: faker.string.alpha({length: {min: 10, max: 3}}), type: faker.helpers.arrayElement(Object.values(StripePriceType)), recurring: {...{interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), interval_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), meter: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType))},}, unit_amount: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined}), null]), undefined]), human_readable_price: faker.string.alpha({length: {min: 10, max: 20}}), metadata: faker.helpers.arrayElement([{}, undefined]), active: faker.datatype.boolean(), product: faker.string.alpha({length: {min: 10, max: 20}}), transform_quantity: faker.helpers.arrayElement([{}, undefined])})), metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) + }})), ...overrideResponse}) + +export const getApiV2StripeSubscriptionsListResponseMock = (overrideResponse: Partial< PaginatedSubscriptionList > = {}): PaginatedSubscriptionList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 255}}), price: {id: faker.string.alpha({length: {min: 10, max: 255}}), nickname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 250}}), undefined]), currency: faker.string.alpha({length: {min: 10, max: 3}}), type: faker.helpers.arrayElement(Object.values(StripePriceType)), recurring: {...{interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), interval_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), meter: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType))},}, unit_amount: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined}), null]), undefined]), human_readable_price: faker.string.alpha({length: {min: 10, max: 20}}), metadata: faker.helpers.arrayElement([{}, undefined]), active: faker.datatype.boolean(), product: {id: faker.string.alpha({length: {min: 10, max: 255}}), name: faker.string.alpha({length: {min: 10, max: 5000}}), description: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), type: faker.helpers.arrayElement(Object.values(StripeProductType)), metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) + }}, transform_quantity: faker.helpers.arrayElement([{}, undefined])}, quantity: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: 0, max: 2147483647, multipleOf: undefined}), null]), undefined])})), schedule: {phases: { + [faker.string.alphanumeric(5)]: {} + }, status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum))}, application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?\d{0,3}(?:\.\d{0,2})?$'), null]), djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, stripe_data: faker.helpers.arrayElement([{}, undefined]), id: faker.string.alpha({length: {min: 10, max: 255}}), livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), created: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), metadata: faker.helpers.arrayElement([{}, undefined]), description: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), billing_cycle_anchor: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), billing_thresholds: faker.helpers.arrayElement([{}, undefined]), cancel_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), canceled_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, days_until_due: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -2147483648, max: 2147483647, multipleOf: undefined}), null]), undefined]), discount: faker.helpers.arrayElement([{}, undefined]), ended_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), next_pending_invoice_item_invoice: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), pause_collection: faker.helpers.arrayElement([{}, undefined]), pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), pending_update: faker.helpers.arrayElement([{}, undefined]), proration_behavior: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)),faker.helpers.arrayElement(Object.values(BlankEnum)),]), undefined]), proration_date: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), quantity: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -2147483648, max: 2147483647, multipleOf: undefined}), null]), undefined]), start_date: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), trial_end: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), trial_start: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), djstripe_owner_account: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), customer: faker.string.alpha({length: {min: 10, max: 20}}), default_payment_method: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), default_source: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), latest_invoice: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_setup_intent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), plan: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), undefined]), default_tax_rates: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.number.int({min: undefined, max: undefined, multipleOf: undefined}))), undefined])})), ...overrideResponse}) + +export const getApiV2StripeSubscriptionsRetrieveResponseMock = (overrideResponse: Partial< Subscription > = {}): Subscription => ({items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 255}}), price: {id: faker.string.alpha({length: {min: 10, max: 255}}), nickname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 250}}), undefined]), currency: faker.string.alpha({length: {min: 10, max: 3}}), type: faker.helpers.arrayElement(Object.values(StripePriceType)), recurring: {...{interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), interval_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), meter: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType))},}, unit_amount: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined}), null]), undefined]), human_readable_price: faker.string.alpha({length: {min: 10, max: 20}}), metadata: faker.helpers.arrayElement([{}, undefined]), active: faker.datatype.boolean(), product: {id: faker.string.alpha({length: {min: 10, max: 255}}), name: faker.string.alpha({length: {min: 10, max: 5000}}), description: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), type: faker.helpers.arrayElement(Object.values(StripeProductType)), metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) + }}, transform_quantity: faker.helpers.arrayElement([{}, undefined])}, quantity: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: 0, max: 2147483647, multipleOf: undefined}), null]), undefined])})), schedule: {phases: { + [faker.string.alphanumeric(5)]: {} + }, status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum))}, application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?\d{0,3}(?:\.\d{0,2})?$'), null]), djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, stripe_data: faker.helpers.arrayElement([{}, undefined]), id: faker.string.alpha({length: {min: 10, max: 255}}), livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), created: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), metadata: faker.helpers.arrayElement([{}, undefined]), description: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), billing_cycle_anchor: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), billing_thresholds: faker.helpers.arrayElement([{}, undefined]), cancel_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), canceled_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, days_until_due: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -2147483648, max: 2147483647, multipleOf: undefined}), null]), undefined]), discount: faker.helpers.arrayElement([{}, undefined]), ended_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), next_pending_invoice_item_invoice: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), pause_collection: faker.helpers.arrayElement([{}, undefined]), pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), pending_update: faker.helpers.arrayElement([{}, undefined]), proration_behavior: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)),faker.helpers.arrayElement(Object.values(BlankEnum)),]), undefined]), proration_date: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), quantity: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -2147483648, max: 2147483647, multipleOf: undefined}), null]), undefined]), start_date: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), trial_end: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), trial_start: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), djstripe_owner_account: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), customer: faker.string.alpha({length: {min: 10, max: 20}}), default_payment_method: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), default_source: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), latest_invoice: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_setup_intent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), plan: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), undefined]), default_tax_rates: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.number.int({min: undefined, max: undefined, multipleOf: undefined}))), undefined]), ...overrideResponse}) + +export const getApiV2TermsOfServiceListResponseMock = (): TermsOfServiceResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), slug: faker.string.alpha({length: {min: 10, max: 20}}), body: faker.string.alpha({length: {min: 10, max: 20}})}))) + +export const getApiV2TermsOfServiceRetrieveResponseMock = (overrideResponse: Partial< TermsOfServiceResponse > = {}): TermsOfServiceResponse => ({url: faker.internet.url(), slug: faker.string.alpha({length: {min: 10, max: 20}}), body: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2TranscriptionServicesListResponseMock = (overrideResponse: Partial< PaginatedTranscriptionServiceList > = {}): PaginatedTranscriptionServiceList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 100}}), code: faker.string.alpha({length: {min: 10, max: 10}})})), ...overrideResponse}) + +export const getApiV2TranscriptionServicesRetrieveResponseMock = (overrideResponse: Partial< TranscriptionService > = {}): TranscriptionService => ({name: faker.string.alpha({length: {min: 10, max: 100}}), code: faker.string.alpha({length: {min: 10, max: 10}}), ...overrideResponse}) + +export const getApiV2TranslationServicesListResponseMock = (overrideResponse: Partial< PaginatedTranslationServiceList > = {}): PaginatedTranslationServiceList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 100}}), code: faker.string.alpha({length: {min: 10, max: 10}})})), ...overrideResponse}) + +export const getApiV2TranslationServicesRetrieveResponseMock = (overrideResponse: Partial< TranslationService > = {}): TranslationService => ({name: faker.string.alpha({length: {min: 10, max: 100}}), code: faker.string.alpha({length: {min: 10, max: 10}}), ...overrideResponse}) + + +export const getApiV2LanguagesListMockHandler = (overrideResponse?: PaginatedLanguageListList | ((info: Parameters[1]>[0]) => Promise | PaginatedLanguageListList)) => { + return http.get('*/api/v2/languages/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2LanguagesListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2LanguagesRetrieveMockHandler = (overrideResponse?: Language | ((info: Parameters[1]>[0]) => Promise | Language)) => { + return http.get('*/api/v2/languages/:code/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2LanguagesRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2PermissionsListMockHandler = (overrideResponse?: PaginatedPermissionResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedPermissionResponseList)) => { + return http.get('*/api/v2/permissions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2PermissionsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2PermissionsRetrieveMockHandler = (overrideResponse?: PermissionResponse | ((info: Parameters[1]>[0]) => Promise | PermissionResponse)) => { + return http.get('*/api/v2/permissions/:codename/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2PermissionsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2StripeAddonsListMockHandler = (overrideResponse?: PaginatedOneTimeAddOnList | ((info: Parameters[1]>[0]) => Promise | PaginatedOneTimeAddOnList)) => { + return http.get('*/api/v2/stripe/addons/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2StripeAddonsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2StripeAddonsRetrieveMockHandler = (overrideResponse?: OneTimeAddOn | ((info: Parameters[1]>[0]) => Promise | OneTimeAddOn)) => { + return http.get('*/api/v2/stripe/addons/:id/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2StripeAddonsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2StripeChangePlanRetrieveMockHandler = (overrideResponse?: ChangePlan | ((info: Parameters[1]>[0]) => Promise | ChangePlan)) => { + return http.get('*/api/v2/stripe/change-plan', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2StripeChangePlanRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2StripeCheckoutLinkCreateMockHandler = (overrideResponse?: CheckoutLink | ((info: Parameters[1]>[0]) => Promise | CheckoutLink)) => { + return http.post('*/api/v2/stripe/checkout-link', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2StripeCheckoutLinkCreateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2StripeCustomerPortalCreateMockHandler = (overrideResponse?: CustomerPortalPostResponse | ((info: Parameters[1]>[0]) => Promise | CustomerPortalPostResponse)) => { + return http.post('*/api/v2/stripe/customer-portal', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2StripeCustomerPortalCreateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2StripeProductsListMockHandler = (overrideResponse?: PaginatedProductList | ((info: Parameters[1]>[0]) => Promise | PaginatedProductList)) => { + return http.get('*/api/v2/stripe/products/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2StripeProductsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2StripeSubscriptionsListMockHandler = (overrideResponse?: PaginatedSubscriptionList | ((info: Parameters[1]>[0]) => Promise | PaginatedSubscriptionList)) => { + return http.get('*/api/v2/stripe/subscriptions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2StripeSubscriptionsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2StripeSubscriptionsRetrieveMockHandler = (overrideResponse?: Subscription | ((info: Parameters[1]>[0]) => Promise | Subscription)) => { + return http.get('*/api/v2/stripe/subscriptions/:id/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2StripeSubscriptionsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2TermsOfServiceListMockHandler = (overrideResponse?: TermsOfServiceResponse[] | ((info: Parameters[1]>[0]) => Promise | TermsOfServiceResponse[])) => { + return http.get('*/api/v2/terms-of-service/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2TermsOfServiceListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2TermsOfServiceRetrieveMockHandler = (overrideResponse?: TermsOfServiceResponse | ((info: Parameters[1]>[0]) => Promise | TermsOfServiceResponse)) => { + return http.get('*/api/v2/terms-of-service/:slug/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2TermsOfServiceRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2TranscriptionServicesListMockHandler = (overrideResponse?: PaginatedTranscriptionServiceList | ((info: Parameters[1]>[0]) => Promise | PaginatedTranscriptionServiceList)) => { + return http.get('*/api/v2/transcription-services/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2TranscriptionServicesListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2TranscriptionServicesRetrieveMockHandler = (overrideResponse?: TranscriptionService | ((info: Parameters[1]>[0]) => Promise | TranscriptionService)) => { + return http.get('*/api/v2/transcription-services/:code/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2TranscriptionServicesRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2TranslationServicesListMockHandler = (overrideResponse?: PaginatedTranslationServiceList | ((info: Parameters[1]>[0]) => Promise | PaginatedTranslationServiceList)) => { + return http.get('*/api/v2/translation-services/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2TranslationServicesListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2TranslationServicesRetrieveMockHandler = (overrideResponse?: TranslationService | ((info: Parameters[1]>[0]) => Promise | TranslationService)) => { + return http.get('*/api/v2/translation-services/:code/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2TranslationServicesRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} +export const getOtherMock = () => [ + getApiV2LanguagesListMockHandler(), + getApiV2LanguagesRetrieveMockHandler(), + getApiV2PermissionsListMockHandler(), + getApiV2PermissionsRetrieveMockHandler(), + getApiV2StripeAddonsListMockHandler(), + getApiV2StripeAddonsRetrieveMockHandler(), + getApiV2StripeChangePlanRetrieveMockHandler(), + getApiV2StripeCheckoutLinkCreateMockHandler(), + getApiV2StripeCustomerPortalCreateMockHandler(), + getApiV2StripeProductsListMockHandler(), + getApiV2StripeSubscriptionsListMockHandler(), + getApiV2StripeSubscriptionsRetrieveMockHandler(), + getApiV2TermsOfServiceListMockHandler(), + getApiV2TermsOfServiceRetrieveMockHandler(), + getApiV2TranscriptionServicesListMockHandler(), + getApiV2TranscriptionServicesRetrieveMockHandler(), + getApiV2TranslationServicesListMockHandler(), + getApiV2TranslationServicesRetrieveMockHandler() +] diff --git a/jsapp/js/api/react-query/other/other.msw.ts b/jsapp/js/api/react-query/other/other.msw.ts deleted file mode 100644 index 073484048d..0000000000 --- a/jsapp/js/api/react-query/other/other.msw.ts +++ /dev/null @@ -1,1051 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import { BlankEnum } from '../../models/blankEnum' - -import type { ChangePlan } from '../../models/changePlan' - -import type { CheckoutLink } from '../../models/checkoutLink' - -import { CollectionMethodEnum } from '../../models/collectionMethodEnum' - -import type { CustomerPortalPostResponse } from '../../models/customerPortalPostResponse' - -import type { Language } from '../../models/language' - -import type { OneTimeAddOn } from '../../models/oneTimeAddOn' - -import type { PaginatedLanguageListList } from '../../models/paginatedLanguageListList' - -import type { PaginatedOneTimeAddOnList } from '../../models/paginatedOneTimeAddOnList' - -import type { PaginatedPermissionResponseList } from '../../models/paginatedPermissionResponseList' - -import type { PaginatedProductList } from '../../models/paginatedProductList' - -import type { PaginatedSubscriptionList } from '../../models/paginatedSubscriptionList' - -import type { PaginatedTranscriptionServiceList } from '../../models/paginatedTranscriptionServiceList' - -import type { PaginatedTranslationServiceList } from '../../models/paginatedTranslationServiceList' - -import type { PermissionResponse } from '../../models/permissionResponse' - -import { ProrationBehaviorEnum } from '../../models/prorationBehaviorEnum' - -import { StripeIntervalEnum } from '../../models/stripeIntervalEnum' - -import { StripePriceType } from '../../models/stripePriceType' - -import { StripeProductType } from '../../models/stripeProductType' - -import { StripeUsageType } from '../../models/stripeUsageType' - -import type { Subscription } from '../../models/subscription' - -import { SubscriptionScheduleStatusEnum } from '../../models/subscriptionScheduleStatusEnum' - -import { SubscriptionStatusEnum } from '../../models/subscriptionStatusEnum' - -import type { TermsOfServiceResponse } from '../../models/termsOfServiceResponse' - -import type { TranscriptionService } from '../../models/transcriptionService' - -import type { TranslationService } from '../../models/translationService' - -export const getApiV2LanguagesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedLanguageListList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - transcription_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - translation_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - url: faker.internet.url(), - })), - ...overrideResponse, -}) - -export const getApiV2LanguagesRetrieveResponseMock = (overrideResponse: Partial = {}): Language => ({ - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - transcription_services: { - [faker.string.alphanumeric(5)]: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - translation_services: { - [faker.string.alphanumeric(5)]: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - regions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - code: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - })), - ...overrideResponse, -}) - -export const getApiV2PermissionsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedPermissionResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - codename: faker.string.alpha({ length: { min: 10, max: 20 } }), - implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.internet.url(), - ), - contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.internet.url(), - ), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2PermissionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PermissionResponse => ({ - url: faker.internet.url(), - codename: faker.string.alpha({ length: { min: 10, max: 20 } }), - implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.internet.url(), - ), - contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.internet.url(), - ), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2StripeAddonsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedOneTimeAddOnList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 27 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_available: faker.datatype.boolean(), - usage_limits: faker.helpers.arrayElement([{}, undefined]), - total_usage_limits: { - [faker.string.alphanumeric(5)]: {}, - }, - limits_remaining: faker.helpers.arrayElement([{}, undefined]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - product: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2StripeAddonsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): OneTimeAddOn => ({ - id: faker.string.alpha({ length: { min: 10, max: 27 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_available: faker.datatype.boolean(), - usage_limits: faker.helpers.arrayElement([{}, undefined]), - total_usage_limits: { - [faker.string.alphanumeric(5)]: {}, - }, - limits_remaining: faker.helpers.arrayElement([{}, undefined]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - product: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2StripeChangePlanRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ChangePlan => ({ - price_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - subscription_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - quantity: faker.helpers.arrayElement([ - faker.number.int({ min: 1, max: undefined, multipleOf: undefined }), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2StripeCheckoutLinkCreateResponseMock = ( - overrideResponse: Partial = {}, -): CheckoutLink => ({ - price_id: faker.string.alpha({ length: { min: 10, max: 20 } }), - organization_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - quantity: faker.helpers.arrayElement([ - faker.number.int({ min: 1, max: undefined, multipleOf: undefined }), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2StripeCustomerPortalCreateResponseMock = ( - overrideResponse: Partial = {}, -): CustomerPortalPostResponse => ({ url: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2StripeProductsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedProductList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - name: faker.string.alpha({ length: { min: 10, max: 5000 } }), - description: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - type: faker.helpers.arrayElement(Object.values(StripeProductType)), - prices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), - currency: faker.string.alpha({ length: { min: 10, max: 3 } }), - type: faker.helpers.arrayElement(Object.values(StripePriceType)), - recurring: { - ...{ - interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), - interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - meter: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), - }, - }, - unit_amount: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), - null, - ]), - undefined, - ]), - human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: faker.helpers.arrayElement([{}, undefined]), - active: faker.datatype.boolean(), - product: faker.string.alpha({ length: { min: 10, max: 20 } }), - transform_quantity: faker.helpers.arrayElement([{}, undefined]), - })), - metadata: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - })), - ...overrideResponse, -}) - -export const getApiV2StripeSubscriptionsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedSubscriptionList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - price: { - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), - currency: faker.string.alpha({ length: { min: 10, max: 3 } }), - type: faker.helpers.arrayElement(Object.values(StripePriceType)), - recurring: { - ...{ - interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), - interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - meter: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), - }, - }, - unit_amount: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), - null, - ]), - undefined, - ]), - human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: faker.helpers.arrayElement([{}, undefined]), - active: faker.datatype.boolean(), - product: { - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - name: faker.string.alpha({ length: { min: 10, max: 5000 } }), - description: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - type: faker.helpers.arrayElement(Object.values(StripeProductType)), - metadata: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - transform_quantity: faker.helpers.arrayElement([{}, undefined]), - }, - quantity: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: 0, max: 2147483647, multipleOf: undefined }), null]), - undefined, - ]), - })), - schedule: { - phases: { - [faker.string.alphanumeric(5)]: {}, - }, - status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum)), - }, - application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?d{0,3}(?:.d{0,2})?$'), null]), - djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, - stripe_data: faker.helpers.arrayElement([{}, undefined]), - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - created: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - metadata: faker.helpers.arrayElement([{}, undefined]), - description: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - billing_cycle_anchor: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - billing_thresholds: faker.helpers.arrayElement([{}, undefined]), - cancel_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - canceled_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), - current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, - current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, - days_until_due: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), - null, - ]), - undefined, - ]), - discount: faker.helpers.arrayElement([{}, undefined]), - ended_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - next_pending_invoice_item_invoice: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - pause_collection: faker.helpers.arrayElement([{}, undefined]), - pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), - pending_update: faker.helpers.arrayElement([{}, undefined]), - proration_behavior: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)), - faker.helpers.arrayElement(Object.values(BlankEnum)), - ]), - undefined, - ]), - proration_date: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - quantity: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), - null, - ]), - undefined, - ]), - start_date: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), - trial_end: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - trial_start: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - djstripe_owner_account: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - customer: faker.string.alpha({ length: { min: 10, max: 20 } }), - default_payment_method: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - default_source: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - latest_invoice: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_setup_intent: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - plan: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), null]), - undefined, - ]), - default_tax_rates: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2StripeSubscriptionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): Subscription => ({ - items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - price: { - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), - currency: faker.string.alpha({ length: { min: 10, max: 3 } }), - type: faker.helpers.arrayElement(Object.values(StripePriceType)), - recurring: { - ...{ - interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), - interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - meter: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), - }, - }, - unit_amount: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), - null, - ]), - undefined, - ]), - human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: faker.helpers.arrayElement([{}, undefined]), - active: faker.datatype.boolean(), - product: { - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - name: faker.string.alpha({ length: { min: 10, max: 5000 } }), - description: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - type: faker.helpers.arrayElement(Object.values(StripeProductType)), - metadata: { - [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - transform_quantity: faker.helpers.arrayElement([{}, undefined]), - }, - quantity: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: 0, max: 2147483647, multipleOf: undefined }), null]), - undefined, - ]), - })), - schedule: { - phases: { - [faker.string.alphanumeric(5)]: {}, - }, - status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum)), - }, - application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?d{0,3}(?:.d{0,2})?$'), null]), - djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, - stripe_data: faker.helpers.arrayElement([{}, undefined]), - id: faker.string.alpha({ length: { min: 10, max: 255 } }), - livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - created: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - metadata: faker.helpers.arrayElement([{}, undefined]), - description: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - billing_cycle_anchor: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - billing_thresholds: faker.helpers.arrayElement([{}, undefined]), - cancel_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - canceled_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), - current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, - current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, - days_until_due: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), null]), - undefined, - ]), - discount: faker.helpers.arrayElement([{}, undefined]), - ended_at: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - next_pending_invoice_item_invoice: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - pause_collection: faker.helpers.arrayElement([{}, undefined]), - pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), - pending_update: faker.helpers.arrayElement([{}, undefined]), - proration_behavior: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)), - faker.helpers.arrayElement(Object.values(BlankEnum)), - ]), - undefined, - ]), - proration_date: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - quantity: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), null]), - undefined, - ]), - start_date: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), - trial_end: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - trial_start: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - djstripe_owner_account: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - customer: faker.string.alpha({ length: { min: 10, max: 20 } }), - default_payment_method: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - default_source: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - latest_invoice: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_setup_intent: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - plan: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), null]), - undefined, - ]), - default_tax_rates: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2TermsOfServiceListResponseMock = (): TermsOfServiceResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - slug: faker.string.alpha({ length: { min: 10, max: 20 } }), - body: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2TermsOfServiceRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): TermsOfServiceResponse => ({ - url: faker.internet.url(), - slug: faker.string.alpha({ length: { min: 10, max: 20 } }), - body: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2TranscriptionServicesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedTranscriptionServiceList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 100 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - })), - ...overrideResponse, -}) - -export const getApiV2TranscriptionServicesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): TranscriptionService => ({ - name: faker.string.alpha({ length: { min: 10, max: 100 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - ...overrideResponse, -}) - -export const getApiV2TranslationServicesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedTranslationServiceList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.string.alpha({ length: { min: 10, max: 100 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - })), - ...overrideResponse, -}) - -export const getApiV2TranslationServicesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): TranslationService => ({ - name: faker.string.alpha({ length: { min: 10, max: 100 } }), - code: faker.string.alpha({ length: { min: 10, max: 10 } }), - ...overrideResponse, -}) - -export const getApiV2LanguagesListMockHandler = ( - overrideResponse?: - | PaginatedLanguageListList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedLanguageListList), -) => { - return http.get('*/api/v2/languages/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2LanguagesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2LanguagesRetrieveMockHandler = ( - overrideResponse?: Language | ((info: Parameters[1]>[0]) => Promise | Language), -) => { - return http.get('*/api/v2/languages/:code/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2LanguagesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2PermissionsListMockHandler = ( - overrideResponse?: - | PaginatedPermissionResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedPermissionResponseList), -) => { - return http.get('*/api/v2/permissions/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2PermissionsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2PermissionsRetrieveMockHandler = ( - overrideResponse?: - | PermissionResponse - | ((info: Parameters[1]>[0]) => Promise | PermissionResponse), -) => { - return http.get('*/api/v2/permissions/:codename/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2PermissionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeAddonsListMockHandler = ( - overrideResponse?: - | PaginatedOneTimeAddOnList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedOneTimeAddOnList), -) => { - return http.get('*/api/v2/stripe/addons/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeAddonsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeAddonsRetrieveMockHandler = ( - overrideResponse?: - | OneTimeAddOn - | ((info: Parameters[1]>[0]) => Promise | OneTimeAddOn), -) => { - return http.get('*/api/v2/stripe/addons/:id/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeAddonsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeChangePlanRetrieveMockHandler = ( - overrideResponse?: - | ChangePlan - | ((info: Parameters[1]>[0]) => Promise | ChangePlan), -) => { - return http.get('*/api/v2/stripe/change-plan', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeChangePlanRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeCheckoutLinkCreateMockHandler = ( - overrideResponse?: - | CheckoutLink - | ((info: Parameters[1]>[0]) => Promise | CheckoutLink), -) => { - return http.post('*/api/v2/stripe/checkout-link', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeCheckoutLinkCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeCustomerPortalCreateMockHandler = ( - overrideResponse?: - | CustomerPortalPostResponse - | (( - info: Parameters[1]>[0], - ) => Promise | CustomerPortalPostResponse), -) => { - return http.post('*/api/v2/stripe/customer-portal', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeCustomerPortalCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeProductsListMockHandler = ( - overrideResponse?: - | PaginatedProductList - | ((info: Parameters[1]>[0]) => Promise | PaginatedProductList), -) => { - return http.get('*/api/v2/stripe/products/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeProductsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeSubscriptionsListMockHandler = ( - overrideResponse?: - | PaginatedSubscriptionList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedSubscriptionList), -) => { - return http.get('*/api/v2/stripe/subscriptions/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeSubscriptionsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2StripeSubscriptionsRetrieveMockHandler = ( - overrideResponse?: - | Subscription - | ((info: Parameters[1]>[0]) => Promise | Subscription), -) => { - return http.get('*/api/v2/stripe/subscriptions/:id/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2StripeSubscriptionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TermsOfServiceListMockHandler = ( - overrideResponse?: - | TermsOfServiceResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | TermsOfServiceResponse[]), -) => { - return http.get('*/api/v2/terms-of-service/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TermsOfServiceListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TermsOfServiceRetrieveMockHandler = ( - overrideResponse?: - | TermsOfServiceResponse - | (( - info: Parameters[1]>[0], - ) => Promise | TermsOfServiceResponse), -) => { - return http.get('*/api/v2/terms-of-service/:slug/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TermsOfServiceRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TranscriptionServicesListMockHandler = ( - overrideResponse?: - | PaginatedTranscriptionServiceList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedTranscriptionServiceList), -) => { - return http.get('*/api/v2/transcription-services/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TranscriptionServicesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TranscriptionServicesRetrieveMockHandler = ( - overrideResponse?: - | TranscriptionService - | ((info: Parameters[1]>[0]) => Promise | TranscriptionService), -) => { - return http.get('*/api/v2/transcription-services/:code/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TranscriptionServicesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TranslationServicesListMockHandler = ( - overrideResponse?: - | PaginatedTranslationServiceList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedTranslationServiceList), -) => { - return http.get('*/api/v2/translation-services/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TranslationServicesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2TranslationServicesRetrieveMockHandler = ( - overrideResponse?: - | TranslationService - | ((info: Parameters[1]>[0]) => Promise | TranslationService), -) => { - return http.get('*/api/v2/translation-services/:code/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2TranslationServicesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getOtherMock = () => [ - getApiV2LanguagesListMockHandler(), - getApiV2LanguagesRetrieveMockHandler(), - getApiV2PermissionsListMockHandler(), - getApiV2PermissionsRetrieveMockHandler(), - getApiV2StripeAddonsListMockHandler(), - getApiV2StripeAddonsRetrieveMockHandler(), - getApiV2StripeChangePlanRetrieveMockHandler(), - getApiV2StripeCheckoutLinkCreateMockHandler(), - getApiV2StripeCustomerPortalCreateMockHandler(), - getApiV2StripeProductsListMockHandler(), - getApiV2StripeSubscriptionsListMockHandler(), - getApiV2StripeSubscriptionsRetrieveMockHandler(), - getApiV2TermsOfServiceListMockHandler(), - getApiV2TermsOfServiceRetrieveMockHandler(), - getApiV2TranscriptionServicesListMockHandler(), - getApiV2TranscriptionServicesRetrieveMockHandler(), - getApiV2TranslationServicesListMockHandler(), - getApiV2TranslationServicesRetrieveMockHandler(), -] diff --git a/jsapp/js/api/react-query/other/other.ts b/jsapp/js/api/react-query/other/other.ts deleted file mode 100644 index 90e69d0c30..0000000000 --- a/jsapp/js/api/react-query/other/other.ts +++ /dev/null @@ -1,1711 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { ChangePlan } from '../../models/changePlan' - -import type { CheckoutLink } from '../../models/checkoutLink' - -import type { CustomerPortal } from '../../models/customerPortal' - -import type { CustomerPortalPostResponse } from '../../models/customerPortalPostResponse' - -import type { ErrorDetail } from '../../models/errorDetail' - -import type { ErrorObject } from '../../models/errorObject' - -import type { Language } from '../../models/language' - -import type { LanguagesListParams } from '../../models/languagesListParams' - -import type { OneTimeAddOn } from '../../models/oneTimeAddOn' - -import type { PaginatedLanguageListList } from '../../models/paginatedLanguageListList' - -import type { PaginatedOneTimeAddOnList } from '../../models/paginatedOneTimeAddOnList' - -import type { PaginatedPermissionResponseList } from '../../models/paginatedPermissionResponseList' - -import type { PaginatedProductList } from '../../models/paginatedProductList' - -import type { PaginatedSubscriptionList } from '../../models/paginatedSubscriptionList' - -import type { PaginatedTranscriptionServiceList } from '../../models/paginatedTranscriptionServiceList' - -import type { PaginatedTranslationServiceList } from '../../models/paginatedTranslationServiceList' - -import type { PermissionResponse } from '../../models/permissionResponse' - -import type { PermissionsListParams } from '../../models/permissionsListParams' - -import type { StripeAddonsListParams } from '../../models/stripeAddonsListParams' - -import type { StripeProductsListParams } from '../../models/stripeProductsListParams' - -import type { StripeSubscriptionsListParams } from '../../models/stripeSubscriptionsListParams' - -import type { Subscription } from '../../models/subscription' - -import type { TermsOfServiceResponse } from '../../models/termsOfServiceResponse' - -import type { TranscriptionService } from '../../models/transcriptionService' - -import type { TranscriptionServicesListParams } from '../../models/transcriptionServicesListParams' - -import type { TranslationService } from '../../models/translationService' - -import type { TranslationServicesListParams } from '../../models/translationServicesListParams' - -import { fetchWithAuth } from '../../orval.mutator' - -type SecondParameter unknown> = Parameters[1] - -/** - * ## List the languages accessible to requesting (authenticated) user. - -Search can be made with `q` parameter. By default, search for the term in language names or language codes. - -Examples: -```shell - curl -X GET https://kf.kobotoolbox.org/api/v2/languages/?q=fr -``` - -Complex searches can be done on other fields, such as `transcription_services` and `translation_services`. - -Examples: -```shell - curl -X GET https://kf.kobotoolbox.org/api/v2/languages/?q=transcription_services__code:goog AND translation_services__code:goog -``` - -Results are order by `featured` first (descending order), then by their name. - - */ -export type languagesListResponse200 = { - data: PaginatedLanguageListList - status: 200 -} - -export type languagesListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type languagesListResponseComposite = languagesListResponse200 | languagesListResponse401 - -export type languagesListResponse = languagesListResponseComposite & { - headers: Headers -} - -export const getLanguagesListUrl = (params?: LanguagesListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/languages/?${stringifiedParams}` : `/api/v2/languages/` -} - -export const languagesList = async ( - params?: LanguagesListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getLanguagesListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getLanguagesListQueryKey = (params?: LanguagesListParams) => { - return ['api', 'v2', 'languages', ...(params ? [params] : [])] as const -} - -export const getLanguagesListQueryOptions = >, TError = ErrorDetail>( - params?: LanguagesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getLanguagesListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - languagesList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type LanguagesListQueryResult = NonNullable>> -export type LanguagesListQueryError = ErrorDetail - -export function useLanguagesList>, TError = ErrorDetail>( - params?: LanguagesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getLanguagesListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve one language - -* `code` - is the unique identifier of a specific language - - */ -export type languagesRetrieveResponse200 = { - data: Language - status: 200 -} - -export type languagesRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type languagesRetrieveResponseComposite = languagesRetrieveResponse200 | languagesRetrieveResponse401 - -export type languagesRetrieveResponse = languagesRetrieveResponseComposite & { - headers: Headers -} - -export const getLanguagesRetrieveUrl = (code: string) => { - return `/api/v2/languages/${code}/` -} - -export const languagesRetrieve = async (code: string, options?: RequestInit): Promise => { - return fetchWithAuth(getLanguagesRetrieveUrl(code), { - ...options, - method: 'GET', - }) -} - -export const getLanguagesRetrieveQueryKey = (code: string) => { - return ['api', 'v2', 'languages', code] as const -} - -export const getLanguagesRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - code: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getLanguagesRetrieveQueryKey(code) - - const queryFn: QueryFunction>> = ({ signal }) => - languagesRetrieve(code, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!code, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type LanguagesRetrieveQueryResult = NonNullable>> -export type LanguagesRetrieveQueryError = ErrorDetail - -export function useLanguagesRetrieve>, TError = ErrorDetail>( - code: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getLanguagesRetrieveQueryOptions(code, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List all assignable permissions for `Asset` - -The `implied` property of a given permission shows which additional -permissions are automatically granted when assigning that particular -permission. - -The `contradictory` property shows which permissions are removed when -assigning that particular permission. - - */ -export type permissionsListResponse200 = { - data: PaginatedPermissionResponseList - status: 200 -} - -export type permissionsListResponseComposite = permissionsListResponse200 - -export type permissionsListResponse = permissionsListResponseComposite & { - headers: Headers -} - -export const getPermissionsListUrl = (params?: PermissionsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/permissions/?${stringifiedParams}` : `/api/v2/permissions/` -} - -export const permissionsList = async ( - params?: PermissionsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getPermissionsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getPermissionsListQueryKey = (params?: PermissionsListParams) => { - return ['api', 'v2', 'permissions', ...(params ? [params] : [])] as const -} - -export const getPermissionsListQueryOptions = >, TError = unknown>( - params?: PermissionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getPermissionsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - permissionsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type PermissionsListQueryResult = NonNullable>> -export type PermissionsListQueryError = unknown - -export function usePermissionsList>, TError = unknown>( - params?: PermissionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getPermissionsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve a codename's permissions - - */ -export type permissionsRetrieveResponse200 = { - data: PermissionResponse - status: 200 -} - -export type permissionsRetrieveResponseComposite = permissionsRetrieveResponse200 - -export type permissionsRetrieveResponse = permissionsRetrieveResponseComposite & { - headers: Headers -} - -export const getPermissionsRetrieveUrl = (codename: string) => { - return `/api/v2/permissions/${codename}/` -} - -export const permissionsRetrieve = async ( - codename: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getPermissionsRetrieveUrl(codename), { - ...options, - method: 'GET', - }) -} - -export const getPermissionsRetrieveQueryKey = (codename: string) => { - return ['api', 'v2', 'permissions', codename] as const -} - -export const getPermissionsRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - codename: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getPermissionsRetrieveQueryKey(codename) - - const queryFn: QueryFunction>> = ({ signal }) => - permissionsRetrieve(codename, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!codename, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type PermissionsRetrieveQueryResult = NonNullable>> -export type PermissionsRetrieveQueryError = unknown - -export function usePermissionsRetrieve>, TError = unknown>( - codename: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getPermissionsRetrieveQueryOptions(codename, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Lists the one-time add-ons for the authenticated user's organization. - */ -export type stripeAddonsListResponse200 = { - data: PaginatedOneTimeAddOnList - status: 200 -} - -export type stripeAddonsListResponseComposite = stripeAddonsListResponse200 - -export type stripeAddonsListResponse = stripeAddonsListResponseComposite & { - headers: Headers -} - -export const getStripeAddonsListUrl = (params?: StripeAddonsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/stripe/addons/?${stringifiedParams}` : `/api/v2/stripe/addons/` -} - -export const stripeAddonsList = async ( - params?: StripeAddonsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getStripeAddonsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getStripeAddonsListQueryKey = (params?: StripeAddonsListParams) => { - return ['api', 'v2', 'stripe', 'addons', ...(params ? [params] : [])] as const -} - -export const getStripeAddonsListQueryOptions = >, TError = unknown>( - params?: StripeAddonsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getStripeAddonsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - stripeAddonsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type StripeAddonsListQueryResult = NonNullable>> -export type StripeAddonsListQueryError = unknown - -export function useStripeAddonsList>, TError = unknown>( - params?: StripeAddonsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getStripeAddonsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Lists the one-time add-ons for the authenticated user's organization. - */ -export type stripeAddonsRetrieveResponse200 = { - data: OneTimeAddOn - status: 200 -} - -export type stripeAddonsRetrieveResponseComposite = stripeAddonsRetrieveResponse200 - -export type stripeAddonsRetrieveResponse = stripeAddonsRetrieveResponseComposite & { - headers: Headers -} - -export const getStripeAddonsRetrieveUrl = (id: string) => { - return `/api/v2/stripe/addons/${id}/` -} - -export const stripeAddonsRetrieve = async ( - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getStripeAddonsRetrieveUrl(id), { - ...options, - method: 'GET', - }) -} - -export const getStripeAddonsRetrieveQueryKey = (id: string) => { - return ['api', 'v2', 'stripe', 'addons', id] as const -} - -export const getStripeAddonsRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getStripeAddonsRetrieveQueryKey(id) - - const queryFn: QueryFunction>> = ({ signal }) => - stripeAddonsRetrieve(id, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!id, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type StripeAddonsRetrieveQueryResult = NonNullable>> -export type StripeAddonsRetrieveQueryError = unknown - -export function useStripeAddonsRetrieve>, TError = unknown>( - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getStripeAddonsRetrieveQueryOptions(id, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Change an existing subscription to a new price. - -This will immediately change their subscription to the new plan if upgrading, prorating the charge. -If the user is downgrading to a lower price, it will schedule the change at the end of the current billing period. - -
-GET /api/v2/stripe/change-plan/?subscription_id={subscription_id}&price_id={price_id}
-
- -> Example -> -> curl -X GET https://[kpi]/api/v2/stripe/change-plan/ - -> **Payload** -> -> { -> "price_id": "price_A34cds8fmske3tf", -> "subscription_id": "sub_s9aNFrd2fsmld4gz", -> "quantity": 100000 -> } - -where: - -* "price_id" (required) is the Stripe Price ID for the plan the user is changing to. -* "quantity" is the quantity for the new subscription price (default: 1). -* "subscription_id" (required) is a Stripe Subscription ID for the subscription being changed. - */ -export type stripeChangePlanRetrieveResponse200 = { - data: ChangePlan - status: 200 -} - -export type stripeChangePlanRetrieveResponseComposite = stripeChangePlanRetrieveResponse200 - -export type stripeChangePlanRetrieveResponse = stripeChangePlanRetrieveResponseComposite & { - headers: Headers -} - -export const getStripeChangePlanRetrieveUrl = () => { - return `/api/v2/stripe/change-plan` -} - -export const stripeChangePlanRetrieve = async (options?: RequestInit): Promise => { - return fetchWithAuth(getStripeChangePlanRetrieveUrl(), { - ...options, - method: 'GET', - }) -} - -export const getStripeChangePlanRetrieveQueryKey = () => { - return ['api', 'v2', 'stripe', 'change-plan'] as const -} - -export const getStripeChangePlanRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getStripeChangePlanRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - stripeChangePlanRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type StripeChangePlanRetrieveQueryResult = NonNullable>> -export type StripeChangePlanRetrieveQueryError = unknown - -export function useStripeChangePlanRetrieve< - TData = Awaited>, - TError = unknown, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getStripeChangePlanRetrieveQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -export type stripeCheckoutLinkCreateResponse200 = { - data: CheckoutLink - status: 200 -} - -export type stripeCheckoutLinkCreateResponseComposite = stripeCheckoutLinkCreateResponse200 - -export type stripeCheckoutLinkCreateResponse = stripeCheckoutLinkCreateResponseComposite & { - headers: Headers -} - -export const getStripeCheckoutLinkCreateUrl = () => { - return `/api/v2/stripe/checkout-link` -} - -export const stripeCheckoutLinkCreate = async ( - checkoutLink: CheckoutLink, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getStripeCheckoutLinkCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(checkoutLink), - }) -} - -export const getStripeCheckoutLinkCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: CheckoutLink }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: CheckoutLink }, - TContext -> => { - const mutationKey = ['stripeCheckoutLinkCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: CheckoutLink }> = ( - props, - ) => { - const { data } = props ?? {} - - return stripeCheckoutLinkCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type StripeCheckoutLinkCreateMutationResult = NonNullable>> -export type StripeCheckoutLinkCreateMutationBody = CheckoutLink -export type StripeCheckoutLinkCreateMutationError = unknown - -export const useStripeCheckoutLinkCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: CheckoutLink }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getStripeCheckoutLinkCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -export type stripeCustomerPortalCreateResponse200 = { - data: CustomerPortalPostResponse - status: 200 -} - -export type stripeCustomerPortalCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type stripeCustomerPortalCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type stripeCustomerPortalCreateResponseComposite = - | stripeCustomerPortalCreateResponse200 - | stripeCustomerPortalCreateResponse400 - | stripeCustomerPortalCreateResponse401 - -export type stripeCustomerPortalCreateResponse = stripeCustomerPortalCreateResponseComposite & { - headers: Headers -} - -export const getStripeCustomerPortalCreateUrl = () => { - return `/api/v2/stripe/customer-portal` -} - -export const stripeCustomerPortalCreate = async ( - customerPortal: CustomerPortal, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getStripeCustomerPortalCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(customerPortal), - }) -} - -export const getStripeCustomerPortalCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: CustomerPortal }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: CustomerPortal }, - TContext -> => { - const mutationKey = ['stripeCustomerPortalCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: CustomerPortal } - > = (props) => { - const { data } = props ?? {} - - return stripeCustomerPortalCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type StripeCustomerPortalCreateMutationResult = NonNullable< - Awaited> -> -export type StripeCustomerPortalCreateMutationBody = CustomerPortal -export type StripeCustomerPortalCreateMutationError = ErrorObject | ErrorDetail - -export const useStripeCustomerPortalCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: CustomerPortal }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getStripeCustomerPortalCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Returns Product and Price Lists, sorted from the product with the lowest price to highest -This endpoint is cached for an amount of time determined by ENDPOINT_CACHE_DURATION - -
-GET /api/v2/stripe/products/
-
- -> Example -> -> curl -X GET https://[kpi]/api/v2/stripe/products/ - -> Response -> -> HTTP 200 Ok -> { -> "count": ... -> "next": ... -> "previous": ... -> "results": [ -> { -> "id": string, -> "name": string, -> "type": string, -> "prices": [ -> { -> "id": string, -> "nickname": string, -> "currency": string, -> "type": string, -> "recurring": { -> "aggregate_usage": string ('sum', 'last_during_period`, `last_ever`, `max`) -> "interval": string ('month', 'year', 'week', 'day') -> "interval_count": int, -> "usage_type": string ('metered', 'licensed') -> }, -> "unit_amount": int (cents), -> "human_readable_price": string, -> "metadata": {}, -> "active": bool, -> "product": string, -> "transform_quantity": null | {'round': 'up'|'down', 'divide_by': int} -> }, -> ... -> ], -> "metadata": {}, -> }, -> ... -> ] -> } -> - -### Note: unit_amount is price in cents (assuming currency is USD/AUD/CAD/etc.) - -## Current Endpoint - */ -export type stripeProductsListResponse200 = { - data: PaginatedProductList - status: 200 -} - -export type stripeProductsListResponseComposite = stripeProductsListResponse200 - -export type stripeProductsListResponse = stripeProductsListResponseComposite & { - headers: Headers -} - -export const getStripeProductsListUrl = (params?: StripeProductsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/stripe/products/?${stringifiedParams}` : `/api/v2/stripe/products/` -} - -export const stripeProductsList = async ( - params?: StripeProductsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getStripeProductsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getStripeProductsListQueryKey = (params?: StripeProductsListParams) => { - return ['api', 'v2', 'stripe', 'products', ...(params ? [params] : [])] as const -} - -export const getStripeProductsListQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - params?: StripeProductsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getStripeProductsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - stripeProductsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type StripeProductsListQueryResult = NonNullable>> -export type StripeProductsListQueryError = unknown - -export function useStripeProductsList>, TError = unknown>( - params?: StripeProductsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getStripeProductsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -export type stripeSubscriptionsListResponse200 = { - data: PaginatedSubscriptionList - status: 200 -} - -export type stripeSubscriptionsListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type stripeSubscriptionsListResponseComposite = - | stripeSubscriptionsListResponse200 - | stripeSubscriptionsListResponse401 - -export type stripeSubscriptionsListResponse = stripeSubscriptionsListResponseComposite & { - headers: Headers -} - -export const getStripeSubscriptionsListUrl = (params?: StripeSubscriptionsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/stripe/subscriptions/?${stringifiedParams}` - : `/api/v2/stripe/subscriptions/` -} - -export const stripeSubscriptionsList = async ( - params?: StripeSubscriptionsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getStripeSubscriptionsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getStripeSubscriptionsListQueryKey = (params?: StripeSubscriptionsListParams) => { - return ['api', 'v2', 'stripe', 'subscriptions', ...(params ? [params] : [])] as const -} - -export const getStripeSubscriptionsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: StripeSubscriptionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getStripeSubscriptionsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - stripeSubscriptionsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type StripeSubscriptionsListQueryResult = NonNullable>> -export type StripeSubscriptionsListQueryError = ErrorDetail - -export function useStripeSubscriptionsList< - TData = Awaited>, - TError = ErrorDetail, ->( - params?: StripeSubscriptionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getStripeSubscriptionsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -export type stripeSubscriptionsRetrieveResponse200 = { - data: Subscription - status: 200 -} - -export type stripeSubscriptionsRetrieveResponseComposite = stripeSubscriptionsRetrieveResponse200 - -export type stripeSubscriptionsRetrieveResponse = stripeSubscriptionsRetrieveResponseComposite & { - headers: Headers -} - -export const getStripeSubscriptionsRetrieveUrl = (id: string) => { - return `/api/v2/stripe/subscriptions/${id}/` -} - -export const stripeSubscriptionsRetrieve = async ( - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getStripeSubscriptionsRetrieveUrl(id), { - ...options, - method: 'GET', - }) -} - -export const getStripeSubscriptionsRetrieveQueryKey = (id: string) => { - return ['api', 'v2', 'stripe', 'subscriptions', id] as const -} - -export const getStripeSubscriptionsRetrieveQueryOptions = < - TData = Awaited>, - TError = unknown, ->( - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getStripeSubscriptionsRetrieveQueryKey(id) - - const queryFn: QueryFunction>> = ({ signal }) => - stripeSubscriptionsRetrieve(id, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!id, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type StripeSubscriptionsRetrieveQueryResult = NonNullable< - Awaited> -> -export type StripeSubscriptionsRetrieveQueryError = unknown - -export function useStripeSubscriptionsRetrieve< - TData = Awaited>, - TError = unknown, ->( - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getStripeSubscriptionsRetrieveQueryOptions(id, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List the different terms of service - - */ -export type termsOfServiceListResponse200 = { - data: TermsOfServiceResponse[] - status: 200 -} - -export type termsOfServiceListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type termsOfServiceListResponseComposite = termsOfServiceListResponse200 | termsOfServiceListResponse401 - -export type termsOfServiceListResponse = termsOfServiceListResponseComposite & { - headers: Headers -} - -export const getTermsOfServiceListUrl = () => { - return `/api/v2/terms-of-service/` -} - -export const termsOfServiceList = async (options?: RequestInit): Promise => { - return fetchWithAuth(getTermsOfServiceListUrl(), { - ...options, - method: 'GET', - }) -} - -export const getTermsOfServiceListQueryKey = () => { - return ['api', 'v2', 'terms-of-service'] as const -} - -export const getTermsOfServiceListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getTermsOfServiceListQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - termsOfServiceList({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type TermsOfServiceListQueryResult = NonNullable>> -export type TermsOfServiceListQueryError = ErrorDetail - -export function useTermsOfServiceList< - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getTermsOfServiceListQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve a specific terms of service - - */ -export type termsOfServiceRetrieveResponse200 = { - data: TermsOfServiceResponse - status: 200 -} - -export type termsOfServiceRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type termsOfServiceRetrieveResponseComposite = - | termsOfServiceRetrieveResponse200 - | termsOfServiceRetrieveResponse401 - -export type termsOfServiceRetrieveResponse = termsOfServiceRetrieveResponseComposite & { - headers: Headers -} - -export const getTermsOfServiceRetrieveUrl = (slug: string) => { - return `/api/v2/terms-of-service/${slug}/` -} - -export const termsOfServiceRetrieve = async ( - slug: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getTermsOfServiceRetrieveUrl(slug), { - ...options, - method: 'GET', - }) -} - -export const getTermsOfServiceRetrieveQueryKey = (slug: string) => { - return ['api', 'v2', 'terms-of-service', slug] as const -} - -export const getTermsOfServiceRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - slug: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getTermsOfServiceRetrieveQueryKey(slug) - - const queryFn: QueryFunction>> = ({ signal }) => - termsOfServiceRetrieve(slug, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!slug, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type TermsOfServiceRetrieveQueryResult = NonNullable>> -export type TermsOfServiceRetrieveQueryError = ErrorDetail - -export function useTermsOfServiceRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - slug: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getTermsOfServiceRetrieveQueryOptions(slug, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List the transcription services accessible to requesting user. - -Search can be made with `q` parameter to search for the term in names and codes. - -Results are order by name. - - */ -export type transcriptionServicesListResponse200 = { - data: PaginatedTranscriptionServiceList - status: 200 -} - -export type transcriptionServicesListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type transcriptionServicesListResponseComposite = - | transcriptionServicesListResponse200 - | transcriptionServicesListResponse401 - -export type transcriptionServicesListResponse = transcriptionServicesListResponseComposite & { - headers: Headers -} - -export const getTranscriptionServicesListUrl = (params?: TranscriptionServicesListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/transcription-services/?${stringifiedParams}` - : `/api/v2/transcription-services/` -} - -export const transcriptionServicesList = async ( - params?: TranscriptionServicesListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getTranscriptionServicesListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getTranscriptionServicesListQueryKey = (params?: TranscriptionServicesListParams) => { - return ['api', 'v2', 'transcription-services', ...(params ? [params] : [])] as const -} - -export const getTranscriptionServicesListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: TranscriptionServicesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getTranscriptionServicesListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - transcriptionServicesList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type TranscriptionServicesListQueryResult = NonNullable>> -export type TranscriptionServicesListQueryError = ErrorDetail - -export function useTranscriptionServicesList< - TData = Awaited>, - TError = ErrorDetail, ->( - params?: TranscriptionServicesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getTranscriptionServicesListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## retrieve a transcription service - -* `code` - is the unique identifier of a specific language - - */ -export type transcriptionServicesRetrieveResponse200 = { - data: TranscriptionService - status: 200 -} - -export type transcriptionServicesRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type transcriptionServicesRetrieveResponseComposite = - | transcriptionServicesRetrieveResponse200 - | transcriptionServicesRetrieveResponse401 - -export type transcriptionServicesRetrieveResponse = transcriptionServicesRetrieveResponseComposite & { - headers: Headers -} - -export const getTranscriptionServicesRetrieveUrl = (code: string) => { - return `/api/v2/transcription-services/${code}/` -} - -export const transcriptionServicesRetrieve = async ( - code: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getTranscriptionServicesRetrieveUrl(code), { - ...options, - method: 'GET', - }) -} - -export const getTranscriptionServicesRetrieveQueryKey = (code: string) => { - return ['api', 'v2', 'transcription-services', code] as const -} - -export const getTranscriptionServicesRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - code: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getTranscriptionServicesRetrieveQueryKey(code) - - const queryFn: QueryFunction>> = ({ signal }) => - transcriptionServicesRetrieve(code, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!code, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type TranscriptionServicesRetrieveQueryResult = NonNullable< - Awaited> -> -export type TranscriptionServicesRetrieveQueryError = ErrorDetail - -export function useTranscriptionServicesRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - code: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getTranscriptionServicesRetrieveQueryOptions(code, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List the translation services accessible to requesting (authenticated) user. - -Search can be made with `q` parameter to search for the term in names and codes. - -Results are ordered by name. - - - */ -export type translationServicesListResponse200 = { - data: PaginatedTranslationServiceList - status: 200 -} - -export type translationServicesListResponse400 = { - data: ErrorObject - status: 400 -} - -export type translationServicesListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type translationServicesListResponseComposite = - | translationServicesListResponse200 - | translationServicesListResponse400 - | translationServicesListResponse401 - -export type translationServicesListResponse = translationServicesListResponseComposite & { - headers: Headers -} - -export const getTranslationServicesListUrl = (params?: TranslationServicesListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/translation-services/?${stringifiedParams}` - : `/api/v2/translation-services/` -} - -export const translationServicesList = async ( - params?: TranslationServicesListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getTranslationServicesListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getTranslationServicesListQueryKey = (params?: TranslationServicesListParams) => { - return ['api', 'v2', 'translation-services', ...(params ? [params] : [])] as const -} - -export const getTranslationServicesListQueryOptions = < - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - params?: TranslationServicesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getTranslationServicesListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - translationServicesList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type TranslationServicesListQueryResult = NonNullable>> -export type TranslationServicesListQueryError = ErrorObject | ErrorDetail - -export function useTranslationServicesList< - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - params?: TranslationServicesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getTranslationServicesListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve a translation service - -* `code` - is the unique identifier of a specific language - - */ -export type translationServicesRetrieveResponse200 = { - data: TranslationService - status: 200 -} - -export type translationServicesRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type translationServicesRetrieveResponseComposite = - | translationServicesRetrieveResponse200 - | translationServicesRetrieveResponse401 - -export type translationServicesRetrieveResponse = translationServicesRetrieveResponseComposite & { - headers: Headers -} - -export const getTranslationServicesRetrieveUrl = (code: string) => { - return `/api/v2/translation-services/${code}/` -} - -export const translationServicesRetrieve = async ( - code: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getTranslationServicesRetrieveUrl(code), { - ...options, - method: 'GET', - }) -} - -export const getTranslationServicesRetrieveQueryKey = (code: string) => { - return ['api', 'v2', 'translation-services', code] as const -} - -export const getTranslationServicesRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - code: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getTranslationServicesRetrieveQueryKey(code) - - const queryFn: QueryFunction>> = ({ signal }) => - translationServicesRetrieve(code, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!code, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type TranslationServicesRetrieveQueryResult = NonNullable< - Awaited> -> -export type TranslationServicesRetrieveQueryError = ErrorDetail - -export function useTranslationServicesRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - code: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getTranslationServicesRetrieveQueryOptions(code, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} diff --git a/jsapp/js/api/react-query/scim/index.ts b/jsapp/js/api/react-query/scim/index.ts new file mode 100644 index 0000000000..4597a58076 --- /dev/null +++ b/jsapp/js/api/react-query/scim/index.ts @@ -0,0 +1,1407 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + PaginatedScimGroupList +} from '../../models/paginatedScimGroupList'; + +import type { + PaginatedScimUserList +} from '../../models/paginatedScimUserList'; + +import type { + PatchedScimGroup +} from '../../models/patchedScimGroup'; + +import type { + PatchedScimUser +} from '../../models/patchedScimUser'; + +import type { + ScimError +} from '../../models/scimError'; + +import type { + ScimGroup +} from '../../models/scimGroup'; + +import type { + ScimUser +} from '../../models/scimUser'; + +import type { + ScimV2GroupsListParams +} from '../../models/scimV2GroupsListParams'; + +import type { + ScimV2ResourceTypesRetrieve200 +} from '../../models/scimV2ResourceTypesRetrieve200'; + +import type { + ScimV2SchemasRetrieve200 +} from '../../models/scimV2SchemasRetrieve200'; + +import type { + ScimV2ServiceProviderConfigRetrieve200 +} from '../../models/scimV2ServiceProviderConfigRetrieve200'; + +import type { + ScimV2UsersCreate400 +} from '../../models/scimV2UsersCreate400'; + +import type { + ScimV2UsersCreate409 +} from '../../models/scimV2UsersCreate409'; + +import type { + ScimV2UsersListParams +} from '../../models/scimV2UsersListParams'; + +import type { + ScimV2UsersUpdate409 +} from '../../models/scimV2UsersUpdate409'; + +import { fetchWithAuth } from '../../orval.mutator'; + +// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 +type IfEquals = (() => T extends X ? 1 : 2) extends < +T, +>() => T extends Y ? 1 : 2 +? A +: B; + +type WritableKeys = { +[P in keyof T]-?: IfEquals< + { [Q in P]: T[P] }, + { -readonly [Q in P]: T[P] }, + P +>; +}[keyof T]; + +type UnionToIntersection = + (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never; +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; + +type Writable = Pick>; +type NonReadonly = [T] extends [UnionToIntersection] ? { + [P in keyof Writable]: T[P] extends object + ? NonReadonly> + : T[P]; +} : DistributeReadOnlyOverUnions; + + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * Returns a list of SCIM groups. + */ +export type scimV2GroupsListResponse200 = { + data: PaginatedScimGroupList + status: 200 +} + +export type scimV2GroupsListResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2GroupsListResponseComposite = scimV2GroupsListResponse200 | scimV2GroupsListResponse401; + +export type scimV2GroupsListResponse = scimV2GroupsListResponseComposite & { + headers: Headers; +} + +export const getScimV2GroupsListUrl = (idpSlug: string, + params?: ScimV2GroupsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/scim/v2/${idpSlug}/Groups?${stringifiedParams}` : `/api/v2/scim/v2/${idpSlug}/Groups` +} + +export const scimV2GroupsList = async (idpSlug: string, + params?: ScimV2GroupsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2GroupsListUrl(idpSlug,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getScimV2GroupsListQueryKey = (idpSlug: string, + params?: ScimV2GroupsListParams,) => { + return ['api','v2','scim','v2',idpSlug,'Groups', ...(params ? [params]: [])] as const; + } + + +export const getScimV2GroupsListQueryOptions = >, TError = ScimError>(idpSlug: string, + params?: ScimV2GroupsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getScimV2GroupsListQueryKey(idpSlug,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => scimV2GroupsList(idpSlug,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(idpSlug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ScimV2GroupsListQueryResult = NonNullable>> +export type ScimV2GroupsListQueryError = ScimError + + + +export function useScimV2GroupsList>, TError = ScimError>( + idpSlug: string, + params?: ScimV2GroupsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getScimV2GroupsListQueryOptions(idpSlug,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Creates a new SCIM group. + */ +export type scimV2GroupsCreateResponse201 = { + data: ScimGroup + status: 201 +} + +export type scimV2GroupsCreateResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2GroupsCreateResponseComposite = scimV2GroupsCreateResponse201 | scimV2GroupsCreateResponse401; + +export type scimV2GroupsCreateResponse = scimV2GroupsCreateResponseComposite & { + headers: Headers; +} + +export const getScimV2GroupsCreateUrl = (idpSlug: string,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Groups` +} + +export const scimV2GroupsCreate = async (idpSlug: string, + scimGroup: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2GroupsCreateUrl(idpSlug), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, + body: JSON.stringify( + scimGroup,) + } +);} + + + + +export const getScimV2GroupsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext> => { + +const mutationKey = ['scimV2GroupsCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {idpSlug: string;data: NonReadonly}> = (props) => { + const {idpSlug,data} = props ?? {}; + + return scimV2GroupsCreate(idpSlug,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ScimV2GroupsCreateMutationResult = NonNullable>> + export type ScimV2GroupsCreateMutationBody = NonReadonly + export type ScimV2GroupsCreateMutationError = ScimError + + export const useScimV2GroupsCreate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getScimV2GroupsCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Returns a specific SCIM group. + */ +export type scimV2GroupsRetrieveResponse200 = { + data: ScimGroup + status: 200 +} + +export type scimV2GroupsRetrieveResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2GroupsRetrieveResponseComposite = scimV2GroupsRetrieveResponse200 | scimV2GroupsRetrieveResponse401; + +export type scimV2GroupsRetrieveResponse = scimV2GroupsRetrieveResponseComposite & { + headers: Headers; +} + +export const getScimV2GroupsRetrieveUrl = (idpSlug: string, + id: string,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` +} + +export const scimV2GroupsRetrieve = async (idpSlug: string, + id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2GroupsRetrieveUrl(idpSlug,id), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getScimV2GroupsRetrieveQueryKey = (idpSlug: string, + id: string,) => { + return ['api','v2','scim','v2',idpSlug,'Groups',id] as const; + } + + +export const getScimV2GroupsRetrieveQueryOptions = >, TError = ScimError>(idpSlug: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getScimV2GroupsRetrieveQueryKey(idpSlug,id); + + + + const queryFn: QueryFunction>> = ({ signal }) => scimV2GroupsRetrieve(idpSlug,id, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(idpSlug && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ScimV2GroupsRetrieveQueryResult = NonNullable>> +export type ScimV2GroupsRetrieveQueryError = ScimError + + + +export function useScimV2GroupsRetrieve>, TError = ScimError>( + idpSlug: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getScimV2GroupsRetrieveQueryOptions(idpSlug,id,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Replaces a SCIM group entirely. + */ +export type scimV2GroupsUpdateResponse200 = { + data: ScimGroup + status: 200 +} + +export type scimV2GroupsUpdateResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2GroupsUpdateResponseComposite = scimV2GroupsUpdateResponse200 | scimV2GroupsUpdateResponse401; + +export type scimV2GroupsUpdateResponse = scimV2GroupsUpdateResponseComposite & { + headers: Headers; +} + +export const getScimV2GroupsUpdateUrl = (idpSlug: string, + id: string,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` +} + +export const scimV2GroupsUpdate = async (idpSlug: string, + id: string, + scimGroup: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2GroupsUpdateUrl(idpSlug,id), + { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, + body: JSON.stringify( + scimGroup,) + } +);} + + + + +export const getScimV2GroupsUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext> => { + +const mutationKey = ['scimV2GroupsUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {idpSlug: string;id: string;data: NonReadonly}> = (props) => { + const {idpSlug,id,data} = props ?? {}; + + return scimV2GroupsUpdate(idpSlug,id,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ScimV2GroupsUpdateMutationResult = NonNullable>> + export type ScimV2GroupsUpdateMutationBody = NonReadonly + export type ScimV2GroupsUpdateMutationError = ScimError + + export const useScimV2GroupsUpdate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getScimV2GroupsUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Updates a SCIM group. Supports adding/removing members via patch operations. + */ +export type scimV2GroupsPartialUpdateResponse200 = { + data: ScimGroup + status: 200 +} + +export type scimV2GroupsPartialUpdateResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2GroupsPartialUpdateResponseComposite = scimV2GroupsPartialUpdateResponse200 | scimV2GroupsPartialUpdateResponse401; + +export type scimV2GroupsPartialUpdateResponse = scimV2GroupsPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getScimV2GroupsPartialUpdateUrl = (idpSlug: string, + id: string,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` +} + +export const scimV2GroupsPartialUpdate = async (idpSlug: string, + id: string, + patchedScimGroup: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2GroupsPartialUpdateUrl(idpSlug,id), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, + body: JSON.stringify( + patchedScimGroup,) + } +);} + + + + +export const getScimV2GroupsPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext> => { + +const mutationKey = ['scimV2GroupsPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {idpSlug: string;id: string;data: NonReadonly}> = (props) => { + const {idpSlug,id,data} = props ?? {}; + + return scimV2GroupsPartialUpdate(idpSlug,id,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ScimV2GroupsPartialUpdateMutationResult = NonNullable>> + export type ScimV2GroupsPartialUpdateMutationBody = NonReadonly + export type ScimV2GroupsPartialUpdateMutationError = ScimError + + export const useScimV2GroupsPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getScimV2GroupsPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Deletes a SCIM group. + */ +export type scimV2GroupsDestroyResponse204 = { + data: void + status: 204 +} + +export type scimV2GroupsDestroyResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2GroupsDestroyResponseComposite = scimV2GroupsDestroyResponse204 | scimV2GroupsDestroyResponse401; + +export type scimV2GroupsDestroyResponse = scimV2GroupsDestroyResponseComposite & { + headers: Headers; +} + +export const getScimV2GroupsDestroyUrl = (idpSlug: string, + id: string,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` +} + +export const scimV2GroupsDestroy = async (idpSlug: string, + id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2GroupsDestroyUrl(idpSlug,id), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getScimV2GroupsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{idpSlug: string;id: string}, TContext> => { + +const mutationKey = ['scimV2GroupsDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {idpSlug: string;id: string}> = (props) => { + const {idpSlug,id} = props ?? {}; + + return scimV2GroupsDestroy(idpSlug,id,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ScimV2GroupsDestroyMutationResult = NonNullable>> + + export type ScimV2GroupsDestroyMutationError = ScimError + + export const useScimV2GroupsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getScimV2GroupsDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Returns the SCIM supported ResourceTypes. + */ +export type scimV2ResourceTypesRetrieveResponse200 = { + data: ScimV2ResourceTypesRetrieve200 + status: 200 +} + +export type scimV2ResourceTypesRetrieveResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2ResourceTypesRetrieveResponseComposite = scimV2ResourceTypesRetrieveResponse200 | scimV2ResourceTypesRetrieveResponse401; + +export type scimV2ResourceTypesRetrieveResponse = scimV2ResourceTypesRetrieveResponseComposite & { + headers: Headers; +} + +export const getScimV2ResourceTypesRetrieveUrl = (idpSlug: string,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/ResourceTypes` +} + +export const scimV2ResourceTypesRetrieve = async (idpSlug: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2ResourceTypesRetrieveUrl(idpSlug), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getScimV2ResourceTypesRetrieveQueryKey = (idpSlug: string,) => { + return ['api','v2','scim','v2',idpSlug,'ResourceTypes'] as const; + } + + +export const getScimV2ResourceTypesRetrieveQueryOptions = >, TError = ScimError>(idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getScimV2ResourceTypesRetrieveQueryKey(idpSlug); + + + + const queryFn: QueryFunction>> = ({ signal }) => scimV2ResourceTypesRetrieve(idpSlug, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(idpSlug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ScimV2ResourceTypesRetrieveQueryResult = NonNullable>> +export type ScimV2ResourceTypesRetrieveQueryError = ScimError + + + +export function useScimV2ResourceTypesRetrieve>, TError = ScimError>( + idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getScimV2ResourceTypesRetrieveQueryOptions(idpSlug,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Returns the SCIM supported Schemas. + */ +export type scimV2SchemasRetrieveResponse200 = { + data: ScimV2SchemasRetrieve200 + status: 200 +} + +export type scimV2SchemasRetrieveResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2SchemasRetrieveResponseComposite = scimV2SchemasRetrieveResponse200 | scimV2SchemasRetrieveResponse401; + +export type scimV2SchemasRetrieveResponse = scimV2SchemasRetrieveResponseComposite & { + headers: Headers; +} + +export const getScimV2SchemasRetrieveUrl = (idpSlug: string,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Schemas` +} + +export const scimV2SchemasRetrieve = async (idpSlug: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2SchemasRetrieveUrl(idpSlug), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getScimV2SchemasRetrieveQueryKey = (idpSlug: string,) => { + return ['api','v2','scim','v2',idpSlug,'Schemas'] as const; + } + + +export const getScimV2SchemasRetrieveQueryOptions = >, TError = ScimError>(idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getScimV2SchemasRetrieveQueryKey(idpSlug); + + + + const queryFn: QueryFunction>> = ({ signal }) => scimV2SchemasRetrieve(idpSlug, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(idpSlug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ScimV2SchemasRetrieveQueryResult = NonNullable>> +export type ScimV2SchemasRetrieveQueryError = ScimError + + + +export function useScimV2SchemasRetrieve>, TError = ScimError>( + idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getScimV2SchemasRetrieveQueryOptions(idpSlug,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Returns the SCIM Service Provider Configuration. + */ +export type scimV2ServiceProviderConfigRetrieveResponse200 = { + data: ScimV2ServiceProviderConfigRetrieve200 + status: 200 +} + +export type scimV2ServiceProviderConfigRetrieveResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2ServiceProviderConfigRetrieveResponseComposite = scimV2ServiceProviderConfigRetrieveResponse200 | scimV2ServiceProviderConfigRetrieveResponse401; + +export type scimV2ServiceProviderConfigRetrieveResponse = scimV2ServiceProviderConfigRetrieveResponseComposite & { + headers: Headers; +} + +export const getScimV2ServiceProviderConfigRetrieveUrl = (idpSlug: string,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/ServiceProviderConfig` +} + +export const scimV2ServiceProviderConfigRetrieve = async (idpSlug: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2ServiceProviderConfigRetrieveUrl(idpSlug), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getScimV2ServiceProviderConfigRetrieveQueryKey = (idpSlug: string,) => { + return ['api','v2','scim','v2',idpSlug,'ServiceProviderConfig'] as const; + } + + +export const getScimV2ServiceProviderConfigRetrieveQueryOptions = >, TError = ScimError>(idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getScimV2ServiceProviderConfigRetrieveQueryKey(idpSlug); + + + + const queryFn: QueryFunction>> = ({ signal }) => scimV2ServiceProviderConfigRetrieve(idpSlug, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(idpSlug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ScimV2ServiceProviderConfigRetrieveQueryResult = NonNullable>> +export type ScimV2ServiceProviderConfigRetrieveQueryError = ScimError + + + +export function useScimV2ServiceProviderConfigRetrieve>, TError = ScimError>( + idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getScimV2ServiceProviderConfigRetrieveQueryOptions(idpSlug,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Returns a list of SCIM users matching the optional query + */ +export type scimV2UsersListResponse200 = { + data: PaginatedScimUserList + status: 200 +} + +export type scimV2UsersListResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2UsersListResponseComposite = scimV2UsersListResponse200 | scimV2UsersListResponse401; + +export type scimV2UsersListResponse = scimV2UsersListResponseComposite & { + headers: Headers; +} + +export const getScimV2UsersListUrl = (idpSlug: string, + params?: ScimV2UsersListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/scim/v2/${idpSlug}/Users?${stringifiedParams}` : `/api/v2/scim/v2/${idpSlug}/Users` +} + +export const scimV2UsersList = async (idpSlug: string, + params?: ScimV2UsersListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2UsersListUrl(idpSlug,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getScimV2UsersListQueryKey = (idpSlug: string, + params?: ScimV2UsersListParams,) => { + return ['api','v2','scim','v2',idpSlug,'Users', ...(params ? [params]: [])] as const; + } + + +export const getScimV2UsersListQueryOptions = >, TError = ScimError>(idpSlug: string, + params?: ScimV2UsersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getScimV2UsersListQueryKey(idpSlug,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => scimV2UsersList(idpSlug,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(idpSlug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ScimV2UsersListQueryResult = NonNullable>> +export type ScimV2UsersListQueryError = ScimError + + + +export function useScimV2UsersList>, TError = ScimError>( + idpSlug: string, + params?: ScimV2UsersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getScimV2UsersListQueryOptions(idpSlug,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Handle POST requests (user provisioning from IdP). + */ +export type scimV2UsersCreateResponse201 = { + data: ScimUser + status: 201 +} + +export type scimV2UsersCreateResponse400 = { + data: ScimV2UsersCreate400 + status: 400 +} + +export type scimV2UsersCreateResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2UsersCreateResponse409 = { + data: ScimV2UsersCreate409 + status: 409 +} + +export type scimV2UsersCreateResponseComposite = scimV2UsersCreateResponse201 | scimV2UsersCreateResponse400 | scimV2UsersCreateResponse401 | scimV2UsersCreateResponse409; + +export type scimV2UsersCreateResponse = scimV2UsersCreateResponseComposite & { + headers: Headers; +} + +export const getScimV2UsersCreateUrl = (idpSlug: string,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Users` +} + +export const scimV2UsersCreate = async (idpSlug: string, + scimUser: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2UsersCreateUrl(idpSlug), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, + body: JSON.stringify( + scimUser,) + } +);} + + + + +export const getScimV2UsersCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext> => { + +const mutationKey = ['scimV2UsersCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {idpSlug: string;data: NonReadonly}> = (props) => { + const {idpSlug,data} = props ?? {}; + + return scimV2UsersCreate(idpSlug,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ScimV2UsersCreateMutationResult = NonNullable>> + export type ScimV2UsersCreateMutationBody = NonReadonly + export type ScimV2UsersCreateMutationError = ScimV2UsersCreate400 | ScimError | ScimV2UsersCreate409 + + export const useScimV2UsersCreate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getScimV2UsersCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Returns a specific SCIM user. + */ +export type scimV2UsersRetrieveResponse200 = { + data: ScimUser + status: 200 +} + +export type scimV2UsersRetrieveResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2UsersRetrieveResponseComposite = scimV2UsersRetrieveResponse200 | scimV2UsersRetrieveResponse401; + +export type scimV2UsersRetrieveResponse = scimV2UsersRetrieveResponseComposite & { + headers: Headers; +} + +export const getScimV2UsersRetrieveUrl = (idpSlug: string, + id: number,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Users/${id}` +} + +export const scimV2UsersRetrieve = async (idpSlug: string, + id: number, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2UsersRetrieveUrl(idpSlug,id), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getScimV2UsersRetrieveQueryKey = (idpSlug: string, + id: number,) => { + return ['api','v2','scim','v2',idpSlug,'Users',id] as const; + } + + +export const getScimV2UsersRetrieveQueryOptions = >, TError = ScimError>(idpSlug: string, + id: number, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getScimV2UsersRetrieveQueryKey(idpSlug,id); + + + + const queryFn: QueryFunction>> = ({ signal }) => scimV2UsersRetrieve(idpSlug,id, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(idpSlug && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ScimV2UsersRetrieveQueryResult = NonNullable>> +export type ScimV2UsersRetrieveQueryError = ScimError + + + +export function useScimV2UsersRetrieve>, TError = ScimError>( + idpSlug: string, + id: number, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getScimV2UsersRetrieveQueryOptions(idpSlug,id,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * Handle PUT requests (user update from IdP). +Authentik can send a PUT request to update a user's details. If it tries to +update a user to have a username or email that already exists on another +account, we intercept the IntegrityError and return a SCIM 409 Conflict. + */ +export type scimV2UsersUpdateResponse200 = { + data: ScimUser + status: 200 +} + +export type scimV2UsersUpdateResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2UsersUpdateResponse409 = { + data: ScimV2UsersUpdate409 + status: 409 +} + +export type scimV2UsersUpdateResponseComposite = scimV2UsersUpdateResponse200 | scimV2UsersUpdateResponse401 | scimV2UsersUpdateResponse409; + +export type scimV2UsersUpdateResponse = scimV2UsersUpdateResponseComposite & { + headers: Headers; +} + +export const getScimV2UsersUpdateUrl = (idpSlug: string, + id: number,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Users/${id}` +} + +export const scimV2UsersUpdate = async (idpSlug: string, + id: number, + scimUser: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2UsersUpdateUrl(idpSlug,id), + { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, + body: JSON.stringify( + scimUser,) + } +);} + + + + +export const getScimV2UsersUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext> => { + +const mutationKey = ['scimV2UsersUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {idpSlug: string;id: number;data: NonReadonly}> = (props) => { + const {idpSlug,id,data} = props ?? {}; + + return scimV2UsersUpdate(idpSlug,id,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ScimV2UsersUpdateMutationResult = NonNullable>> + export type ScimV2UsersUpdateMutationBody = NonReadonly + export type ScimV2UsersUpdateMutationError = ScimError | ScimV2UsersUpdate409 + + export const useScimV2UsersUpdate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getScimV2UsersUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Updates a SCIM user. Currently only supports deactivation via the `active` attribute. + */ +export type scimV2UsersPartialUpdateResponse200 = { + data: ScimUser + status: 200 +} + +export type scimV2UsersPartialUpdateResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2UsersPartialUpdateResponseComposite = scimV2UsersPartialUpdateResponse200 | scimV2UsersPartialUpdateResponse401; + +export type scimV2UsersPartialUpdateResponse = scimV2UsersPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getScimV2UsersPartialUpdateUrl = (idpSlug: string, + id: number,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Users/${id}` +} + +export const scimV2UsersPartialUpdate = async (idpSlug: string, + id: number, + patchedScimUser: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2UsersPartialUpdateUrl(idpSlug,id), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, + body: JSON.stringify( + patchedScimUser,) + } +);} + + + + +export const getScimV2UsersPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext> => { + +const mutationKey = ['scimV2UsersPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {idpSlug: string;id: number;data: NonReadonly}> = (props) => { + const {idpSlug,id,data} = props ?? {}; + + return scimV2UsersPartialUpdate(idpSlug,id,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ScimV2UsersPartialUpdateMutationResult = NonNullable>> + export type ScimV2UsersPartialUpdateMutationBody = NonReadonly + export type ScimV2UsersPartialUpdateMutationError = ScimError + + export const useScimV2UsersPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getScimV2UsersPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * Deactivates all Kobo accounts linked to the user's email address. + */ +export type scimV2UsersDestroyResponse204 = { + data: void + status: 204 +} + +export type scimV2UsersDestroyResponse401 = { + data: ScimError + status: 401 +} + +export type scimV2UsersDestroyResponseComposite = scimV2UsersDestroyResponse204 | scimV2UsersDestroyResponse401; + +export type scimV2UsersDestroyResponse = scimV2UsersDestroyResponseComposite & { + headers: Headers; +} + +export const getScimV2UsersDestroyUrl = (idpSlug: string, + id: number,) => { + + + + + return `/api/v2/scim/v2/${idpSlug}/Users/${id}` +} + +export const scimV2UsersDestroy = async (idpSlug: string, + id: number, options?: RequestInit): Promise => { + + return fetchWithAuth(getScimV2UsersDestroyUrl(idpSlug,id), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getScimV2UsersDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{idpSlug: string;id: number}, TContext> => { + +const mutationKey = ['scimV2UsersDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {idpSlug: string;id: number}> = (props) => { + const {idpSlug,id} = props ?? {}; + + return scimV2UsersDestroy(idpSlug,id,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ScimV2UsersDestroyMutationResult = NonNullable>> + + export type ScimV2UsersDestroyMutationError = ScimError + + export const useScimV2UsersDestroy = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getScimV2UsersDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + \ No newline at end of file diff --git a/jsapp/js/api/react-query/scim/msw.ts b/jsapp/js/api/react-query/scim/msw.ts new file mode 100644 index 0000000000..74b87e08ec --- /dev/null +++ b/jsapp/js/api/react-query/scim/msw.ts @@ -0,0 +1,274 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import type { + PaginatedScimGroupList +} from '../../models/paginatedScimGroupList'; + +import type { + PaginatedScimUserList +} from '../../models/paginatedScimUserList'; + +import type { + ScimGroup +} from '../../models/scimGroup'; + +import type { + ScimUser +} from '../../models/scimUser'; + +import type { + ScimV2ResourceTypesRetrieve200 +} from '../../models/scimV2ResourceTypesRetrieve200'; + +import type { + ScimV2SchemasRetrieve200 +} from '../../models/scimV2SchemasRetrieve200'; + +import type { + ScimV2ServiceProviderConfigRetrieve200 +} from '../../models/scimV2ServiceProviderConfigRetrieve200'; + + +export const getApiV2ScimV2GroupsListResponseMock = (overrideResponse: Partial< PaginatedScimGroupList > = {}): PaginatedScimGroupList => ({schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), totalResults: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), itemsPerPage: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), startIndex: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), displayName: faker.string.alpha({length: {min: 10, max: 20}}), externalId: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), members: {}, meta: { + [faker.string.alphanumeric(5)]: {} + }})), ...overrideResponse}) + +export const getApiV2ScimV2GroupsCreateResponseMock = (overrideResponse: Partial< ScimGroup > = {}): ScimGroup => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), displayName: faker.string.alpha({length: {min: 10, max: 20}}), externalId: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), members: {}, meta: { + [faker.string.alphanumeric(5)]: {} + }, ...overrideResponse}) + +export const getApiV2ScimV2GroupsRetrieveResponseMock = (overrideResponse: Partial< ScimGroup > = {}): ScimGroup => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), displayName: faker.string.alpha({length: {min: 10, max: 20}}), externalId: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), members: {}, meta: { + [faker.string.alphanumeric(5)]: {} + }, ...overrideResponse}) + +export const getApiV2ScimV2GroupsUpdateResponseMock = (overrideResponse: Partial< ScimGroup > = {}): ScimGroup => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), displayName: faker.string.alpha({length: {min: 10, max: 20}}), externalId: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), members: {}, meta: { + [faker.string.alphanumeric(5)]: {} + }, ...overrideResponse}) + +export const getApiV2ScimV2GroupsPartialUpdateResponseMock = (overrideResponse: Partial< ScimGroup > = {}): ScimGroup => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), displayName: faker.string.alpha({length: {min: 10, max: 20}}), externalId: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), members: {}, meta: { + [faker.string.alphanumeric(5)]: {} + }, ...overrideResponse}) + +export const getApiV2ScimV2ResourceTypesRetrieveResponseMock = (): ScimV2ResourceTypesRetrieve200 => ({ + [faker.string.alphanumeric(5)]: {} + }) + +export const getApiV2ScimV2SchemasRetrieveResponseMock = (): ScimV2SchemasRetrieve200 => ({ + [faker.string.alphanumeric(5)]: {} + }) + +export const getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock = (): ScimV2ServiceProviderConfigRetrieve200 => ({ + [faker.string.alphanumeric(5)]: {} + }) + +export const getApiV2ScimV2UsersListResponseMock = (overrideResponse: Partial< PaginatedScimUserList > = {}): PaginatedScimUserList => ({schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), totalResults: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), itemsPerPage: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), startIndex: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), userName: faker.string.alpha({length: {min: 10, max: 20}}), name: { + [faker.string.alphanumeric(5)]: {} + }, emails: {}, active: faker.datatype.boolean(), meta: { + [faker.string.alphanumeric(5)]: {} + }})), ...overrideResponse}) + +export const getApiV2ScimV2UsersCreateResponseMock = (overrideResponse: Partial< ScimUser > = {}): ScimUser => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), userName: faker.string.alpha({length: {min: 10, max: 20}}), name: { + [faker.string.alphanumeric(5)]: {} + }, emails: {}, active: faker.datatype.boolean(), meta: { + [faker.string.alphanumeric(5)]: {} + }, ...overrideResponse}) + +export const getApiV2ScimV2UsersRetrieveResponseMock = (overrideResponse: Partial< ScimUser > = {}): ScimUser => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), userName: faker.string.alpha({length: {min: 10, max: 20}}), name: { + [faker.string.alphanumeric(5)]: {} + }, emails: {}, active: faker.datatype.boolean(), meta: { + [faker.string.alphanumeric(5)]: {} + }, ...overrideResponse}) + +export const getApiV2ScimV2UsersUpdateResponseMock = (overrideResponse: Partial< ScimUser > = {}): ScimUser => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), userName: faker.string.alpha({length: {min: 10, max: 20}}), name: { + [faker.string.alphanumeric(5)]: {} + }, emails: {}, active: faker.datatype.boolean(), meta: { + [faker.string.alphanumeric(5)]: {} + }, ...overrideResponse}) + +export const getApiV2ScimV2UsersPartialUpdateResponseMock = (overrideResponse: Partial< ScimUser > = {}): ScimUser => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), userName: faker.string.alpha({length: {min: 10, max: 20}}), name: { + [faker.string.alphanumeric(5)]: {} + }, emails: {}, active: faker.datatype.boolean(), meta: { + [faker.string.alphanumeric(5)]: {} + }, ...overrideResponse}) + + +export const getApiV2ScimV2GroupsListMockHandler = (overrideResponse?: PaginatedScimGroupList | ((info: Parameters[1]>[0]) => Promise | PaginatedScimGroupList)) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2GroupsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2GroupsCreateMockHandler = (overrideResponse?: ScimGroup | ((info: Parameters[1]>[0]) => Promise | ScimGroup)) => { + return http.post('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2GroupsCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2GroupsRetrieveMockHandler = (overrideResponse?: ScimGroup | ((info: Parameters[1]>[0]) => Promise | ScimGroup)) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2GroupsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2GroupsUpdateMockHandler = (overrideResponse?: ScimGroup | ((info: Parameters[1]>[0]) => Promise | ScimGroup)) => { + return http.put('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2GroupsUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2GroupsPartialUpdateMockHandler = (overrideResponse?: ScimGroup | ((info: Parameters[1]>[0]) => Promise | ScimGroup)) => { + return http.patch('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2GroupsPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2GroupsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2ScimV2ResourceTypesRetrieveMockHandler = (overrideResponse?: ScimV2ResourceTypesRetrieve200 | ((info: Parameters[1]>[0]) => Promise | ScimV2ResourceTypesRetrieve200)) => { + return http.get('*/api/v2/scim/v2/:idpSlug/ResourceTypes', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2ResourceTypesRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2SchemasRetrieveMockHandler = (overrideResponse?: ScimV2SchemasRetrieve200 | ((info: Parameters[1]>[0]) => Promise | ScimV2SchemasRetrieve200)) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Schemas', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2SchemasRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler = (overrideResponse?: ScimV2ServiceProviderConfigRetrieve200 | ((info: Parameters[1]>[0]) => Promise | ScimV2ServiceProviderConfigRetrieve200)) => { + return http.get('*/api/v2/scim/v2/:idpSlug/ServiceProviderConfig', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2UsersListMockHandler = (overrideResponse?: PaginatedScimUserList | ((info: Parameters[1]>[0]) => Promise | PaginatedScimUserList)) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Users', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2UsersListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2UsersCreateMockHandler = (overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser)) => { + return http.post('*/api/v2/scim/v2/:idpSlug/Users', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2UsersCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2UsersRetrieveMockHandler = (overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser)) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2UsersRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2UsersUpdateMockHandler = (overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser)) => { + return http.put('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2UsersUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2UsersPartialUpdateMockHandler = (overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser)) => { + return http.patch('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ScimV2UsersPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ScimV2UsersDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} +export const getScimMock = () => [ + getApiV2ScimV2GroupsListMockHandler(), + getApiV2ScimV2GroupsCreateMockHandler(), + getApiV2ScimV2GroupsRetrieveMockHandler(), + getApiV2ScimV2GroupsUpdateMockHandler(), + getApiV2ScimV2GroupsPartialUpdateMockHandler(), + getApiV2ScimV2GroupsDestroyMockHandler(), + getApiV2ScimV2ResourceTypesRetrieveMockHandler(), + getApiV2ScimV2SchemasRetrieveMockHandler(), + getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler(), + getApiV2ScimV2UsersListMockHandler(), + getApiV2ScimV2UsersCreateMockHandler(), + getApiV2ScimV2UsersRetrieveMockHandler(), + getApiV2ScimV2UsersUpdateMockHandler(), + getApiV2ScimV2UsersPartialUpdateMockHandler(), + getApiV2ScimV2UsersDestroyMockHandler() +] diff --git a/jsapp/js/api/react-query/scim/scim.msw.ts b/jsapp/js/api/react-query/scim/scim.msw.ts deleted file mode 100644 index ec33e2a8a2..0000000000 --- a/jsapp/js/api/react-query/scim/scim.msw.ts +++ /dev/null @@ -1,487 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import type { PaginatedScimGroupList } from '../../models/paginatedScimGroupList' - -import type { PaginatedScimUserList } from '../../models/paginatedScimUserList' - -import type { ScimGroup } from '../../models/scimGroup' - -import type { ScimUser } from '../../models/scimUser' - -import type { ScimV2ResourceTypesRetrieve200 } from '../../models/scimV2ResourceTypesRetrieve200' - -import type { ScimV2SchemasRetrieve200 } from '../../models/scimV2SchemasRetrieve200' - -import type { ScimV2ServiceProviderConfigRetrieve200 } from '../../models/scimV2ServiceProviderConfigRetrieve200' - -export const getApiV2ScimV2GroupsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedScimGroupList => ({ - schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - totalResults: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - itemsPerPage: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - startIndex: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), - externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - members: {}, - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - ...overrideResponse, -}) - -export const getApiV2ScimV2GroupsCreateResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), - externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - members: {}, - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2GroupsRetrieveResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), - externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - members: {}, - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2GroupsUpdateResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), - externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - members: {}, - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2GroupsPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): ScimGroup => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), - externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - members: {}, - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2ResourceTypesRetrieveResponseMock = (): ScimV2ResourceTypesRetrieve200 => ({ - [faker.string.alphanumeric(5)]: {}, -}) - -export const getApiV2ScimV2SchemasRetrieveResponseMock = (): ScimV2SchemasRetrieve200 => ({ - [faker.string.alphanumeric(5)]: {}, -}) - -export const getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock = (): ScimV2ServiceProviderConfigRetrieve200 => ({ - [faker.string.alphanumeric(5)]: {}, -}) - -export const getApiV2ScimV2UsersListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedScimUserList => ({ - schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - totalResults: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - itemsPerPage: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - startIndex: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - userName: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: { - [faker.string.alphanumeric(5)]: {}, - }, - emails: {}, - active: faker.datatype.boolean(), - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - ...overrideResponse, -}) - -export const getApiV2ScimV2UsersCreateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - userName: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: { - [faker.string.alphanumeric(5)]: {}, - }, - emails: {}, - active: faker.datatype.boolean(), - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2UsersRetrieveResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - userName: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: { - [faker.string.alphanumeric(5)]: {}, - }, - emails: {}, - active: faker.datatype.boolean(), - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2UsersUpdateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - userName: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: { - [faker.string.alphanumeric(5)]: {}, - }, - emails: {}, - active: faker.datatype.boolean(), - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2UsersPartialUpdateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ - schemas: {}, - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - userName: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: { - [faker.string.alphanumeric(5)]: {}, - }, - emails: {}, - active: faker.datatype.boolean(), - meta: { - [faker.string.alphanumeric(5)]: {}, - }, - ...overrideResponse, -}) - -export const getApiV2ScimV2GroupsListMockHandler = ( - overrideResponse?: - | PaginatedScimGroupList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedScimGroupList), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2GroupsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2GroupsCreateMockHandler = ( - overrideResponse?: - | ScimGroup - | ((info: Parameters[1]>[0]) => Promise | ScimGroup), -) => { - return http.post('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2GroupsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2GroupsRetrieveMockHandler = ( - overrideResponse?: - | ScimGroup - | ((info: Parameters[1]>[0]) => Promise | ScimGroup), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2GroupsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2GroupsUpdateMockHandler = ( - overrideResponse?: - | ScimGroup - | ((info: Parameters[1]>[0]) => Promise | ScimGroup), -) => { - return http.put('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2GroupsUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2GroupsPartialUpdateMockHandler = ( - overrideResponse?: - | ScimGroup - | ((info: Parameters[1]>[0]) => Promise | ScimGroup), -) => { - return http.patch('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2GroupsPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2GroupsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2ScimV2ResourceTypesRetrieveMockHandler = ( - overrideResponse?: - | ScimV2ResourceTypesRetrieve200 - | (( - info: Parameters[1]>[0], - ) => Promise | ScimV2ResourceTypesRetrieve200), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/ResourceTypes', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2ResourceTypesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2SchemasRetrieveMockHandler = ( - overrideResponse?: - | ScimV2SchemasRetrieve200 - | (( - info: Parameters[1]>[0], - ) => Promise | ScimV2SchemasRetrieve200), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Schemas', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2SchemasRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler = ( - overrideResponse?: - | ScimV2ServiceProviderConfigRetrieve200 - | (( - info: Parameters[1]>[0], - ) => Promise | ScimV2ServiceProviderConfigRetrieve200), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/ServiceProviderConfig', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersListMockHandler = ( - overrideResponse?: - | PaginatedScimUserList - | ((info: Parameters[1]>[0]) => Promise | PaginatedScimUserList), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2UsersListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersCreateMockHandler = ( - overrideResponse?: - | ScimUser - | ((info: Parameters[1]>[0]) => Promise | ScimUser), -) => { - return http.post('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2UsersCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersRetrieveMockHandler = ( - overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), -) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2UsersRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersUpdateMockHandler = ( - overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), -) => { - return http.put('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2UsersUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersPartialUpdateMockHandler = ( - overrideResponse?: - | ScimUser - | ((info: Parameters[1]>[0]) => Promise | ScimUser), -) => { - return http.patch('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ScimV2UsersPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ScimV2UsersDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} -export const getScimMock = () => [ - getApiV2ScimV2GroupsListMockHandler(), - getApiV2ScimV2GroupsCreateMockHandler(), - getApiV2ScimV2GroupsRetrieveMockHandler(), - getApiV2ScimV2GroupsUpdateMockHandler(), - getApiV2ScimV2GroupsPartialUpdateMockHandler(), - getApiV2ScimV2GroupsDestroyMockHandler(), - getApiV2ScimV2ResourceTypesRetrieveMockHandler(), - getApiV2ScimV2SchemasRetrieveMockHandler(), - getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler(), - getApiV2ScimV2UsersListMockHandler(), - getApiV2ScimV2UsersCreateMockHandler(), - getApiV2ScimV2UsersRetrieveMockHandler(), - getApiV2ScimV2UsersUpdateMockHandler(), - getApiV2ScimV2UsersPartialUpdateMockHandler(), - getApiV2ScimV2UsersDestroyMockHandler(), -] diff --git a/jsapp/js/api/react-query/scim/scim.ts b/jsapp/js/api/react-query/scim/scim.ts deleted file mode 100644 index bc1385070e..0000000000 --- a/jsapp/js/api/react-query/scim/scim.ts +++ /dev/null @@ -1,1408 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { PaginatedScimGroupList } from '../../models/paginatedScimGroupList' - -import type { PaginatedScimUserList } from '../../models/paginatedScimUserList' - -import type { PatchedScimGroup } from '../../models/patchedScimGroup' - -import type { PatchedScimUser } from '../../models/patchedScimUser' - -import type { ScimError } from '../../models/scimError' - -import type { ScimGroup } from '../../models/scimGroup' - -import type { ScimUser } from '../../models/scimUser' - -import type { ScimV2GroupsListParams } from '../../models/scimV2GroupsListParams' - -import type { ScimV2ResourceTypesRetrieve200 } from '../../models/scimV2ResourceTypesRetrieve200' - -import type { ScimV2SchemasRetrieve200 } from '../../models/scimV2SchemasRetrieve200' - -import type { ScimV2ServiceProviderConfigRetrieve200 } from '../../models/scimV2ServiceProviderConfigRetrieve200' - -import type { ScimV2UsersCreate400 } from '../../models/scimV2UsersCreate400' - -import type { ScimV2UsersCreate409 } from '../../models/scimV2UsersCreate409' - -import type { ScimV2UsersListParams } from '../../models/scimV2UsersListParams' - -import type { ScimV2UsersUpdate409 } from '../../models/scimV2UsersUpdate409' - -import { fetchWithAuth } from '../../orval.mutator' - -// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B - -type WritableKeys = { - [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P> -}[keyof T] - -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never - -type Writable = Pick> -type NonReadonly = [T] extends [UnionToIntersection] - ? { - [P in keyof Writable]: T[P] extends object ? NonReadonly> : T[P] - } - : DistributeReadOnlyOverUnions - -type SecondParameter unknown> = Parameters[1] - -/** - * Returns a list of SCIM groups. - */ -export type scimV2GroupsListResponse200 = { - data: PaginatedScimGroupList - status: 200 -} - -export type scimV2GroupsListResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2GroupsListResponseComposite = scimV2GroupsListResponse200 | scimV2GroupsListResponse401 - -export type scimV2GroupsListResponse = scimV2GroupsListResponseComposite & { - headers: Headers -} - -export const getScimV2GroupsListUrl = (idpSlug: string, params?: ScimV2GroupsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/scim/v2/${idpSlug}/Groups?${stringifiedParams}` - : `/api/v2/scim/v2/${idpSlug}/Groups` -} - -export const scimV2GroupsList = async ( - idpSlug: string, - params?: ScimV2GroupsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2GroupsListUrl(idpSlug, params), { - ...options, - method: 'GET', - }) -} - -export const getScimV2GroupsListQueryKey = (idpSlug: string, params?: ScimV2GroupsListParams) => { - return ['api', 'v2', 'scim', 'v2', idpSlug, 'Groups', ...(params ? [params] : [])] as const -} - -export const getScimV2GroupsListQueryOptions = < - TData = Awaited>, - TError = ScimError, ->( - idpSlug: string, - params?: ScimV2GroupsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getScimV2GroupsListQueryKey(idpSlug, params) - - const queryFn: QueryFunction>> = ({ signal }) => - scimV2GroupsList(idpSlug, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!idpSlug, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ScimV2GroupsListQueryResult = NonNullable>> -export type ScimV2GroupsListQueryError = ScimError - -export function useScimV2GroupsList>, TError = ScimError>( - idpSlug: string, - params?: ScimV2GroupsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getScimV2GroupsListQueryOptions(idpSlug, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Creates a new SCIM group. - */ -export type scimV2GroupsCreateResponse201 = { - data: ScimGroup - status: 201 -} - -export type scimV2GroupsCreateResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2GroupsCreateResponseComposite = scimV2GroupsCreateResponse201 | scimV2GroupsCreateResponse401 - -export type scimV2GroupsCreateResponse = scimV2GroupsCreateResponseComposite & { - headers: Headers -} - -export const getScimV2GroupsCreateUrl = (idpSlug: string) => { - return `/api/v2/scim/v2/${idpSlug}/Groups` -} - -export const scimV2GroupsCreate = async ( - idpSlug: string, - scimGroup: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2GroupsCreateUrl(idpSlug), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify(scimGroup), - }) -} - -export const getScimV2GroupsCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; data: NonReadonly }, - TContext -> => { - const mutationKey = ['scimV2GroupsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { idpSlug: string; data: NonReadonly } - > = (props) => { - const { idpSlug, data } = props ?? {} - - return scimV2GroupsCreate(idpSlug, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ScimV2GroupsCreateMutationResult = NonNullable>> -export type ScimV2GroupsCreateMutationBody = NonReadonly -export type ScimV2GroupsCreateMutationError = ScimError - -export const useScimV2GroupsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getScimV2GroupsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Returns a specific SCIM group. - */ -export type scimV2GroupsRetrieveResponse200 = { - data: ScimGroup - status: 200 -} - -export type scimV2GroupsRetrieveResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2GroupsRetrieveResponseComposite = scimV2GroupsRetrieveResponse200 | scimV2GroupsRetrieveResponse401 - -export type scimV2GroupsRetrieveResponse = scimV2GroupsRetrieveResponseComposite & { - headers: Headers -} - -export const getScimV2GroupsRetrieveUrl = (idpSlug: string, id: string) => { - return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` -} - -export const scimV2GroupsRetrieve = async ( - idpSlug: string, - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2GroupsRetrieveUrl(idpSlug, id), { - ...options, - method: 'GET', - }) -} - -export const getScimV2GroupsRetrieveQueryKey = (idpSlug: string, id: string) => { - return ['api', 'v2', 'scim', 'v2', idpSlug, 'Groups', id] as const -} - -export const getScimV2GroupsRetrieveQueryOptions = < - TData = Awaited>, - TError = ScimError, ->( - idpSlug: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getScimV2GroupsRetrieveQueryKey(idpSlug, id) - - const queryFn: QueryFunction>> = ({ signal }) => - scimV2GroupsRetrieve(idpSlug, id, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(idpSlug && id), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ScimV2GroupsRetrieveQueryResult = NonNullable>> -export type ScimV2GroupsRetrieveQueryError = ScimError - -export function useScimV2GroupsRetrieve>, TError = ScimError>( - idpSlug: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getScimV2GroupsRetrieveQueryOptions(idpSlug, id, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Replaces a SCIM group entirely. - */ -export type scimV2GroupsUpdateResponse200 = { - data: ScimGroup - status: 200 -} - -export type scimV2GroupsUpdateResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2GroupsUpdateResponseComposite = scimV2GroupsUpdateResponse200 | scimV2GroupsUpdateResponse401 - -export type scimV2GroupsUpdateResponse = scimV2GroupsUpdateResponseComposite & { - headers: Headers -} - -export const getScimV2GroupsUpdateUrl = (idpSlug: string, id: string) => { - return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` -} - -export const scimV2GroupsUpdate = async ( - idpSlug: string, - id: string, - scimGroup: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2GroupsUpdateUrl(idpSlug, id), { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify(scimGroup), - }) -} - -export const getScimV2GroupsUpdateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: string; data: NonReadonly }, - TContext -> => { - const mutationKey = ['scimV2GroupsUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { idpSlug: string; id: string; data: NonReadonly } - > = (props) => { - const { idpSlug, id, data } = props ?? {} - - return scimV2GroupsUpdate(idpSlug, id, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ScimV2GroupsUpdateMutationResult = NonNullable>> -export type ScimV2GroupsUpdateMutationBody = NonReadonly -export type ScimV2GroupsUpdateMutationError = ScimError - -export const useScimV2GroupsUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getScimV2GroupsUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Updates a SCIM group. Supports adding/removing members via patch operations. - */ -export type scimV2GroupsPartialUpdateResponse200 = { - data: ScimGroup - status: 200 -} - -export type scimV2GroupsPartialUpdateResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2GroupsPartialUpdateResponseComposite = - | scimV2GroupsPartialUpdateResponse200 - | scimV2GroupsPartialUpdateResponse401 - -export type scimV2GroupsPartialUpdateResponse = scimV2GroupsPartialUpdateResponseComposite & { - headers: Headers -} - -export const getScimV2GroupsPartialUpdateUrl = (idpSlug: string, id: string) => { - return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` -} - -export const scimV2GroupsPartialUpdate = async ( - idpSlug: string, - id: string, - patchedScimGroup: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2GroupsPartialUpdateUrl(idpSlug, id), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify(patchedScimGroup), - }) -} - -export const getScimV2GroupsPartialUpdateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: string; data: NonReadonly }, - TContext -> => { - const mutationKey = ['scimV2GroupsPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { idpSlug: string; id: string; data: NonReadonly } - > = (props) => { - const { idpSlug, id, data } = props ?? {} - - return scimV2GroupsPartialUpdate(idpSlug, id, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ScimV2GroupsPartialUpdateMutationResult = NonNullable>> -export type ScimV2GroupsPartialUpdateMutationBody = NonReadonly -export type ScimV2GroupsPartialUpdateMutationError = ScimError - -export const useScimV2GroupsPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getScimV2GroupsPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Deletes a SCIM group. - */ -export type scimV2GroupsDestroyResponse204 = { - data: void - status: 204 -} - -export type scimV2GroupsDestroyResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2GroupsDestroyResponseComposite = scimV2GroupsDestroyResponse204 | scimV2GroupsDestroyResponse401 - -export type scimV2GroupsDestroyResponse = scimV2GroupsDestroyResponseComposite & { - headers: Headers -} - -export const getScimV2GroupsDestroyUrl = (idpSlug: string, id: string) => { - return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` -} - -export const scimV2GroupsDestroy = async ( - idpSlug: string, - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2GroupsDestroyUrl(idpSlug, id), { - ...options, - method: 'DELETE', - }) -} - -export const getScimV2GroupsDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: string }, - TContext -> => { - const mutationKey = ['scimV2GroupsDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { idpSlug: string; id: string } - > = (props) => { - const { idpSlug, id } = props ?? {} - - return scimV2GroupsDestroy(idpSlug, id, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ScimV2GroupsDestroyMutationResult = NonNullable>> - -export type ScimV2GroupsDestroyMutationError = ScimError - -export const useScimV2GroupsDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getScimV2GroupsDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Returns the SCIM supported ResourceTypes. - */ -export type scimV2ResourceTypesRetrieveResponse200 = { - data: ScimV2ResourceTypesRetrieve200 - status: 200 -} - -export type scimV2ResourceTypesRetrieveResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2ResourceTypesRetrieveResponseComposite = - | scimV2ResourceTypesRetrieveResponse200 - | scimV2ResourceTypesRetrieveResponse401 - -export type scimV2ResourceTypesRetrieveResponse = scimV2ResourceTypesRetrieveResponseComposite & { - headers: Headers -} - -export const getScimV2ResourceTypesRetrieveUrl = (idpSlug: string) => { - return `/api/v2/scim/v2/${idpSlug}/ResourceTypes` -} - -export const scimV2ResourceTypesRetrieve = async ( - idpSlug: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2ResourceTypesRetrieveUrl(idpSlug), { - ...options, - method: 'GET', - }) -} - -export const getScimV2ResourceTypesRetrieveQueryKey = (idpSlug: string) => { - return ['api', 'v2', 'scim', 'v2', idpSlug, 'ResourceTypes'] as const -} - -export const getScimV2ResourceTypesRetrieveQueryOptions = < - TData = Awaited>, - TError = ScimError, ->( - idpSlug: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getScimV2ResourceTypesRetrieveQueryKey(idpSlug) - - const queryFn: QueryFunction>> = ({ signal }) => - scimV2ResourceTypesRetrieve(idpSlug, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!idpSlug, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ScimV2ResourceTypesRetrieveQueryResult = NonNullable< - Awaited> -> -export type ScimV2ResourceTypesRetrieveQueryError = ScimError - -export function useScimV2ResourceTypesRetrieve< - TData = Awaited>, - TError = ScimError, ->( - idpSlug: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getScimV2ResourceTypesRetrieveQueryOptions(idpSlug, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Returns the SCIM supported Schemas. - */ -export type scimV2SchemasRetrieveResponse200 = { - data: ScimV2SchemasRetrieve200 - status: 200 -} - -export type scimV2SchemasRetrieveResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2SchemasRetrieveResponseComposite = scimV2SchemasRetrieveResponse200 | scimV2SchemasRetrieveResponse401 - -export type scimV2SchemasRetrieveResponse = scimV2SchemasRetrieveResponseComposite & { - headers: Headers -} - -export const getScimV2SchemasRetrieveUrl = (idpSlug: string) => { - return `/api/v2/scim/v2/${idpSlug}/Schemas` -} - -export const scimV2SchemasRetrieve = async ( - idpSlug: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2SchemasRetrieveUrl(idpSlug), { - ...options, - method: 'GET', - }) -} - -export const getScimV2SchemasRetrieveQueryKey = (idpSlug: string) => { - return ['api', 'v2', 'scim', 'v2', idpSlug, 'Schemas'] as const -} - -export const getScimV2SchemasRetrieveQueryOptions = < - TData = Awaited>, - TError = ScimError, ->( - idpSlug: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getScimV2SchemasRetrieveQueryKey(idpSlug) - - const queryFn: QueryFunction>> = ({ signal }) => - scimV2SchemasRetrieve(idpSlug, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!idpSlug, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ScimV2SchemasRetrieveQueryResult = NonNullable>> -export type ScimV2SchemasRetrieveQueryError = ScimError - -export function useScimV2SchemasRetrieve>, TError = ScimError>( - idpSlug: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getScimV2SchemasRetrieveQueryOptions(idpSlug, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Returns the SCIM Service Provider Configuration. - */ -export type scimV2ServiceProviderConfigRetrieveResponse200 = { - data: ScimV2ServiceProviderConfigRetrieve200 - status: 200 -} - -export type scimV2ServiceProviderConfigRetrieveResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2ServiceProviderConfigRetrieveResponseComposite = - | scimV2ServiceProviderConfigRetrieveResponse200 - | scimV2ServiceProviderConfigRetrieveResponse401 - -export type scimV2ServiceProviderConfigRetrieveResponse = scimV2ServiceProviderConfigRetrieveResponseComposite & { - headers: Headers -} - -export const getScimV2ServiceProviderConfigRetrieveUrl = (idpSlug: string) => { - return `/api/v2/scim/v2/${idpSlug}/ServiceProviderConfig` -} - -export const scimV2ServiceProviderConfigRetrieve = async ( - idpSlug: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getScimV2ServiceProviderConfigRetrieveUrl(idpSlug), - { - ...options, - method: 'GET', - }, - ) -} - -export const getScimV2ServiceProviderConfigRetrieveQueryKey = (idpSlug: string) => { - return ['api', 'v2', 'scim', 'v2', idpSlug, 'ServiceProviderConfig'] as const -} - -export const getScimV2ServiceProviderConfigRetrieveQueryOptions = < - TData = Awaited>, - TError = ScimError, ->( - idpSlug: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getScimV2ServiceProviderConfigRetrieveQueryKey(idpSlug) - - const queryFn: QueryFunction>> = ({ signal }) => - scimV2ServiceProviderConfigRetrieve(idpSlug, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!idpSlug, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ScimV2ServiceProviderConfigRetrieveQueryResult = NonNullable< - Awaited> -> -export type ScimV2ServiceProviderConfigRetrieveQueryError = ScimError - -export function useScimV2ServiceProviderConfigRetrieve< - TData = Awaited>, - TError = ScimError, ->( - idpSlug: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getScimV2ServiceProviderConfigRetrieveQueryOptions(idpSlug, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Returns a list of SCIM users matching the optional query - */ -export type scimV2UsersListResponse200 = { - data: PaginatedScimUserList - status: 200 -} - -export type scimV2UsersListResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2UsersListResponseComposite = scimV2UsersListResponse200 | scimV2UsersListResponse401 - -export type scimV2UsersListResponse = scimV2UsersListResponseComposite & { - headers: Headers -} - -export const getScimV2UsersListUrl = (idpSlug: string, params?: ScimV2UsersListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/scim/v2/${idpSlug}/Users?${stringifiedParams}` - : `/api/v2/scim/v2/${idpSlug}/Users` -} - -export const scimV2UsersList = async ( - idpSlug: string, - params?: ScimV2UsersListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2UsersListUrl(idpSlug, params), { - ...options, - method: 'GET', - }) -} - -export const getScimV2UsersListQueryKey = (idpSlug: string, params?: ScimV2UsersListParams) => { - return ['api', 'v2', 'scim', 'v2', idpSlug, 'Users', ...(params ? [params] : [])] as const -} - -export const getScimV2UsersListQueryOptions = >, TError = ScimError>( - idpSlug: string, - params?: ScimV2UsersListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getScimV2UsersListQueryKey(idpSlug, params) - - const queryFn: QueryFunction>> = ({ signal }) => - scimV2UsersList(idpSlug, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!idpSlug, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ScimV2UsersListQueryResult = NonNullable>> -export type ScimV2UsersListQueryError = ScimError - -export function useScimV2UsersList>, TError = ScimError>( - idpSlug: string, - params?: ScimV2UsersListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getScimV2UsersListQueryOptions(idpSlug, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Handle POST requests (user provisioning from IdP). - */ -export type scimV2UsersCreateResponse201 = { - data: ScimUser - status: 201 -} - -export type scimV2UsersCreateResponse400 = { - data: ScimV2UsersCreate400 - status: 400 -} - -export type scimV2UsersCreateResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2UsersCreateResponse409 = { - data: ScimV2UsersCreate409 - status: 409 -} - -export type scimV2UsersCreateResponseComposite = - | scimV2UsersCreateResponse201 - | scimV2UsersCreateResponse400 - | scimV2UsersCreateResponse401 - | scimV2UsersCreateResponse409 - -export type scimV2UsersCreateResponse = scimV2UsersCreateResponseComposite & { - headers: Headers -} - -export const getScimV2UsersCreateUrl = (idpSlug: string) => { - return `/api/v2/scim/v2/${idpSlug}/Users` -} - -export const scimV2UsersCreate = async ( - idpSlug: string, - scimUser: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2UsersCreateUrl(idpSlug), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify(scimUser), - }) -} - -export const getScimV2UsersCreateMutationOptions = < - TError = ScimV2UsersCreate400 | ScimError | ScimV2UsersCreate409, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; data: NonReadonly }, - TContext -> => { - const mutationKey = ['scimV2UsersCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { idpSlug: string; data: NonReadonly } - > = (props) => { - const { idpSlug, data } = props ?? {} - - return scimV2UsersCreate(idpSlug, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ScimV2UsersCreateMutationResult = NonNullable>> -export type ScimV2UsersCreateMutationBody = NonReadonly -export type ScimV2UsersCreateMutationError = ScimV2UsersCreate400 | ScimError | ScimV2UsersCreate409 - -export const useScimV2UsersCreate = < - TError = ScimV2UsersCreate400 | ScimError | ScimV2UsersCreate409, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getScimV2UsersCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Returns a specific SCIM user. - */ -export type scimV2UsersRetrieveResponse200 = { - data: ScimUser - status: 200 -} - -export type scimV2UsersRetrieveResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2UsersRetrieveResponseComposite = scimV2UsersRetrieveResponse200 | scimV2UsersRetrieveResponse401 - -export type scimV2UsersRetrieveResponse = scimV2UsersRetrieveResponseComposite & { - headers: Headers -} - -export const getScimV2UsersRetrieveUrl = (idpSlug: string, id: number) => { - return `/api/v2/scim/v2/${idpSlug}/Users/${id}` -} - -export const scimV2UsersRetrieve = async ( - idpSlug: string, - id: number, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2UsersRetrieveUrl(idpSlug, id), { - ...options, - method: 'GET', - }) -} - -export const getScimV2UsersRetrieveQueryKey = (idpSlug: string, id: number) => { - return ['api', 'v2', 'scim', 'v2', idpSlug, 'Users', id] as const -} - -export const getScimV2UsersRetrieveQueryOptions = < - TData = Awaited>, - TError = ScimError, ->( - idpSlug: string, - id: number, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getScimV2UsersRetrieveQueryKey(idpSlug, id) - - const queryFn: QueryFunction>> = ({ signal }) => - scimV2UsersRetrieve(idpSlug, id, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(idpSlug && id), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ScimV2UsersRetrieveQueryResult = NonNullable>> -export type ScimV2UsersRetrieveQueryError = ScimError - -export function useScimV2UsersRetrieve>, TError = ScimError>( - idpSlug: string, - id: number, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getScimV2UsersRetrieveQueryOptions(idpSlug, id, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * Handle PUT requests (user update from IdP). -Authentik can send a PUT request to update a user's details. If it tries to -update a user to have a username or email that already exists on another -account, we intercept the IntegrityError and return a SCIM 409 Conflict. - */ -export type scimV2UsersUpdateResponse200 = { - data: ScimUser - status: 200 -} - -export type scimV2UsersUpdateResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2UsersUpdateResponse409 = { - data: ScimV2UsersUpdate409 - status: 409 -} - -export type scimV2UsersUpdateResponseComposite = - | scimV2UsersUpdateResponse200 - | scimV2UsersUpdateResponse401 - | scimV2UsersUpdateResponse409 - -export type scimV2UsersUpdateResponse = scimV2UsersUpdateResponseComposite & { - headers: Headers -} - -export const getScimV2UsersUpdateUrl = (idpSlug: string, id: number) => { - return `/api/v2/scim/v2/${idpSlug}/Users/${id}` -} - -export const scimV2UsersUpdate = async ( - idpSlug: string, - id: number, - scimUser: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2UsersUpdateUrl(idpSlug, id), { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify(scimUser), - }) -} - -export const getScimV2UsersUpdateMutationOptions = < - TError = ScimError | ScimV2UsersUpdate409, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: number; data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ['scimV2UsersUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { idpSlug: string; id: number; data: NonReadonly } - > = (props) => { - const { idpSlug, id, data } = props ?? {} - - return scimV2UsersUpdate(idpSlug, id, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ScimV2UsersUpdateMutationResult = NonNullable>> -export type ScimV2UsersUpdateMutationBody = NonReadonly -export type ScimV2UsersUpdateMutationError = ScimError | ScimV2UsersUpdate409 - -export const useScimV2UsersUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: number; data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getScimV2UsersUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Updates a SCIM user. Currently only supports deactivation via the `active` attribute. - */ -export type scimV2UsersPartialUpdateResponse200 = { - data: ScimUser - status: 200 -} - -export type scimV2UsersPartialUpdateResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2UsersPartialUpdateResponseComposite = - | scimV2UsersPartialUpdateResponse200 - | scimV2UsersPartialUpdateResponse401 - -export type scimV2UsersPartialUpdateResponse = scimV2UsersPartialUpdateResponseComposite & { - headers: Headers -} - -export const getScimV2UsersPartialUpdateUrl = (idpSlug: string, id: number) => { - return `/api/v2/scim/v2/${idpSlug}/Users/${id}` -} - -export const scimV2UsersPartialUpdate = async ( - idpSlug: string, - id: number, - patchedScimUser: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2UsersPartialUpdateUrl(idpSlug, id), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify(patchedScimUser), - }) -} - -export const getScimV2UsersPartialUpdateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: number; data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: number; data: NonReadonly }, - TContext -> => { - const mutationKey = ['scimV2UsersPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { idpSlug: string; id: number; data: NonReadonly } - > = (props) => { - const { idpSlug, id, data } = props ?? {} - - return scimV2UsersPartialUpdate(idpSlug, id, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ScimV2UsersPartialUpdateMutationResult = NonNullable>> -export type ScimV2UsersPartialUpdateMutationBody = NonReadonly -export type ScimV2UsersPartialUpdateMutationError = ScimError - -export const useScimV2UsersPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: number; data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getScimV2UsersPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * Deactivates all Kobo accounts linked to the user's email address. - */ -export type scimV2UsersDestroyResponse204 = { - data: void - status: 204 -} - -export type scimV2UsersDestroyResponse401 = { - data: ScimError - status: 401 -} - -export type scimV2UsersDestroyResponseComposite = scimV2UsersDestroyResponse204 | scimV2UsersDestroyResponse401 - -export type scimV2UsersDestroyResponse = scimV2UsersDestroyResponseComposite & { - headers: Headers -} - -export const getScimV2UsersDestroyUrl = (idpSlug: string, id: number) => { - return `/api/v2/scim/v2/${idpSlug}/Users/${id}` -} - -export const scimV2UsersDestroy = async ( - idpSlug: string, - id: number, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getScimV2UsersDestroyUrl(idpSlug, id), { - ...options, - method: 'DELETE', - }) -} - -export const getScimV2UsersDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: number }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: number }, - TContext -> => { - const mutationKey = ['scimV2UsersDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { idpSlug: string; id: number } - > = (props) => { - const { idpSlug, id } = props ?? {} - - return scimV2UsersDestroy(idpSlug, id, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ScimV2UsersDestroyMutationResult = NonNullable>> - -export type ScimV2UsersDestroyMutationError = ScimError - -export const useScimV2UsersDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { idpSlug: string; id: number }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getScimV2UsersDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} diff --git a/jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.ts b/jsapp/js/api/react-query/server-logs-superusers/index.ts similarity index 50% rename from jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.ts rename to jsapp/js/api/react-query/server-logs-superusers/index.ts index d753203c53..e07153ced9 100644 --- a/jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.ts +++ b/jsapp/js/api/react-query/server-logs-superusers/index.ts @@ -9,45 +9,77 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { useMutation, useQuery } from '@tanstack/react-query' +import { + useMutation, + useQuery +} from '@tanstack/react-query'; import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' + UseQueryResult +} from '@tanstack/react-query'; -import type { AccessLogsListParams } from '../../models/accessLogsListParams' +import type { + AccessLogsListParams +} from '../../models/accessLogsListParams'; -import type { AuditLogsListParams } from '../../models/auditLogsListParams' +import type { + AuditLogsListParams +} from '../../models/auditLogsListParams'; -import type { ErrorDetail } from '../../models/errorDetail' +import type { + ErrorDetail +} from '../../models/errorDetail'; -import type { ErrorObject } from '../../models/errorObject' +import type { + ErrorObject +} from '../../models/errorObject'; -import type { ExportCreateResponse } from '../../models/exportCreateResponse' +import type { + ExportCreateResponse +} from '../../models/exportCreateResponse'; -import type { ExportHistoryResponse } from '../../models/exportHistoryResponse' +import type { + ExportHistoryResponse +} from '../../models/exportHistoryResponse'; -import type { ExportListResponse } from '../../models/exportListResponse' +import type { + ExportListResponse +} from '../../models/exportListResponse'; -import type { PaginatedAuditLogResponseList } from '../../models/paginatedAuditLogResponseList' +import type { + PaginatedAuditLogResponseList +} from '../../models/paginatedAuditLogResponseList'; -import type { PaginatedProjectHistoryLogResponseList } from '../../models/paginatedProjectHistoryLogResponseList' +import type { + PaginatedProjectHistoryLogResponseList +} from '../../models/paginatedProjectHistoryLogResponseList'; -import type { PaginatedSuperUserAccessLogResponseList } from '../../models/paginatedSuperUserAccessLogResponseList' +import type { + PaginatedSuperUserAccessLogResponseList +} from '../../models/paginatedSuperUserAccessLogResponseList'; -import type { PaginatedUserReportsListResponseList } from '../../models/paginatedUserReportsListResponseList' +import type { + PaginatedUserReportsListResponseList +} from '../../models/paginatedUserReportsListResponseList'; -import type { ProjectHistoryLogsListParams } from '../../models/projectHistoryLogsListParams' +import type { + ProjectHistoryLogsListParams +} from '../../models/projectHistoryLogsListParams'; + +import type { + UserReportsListParams +} from '../../models/userReportsListParams'; + +import { fetchWithAuth } from '../../orval.mutator'; -import type { UserReportsListParams } from '../../models/userReportsListParams' -import { fetchWithAuth } from '../../orval.mutator' +type SecondParameter unknown> = Parameters[1]; + -type SecondParameter unknown> = Parameters[1] /** * ## List all access logs for all users @@ -86,81 +118,85 @@ export type accessLogsListResponse403 = { data: ErrorDetail status: 403 } - -export type accessLogsListResponseComposite = accessLogsListResponse200 | accessLogsListResponse403 - + +export type accessLogsListResponseComposite = accessLogsListResponse200 | accessLogsListResponse403; + export type accessLogsListResponse = accessLogsListResponseComposite & { - headers: Headers + headers: Headers; } -export const getAccessLogsListUrl = (params?: AccessLogsListParams) => { - const normalizedParams = new URLSearchParams() +export const getAccessLogsListUrl = (params?: AccessLogsListParams,) => { + const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }) + }); - const stringifiedParams = normalizedParams.toString() + const stringifiedParams = normalizedParams.toString(); return stringifiedParams.length > 0 ? `/api/v2/access-logs/?${stringifiedParams}` : `/api/v2/access-logs/` } -export const accessLogsList = async ( - params?: AccessLogsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAccessLogsListUrl(params), { +export const accessLogsList = async (params?: AccessLogsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAccessLogsListUrl(params), + { ...options, - method: 'GET', - }) -} + method: 'GET' + + + } +);} -export const getAccessLogsListQueryKey = (params?: AccessLogsListParams) => { - return ['api', 'v2', 'access-logs', ...(params ? [params] : [])] as const -} -export const getAccessLogsListQueryOptions = >, TError = ErrorDetail>( - params?: AccessLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, + +export const getAccessLogsListQueryKey = (params?: AccessLogsListParams,) => { + return ['api','v2','access-logs', ...(params ? [params]: [])] as const; + } + + +export const getAccessLogsListQueryOptions = >, TError = ErrorDetail>(params?: AccessLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} ) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - const queryKey = queryOptions?.queryKey ?? getAccessLogsListQueryKey(params) +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAccessLogsListQueryKey(params); + + - const queryFn: QueryFunction>> = ({ signal }) => - accessLogsList(params, { signal, ...requestOptions }) + const queryFn: QueryFunction>> = ({ signal }) => accessLogsList(params, { signal, ...requestOptions }); - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } } export type AccessLogsListQueryResult = NonNullable>> export type AccessLogsListQueryError = ErrorDetail + + export function useAccessLogsList>, TError = ErrorDetail>( - params?: AccessLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAccessLogsListQueryOptions(params, options) + params?: AccessLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAccessLogsListQueryOptions(params,options) - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - query.queryKey = queryOptions.queryKey + query.queryKey = queryOptions.queryKey ; - return query + return query; } + + /** * ## List all access logs export tasks for all users @@ -176,68 +212,78 @@ export type accessLogsExportListResponse403 = { data: ErrorDetail status: 403 } - -export type accessLogsExportListResponseComposite = accessLogsExportListResponse200 | accessLogsExportListResponse403 - + +export type accessLogsExportListResponseComposite = accessLogsExportListResponse200 | accessLogsExportListResponse403; + export type accessLogsExportListResponse = accessLogsExportListResponseComposite & { - headers: Headers + headers: Headers; } export const getAccessLogsExportListUrl = () => { + + + + return `/api/v2/access-logs/export/` } -export const accessLogsExportList = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAccessLogsExportListUrl(), { +export const accessLogsExportList = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAccessLogsExportListUrl(), + { ...options, - method: 'GET', - }) -} + method: 'GET' + + + } +);} + + export const getAccessLogsExportListQueryKey = () => { - return ['api', 'v2', 'access-logs', 'export'] as const -} + return ['api','v2','access-logs','export'] as const; + } -export const getAccessLogsExportListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAccessLogsExportListQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - accessLogsExportList({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } + +export const getAccessLogsExportListQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAccessLogsExportListQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => accessLogsExportList({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } } export type AccessLogsExportListQueryResult = NonNullable>> export type AccessLogsExportListQueryError = ErrorDetail -export function useAccessLogsExportList< - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { + + +export function useAccessLogsExportList>, TError = ErrorDetail>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAccessLogsExportListQueryOptions(options) - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - query.queryKey = queryOptions.queryKey + query.queryKey = queryOptions.queryKey ; - return query + return query; } + + /** * ## Create an export task for all users @@ -253,57 +299,73 @@ export type accessLogsExportCreateResponse401 = { data: ErrorDetail status: 401 } - -export type accessLogsExportCreateResponseComposite = - | accessLogsExportCreateResponse202 - | accessLogsExportCreateResponse401 - + +export type accessLogsExportCreateResponseComposite = accessLogsExportCreateResponse202 | accessLogsExportCreateResponse401; + export type accessLogsExportCreateResponse = accessLogsExportCreateResponseComposite & { - headers: Headers + headers: Headers; } export const getAccessLogsExportCreateUrl = () => { + + + + return `/api/v2/access-logs/export/` } -export const accessLogsExportCreate = async (options?: RequestInit): Promise => { - return fetchWithAuth(getAccessLogsExportCreateUrl(), { +export const accessLogsExportCreate = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getAccessLogsExportCreateUrl(), + { ...options, - method: 'POST', - }) -} - -export const getAccessLogsExportCreateMutationOptions = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['accessLogsExportCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return accessLogsExportCreate(requestOptions) + method: 'POST' + + } +);} - return { mutationFn, ...mutationOptions } -} -export type AccessLogsExportCreateMutationResult = NonNullable>> -export type AccessLogsExportCreateMutationError = ErrorDetail -export const useAccessLogsExportCreate = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}) => { - const mutationOptions = getAccessLogsExportCreateMutationOptions(options) +export const getAccessLogsExportCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { - return useMutation(mutationOptions) -} -/** +const mutationKey = ['accessLogsExportCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return accessLogsExportCreate(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AccessLogsExportCreateMutationResult = NonNullable>> + + export type AccessLogsExportCreateMutationError = ErrorDetail + + export const useAccessLogsExportCreate = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAccessLogsExportCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** * ## List actions performed by users. ⚠️ _Only available to superusers_ @@ -369,81 +431,85 @@ export type auditLogsListResponse403 = { data: ErrorDetail status: 403 } - -export type auditLogsListResponseComposite = auditLogsListResponse200 | auditLogsListResponse403 - + +export type auditLogsListResponseComposite = auditLogsListResponse200 | auditLogsListResponse403; + export type auditLogsListResponse = auditLogsListResponseComposite & { - headers: Headers + headers: Headers; } -export const getAuditLogsListUrl = (params?: AuditLogsListParams) => { - const normalizedParams = new URLSearchParams() +export const getAuditLogsListUrl = (params?: AuditLogsListParams,) => { + const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }) + }); - const stringifiedParams = normalizedParams.toString() + const stringifiedParams = normalizedParams.toString(); return stringifiedParams.length > 0 ? `/api/v2/audit-logs/?${stringifiedParams}` : `/api/v2/audit-logs/` } -export const auditLogsList = async ( - params?: AuditLogsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAuditLogsListUrl(params), { +export const auditLogsList = async (params?: AuditLogsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAuditLogsListUrl(params), + { ...options, - method: 'GET', - }) -} + method: 'GET' + + + } +);} -export const getAuditLogsListQueryKey = (params?: AuditLogsListParams) => { - return ['api', 'v2', 'audit-logs', ...(params ? [params] : [])] as const -} -export const getAuditLogsListQueryOptions = >, TError = ErrorDetail>( - params?: AuditLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, + +export const getAuditLogsListQueryKey = (params?: AuditLogsListParams,) => { + return ['api','v2','audit-logs', ...(params ? [params]: [])] as const; + } + + +export const getAuditLogsListQueryOptions = >, TError = ErrorDetail>(params?: AuditLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} ) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - const queryKey = queryOptions?.queryKey ?? getAuditLogsListQueryKey(params) +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAuditLogsListQueryKey(params); + + - const queryFn: QueryFunction>> = ({ signal }) => - auditLogsList(params, { signal, ...requestOptions }) + const queryFn: QueryFunction>> = ({ signal }) => auditLogsList(params, { signal, ...requestOptions }); - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } } export type AuditLogsListQueryResult = NonNullable>> export type AuditLogsListQueryError = ErrorDetail + + export function useAuditLogsList>, TError = ErrorDetail>( - params?: AuditLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAuditLogsListQueryOptions(params, options) + params?: AuditLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAuditLogsListQueryOptions(params,options) - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - query.queryKey = queryOptions.queryKey + query.queryKey = queryOptions.queryKey ; - return query + return query; } + + /** * ## List all project history logs for all projects. @@ -641,91 +707,85 @@ export type projectHistoryLogsListResponse403 = { data: ErrorDetail status: 403 } - -export type projectHistoryLogsListResponseComposite = - | projectHistoryLogsListResponse200 - | projectHistoryLogsListResponse403 - + +export type projectHistoryLogsListResponseComposite = projectHistoryLogsListResponse200 | projectHistoryLogsListResponse403; + export type projectHistoryLogsListResponse = projectHistoryLogsListResponseComposite & { - headers: Headers + headers: Headers; } -export const getProjectHistoryLogsListUrl = (params?: ProjectHistoryLogsListParams) => { - const normalizedParams = new URLSearchParams() +export const getProjectHistoryLogsListUrl = (params?: ProjectHistoryLogsListParams,) => { + const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }) + }); - const stringifiedParams = normalizedParams.toString() + const stringifiedParams = normalizedParams.toString(); - return stringifiedParams.length > 0 - ? `/api/v2/project-history-logs/?${stringifiedParams}` - : `/api/v2/project-history-logs/` + return stringifiedParams.length > 0 ? `/api/v2/project-history-logs/?${stringifiedParams}` : `/api/v2/project-history-logs/` } -export const projectHistoryLogsList = async ( - params?: ProjectHistoryLogsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectHistoryLogsListUrl(params), { +export const projectHistoryLogsList = async (params?: ProjectHistoryLogsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectHistoryLogsListUrl(params), + { ...options, - method: 'GET', - }) -} + method: 'GET' + + + } +);} -export const getProjectHistoryLogsListQueryKey = (params?: ProjectHistoryLogsListParams) => { - return ['api', 'v2', 'project-history-logs', ...(params ? [params] : [])] as const -} -export const getProjectHistoryLogsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: ProjectHistoryLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, + +export const getProjectHistoryLogsListQueryKey = (params?: ProjectHistoryLogsListParams,) => { + return ['api','v2','project-history-logs', ...(params ? [params]: [])] as const; + } + + +export const getProjectHistoryLogsListQueryOptions = >, TError = ErrorDetail>(params?: ProjectHistoryLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} ) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsListQueryKey(params) +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsListQueryKey(params); + + - const queryFn: QueryFunction>> = ({ signal }) => - projectHistoryLogsList(params, { signal, ...requestOptions }) + const queryFn: QueryFunction>> = ({ signal }) => projectHistoryLogsList(params, { signal, ...requestOptions }); - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } } export type ProjectHistoryLogsListQueryResult = NonNullable>> export type ProjectHistoryLogsListQueryError = ErrorDetail -export function useProjectHistoryLogsList< - TData = Awaited>, - TError = ErrorDetail, ->( - params?: ProjectHistoryLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectHistoryLogsListQueryOptions(params, options) - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey +export function useProjectHistoryLogsList>, TError = ErrorDetail>( + params?: ProjectHistoryLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectHistoryLogsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; - return query + return query; } + + /** * ## List of Project History Exports @@ -741,74 +801,78 @@ export type projectHistoryLogsExportRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type projectHistoryLogsExportRetrieveResponseComposite = - | projectHistoryLogsExportRetrieveResponse202 - | projectHistoryLogsExportRetrieveResponse403 - + +export type projectHistoryLogsExportRetrieveResponseComposite = projectHistoryLogsExportRetrieveResponse202 | projectHistoryLogsExportRetrieveResponse403; + export type projectHistoryLogsExportRetrieveResponse = projectHistoryLogsExportRetrieveResponseComposite & { - headers: Headers + headers: Headers; } export const getProjectHistoryLogsExportRetrieveUrl = () => { + + + + return `/api/v2/project-history-logs/export/` } -export const projectHistoryLogsExportRetrieve = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectHistoryLogsExportRetrieveUrl(), { +export const projectHistoryLogsExportRetrieve = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectHistoryLogsExportRetrieveUrl(), + { ...options, - method: 'GET', - }) -} + method: 'GET' + + + } +);} + + export const getProjectHistoryLogsExportRetrieveQueryKey = () => { - return ['api', 'v2', 'project-history-logs', 'export'] as const -} + return ['api','v2','project-history-logs','export'] as const; + } + + +export const getProjectHistoryLogsExportRetrieveQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsExportRetrieveQueryKey(); -export const getProjectHistoryLogsExportRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsExportRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - projectHistoryLogsExportRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } + + + const queryFn: QueryFunction>> = ({ signal }) => projectHistoryLogsExportRetrieve({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } } -export type ProjectHistoryLogsExportRetrieveQueryResult = NonNullable< - Awaited> -> +export type ProjectHistoryLogsExportRetrieveQueryResult = NonNullable>> export type ProjectHistoryLogsExportRetrieveQueryError = ErrorDetail -export function useProjectHistoryLogsExportRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { + + +export function useProjectHistoryLogsExportRetrieve>, TError = ErrorDetail>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectHistoryLogsExportRetrieveQueryOptions(options) - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - query.queryKey = queryOptions.queryKey + query.queryKey = queryOptions.queryKey ; - return query + return query; } + + /** * ## Create an export of projects history logs @@ -826,61 +890,73 @@ export type projectHistoryLogsExportCreateResponse403 = { data: ErrorDetail status: 403 } - -export type projectHistoryLogsExportCreateResponseComposite = - | projectHistoryLogsExportCreateResponse202 - | projectHistoryLogsExportCreateResponse403 - + +export type projectHistoryLogsExportCreateResponseComposite = projectHistoryLogsExportCreateResponse202 | projectHistoryLogsExportCreateResponse403; + export type projectHistoryLogsExportCreateResponse = projectHistoryLogsExportCreateResponseComposite & { - headers: Headers + headers: Headers; } export const getProjectHistoryLogsExportCreateUrl = () => { + + + + return `/api/v2/project-history-logs/export/` } -export const projectHistoryLogsExportCreate = async ( - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectHistoryLogsExportCreateUrl(), { +export const projectHistoryLogsExportCreate = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectHistoryLogsExportCreateUrl(), + { ...options, - method: 'POST', - }) -} - -export const getProjectHistoryLogsExportCreateMutationOptions = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['projectHistoryLogsExportCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return projectHistoryLogsExportCreate(requestOptions) + method: 'POST' + + } +);} - return { mutationFn, ...mutationOptions } -} -export type ProjectHistoryLogsExportCreateMutationResult = NonNullable< - Awaited> -> -export type ProjectHistoryLogsExportCreateMutationError = ErrorDetail -export const useProjectHistoryLogsExportCreate = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}) => { - const mutationOptions = getProjectHistoryLogsExportCreateMutationOptions(options) +export const getProjectHistoryLogsExportCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { - return useMutation(mutationOptions) -} -/** +const mutationKey = ['projectHistoryLogsExportCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return projectHistoryLogsExportCreate(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ProjectHistoryLogsExportCreateMutationResult = NonNullable>> + + export type ProjectHistoryLogsExportCreateMutationError = ErrorDetail + + export const useProjectHistoryLogsExportCreate = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getProjectHistoryLogsExportCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** * # List user reports ⚠️ _Only available to superusers_ @@ -994,86 +1070,82 @@ export type userReportsListResponse403 = { data: ErrorDetail status: 403 } - -export type userReportsListResponseComposite = - | userReportsListResponse200 - | userReportsListResponse400 - | userReportsListResponse403 - + +export type userReportsListResponseComposite = userReportsListResponse200 | userReportsListResponse400 | userReportsListResponse403; + export type userReportsListResponse = userReportsListResponseComposite & { - headers: Headers + headers: Headers; } -export const getUserReportsListUrl = (params?: UserReportsListParams) => { - const normalizedParams = new URLSearchParams() +export const getUserReportsListUrl = (params?: UserReportsListParams,) => { + const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { + if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }) + }); - const stringifiedParams = normalizedParams.toString() + const stringifiedParams = normalizedParams.toString(); return stringifiedParams.length > 0 ? `/api/v2/user-reports/?${stringifiedParams}` : `/api/v2/user-reports/` } -export const userReportsList = async ( - params?: UserReportsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getUserReportsListUrl(params), { +export const userReportsList = async (params?: UserReportsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getUserReportsListUrl(params), + { ...options, - method: 'GET', - }) -} + method: 'GET' + + + } +);} -export const getUserReportsListQueryKey = (params?: UserReportsListParams) => { - return ['api', 'v2', 'user-reports', ...(params ? [params] : [])] as const -} -export const getUserReportsListQueryOptions = < - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - params?: UserReportsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, + +export const getUserReportsListQueryKey = (params?: UserReportsListParams,) => { + return ['api','v2','user-reports', ...(params ? [params]: [])] as const; + } + + +export const getUserReportsListQueryOptions = >, TError = ErrorObject | ErrorDetail>(params?: UserReportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} ) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - const queryKey = queryOptions?.queryKey ?? getUserReportsListQueryKey(params) +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getUserReportsListQueryKey(params); + + - const queryFn: QueryFunction>> = ({ signal }) => - userReportsList(params, { signal, ...requestOptions }) + const queryFn: QueryFunction>> = ({ signal }) => userReportsList(params, { signal, ...requestOptions }); - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } } export type UserReportsListQueryResult = NonNullable>> export type UserReportsListQueryError = ErrorObject | ErrorDetail -export function useUserReportsList< - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - params?: UserReportsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getUserReportsListQueryOptions(params, options) - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey +export function useUserReportsList>, TError = ErrorObject | ErrorDetail>( + params?: UserReportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getUserReportsListQueryOptions(params,options) - return query + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; } + + + diff --git a/jsapp/js/api/react-query/server-logs-superusers/msw.ts b/jsapp/js/api/react-query/server-logs-superusers/msw.ts new file mode 100644 index 0000000000..66ca28f3ae --- /dev/null +++ b/jsapp/js/api/react-query/server-logs-superusers/msw.ts @@ -0,0 +1,159 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import type { + ExportCreateResponse +} from '../../models/exportCreateResponse'; + +import type { + ExportHistoryResponse +} from '../../models/exportHistoryResponse'; + +import type { + ExportListResponse +} from '../../models/exportListResponse'; + +import type { + PaginatedAuditLogResponseList +} from '../../models/paginatedAuditLogResponseList'; + +import type { + PaginatedProjectHistoryLogResponseList +} from '../../models/paginatedProjectHistoryLogResponseList'; + +import type { + PaginatedSuperUserAccessLogResponseList +} from '../../models/paginatedSuperUserAccessLogResponseList'; + +import type { + PaginatedUserReportsListResponseList +} from '../../models/paginatedUserReportsListResponseList'; + +import type { + ServiceUsageBalanceData +} from '../../models/serviceUsageBalanceData'; + + +export const getApiV2AccessLogsListResponseMock = (overrideResponse: Partial< PaginatedSuperUserAccessLogResponseList > = {}): PaginatedSuperUserAccessLogResponseList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, username: faker.string.alpha({length: {min: 10, max: 20}}), metadata: {source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), auth_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), initial_user_username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), authorized_app_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, user_uid: faker.string.alpha({length: {min: 10, max: 20}}), count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), action: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) + +export const getApiV2AccessLogsExportListResponseMock = (): ExportListResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 24}}), status: faker.string.alpha({length: {min: 10, max: 32}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`}))) + +export const getApiV2AccessLogsExportCreateResponseMock = (overrideResponse: Partial< ExportCreateResponse > = {}): ExportCreateResponse => ({status: faker.string.alpha({length: {min: 10, max: 32}}), ...overrideResponse}) + +export const getApiV2AuditLogsListResponseMock = (overrideResponse: Partial< PaginatedAuditLogResponseList > = {}): PaginatedAuditLogResponseList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({app_label: faker.string.alpha({length: {min: 10, max: 20}}), model_name: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.internet.url(), user_uid: faker.string.alpha({length: {min: 10, max: 20}}), username: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.string.alpha({length: {min: 10, max: 20}}), metadata: {source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), old: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), country: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), removed: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), description: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country_codes: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), 'data-table': faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined])}, undefined])}, undefined]), asset_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), auth_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), log_subtype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_owner: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'asset-files': faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), md5_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), download_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), permissions: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), latest_deployed_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submission: faker.helpers.arrayElement([{root_uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submitted_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), hook: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), bulk_action: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), action_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), question_xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), params: faker.helpers.arrayElement([{}, undefined]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cancelled_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), total_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), processed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), completed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), failed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), cancelled_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), name: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), shared_fields: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, log_type: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) + +export const getApiV2ProjectHistoryLogsListResponseMock = (overrideResponse: Partial< PaginatedProjectHistoryLogResponseList > = {}): PaginatedProjectHistoryLogResponseList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user: faker.internet.url(), user_uid: faker.string.alpha({length: {min: 10, max: 20}}), username: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.string.alpha({length: {min: 10, max: 20}}), metadata: {source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cloned_from: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), log_subtype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'paired-data': faker.helpers.arrayElement([{fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), source_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), old: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), country: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), removed: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), description: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country_codes: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), 'data-table': faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined])}, undefined])}, undefined]), 'asset-files': faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), md5_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), download_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), permissions: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), project_owner: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submission: faker.helpers.arrayElement([{root_uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submitted_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), hook: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), bulk_action: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), action_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), question_xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), params: faker.helpers.arrayElement([{}, undefined]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cancelled_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), total_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), processed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), completed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), failed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), cancelled_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), name: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), shared_fields: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) + +export const getApiV2ProjectHistoryLogsExportRetrieveResponseMock = (overrideResponse: Partial< ExportHistoryResponse > = {}): ExportHistoryResponse => ({status: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2ProjectHistoryLogsExportCreateResponseMock = (overrideResponse: Partial< ExportHistoryResponse > = {}): ExportHistoryResponse => ({status: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2UserReportsListResponseServiceUsageBalanceDataMock = (overrideResponse: Partial = {}): ServiceUsageBalanceData => ({...{effective_limit: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_value: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_percent: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), exceeded: faker.datatype.boolean()}, ...overrideResponse}); + +export const getApiV2UserReportsListResponseMock = (overrideResponse: Partial< PaginatedUserReportsListResponseList > = {}): PaginatedUserReportsListResponseList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user_uid: faker.string.alpha({length: {min: 10, max: 20}}), username: faker.string.alpha({length: {min: 10, max: 20}}), first_name: faker.string.alpha({length: {min: 10, max: 20}}), last_name: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.internet.email(), is_superuser: faker.datatype.boolean(), is_staff: faker.datatype.boolean(), is_active: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, validated_email: faker.datatype.boolean(), mfa_is_active: faker.datatype.boolean(), sso_is_active: faker.datatype.boolean(), accepted_tos: faker.datatype.boolean(), social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({provider: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), email: faker.helpers.arrayElement([faker.internet.email(), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), organizations: {organization_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), role: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, extra_details: {data: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), sector: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_ui_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_website: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), newsletter_subscription: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), date_removed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), validated_password: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), password_date_changed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_removal_requested: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined])}, subscriptions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({items: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), price: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), nickname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), currency: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), recurring: faker.helpers.arrayElement([{meter: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), interval: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), usage_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), interval_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), aggregate_usage: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), trial_period_days: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), unit_amount: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), human_readable_price: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined]), active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), product: faker.helpers.arrayElement([{id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{product_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), storage_bytes_limit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), transform_quantity: faker.helpers.arrayElement([{divide_by: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), round: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])})), undefined]), quantity: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])})), undefined]), schedule: faker.helpers.arrayElement([{phases: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({items: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({plan: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), price: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined]), quantity: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), tax_rates: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.number.int({min: undefined, max: undefined, multipleOf: undefined}))), undefined]), billing_thresholds: faker.helpers.arrayElement([{}, undefined])})), undefined]), coupon: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), currency: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), end_date: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined]), trial_end: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), start_date: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), on_behalf_of: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), automatic_tax: faker.helpers.arrayElement([{}, undefined]), transfer_data: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), invoice_settings: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), add_invoice_items: faker.helpers.arrayElement([{}, undefined]), collection_method: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_tax_rates: faker.helpers.arrayElement([{}, undefined]), billing_thresholds: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), proration_behavior: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), billing_cycle_anchor: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), default_payment_method: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), application_fee_percent: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])})), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), djstripe_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), djstripe_updated: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{request_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kpi_owner_user_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kpi_owner_username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), application_fee_percent: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined]), billing_cycle_anchor: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), billing_thresholds: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cancel_at: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), canceled_at: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collection_method: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), current_period_end: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), current_period_start: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), days_until_due: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), discount: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ended_at: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), next_pending_invoice_item_invoice: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), pause_collection: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), pending_invoice_item_interval: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), pending_update: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), proration_behavior: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), proration_date: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), quantity: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), start_date: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), trial_end: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), trial_start: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), djstripe_owner_account: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), customer: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_payment_method: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_invoice: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), pending_setup_intent: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), plan: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), default_tax_rates: faker.helpers.arrayElement([{}, undefined])})), service_usage: {total_nlp_usage: {asr_seconds_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), asr_seconds_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, total_storage_bytes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_submission_count: {retention_days: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), cumulative: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), current_period: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, balances: {submission: faker.helpers.arrayElement([{...getApiV2UserReportsListResponseServiceUsageBalanceDataMock()},null,]), storage_bytes: faker.helpers.arrayElement([{...getApiV2UserReportsListResponseServiceUsageBalanceDataMock()},null,]), asr_seconds: faker.helpers.arrayElement([{...getApiV2UserReportsListResponseServiceUsageBalanceDataMock()},null,]), mt_characters: faker.helpers.arrayElement([{...getApiV2UserReportsListResponseServiceUsageBalanceDataMock()},null,]), llm_requests: faker.helpers.arrayElement([{...getApiV2UserReportsListResponseServiceUsageBalanceDataMock()},null,])}, current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`}, account_restricted: faker.datatype.boolean(), asset_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), active_project_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) + + +export const getApiV2AccessLogsListMockHandler = (overrideResponse?: PaginatedSuperUserAccessLogResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedSuperUserAccessLogResponseList)) => { + return http.get('*/api/v2/access-logs/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AccessLogsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AccessLogsExportListMockHandler = (overrideResponse?: ExportListResponse[] | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[])) => { + return http.get('*/api/v2/access-logs/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AccessLogsExportListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AccessLogsExportCreateMockHandler = (overrideResponse?: ExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse)) => { + return http.post('*/api/v2/access-logs/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AccessLogsExportCreateResponseMock()), + { status: 202, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AuditLogsListMockHandler = (overrideResponse?: PaginatedAuditLogResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAuditLogResponseList)) => { + return http.get('*/api/v2/audit-logs/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AuditLogsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectHistoryLogsListMockHandler = (overrideResponse?: PaginatedProjectHistoryLogResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedProjectHistoryLogResponseList)) => { + return http.get('*/api/v2/project-history-logs/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectHistoryLogsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectHistoryLogsExportRetrieveMockHandler = (overrideResponse?: ExportHistoryResponse | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse)) => { + return http.get('*/api/v2/project-history-logs/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectHistoryLogsExportRetrieveResponseMock()), + { status: 202, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectHistoryLogsExportCreateMockHandler = (overrideResponse?: ExportHistoryResponse | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse)) => { + return http.post('*/api/v2/project-history-logs/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectHistoryLogsExportCreateResponseMock()), + { status: 202, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2UserReportsListMockHandler = (overrideResponse?: PaginatedUserReportsListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedUserReportsListResponseList)) => { + return http.get('*/api/v2/user-reports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2UserReportsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} +export const getServerLogsSuperusersMock = () => [ + getApiV2AccessLogsListMockHandler(), + getApiV2AccessLogsExportListMockHandler(), + getApiV2AccessLogsExportCreateMockHandler(), + getApiV2AuditLogsListMockHandler(), + getApiV2ProjectHistoryLogsListMockHandler(), + getApiV2ProjectHistoryLogsExportRetrieveMockHandler(), + getApiV2ProjectHistoryLogsExportCreateMockHandler(), + getApiV2UserReportsListMockHandler() +] diff --git a/jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.msw.ts b/jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.msw.ts deleted file mode 100644 index 4b094c7f3a..0000000000 --- a/jsapp/js/api/react-query/server-logs-superusers/server-logs-superusers.msw.ts +++ /dev/null @@ -1,1062 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import type { ExportCreateResponse } from '../../models/exportCreateResponse' - -import type { ExportHistoryResponse } from '../../models/exportHistoryResponse' - -import type { ExportListResponse } from '../../models/exportListResponse' - -import type { PaginatedAuditLogResponseList } from '../../models/paginatedAuditLogResponseList' - -import type { PaginatedProjectHistoryLogResponseList } from '../../models/paginatedProjectHistoryLogResponseList' - -import type { PaginatedSuperUserAccessLogResponseList } from '../../models/paginatedSuperUserAccessLogResponseList' - -import type { PaginatedUserReportsListResponseList } from '../../models/paginatedUserReportsListResponseList' - -import type { ServiceUsageBalanceData } from '../../models/serviceUsageBalanceData' - -export const getApiV2AccessLogsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedSuperUserAccessLogResponseList => ({ - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: { - source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - initial_user_username: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - authorized_app_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - action: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2AccessLogsExportListResponseMock = (): ExportListResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 24 } }), - status: faker.string.alpha({ length: { min: 10, max: 32 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - })) - -export const getApiV2AccessLogsExportCreateResponseMock = ( - overrideResponse: Partial = {}, -): ExportCreateResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 32 } }), ...overrideResponse }) - -export const getApiV2AuditLogsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAuditLogResponseList => ({ - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - app_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - model_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: faker.internet.url(), - user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: { - source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - old: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - removed: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - description: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - 'data-table': faker.helpers.arrayElement([ - { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, - undefined, - ]), - }, - undefined, - ]), - asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'asset-files': faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - permissions: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - latest_deployed_version_uid: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - submission: faker.helpers.arrayElement([ - { - root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - hook: faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - undefined, - ]), - bulk_action: faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - params: faker.helpers.arrayElement([{}, undefined]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - total_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - processed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - completed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - failed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - cancelled_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - name: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - shared_fields: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - log_type: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectHistoryLogsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedProjectHistoryLogResponseList => ({ - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user: faker.internet.url(), - user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.string.alpha({ length: { min: 10, max: 20 } }), - metadata: { - source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - cloned_from: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'paired-data': faker.helpers.arrayElement([ - { - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - source_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - old: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - removed: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - description: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - 'data-table': faker.helpers.arrayElement([ - { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, - undefined, - ]), - }, - undefined, - ]), - 'asset-files': faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - permissions: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - submission: faker.helpers.arrayElement([ - { - root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - hook: faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - undefined, - ]), - bulk_action: faker.helpers.arrayElement([ - { - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - params: faker.helpers.arrayElement([{}, undefined]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - total_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - processed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - completed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - failed_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - cancelled_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - name: faker.helpers.arrayElement([ - { - new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - shared_fields: faker.helpers.arrayElement([ - { - added: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - removed: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - ...overrideResponse, -}) - -export const getApiV2ProjectHistoryLogsExportRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ExportHistoryResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2ProjectHistoryLogsExportCreateResponseMock = ( - overrideResponse: Partial = {}, -): ExportHistoryResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2UserReportsListResponseServiceUsageBalanceDataMock = ( - overrideResponse: Partial = {}, -): ServiceUsageBalanceData => ({ - ...{ - effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - exceeded: faker.datatype.boolean(), - }, - ...overrideResponse, -}) - -export const getApiV2UserReportsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedUserReportsListResponseList => ({ - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.internet.email(), - is_superuser: faker.datatype.boolean(), - is_staff: faker.datatype.boolean(), - is_active: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, - validated_email: faker.datatype.boolean(), - mfa_is_active: faker.datatype.boolean(), - sso_is_active: faker.datatype.boolean(), - accepted_tos: faker.datatype.boolean(), - social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - email: faker.helpers.arrayElement([faker.internet.email(), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - organizations: { - organization_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - role: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - extra_details: { - data: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_ui_language: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - organization_type: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - organization_website: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - newsletter_subscription: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - undefined, - ]), - date_removed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - validated_password: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - password_date_changed: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - date_removal_requested: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - }, - subscriptions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - items: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - price: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - currency: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - recurring: faker.helpers.arrayElement([ - { - meter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - interval: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - usage_type: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - interval_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - aggregate_usage: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - trial_period_days: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - unit_amount: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - human_readable_price: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - metadata: faker.helpers.arrayElement([{}, undefined]), - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - product: faker.helpers.arrayElement([ - { - id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - description: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([ - { - product_type: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - storage_bytes_limit: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - transform_quantity: faker.helpers.arrayElement([ - { - divide_by: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - round: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - })), - undefined, - ]), - quantity: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - })), - undefined, - ]), - schedule: faker.helpers.arrayElement([ - { - phases: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - items: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - plan: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - price: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([{}, undefined]), - quantity: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - tax_rates: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ), - undefined, - ]), - billing_thresholds: faker.helpers.arrayElement([{}, undefined]), - })), - undefined, - ]), - coupon: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - currency: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - end_date: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - metadata: faker.helpers.arrayElement([{}, undefined]), - trial_end: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - start_date: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - description: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - on_behalf_of: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - automatic_tax: faker.helpers.arrayElement([{}, undefined]), - transfer_data: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - invoice_settings: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - add_invoice_items: faker.helpers.arrayElement([{}, undefined]), - collection_method: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_tax_rates: faker.helpers.arrayElement([{}, undefined]), - billing_thresholds: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - proration_behavior: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - billing_cycle_anchor: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - default_payment_method: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - application_fee_percent: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - })), - undefined, - ]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - djstripe_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - djstripe_updated: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([ - { - request_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_id: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - kpi_owner_user_id: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - kpi_owner_username: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - application_fee_percent: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - billing_cycle_anchor: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - billing_thresholds: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - cancel_at: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - canceled_at: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collection_method: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - current_period_end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - current_period_start: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - days_until_due: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - discount: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - ended_at: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - next_pending_invoice_item_invoice: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - pause_collection: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - pending_invoice_item_interval: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - pending_update: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - proration_behavior: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - proration_date: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - quantity: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - start_date: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - trial_end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - trial_start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - djstripe_owner_account: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - customer: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - default_payment_method: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - latest_invoice: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - pending_setup_intent: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - plan: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - default_tax_rates: faker.helpers.arrayElement([{}, undefined]), - })), - service_usage: { - total_nlp_usage: { - asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_submission_count: { - retention_days: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - cumulative: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - current_period: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - balances: { - submission: faker.helpers.arrayElement([ - { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, - null, - ]), - storage_bytes: faker.helpers.arrayElement([ - { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, - null, - ]), - asr_seconds: faker.helpers.arrayElement([ - { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, - null, - ]), - mt_characters: faker.helpers.arrayElement([ - { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, - null, - ]), - llm_requests: faker.helpers.arrayElement([ - { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, - null, - ]), - }, - current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, - current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, - }, - account_restricted: faker.datatype.boolean(), - asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - active_project_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - ...overrideResponse, -}) - -export const getApiV2AccessLogsListMockHandler = ( - overrideResponse?: - | PaginatedSuperUserAccessLogResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedSuperUserAccessLogResponseList), -) => { - return http.get('*/api/v2/access-logs/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AccessLogsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AccessLogsExportListMockHandler = ( - overrideResponse?: - | ExportListResponse[] - | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), -) => { - return http.get('*/api/v2/access-logs/export/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AccessLogsExportListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AccessLogsExportCreateMockHandler = ( - overrideResponse?: - | ExportCreateResponse - | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), -) => { - return http.post('*/api/v2/access-logs/export/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AccessLogsExportCreateResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AuditLogsListMockHandler = ( - overrideResponse?: - | PaginatedAuditLogResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAuditLogResponseList), -) => { - return http.get('*/api/v2/audit-logs/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AuditLogsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectHistoryLogsListMockHandler = ( - overrideResponse?: - | PaginatedProjectHistoryLogResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedProjectHistoryLogResponseList), -) => { - return http.get('*/api/v2/project-history-logs/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectHistoryLogsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectHistoryLogsExportRetrieveMockHandler = ( - overrideResponse?: - | ExportHistoryResponse - | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse), -) => { - return http.get('*/api/v2/project-history-logs/export/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectHistoryLogsExportRetrieveResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectHistoryLogsExportCreateMockHandler = ( - overrideResponse?: - | ExportHistoryResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ExportHistoryResponse), -) => { - return http.post('*/api/v2/project-history-logs/export/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectHistoryLogsExportCreateResponseMock(), - ), - { status: 202, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2UserReportsListMockHandler = ( - overrideResponse?: - | PaginatedUserReportsListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedUserReportsListResponseList), -) => { - return http.get('*/api/v2/user-reports/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2UserReportsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getServerLogsSuperusersMock = () => [ - getApiV2AccessLogsListMockHandler(), - getApiV2AccessLogsExportListMockHandler(), - getApiV2AccessLogsExportCreateMockHandler(), - getApiV2AuditLogsListMockHandler(), - getApiV2ProjectHistoryLogsListMockHandler(), - getApiV2ProjectHistoryLogsExportRetrieveMockHandler(), - getApiV2ProjectHistoryLogsExportCreateMockHandler(), - getApiV2UserReportsListMockHandler(), -] diff --git a/jsapp/js/api/react-query/survey-data-rest-services/index.ts b/jsapp/js/api/react-query/survey-data-rest-services/index.ts new file mode 100644 index 0000000000..43d7068cd7 --- /dev/null +++ b/jsapp/js/api/react-query/survey-data-rest-services/index.ts @@ -0,0 +1,968 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + AssetsHooksListParams +} from '../../models/assetsHooksListParams'; + +import type { + AssetsHooksLogsListParams +} from '../../models/assetsHooksLogsListParams'; + +import type { + ErrorDetail +} from '../../models/errorDetail'; + +import type { + ErrorObject +} from '../../models/errorObject'; + +import type { + Hook +} from '../../models/hook'; + +import type { + HookLog +} from '../../models/hookLog'; + +import type { + HookRetryResponse +} from '../../models/hookRetryResponse'; + +import type { + LogsRetryResponse +} from '../../models/logsRetryResponse'; + +import type { + PaginatedHookList +} from '../../models/paginatedHookList'; + +import type { + PaginatedHookLogList +} from '../../models/paginatedHookLogList'; + +import type { + PatchedHook +} from '../../models/patchedHook'; + +import type { + PatchedHookLog +} from '../../models/patchedHookLog'; + +import { fetchWithAuth } from '../../orval.mutator'; + +// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 +type IfEquals = (() => T extends X ? 1 : 2) extends < +T, +>() => T extends Y ? 1 : 2 +? A +: B; + +type WritableKeys = { +[P in keyof T]-?: IfEquals< + { [Q in P]: T[P] }, + { -readonly [Q in P]: T[P] }, + P +>; +}[keyof T]; + +type UnionToIntersection = + (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never; +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; + +type Writable = Pick>; +type NonReadonly = [T] extends [UnionToIntersection] ? { + [P in keyof Writable]: T[P] extends object + ? NonReadonly> + : T[P]; +} : DistributeReadOnlyOverUnions; + + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * ## List external services + +Lists the external services endpoints accessible to requesting user + + */ +export type assetsHooksListResponse200 = { + data: PaginatedHookList + status: 200 +} + +export type assetsHooksListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsHooksListResponseComposite = assetsHooksListResponse200 | assetsHooksListResponse404; + +export type assetsHooksListResponse = assetsHooksListResponseComposite & { + headers: Headers; +} + +export const getAssetsHooksListUrl = (uidAsset: string, + params?: AssetsHooksListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/hooks/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/hooks/` +} + +export const assetsHooksList = async (uidAsset: string, + params?: AssetsHooksListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHooksListUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsHooksListQueryKey = (uidAsset: string, + params?: AssetsHooksListParams,) => { + return ['api','v2','assets',uidAsset,'hooks', ...(params ? [params]: [])] as const; + } + + +export const getAssetsHooksListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsHooksListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsHooksListQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsHooksList(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsHooksListQueryResult = NonNullable>> +export type AssetsHooksListQueryError = ErrorDetail + + + +export function useAssetsHooksList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsHooksListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsHooksListQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Add an external service to asset. + +Where: + +* `name` and `endpoint` are required +* `active` is True by default +* `export_type` must be one of these values: + + 1. `json` (_default_) + 2. `xml` + +* `email_notification` is a boolean. If true, User will be notified when request to remote server has failed. +* `auth_level` must be one of these values: + + 1. `no_auth` (_default_) + 2. `basic_auth` + +* `subset_fields` is the list of fields of the form definition. Only these fields should be present in data sent to remote server +* `settings`.`custom_headers` is dictionary of `custom header`: `value` + +For example: +> "settings": { +> "customer_headers": { +> "Authorization" : "Token 1af538baa9045a84c0e889f672baf83ff24" +> } + +* `payload_template` is a custom wrapper around `%SUBMISSION%` when sending data to remote server. + It can be used only with JSON submission format. + +For example: +> "payload_template": '{"fields": %SUBMISSION%}' + + */ +export type assetsHooksCreateResponse201 = { + data: Hook + status: 201 +} + +export type assetsHooksCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsHooksCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsHooksCreateResponseComposite = assetsHooksCreateResponse201 | assetsHooksCreateResponse400 | assetsHooksCreateResponse404; + +export type assetsHooksCreateResponse = assetsHooksCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsHooksCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/hooks/` +} + +export const assetsHooksCreate = async (uidAsset: string, + hook: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHooksCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + hook,) + } +);} + + + + +export const getAssetsHooksCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext> => { + +const mutationKey = ['assetsHooksCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: NonReadonly}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsHooksCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsHooksCreateMutationResult = NonNullable>> + export type AssetsHooksCreateMutationBody = NonReadonly + export type AssetsHooksCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsHooksCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsHooksCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve an external service + + */ +export type assetsHooksRetrieveResponse200 = { + data: Hook + status: 200 +} + +export type assetsHooksRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsHooksRetrieveResponseComposite = assetsHooksRetrieveResponse200 | assetsHooksRetrieveResponse404; + +export type assetsHooksRetrieveResponse = assetsHooksRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsHooksRetrieveUrl = (uidAsset: string, + uidHook: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/` +} + +export const assetsHooksRetrieve = async (uidAsset: string, + uidHook: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHooksRetrieveUrl(uidAsset,uidHook), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsHooksRetrieveQueryKey = (uidAsset: string, + uidHook: string,) => { + return ['api','v2','assets',uidAsset,'hooks',uidHook] as const; + } + + +export const getAssetsHooksRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidHook: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsHooksRetrieveQueryKey(uidAsset,uidHook); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsHooksRetrieve(uidAsset,uidHook, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidHook), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsHooksRetrieveQueryResult = NonNullable>> +export type AssetsHooksRetrieveQueryError = ErrorDetail + + + +export function useAssetsHooksRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidHook: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsHooksRetrieveQueryOptions(uidAsset,uidHook,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update an external service. + + */ +export type assetsHooksPartialUpdateResponse200 = { + data: Hook + status: 200 +} + +export type assetsHooksPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsHooksPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsHooksPartialUpdateResponseComposite = assetsHooksPartialUpdateResponse200 | assetsHooksPartialUpdateResponse400 | assetsHooksPartialUpdateResponse404; + +export type assetsHooksPartialUpdateResponse = assetsHooksPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsHooksPartialUpdateUrl = (uidAsset: string, + uidHook: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/` +} + +export const assetsHooksPartialUpdate = async (uidAsset: string, + uidHook: string, + patchedHook: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHooksPartialUpdateUrl(uidAsset,uidHook), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedHook,) + } +);} + + + + +export const getAssetsHooksPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string;data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidHook: string;data: NonReadonly}, TContext> => { + +const mutationKey = ['assetsHooksPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidHook: string;data: NonReadonly}> = (props) => { + const {uidAsset,uidHook,data} = props ?? {}; + + return assetsHooksPartialUpdate(uidAsset,uidHook,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsHooksPartialUpdateMutationResult = NonNullable>> + export type AssetsHooksPartialUpdateMutationBody = NonReadonly + export type AssetsHooksPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useAssetsHooksPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string;data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsHooksPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Delete an external service. + + */ +export type assetsHooksDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsHooksDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsHooksDestroyResponseComposite = assetsHooksDestroyResponse204 | assetsHooksDestroyResponse404; + +export type assetsHooksDestroyResponse = assetsHooksDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsHooksDestroyUrl = (uidAsset: string, + uidHook: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/` +} + +export const assetsHooksDestroy = async (uidAsset: string, + uidHook: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHooksDestroyUrl(uidAsset,uidHook), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsHooksDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext> => { + +const mutationKey = ['assetsHooksDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidHook: string}> = (props) => { + const {uidAsset,uidHook} = props ?? {}; + + return assetsHooksDestroy(uidAsset,uidHook,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsHooksDestroyMutationResult = NonNullable>> + + export type AssetsHooksDestroyMutationError = ErrorDetail + + export const useAssetsHooksDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsHooksDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## List logs of an external services endpoints accessible to requesting user + +⚠️ The `page` query parameter is deprecated, use `start` and `limit` instead. + +Where: +* `asset_uid` - is the unique identifier of a specific asset +* `hook_uid` - is the unique identifier of a specific external service +* `uid` - is the unique identifier of a specific log + +Use the `status` query parameter to filter logs by numeric status: +* `status=0`: hook has failed after exhausting all retries +* `status=1`: hook is still pending +* `status=2`: hook has succeeded + +Use the `start_date` and `end_date` query parameters to filter logs by date range, +providing ISO-8601 date strings (e.g. '2022-01-14', '2022-01-21 06:51:04', +'2022-01-21T06:51:08.144004+02:00'). Time zone is assumed to be UTC. If provided, it +needs to be in '+00:00' format ('Z' is not supported). Watch out for url encoding for +the '+' character (%2B). + +Note that `start_date` is inclusive, while `end_date` is exclusive. + + */ +export type assetsHooksLogsListResponse200 = { + data: PaginatedHookLogList + status: 200 +} + +export type assetsHooksLogsListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsHooksLogsListResponseComposite = assetsHooksLogsListResponse200 | assetsHooksLogsListResponse403; + +export type assetsHooksLogsListResponse = assetsHooksLogsListResponseComposite & { + headers: Headers; +} + +export const getAssetsHooksLogsListUrl = (uidAsset: string, + uidHook: string, + params?: AssetsHooksLogsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/` +} + +export const assetsHooksLogsList = async (uidAsset: string, + uidHook: string, + params?: AssetsHooksLogsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHooksLogsListUrl(uidAsset,uidHook,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsHooksLogsListQueryKey = (uidAsset: string, + uidHook: string, + params?: AssetsHooksLogsListParams,) => { + return ['api','v2','assets',uidAsset,'hooks',uidHook,'logs', ...(params ? [params]: [])] as const; + } + + +export const getAssetsHooksLogsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidHook: string, + params?: AssetsHooksLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsHooksLogsListQueryKey(uidAsset,uidHook,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsHooksLogsList(uidAsset,uidHook,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidHook), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsHooksLogsListQueryResult = NonNullable>> +export type AssetsHooksLogsListQueryError = ErrorDetail + + + +export function useAssetsHooksLogsList>, TError = ErrorDetail>( + uidAsset: string, + uidHook: string, + params?: AssetsHooksLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsHooksLogsListQueryOptions(uidAsset,uidHook,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve an external service endpoint log + + */ +export type assetsHooksLogsRetrieveResponse200 = { + data: HookLog + status: 200 +} + +export type assetsHooksLogsRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsHooksLogsRetrieveResponseComposite = assetsHooksLogsRetrieveResponse200 | assetsHooksLogsRetrieveResponse403; + +export type assetsHooksLogsRetrieveResponse = assetsHooksLogsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsHooksLogsRetrieveUrl = (uidAsset: string, + uidHook: string, + uidLog: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/${uidLog}/` +} + +export const assetsHooksLogsRetrieve = async (uidAsset: string, + uidHook: string, + uidLog: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHooksLogsRetrieveUrl(uidAsset,uidHook,uidLog), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsHooksLogsRetrieveQueryKey = (uidAsset: string, + uidHook: string, + uidLog: string,) => { + return ['api','v2','assets',uidAsset,'hooks',uidHook,'logs',uidLog] as const; + } + + +export const getAssetsHooksLogsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidHook: string, + uidLog: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsHooksLogsRetrieveQueryKey(uidAsset,uidHook,uidLog); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsHooksLogsRetrieve(uidAsset,uidHook,uidLog, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidHook && uidLog), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsHooksLogsRetrieveQueryResult = NonNullable>> +export type AssetsHooksLogsRetrieveQueryError = ErrorDetail + + + +export function useAssetsHooksLogsRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidHook: string, + uidLog: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsHooksLogsRetrieveQueryOptions(uidAsset,uidHook,uidLog,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retry a failed submission attempt + + */ +export type assetsHooksLogsRetryPartialUpdateResponse200 = { + data: LogsRetryResponse + status: 200 +} + +export type assetsHooksLogsRetryPartialUpdateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsHooksLogsRetryPartialUpdateResponseComposite = assetsHooksLogsRetryPartialUpdateResponse200 | assetsHooksLogsRetryPartialUpdateResponse403; + +export type assetsHooksLogsRetryPartialUpdateResponse = assetsHooksLogsRetryPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsHooksLogsRetryPartialUpdateUrl = (uidAsset: string, + uidHook: string, + uidLog: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/${uidLog}/retry/` +} + +export const assetsHooksLogsRetryPartialUpdate = async (uidAsset: string, + uidHook: string, + uidLog: string, + patchedHookLog: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHooksLogsRetryPartialUpdateUrl(uidAsset,uidHook,uidLog), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedHookLog,) + } +);} + + + + +export const getAssetsHooksLogsRetryPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string;uidLog: string;data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidHook: string;uidLog: string;data: NonReadonly}, TContext> => { + +const mutationKey = ['assetsHooksLogsRetryPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidHook: string;uidLog: string;data: NonReadonly}> = (props) => { + const {uidAsset,uidHook,uidLog,data} = props ?? {}; + + return assetsHooksLogsRetryPartialUpdate(uidAsset,uidHook,uidLog,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsHooksLogsRetryPartialUpdateMutationResult = NonNullable>> + export type AssetsHooksLogsRetryPartialUpdateMutationBody = NonReadonly + export type AssetsHooksLogsRetryPartialUpdateMutationError = ErrorDetail + + export const useAssetsHooksLogsRetryPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string;uidLog: string;data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsHooksLogsRetryPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retries all failed attempts + +**This call is asynchronous. Job is sent to Celery to be run in background** + +It returns all logs `uid`s that are being retried. + + */ +export type assetsHooksRetryPartialUpdateResponse200 = { + data: HookRetryResponse + status: 200 +} + +export type assetsHooksRetryPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsHooksRetryPartialUpdateResponseComposite = assetsHooksRetryPartialUpdateResponse200 | assetsHooksRetryPartialUpdateResponse404; + +export type assetsHooksRetryPartialUpdateResponse = assetsHooksRetryPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsHooksRetryPartialUpdateUrl = (uidAsset: string, + uidHook: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/retry/` +} + +export const assetsHooksRetryPartialUpdate = async (uidAsset: string, + uidHook: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsHooksRetryPartialUpdateUrl(uidAsset,uidHook), + { + ...options, + method: 'PATCH' + + + } +);} + + + + +export const getAssetsHooksRetryPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext> => { + +const mutationKey = ['assetsHooksRetryPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidHook: string}> = (props) => { + const {uidAsset,uidHook} = props ?? {}; + + return assetsHooksRetryPartialUpdate(uidAsset,uidHook,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsHooksRetryPartialUpdateMutationResult = NonNullable>> + + export type AssetsHooksRetryPartialUpdateMutationError = ErrorDetail + + export const useAssetsHooksRetryPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsHooksRetryPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + \ No newline at end of file diff --git a/jsapp/js/api/react-query/survey-data-rest-services/msw.ts b/jsapp/js/api/react-query/survey-data-rest-services/msw.ts new file mode 100644 index 0000000000..f1fc72154e --- /dev/null +++ b/jsapp/js/api/react-query/survey-data-rest-services/msw.ts @@ -0,0 +1,167 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import { + AuthLevelEnum +} from '../../models/authLevelEnum'; + +import { + ExportTypeEnum +} from '../../models/exportTypeEnum'; + +import type { + Hook +} from '../../models/hook'; + +import type { + HookLog +} from '../../models/hookLog'; + +import type { + HookRetryResponse +} from '../../models/hookRetryResponse'; + +import type { + LogsRetryResponse +} from '../../models/logsRetryResponse'; + +import type { + PaginatedHookList +} from '../../models/paginatedHookList'; + +import type { + PaginatedHookLogList +} from '../../models/paginatedHookLogList'; + + +export const getApiV2AssetsHooksListResponseMock = (overrideResponse: Partial< PaginatedHookList > = {}): PaginatedHookList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), asset: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.string.alpha({length: {min: 10, max: 500}}), export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), failed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), logs_url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 255}}), payload_template: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), settings: faker.helpers.arrayElement([{password: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), custom_headers: faker.helpers.arrayElement([{value_field: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value_field_2: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), subset_fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), success_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url()})), ...overrideResponse}) + +export const getApiV2AssetsHooksCreateResponseMock = (overrideResponse: Partial< Hook > = {}): Hook => ({active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), asset: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.string.alpha({length: {min: 10, max: 500}}), export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), failed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), logs_url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 255}}), payload_template: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), settings: faker.helpers.arrayElement([{password: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), custom_headers: faker.helpers.arrayElement([{value_field: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value_field_2: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), subset_fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), success_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) + +export const getApiV2AssetsHooksRetrieveResponseMock = (overrideResponse: Partial< Hook > = {}): Hook => ({active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), asset: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.string.alpha({length: {min: 10, max: 500}}), export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), failed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), logs_url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 255}}), payload_template: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), settings: faker.helpers.arrayElement([{password: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), custom_headers: faker.helpers.arrayElement([{value_field: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value_field_2: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), subset_fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), success_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) + +export const getApiV2AssetsHooksPartialUpdateResponseMock = (overrideResponse: Partial< Hook > = {}): Hook => ({active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), asset: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.string.alpha({length: {min: 10, max: 500}}), export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), failed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), logs_url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 255}}), payload_template: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), settings: faker.helpers.arrayElement([{password: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), custom_headers: faker.helpers.arrayElement([{value_field: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value_field_2: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), subset_fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), success_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) + +export const getApiV2AssetsHooksLogsListResponseMock = (overrideResponse: Partial< PaginatedHookLogList > = {}): PaginatedHookLogList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), submission_id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), tries: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.helpers.arrayElement([0,1,3,2] as const), status_str: faker.string.alpha({length: {min: 10, max: 20}}), status_code: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), message: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) + +export const getApiV2AssetsHooksLogsRetrieveResponseMock = (overrideResponse: Partial< HookLog > = {}): HookLog => ({url: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), submission_id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), tries: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.helpers.arrayElement([0,1,3,2] as const), status_str: faker.string.alpha({length: {min: 10, max: 20}}), status_code: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), message: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, ...overrideResponse}) + +export const getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock = (overrideResponse: Partial< LogsRetryResponse > = {}): LogsRetryResponse => ({detail: faker.string.alpha({length: {min: 10, max: 20}}), pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) + +export const getApiV2AssetsHooksRetryPartialUpdateResponseMock = (overrideResponse: Partial< HookRetryResponse > = {}): HookRetryResponse => ({detail: faker.string.alpha({length: {min: 10, max: 20}}), pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) + + +export const getApiV2AssetsHooksListMockHandler = (overrideResponse?: PaginatedHookList | ((info: Parameters[1]>[0]) => Promise | PaginatedHookList)) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHooksListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHooksCreateMockHandler = (overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook)) => { + return http.post('*/api/v2/assets/:uidAsset/hooks/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHooksCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHooksRetrieveMockHandler = (overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook)) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHooksRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHooksPartialUpdateMockHandler = (overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook)) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHooksPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHooksDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsHooksLogsListMockHandler = (overrideResponse?: PaginatedHookLogList | ((info: Parameters[1]>[0]) => Promise | PaginatedHookLogList)) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHooksLogsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHooksLogsRetrieveMockHandler = (overrideResponse?: HookLog | ((info: Parameters[1]>[0]) => Promise | HookLog)) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHooksLogsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler = (overrideResponse?: LogsRetryResponse | ((info: Parameters[1]>[0]) => Promise | LogsRetryResponse)) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsHooksRetryPartialUpdateMockHandler = (overrideResponse?: HookRetryResponse | ((info: Parameters[1]>[0]) => Promise | HookRetryResponse)) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsHooksRetryPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} +export const getSurveyDataRestServicesMock = () => [ + getApiV2AssetsHooksListMockHandler(), + getApiV2AssetsHooksCreateMockHandler(), + getApiV2AssetsHooksRetrieveMockHandler(), + getApiV2AssetsHooksPartialUpdateMockHandler(), + getApiV2AssetsHooksDestroyMockHandler(), + getApiV2AssetsHooksLogsListMockHandler(), + getApiV2AssetsHooksLogsRetrieveMockHandler(), + getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler(), + getApiV2AssetsHooksRetryPartialUpdateMockHandler() +] diff --git a/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.msw.ts b/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.msw.ts deleted file mode 100644 index 3de9d07081..0000000000 --- a/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.msw.ts +++ /dev/null @@ -1,433 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import { AuthLevelEnum } from '../../models/authLevelEnum' - -import { ExportTypeEnum } from '../../models/exportTypeEnum' - -import type { Hook } from '../../models/hook' - -import type { HookLog } from '../../models/hookLog' - -import type { HookRetryResponse } from '../../models/hookRetryResponse' - -import type { LogsRetryResponse } from '../../models/logsRetryResponse' - -import type { PaginatedHookList } from '../../models/paginatedHookList' - -import type { PaginatedHookLogList } from '../../models/paginatedHookLogList' - -export const getApiV2AssetsHooksListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedHookList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), - export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), - failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - logs_url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 255 } }), - payload_template: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - settings: faker.helpers.arrayElement([ - { - password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - custom_headers: faker.helpers.arrayElement([ - { - value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value_field_2: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - subset_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksCreateResponseMock = (overrideResponse: Partial = {}): Hook => ({ - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), - export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), - failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - logs_url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 255 } }), - payload_template: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - settings: faker.helpers.arrayElement([ - { - password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - custom_headers: faker.helpers.arrayElement([ - { - value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - subset_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksRetrieveResponseMock = (overrideResponse: Partial = {}): Hook => ({ - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), - export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), - failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - logs_url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 255 } }), - payload_template: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - settings: faker.helpers.arrayElement([ - { - password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - custom_headers: faker.helpers.arrayElement([ - { - value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - subset_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksPartialUpdateResponseMock = (overrideResponse: Partial = {}): Hook => ({ - active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), - export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), - failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - logs_url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 255 } }), - payload_template: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - settings: faker.helpers.arrayElement([ - { - password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - custom_headers: faker.helpers.arrayElement([ - { - value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - subset_fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksLogsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedHookLogList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - tries: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.helpers.arrayElement([0, 1, 3, 2] as const), - status_str: faker.string.alpha({ length: { min: 10, max: 20 } }), - status_code: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - message: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksLogsRetrieveResponseMock = (overrideResponse: Partial = {}): HookLog => ({ - url: faker.internet.url(), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - tries: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.helpers.arrayElement([0, 1, 3, 2] as const), - status_str: faker.string.alpha({ length: { min: 10, max: 20 } }), - status_code: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - message: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - ...overrideResponse, -}) - -export const getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): LogsRetryResponse => ({ - detail: faker.string.alpha({ length: { min: 10, max: 20 } }), - pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksRetryPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): HookRetryResponse => ({ - detail: faker.string.alpha({ length: { min: 10, max: 20 } }), - pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2AssetsHooksListMockHandler = ( - overrideResponse?: - | PaginatedHookList - | ((info: Parameters[1]>[0]) => Promise | PaginatedHookList), -) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksCreateMockHandler = ( - overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), -) => { - return http.post('*/api/v2/assets/:uidAsset/hooks/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksRetrieveMockHandler = ( - overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), -) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksPartialUpdateMockHandler = ( - overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), -) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsHooksLogsListMockHandler = ( - overrideResponse?: - | PaginatedHookLogList - | ((info: Parameters[1]>[0]) => Promise | PaginatedHookLogList), -) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksLogsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksLogsRetrieveMockHandler = ( - overrideResponse?: HookLog | ((info: Parameters[1]>[0]) => Promise | HookLog), -) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksLogsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler = ( - overrideResponse?: - | LogsRetryResponse - | ((info: Parameters[1]>[0]) => Promise | LogsRetryResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsHooksRetryPartialUpdateMockHandler = ( - overrideResponse?: - | HookRetryResponse - | ((info: Parameters[1]>[0]) => Promise | HookRetryResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsHooksRetryPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getSurveyDataRestServicesMock = () => [ - getApiV2AssetsHooksListMockHandler(), - getApiV2AssetsHooksCreateMockHandler(), - getApiV2AssetsHooksRetrieveMockHandler(), - getApiV2AssetsHooksPartialUpdateMockHandler(), - getApiV2AssetsHooksDestroyMockHandler(), - getApiV2AssetsHooksLogsListMockHandler(), - getApiV2AssetsHooksLogsRetrieveMockHandler(), - getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler(), - getApiV2AssetsHooksRetryPartialUpdateMockHandler(), -] diff --git a/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.ts b/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.ts deleted file mode 100644 index 61387a7e2e..0000000000 --- a/jsapp/js/api/react-query/survey-data-rest-services/survey-data-rest-services.ts +++ /dev/null @@ -1,964 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { AssetsHooksListParams } from '../../models/assetsHooksListParams' - -import type { AssetsHooksLogsListParams } from '../../models/assetsHooksLogsListParams' - -import type { ErrorDetail } from '../../models/errorDetail' - -import type { ErrorObject } from '../../models/errorObject' - -import type { Hook } from '../../models/hook' - -import type { HookLog } from '../../models/hookLog' - -import type { HookRetryResponse } from '../../models/hookRetryResponse' - -import type { LogsRetryResponse } from '../../models/logsRetryResponse' - -import type { PaginatedHookList } from '../../models/paginatedHookList' - -import type { PaginatedHookLogList } from '../../models/paginatedHookLogList' - -import type { PatchedHook } from '../../models/patchedHook' - -import type { PatchedHookLog } from '../../models/patchedHookLog' - -import { fetchWithAuth } from '../../orval.mutator' - -// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B - -type WritableKeys = { - [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P> -}[keyof T] - -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never - -type Writable = Pick> -type NonReadonly = [T] extends [UnionToIntersection] - ? { - [P in keyof Writable]: T[P] extends object ? NonReadonly> : T[P] - } - : DistributeReadOnlyOverUnions - -type SecondParameter unknown> = Parameters[1] - -/** - * ## List external services - -Lists the external services endpoints accessible to requesting user - - */ -export type assetsHooksListResponse200 = { - data: PaginatedHookList - status: 200 -} - -export type assetsHooksListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsHooksListResponseComposite = assetsHooksListResponse200 | assetsHooksListResponse404 - -export type assetsHooksListResponse = assetsHooksListResponseComposite & { - headers: Headers -} - -export const getAssetsHooksListUrl = (uidAsset: string, params?: AssetsHooksListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/hooks/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/hooks/` -} - -export const assetsHooksList = async ( - uidAsset: string, - params?: AssetsHooksListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHooksListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsHooksListQueryKey = (uidAsset: string, params?: AssetsHooksListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'hooks', ...(params ? [params] : [])] as const -} - -export const getAssetsHooksListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsHooksListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsHooksListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsHooksList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsHooksListQueryResult = NonNullable>> -export type AssetsHooksListQueryError = ErrorDetail - -export function useAssetsHooksList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsHooksListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsHooksListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Add an external service to asset. - -Where: - -* `name` and `endpoint` are required -* `active` is True by default -* `export_type` must be one of these values: - - 1. `json` (_default_) - 2. `xml` - -* `email_notification` is a boolean. If true, User will be notified when request to remote server has failed. -* `auth_level` must be one of these values: - - 1. `no_auth` (_default_) - 2. `basic_auth` - -* `subset_fields` is the list of fields of the form definition. Only these fields should be present in data sent to remote server -* `settings`.`custom_headers` is dictionary of `custom header`: `value` - -For example: -> "settings": { -> "customer_headers": { -> "Authorization" : "Token 1af538baa9045a84c0e889f672baf83ff24" -> } - -* `payload_template` is a custom wrapper around `%SUBMISSION%` when sending data to remote server. - It can be used only with JSON submission format. - -For example: -> "payload_template": '{"fields": %SUBMISSION%}' - - */ -export type assetsHooksCreateResponse201 = { - data: Hook - status: 201 -} - -export type assetsHooksCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsHooksCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsHooksCreateResponseComposite = - | assetsHooksCreateResponse201 - | assetsHooksCreateResponse400 - | assetsHooksCreateResponse404 - -export type assetsHooksCreateResponse = assetsHooksCreateResponseComposite & { - headers: Headers -} - -export const getAssetsHooksCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/hooks/` -} - -export const assetsHooksCreate = async ( - uidAsset: string, - hook: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHooksCreateUrl(uidAsset), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(hook), - }) -} - -export const getAssetsHooksCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: NonReadonly }, - TContext -> => { - const mutationKey = ['assetsHooksCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: NonReadonly } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsHooksCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsHooksCreateMutationResult = NonNullable>> -export type AssetsHooksCreateMutationBody = NonReadonly -export type AssetsHooksCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsHooksCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsHooksCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve an external service - - */ -export type assetsHooksRetrieveResponse200 = { - data: Hook - status: 200 -} - -export type assetsHooksRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsHooksRetrieveResponseComposite = assetsHooksRetrieveResponse200 | assetsHooksRetrieveResponse404 - -export type assetsHooksRetrieveResponse = assetsHooksRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsHooksRetrieveUrl = (uidAsset: string, uidHook: string) => { - return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/` -} - -export const assetsHooksRetrieve = async ( - uidAsset: string, - uidHook: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHooksRetrieveUrl(uidAsset, uidHook), { - ...options, - method: 'GET', - }) -} - -export const getAssetsHooksRetrieveQueryKey = (uidAsset: string, uidHook: string) => { - return ['api', 'v2', 'assets', uidAsset, 'hooks', uidHook] as const -} - -export const getAssetsHooksRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidHook: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsHooksRetrieveQueryKey(uidAsset, uidHook) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsHooksRetrieve(uidAsset, uidHook, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidHook), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsHooksRetrieveQueryResult = NonNullable>> -export type AssetsHooksRetrieveQueryError = ErrorDetail - -export function useAssetsHooksRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidHook: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsHooksRetrieveQueryOptions(uidAsset, uidHook, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update an external service. - - */ -export type assetsHooksPartialUpdateResponse200 = { - data: Hook - status: 200 -} - -export type assetsHooksPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsHooksPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsHooksPartialUpdateResponseComposite = - | assetsHooksPartialUpdateResponse200 - | assetsHooksPartialUpdateResponse400 - | assetsHooksPartialUpdateResponse404 - -export type assetsHooksPartialUpdateResponse = assetsHooksPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsHooksPartialUpdateUrl = (uidAsset: string, uidHook: string) => { - return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/` -} - -export const assetsHooksPartialUpdate = async ( - uidAsset: string, - uidHook: string, - patchedHook: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHooksPartialUpdateUrl(uidAsset, uidHook), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedHook), - }) -} - -export const getAssetsHooksPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string; data: NonReadonly }, - TContext -> => { - const mutationKey = ['assetsHooksPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidHook: string; data: NonReadonly } - > = (props) => { - const { uidAsset, uidHook, data } = props ?? {} - - return assetsHooksPartialUpdate(uidAsset, uidHook, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsHooksPartialUpdateMutationResult = NonNullable>> -export type AssetsHooksPartialUpdateMutationBody = NonReadonly -export type AssetsHooksPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useAssetsHooksPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsHooksPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete an external service. - - */ -export type assetsHooksDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsHooksDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsHooksDestroyResponseComposite = assetsHooksDestroyResponse204 | assetsHooksDestroyResponse404 - -export type assetsHooksDestroyResponse = assetsHooksDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsHooksDestroyUrl = (uidAsset: string, uidHook: string) => { - return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/` -} - -export const assetsHooksDestroy = async ( - uidAsset: string, - uidHook: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHooksDestroyUrl(uidAsset, uidHook), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetsHooksDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string }, - TContext -> => { - const mutationKey = ['assetsHooksDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidHook: string } - > = (props) => { - const { uidAsset, uidHook } = props ?? {} - - return assetsHooksDestroy(uidAsset, uidHook, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsHooksDestroyMutationResult = NonNullable>> - -export type AssetsHooksDestroyMutationError = ErrorDetail - -export const useAssetsHooksDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsHooksDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## List logs of an external services endpoints accessible to requesting user - -⚠️ The `page` query parameter is deprecated, use `start` and `limit` instead. - -Where: -* `asset_uid` - is the unique identifier of a specific asset -* `hook_uid` - is the unique identifier of a specific external service -* `uid` - is the unique identifier of a specific log - -Use the `status` query parameter to filter logs by numeric status: -* `status=0`: hook has failed after exhausting all retries -* `status=1`: hook is still pending -* `status=2`: hook has succeeded - -Use the `start_date` and `end_date` query parameters to filter logs by date range, -providing ISO-8601 date strings (e.g. '2022-01-14', '2022-01-21 06:51:04', -'2022-01-21T06:51:08.144004+02:00'). Time zone is assumed to be UTC. If provided, it -needs to be in '+00:00' format ('Z' is not supported). Watch out for url encoding for -the '+' character (%2B). - -Note that `start_date` is inclusive, while `end_date` is exclusive. - - */ -export type assetsHooksLogsListResponse200 = { - data: PaginatedHookLogList - status: 200 -} - -export type assetsHooksLogsListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsHooksLogsListResponseComposite = assetsHooksLogsListResponse200 | assetsHooksLogsListResponse403 - -export type assetsHooksLogsListResponse = assetsHooksLogsListResponseComposite & { - headers: Headers -} - -export const getAssetsHooksLogsListUrl = (uidAsset: string, uidHook: string, params?: AssetsHooksLogsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/` -} - -export const assetsHooksLogsList = async ( - uidAsset: string, - uidHook: string, - params?: AssetsHooksLogsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHooksLogsListUrl(uidAsset, uidHook, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsHooksLogsListQueryKey = ( - uidAsset: string, - uidHook: string, - params?: AssetsHooksLogsListParams, -) => { - return ['api', 'v2', 'assets', uidAsset, 'hooks', uidHook, 'logs', ...(params ? [params] : [])] as const -} - -export const getAssetsHooksLogsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidHook: string, - params?: AssetsHooksLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsHooksLogsListQueryKey(uidAsset, uidHook, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsHooksLogsList(uidAsset, uidHook, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidHook), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsHooksLogsListQueryResult = NonNullable>> -export type AssetsHooksLogsListQueryError = ErrorDetail - -export function useAssetsHooksLogsList>, TError = ErrorDetail>( - uidAsset: string, - uidHook: string, - params?: AssetsHooksLogsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsHooksLogsListQueryOptions(uidAsset, uidHook, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve an external service endpoint log - - */ -export type assetsHooksLogsRetrieveResponse200 = { - data: HookLog - status: 200 -} - -export type assetsHooksLogsRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsHooksLogsRetrieveResponseComposite = - | assetsHooksLogsRetrieveResponse200 - | assetsHooksLogsRetrieveResponse403 - -export type assetsHooksLogsRetrieveResponse = assetsHooksLogsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsHooksLogsRetrieveUrl = (uidAsset: string, uidHook: string, uidLog: string) => { - return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/${uidLog}/` -} - -export const assetsHooksLogsRetrieve = async ( - uidAsset: string, - uidHook: string, - uidLog: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHooksLogsRetrieveUrl(uidAsset, uidHook, uidLog), { - ...options, - method: 'GET', - }) -} - -export const getAssetsHooksLogsRetrieveQueryKey = (uidAsset: string, uidHook: string, uidLog: string) => { - return ['api', 'v2', 'assets', uidAsset, 'hooks', uidHook, 'logs', uidLog] as const -} - -export const getAssetsHooksLogsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidHook: string, - uidLog: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsHooksLogsRetrieveQueryKey(uidAsset, uidHook, uidLog) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsHooksLogsRetrieve(uidAsset, uidHook, uidLog, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidHook && uidLog), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsHooksLogsRetrieveQueryResult = NonNullable>> -export type AssetsHooksLogsRetrieveQueryError = ErrorDetail - -export function useAssetsHooksLogsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidHook: string, - uidLog: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsHooksLogsRetrieveQueryOptions(uidAsset, uidHook, uidLog, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retry a failed submission attempt - - */ -export type assetsHooksLogsRetryPartialUpdateResponse200 = { - data: LogsRetryResponse - status: 200 -} - -export type assetsHooksLogsRetryPartialUpdateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsHooksLogsRetryPartialUpdateResponseComposite = - | assetsHooksLogsRetryPartialUpdateResponse200 - | assetsHooksLogsRetryPartialUpdateResponse403 - -export type assetsHooksLogsRetryPartialUpdateResponse = assetsHooksLogsRetryPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsHooksLogsRetryPartialUpdateUrl = (uidAsset: string, uidHook: string, uidLog: string) => { - return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/${uidLog}/retry/` -} - -export const assetsHooksLogsRetryPartialUpdate = async ( - uidAsset: string, - uidHook: string, - uidLog: string, - patchedHookLog: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsHooksLogsRetryPartialUpdateUrl(uidAsset, uidHook, uidLog), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedHookLog), - }, - ) -} - -export const getAssetsHooksLogsRetryPartialUpdateMutationOptions = < - TError = ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string; uidLog: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string; uidLog: string; data: NonReadonly }, - TContext -> => { - const mutationKey = ['assetsHooksLogsRetryPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidHook: string; uidLog: string; data: NonReadonly } - > = (props) => { - const { uidAsset, uidHook, uidLog, data } = props ?? {} - - return assetsHooksLogsRetryPartialUpdate(uidAsset, uidHook, uidLog, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsHooksLogsRetryPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsHooksLogsRetryPartialUpdateMutationBody = NonReadonly -export type AssetsHooksLogsRetryPartialUpdateMutationError = ErrorDetail - -export const useAssetsHooksLogsRetryPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string; uidLog: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsHooksLogsRetryPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retries all failed attempts - -**This call is asynchronous. Job is sent to Celery to be run in background** - -It returns all logs `uid`s that are being retried. - - */ -export type assetsHooksRetryPartialUpdateResponse200 = { - data: HookRetryResponse - status: 200 -} - -export type assetsHooksRetryPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsHooksRetryPartialUpdateResponseComposite = - | assetsHooksRetryPartialUpdateResponse200 - | assetsHooksRetryPartialUpdateResponse404 - -export type assetsHooksRetryPartialUpdateResponse = assetsHooksRetryPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsHooksRetryPartialUpdateUrl = (uidAsset: string, uidHook: string) => { - return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/retry/` -} - -export const assetsHooksRetryPartialUpdate = async ( - uidAsset: string, - uidHook: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsHooksRetryPartialUpdateUrl(uidAsset, uidHook), { - ...options, - method: 'PATCH', - }) -} - -export const getAssetsHooksRetryPartialUpdateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string }, - TContext -> => { - const mutationKey = ['assetsHooksRetryPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidHook: string } - > = (props) => { - const { uidAsset, uidHook } = props ?? {} - - return assetsHooksRetryPartialUpdate(uidAsset, uidHook, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsHooksRetryPartialUpdateMutationResult = NonNullable< - Awaited> -> - -export type AssetsHooksRetryPartialUpdateMutationError = ErrorDetail - -export const useAssetsHooksRetryPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidHook: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsHooksRetryPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} diff --git a/jsapp/js/api/react-query/survey-data/index.ts b/jsapp/js/api/react-query/survey-data/index.ts new file mode 100644 index 0000000000..1d9ffef1e5 --- /dev/null +++ b/jsapp/js/api/react-query/survey-data/index.ts @@ -0,0 +1,5895 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + AdvancedFeatureCreateResponse +} from '../../models/advancedFeatureCreateResponse'; + +import type { + AdvancedFeaturePostRequest +} from '../../models/advancedFeaturePostRequest'; + +import type { + AdvancedFeatureResponse +} from '../../models/advancedFeatureResponse'; + +import type { + AssetAttachmentAudioDurationRequest +} from '../../models/assetAttachmentAudioDurationRequest'; + +import type { + AssetAttachmentAudioDurationResponse +} from '../../models/assetAttachmentAudioDurationResponse'; + +import type { + AssetsAdvancedFeaturesBulkActionsListParams +} from '../../models/assetsAdvancedFeaturesBulkActionsListParams'; + +import type { + AssetsDataAttachmentsListParams +} from '../../models/assetsDataAttachmentsListParams'; + +import type { + AssetsDataListParams +} from '../../models/assetsDataListParams'; + +import type { + AssetsDataRetrieveParams +} from '../../models/assetsDataRetrieveParams'; + +import type { + AssetsExportSettingsDataRetrieveParams +} from '../../models/assetsExportSettingsDataRetrieveParams'; + +import type { + AssetsExportSettingsListParams +} from '../../models/assetsExportSettingsListParams'; + +import type { + AssetsExportsListParams +} from '../../models/assetsExportsListParams'; + +import type { + AssetsFilesListParams +} from '../../models/assetsFilesListParams'; + +import type { + AssetsPairedDataListParams +} from '../../models/assetsPairedDataListParams'; + +import type { + AttachmentRetrieveParams +} from '../../models/attachmentRetrieveParams'; + +import type { + BulkAcceptRequest +} from '../../models/bulkAcceptRequest'; + +import type { + BulkAcceptResponse +} from '../../models/bulkAcceptResponse'; + +import type { + BulkActionCreateRequest +} from '../../models/bulkActionCreateRequest'; + +import type { + BulkActionCreateResponse +} from '../../models/bulkActionCreateResponse'; + +import type { + BulkActionListResponse +} from '../../models/bulkActionListResponse'; + +import type { + BulkActionResponse +} from '../../models/bulkActionResponse'; + +import type { + CreateFilePayload +} from '../../models/createFilePayload'; + +import type { + DataBulkDelete +} from '../../models/dataBulkDelete'; + +import type { + DataBulkUpdateResponse +} from '../../models/dataBulkUpdateResponse'; + +import type { + DataResponse +} from '../../models/dataResponse'; + +import type { + DataStatusesUpdate +} from '../../models/dataStatusesUpdate'; + +import type { + DataSupplementResponse +} from '../../models/dataSupplementResponse'; + +import type { + DataValidationStatusUpdateResponse +} from '../../models/dataValidationStatusUpdateResponse'; + +import type { + EnketoEditResponse +} from '../../models/enketoEditResponse'; + +import type { + EnketoViewResponse +} from '../../models/enketoViewResponse'; + +import type { + ErrorDetail +} from '../../models/errorDetail'; + +import type { + ErrorObject +} from '../../models/errorObject'; + +import type { + ExportCreatePayload +} from '../../models/exportCreatePayload'; + +import type { + ExportResponse +} from '../../models/exportResponse'; + +import type { + ExportSettingCreatePayload +} from '../../models/exportSettingCreatePayload'; + +import type { + ExportSettingResponse +} from '../../models/exportSettingResponse'; + +import type { + ExternalResponse +} from '../../models/externalResponse'; + +import type { + FilesResponse +} from '../../models/filesResponse'; + +import type { + PaginatedDataResponseList +} from '../../models/paginatedDataResponseList'; + +import type { + PaginatedExportResponseList +} from '../../models/paginatedExportResponseList'; + +import type { + PaginatedExportSettingResponseList +} from '../../models/paginatedExportSettingResponseList'; + +import type { + PaginatedFilesResponseList +} from '../../models/paginatedFilesResponseList'; + +import type { + PaginatedPairedDataResponseList +} from '../../models/paginatedPairedDataResponseList'; + +import type { + PairedData +} from '../../models/pairedData'; + +import type { + PairedDataResponse +} from '../../models/pairedDataResponse'; + +import type { + PatchedAdvancedFeaturePatchRequest +} from '../../models/patchedAdvancedFeaturePatchRequest'; + +import type { + PatchedBulkActionPatchRequest +} from '../../models/patchedBulkActionPatchRequest'; + +import type { + PatchedDataBulkUpdate +} from '../../models/patchedDataBulkUpdate'; + +import type { + PatchedDataSupplementPayload +} from '../../models/patchedDataSupplementPayload'; + +import type { + PatchedDataValidationStatusUpdatePayload +} from '../../models/patchedDataValidationStatusUpdatePayload'; + +import type { + PatchedDataValidationStatusesUpdatePayload +} from '../../models/patchedDataValidationStatusesUpdatePayload'; + +import type { + PatchedExportSettingUpdatePayload +} from '../../models/patchedExportSettingUpdatePayload'; + +import type { + PatchedPairedDataPatchPayload +} from '../../models/patchedPairedDataPatchPayload'; + +import type { + ReportResponse +} from '../../models/reportResponse'; + +import { fetchWithAuth } from '../../orval.mutator'; + +// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 +type IfEquals = (() => T extends X ? 1 : 2) extends < +T, +>() => T extends Y ? 1 : 2 +? A +: B; + +type WritableKeys = { +[P in keyof T]-?: IfEquals< + { [Q in P]: T[P] }, + { -readonly [Q in P]: T[P] }, + P +>; +}[keyof T]; + +type UnionToIntersection = + (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never; +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; + +type Writable = Pick>; +type NonReadonly = [T] extends [UnionToIntersection] ? { + [P in keyof Writable]: T[P] extends object + ? NonReadonly> + : T[P]; +} : DistributeReadOnlyOverUnions; + + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * ## List all advanced features on an asset + +Lists all advanced features on all questions in an asset. Examples show one type at a time, but the response may contain multiple advanced features items. + + */ +export type assetsAdvancedFeaturesListResponse200 = { + data: AdvancedFeatureResponse[] + status: 200 +} + +export type assetsAdvancedFeaturesListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsAdvancedFeaturesListResponseComposite = assetsAdvancedFeaturesListResponse200 | assetsAdvancedFeaturesListResponse404; + +export type assetsAdvancedFeaturesListResponse = assetsAdvancedFeaturesListResponseComposite & { + headers: Headers; +} + +export const getAssetsAdvancedFeaturesListUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/advanced-features/` +} + +export const assetsAdvancedFeaturesList = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAdvancedFeaturesListUrl(uidAsset), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsAdvancedFeaturesListQueryKey = (uidAsset: string,) => { + return ['api','v2','assets',uidAsset,'advanced-features'] as const; + } + + +export const getAssetsAdvancedFeaturesListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesListQueryKey(uidAsset); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsAdvancedFeaturesList(uidAsset, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsAdvancedFeaturesListQueryResult = NonNullable>> +export type AssetsAdvancedFeaturesListQueryError = ErrorDetail + + + +export function useAssetsAdvancedFeaturesList>, TError = ErrorDetail>( + uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsAdvancedFeaturesListQueryOptions(uidAsset,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Add an advanced action to an asset + +Enables a new type of advanced action on a question in the asset. +* `action`, `params`, and `question_xpath` are required +* `params` must match the expected param_schema of the `action` + +Accepted `action`s include: +* `manual_transcription` +* `automatic_google_transcription` +* `manual_translation` +* `automatic_google_translation` +* `manual_qual` + + + */ +export type assetsAdvancedFeaturesCreateResponse201 = { + data: AdvancedFeatureCreateResponse + status: 201 +} + +export type assetsAdvancedFeaturesCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsAdvancedFeaturesCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsAdvancedFeaturesCreateResponseComposite = assetsAdvancedFeaturesCreateResponse201 | assetsAdvancedFeaturesCreateResponse400 | assetsAdvancedFeaturesCreateResponse404; + +export type assetsAdvancedFeaturesCreateResponse = assetsAdvancedFeaturesCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsAdvancedFeaturesCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/advanced-features/` +} + +export const assetsAdvancedFeaturesCreate = async (uidAsset: string, + advancedFeaturePostRequest: AdvancedFeaturePostRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAdvancedFeaturesCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + advancedFeaturePostRequest,) + } +);} + + + + +export const getAssetsAdvancedFeaturesCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: AdvancedFeaturePostRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: AdvancedFeaturePostRequest}, TContext> => { + +const mutationKey = ['assetsAdvancedFeaturesCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: AdvancedFeaturePostRequest}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsAdvancedFeaturesCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsAdvancedFeaturesCreateMutationResult = NonNullable>> + export type AssetsAdvancedFeaturesCreateMutationBody = AdvancedFeaturePostRequest + export type AssetsAdvancedFeaturesCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsAdvancedFeaturesCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: AdvancedFeaturePostRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsAdvancedFeaturesCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve advanced feature configuration for a question on an asset + +Gets the params for one advanced action for one question in an asset + + */ +export type assetsAdvancedFeaturesRetrieveResponse200 = { + data: AdvancedFeatureResponse + status: 200 +} + +export type assetsAdvancedFeaturesRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsAdvancedFeaturesRetrieveResponseComposite = assetsAdvancedFeaturesRetrieveResponse200 | assetsAdvancedFeaturesRetrieveResponse404; + +export type assetsAdvancedFeaturesRetrieveResponse = assetsAdvancedFeaturesRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsAdvancedFeaturesRetrieveUrl = (uidAsset: string, + uidAdvancedFeature: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/advanced-features/${uidAdvancedFeature}/` +} + +export const assetsAdvancedFeaturesRetrieve = async (uidAsset: string, + uidAdvancedFeature: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAdvancedFeaturesRetrieveUrl(uidAsset,uidAdvancedFeature), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsAdvancedFeaturesRetrieveQueryKey = (uidAsset: string, + uidAdvancedFeature: string,) => { + return ['api','v2','assets',uidAsset,'advanced-features',uidAdvancedFeature] as const; + } + + +export const getAssetsAdvancedFeaturesRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidAdvancedFeature: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesRetrieveQueryKey(uidAsset,uidAdvancedFeature); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsAdvancedFeaturesRetrieve(uidAsset,uidAdvancedFeature, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidAdvancedFeature), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsAdvancedFeaturesRetrieveQueryResult = NonNullable>> +export type AssetsAdvancedFeaturesRetrieveQueryError = ErrorDetail + + + +export function useAssetsAdvancedFeaturesRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidAdvancedFeature: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsAdvancedFeaturesRetrieveQueryOptions(uidAsset,uidAdvancedFeature,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update an advanced action on an asset + +Update the params of an advanced action on a question in the asset. +`params` are always additive. That means that if you PATCH a feature with a new param array, the new ones +will be added to the existing ones. You cannot delete a param via the API. + +In the case of NLP actions, this means you can only add languages, not delete. +In the case of QA analysis questions, you should send the full set questions and choices in the desired order. Any existing +choices or questions in the existing params not present in the new ones will be marked as deleted, but not actually removed from the data. +Deleted questions and choices will be placed at the end of the relevant list. + +* `params` is required +* `params` must match the expected param_schema of the action being updated + + + + */ +export type assetsAdvancedFeaturesPartialUpdateResponse200 = { + data: AdvancedFeatureResponse + status: 200 +} + +export type assetsAdvancedFeaturesPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsAdvancedFeaturesPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsAdvancedFeaturesPartialUpdateResponseComposite = assetsAdvancedFeaturesPartialUpdateResponse200 | assetsAdvancedFeaturesPartialUpdateResponse400 | assetsAdvancedFeaturesPartialUpdateResponse404; + +export type assetsAdvancedFeaturesPartialUpdateResponse = assetsAdvancedFeaturesPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsAdvancedFeaturesPartialUpdateUrl = (uidAsset: string, + uidAdvancedFeature: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/advanced-features/${uidAdvancedFeature}/` +} + +export const assetsAdvancedFeaturesPartialUpdate = async (uidAsset: string, + uidAdvancedFeature: string, + patchedAdvancedFeaturePatchRequest: PatchedAdvancedFeaturePatchRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAdvancedFeaturesPartialUpdateUrl(uidAsset,uidAdvancedFeature), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedAdvancedFeaturePatchRequest,) + } +);} + + + + +export const getAssetsAdvancedFeaturesPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidAdvancedFeature: string;data: PatchedAdvancedFeaturePatchRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidAdvancedFeature: string;data: PatchedAdvancedFeaturePatchRequest}, TContext> => { + +const mutationKey = ['assetsAdvancedFeaturesPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidAdvancedFeature: string;data: PatchedAdvancedFeaturePatchRequest}> = (props) => { + const {uidAsset,uidAdvancedFeature,data} = props ?? {}; + + return assetsAdvancedFeaturesPartialUpdate(uidAsset,uidAdvancedFeature,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsAdvancedFeaturesPartialUpdateMutationResult = NonNullable>> + export type AssetsAdvancedFeaturesPartialUpdateMutationBody = PatchedAdvancedFeaturePatchRequest + export type AssetsAdvancedFeaturesPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useAssetsAdvancedFeaturesPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidAdvancedFeature: string;data: PatchedAdvancedFeaturePatchRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsAdvancedFeaturesPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## List bulk processing jobs on an asset + +Returns paginated bulk processing jobs associated with the specified asset. Each +job is organized around one action, one question, and many submissions. + +Use this endpoint to monitor recently-created bulk transcription and translation +jobs. Each result includes the parent job status, per-submission statuses, the +original deterministic params, the user who created the job, cancellation +metadata, and integer `progress` from `0` to `100`. + +Job statuses: + +* `pending`: the job exists but has not started. +* `in_progress`: one or more child submissions are still active. +* `complete`: every child submission has reached a terminal state. +* `cancelled`: the job was cancelled. + +Child submission statuses: + +* `pending` +* `in_progress` +* `complete` +* `failed` +* `cancelled` + + */ +export type assetsAdvancedFeaturesBulkActionsListResponse200 = { + data: BulkActionListResponse + status: 200 +} + +export type assetsAdvancedFeaturesBulkActionsListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsAdvancedFeaturesBulkActionsListResponseComposite = assetsAdvancedFeaturesBulkActionsListResponse200 | assetsAdvancedFeaturesBulkActionsListResponse404; + +export type assetsAdvancedFeaturesBulkActionsListResponse = assetsAdvancedFeaturesBulkActionsListResponseComposite & { + headers: Headers; +} + +export const getAssetsAdvancedFeaturesBulkActionsListUrl = (uidAsset: string, + params?: AssetsAdvancedFeaturesBulkActionsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/` +} + +export const assetsAdvancedFeaturesBulkActionsList = async (uidAsset: string, + params?: AssetsAdvancedFeaturesBulkActionsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAdvancedFeaturesBulkActionsListUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsAdvancedFeaturesBulkActionsListQueryKey = (uidAsset: string, + params?: AssetsAdvancedFeaturesBulkActionsListParams,) => { + return ['api','v2','assets',uidAsset,'advanced-features','bulk-actions', ...(params ? [params]: [])] as const; + } + + +export const getAssetsAdvancedFeaturesBulkActionsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsAdvancedFeaturesBulkActionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesBulkActionsListQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsAdvancedFeaturesBulkActionsList(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsAdvancedFeaturesBulkActionsListQueryResult = NonNullable>> +export type AssetsAdvancedFeaturesBulkActionsListQueryError = ErrorDetail + + + +export function useAssetsAdvancedFeaturesBulkActionsList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsAdvancedFeaturesBulkActionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsAdvancedFeaturesBulkActionsListQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create a bulk processing job + +Creates and starts a bulk processing job for one question across multiple +submissions. + +Supported actions: + +* `automatic_google_transcription` +* `automatic_google_translation` + +The request must include the target `question_xpath`, the submission root UUIDs +to process, and deterministic `params`. `params.language` is required. For +transcription, `params.locale` may also be supplied when a more specific Google +Speech locale is needed. + +Creation is atomic. If any selected submission is unknown, already has matching +results, or already has an active matching bulk action, no job or child items are +created. + +The response is the created job. Its initial status is `in_progress` because +creation immediately starts background processing. + + */ +export type assetsAdvancedFeaturesBulkActionsCreateResponse201 = { + data: BulkActionCreateResponse + status: 201 +} + +export type assetsAdvancedFeaturesBulkActionsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsAdvancedFeaturesBulkActionsCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsAdvancedFeaturesBulkActionsCreateResponseComposite = assetsAdvancedFeaturesBulkActionsCreateResponse201 | assetsAdvancedFeaturesBulkActionsCreateResponse400 | assetsAdvancedFeaturesBulkActionsCreateResponse404; + +export type assetsAdvancedFeaturesBulkActionsCreateResponse = assetsAdvancedFeaturesBulkActionsCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsAdvancedFeaturesBulkActionsCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/` +} + +export const assetsAdvancedFeaturesBulkActionsCreate = async (uidAsset: string, + bulkActionCreateRequest: BulkActionCreateRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAdvancedFeaturesBulkActionsCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + bulkActionCreateRequest,) + } +);} + + + + +export const getAssetsAdvancedFeaturesBulkActionsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: BulkActionCreateRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: BulkActionCreateRequest}, TContext> => { + +const mutationKey = ['assetsAdvancedFeaturesBulkActionsCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: BulkActionCreateRequest}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsAdvancedFeaturesBulkActionsCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsAdvancedFeaturesBulkActionsCreateMutationResult = NonNullable>> + export type AssetsAdvancedFeaturesBulkActionsCreateMutationBody = BulkActionCreateRequest + export type AssetsAdvancedFeaturesBulkActionsCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsAdvancedFeaturesBulkActionsCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: BulkActionCreateRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsAdvancedFeaturesBulkActionsCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve a bulk processing job + +Returns detailed information about a single bulk processing job, including its +current status, per-submission status, processing params, creator, cancellation +metadata, timestamps, and integer `progress` from `0` to `100`. + +The response shape is identical to the item returned by the bulk job creation +endpoint and to each item in the paginated list response. + + */ +export type assetsAdvancedFeaturesBulkActionsRetrieveResponse200 = { + data: BulkActionResponse + status: 200 +} + +export type assetsAdvancedFeaturesBulkActionsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsAdvancedFeaturesBulkActionsRetrieveResponseComposite = assetsAdvancedFeaturesBulkActionsRetrieveResponse200 | assetsAdvancedFeaturesBulkActionsRetrieveResponse404; + +export type assetsAdvancedFeaturesBulkActionsRetrieveResponse = assetsAdvancedFeaturesBulkActionsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsAdvancedFeaturesBulkActionsRetrieveUrl = (uidAsset: string, + actionUid: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/${actionUid}/` +} + +export const assetsAdvancedFeaturesBulkActionsRetrieve = async (uidAsset: string, + actionUid: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAdvancedFeaturesBulkActionsRetrieveUrl(uidAsset,actionUid), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsAdvancedFeaturesBulkActionsRetrieveQueryKey = (uidAsset: string, + actionUid: string,) => { + return ['api','v2','assets',uidAsset,'advanced-features','bulk-actions',actionUid] as const; + } + + +export const getAssetsAdvancedFeaturesBulkActionsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + actionUid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesBulkActionsRetrieveQueryKey(uidAsset,actionUid); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsAdvancedFeaturesBulkActionsRetrieve(uidAsset,actionUid, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && actionUid), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsAdvancedFeaturesBulkActionsRetrieveQueryResult = NonNullable>> +export type AssetsAdvancedFeaturesBulkActionsRetrieveQueryError = ErrorDetail + + + +export function useAssetsAdvancedFeaturesBulkActionsRetrieve>, TError = ErrorDetail>( + uidAsset: string, + actionUid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsAdvancedFeaturesBulkActionsRetrieveQueryOptions(uidAsset,actionUid,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update a bulk processing job + +Cancels a single bulk processing job for an asset. This endpoint currently only +supports cancellation. + +Request body: + +```json +{ + "status": "cancelled" +} +``` + +Cancellation is idempotent. Cancelling an already-cancelled job returns the +current cancelled job. Completed jobs cannot be cancelled. + +When a job is cancelled, pending and in-progress child items are marked +`cancelled`; terminal child items are not modified. The response is the updated +job, including `cancelled_by`. + + */ +export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponse200 = { + data: BulkActionResponse + status: 200 +} + +export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponseComposite = assetsAdvancedFeaturesBulkActionsPartialUpdateResponse200 | assetsAdvancedFeaturesBulkActionsPartialUpdateResponse404; + +export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponse = assetsAdvancedFeaturesBulkActionsPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsAdvancedFeaturesBulkActionsPartialUpdateUrl = (uidAsset: string, + actionUid: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/${actionUid}/` +} + +export const assetsAdvancedFeaturesBulkActionsPartialUpdate = async (uidAsset: string, + actionUid: string, + patchedBulkActionPatchRequest: PatchedBulkActionPatchRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAdvancedFeaturesBulkActionsPartialUpdateUrl(uidAsset,actionUid), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedBulkActionPatchRequest,) + } +);} + + + + +export const getAssetsAdvancedFeaturesBulkActionsPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;actionUid: string;data: PatchedBulkActionPatchRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;actionUid: string;data: PatchedBulkActionPatchRequest}, TContext> => { + +const mutationKey = ['assetsAdvancedFeaturesBulkActionsPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;actionUid: string;data: PatchedBulkActionPatchRequest}> = (props) => { + const {uidAsset,actionUid,data} = props ?? {}; + + return assetsAdvancedFeaturesBulkActionsPartialUpdate(uidAsset,actionUid,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationResult = NonNullable>> + export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationBody = PatchedBulkActionPatchRequest + export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationError = ErrorDetail + + export const useAssetsAdvancedFeaturesBulkActionsPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;actionUid: string;data: PatchedBulkActionPatchRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsAdvancedFeaturesBulkActionsPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Delete a specific attachment of an Asset + +* `id` can only be the uid of attachment to be deleted + + */ +export type assetsAttachmentsDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsAttachmentsDestroyResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsAttachmentsDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsAttachmentsDestroyResponseComposite = assetsAttachmentsDestroyResponse204 | assetsAttachmentsDestroyResponse400 | assetsAttachmentsDestroyResponse404; + +export type assetsAttachmentsDestroyResponse = assetsAttachmentsDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsAttachmentsDestroyUrl = (uidAsset: string, + id: number,) => { + + + + + return `/api/v2/assets/${uidAsset}/attachments/${id}/` +} + +export const assetsAttachmentsDestroy = async (uidAsset: string, + id: number, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAttachmentsDestroyUrl(uidAsset,id), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsAttachmentsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: number}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;id: number}, TContext> => { + +const mutationKey = ['assetsAttachmentsDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;id: number}> = (props) => { + const {uidAsset,id} = props ?? {}; + + return assetsAttachmentsDestroy(uidAsset,id,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsAttachmentsDestroyMutationResult = NonNullable>> + + export type AssetsAttachmentsDestroyMutationError = ErrorObject | ErrorDetail + + export const useAssetsAttachmentsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: number}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsAttachmentsDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Get total audio duration for a list of attachments + +```curl + curl -X POST https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/attachments/audio-duration/ +``` + +> **Payload** +> +> { +> "attachment_uids": [ +> "attXXXXXXXXXXXXXXXXX", +> "attYYYYYYYYYYYYYYYYY" +> ] +> } + +* Where: `attachment_uids` (required) is a list of attachment UIDs whose audio duration to retrieve. Maximum 200 UIDs per request. + + +> **Response** +> +> { +> "attachments": [ +> { "uid": "attXXXXXXXXXXXXXXXXX", "seconds": 42 }, +> { "uid": "attYYYYYYYYYYYYYYYYY", "seconds": null } +> ], +> "total": 42 +> } + +* `attachments` - one entry per recognised, accessible UID in the order submitted. + Unrecognised or inaccessible UIDs are silently omitted. +* `seconds` - integer duration, or `null` when `ffprobe` could not determine the duration (corrupt file, unsupported format, etc.). +* `total` - sum of all non-null `seconds` values. + + +### Batching and timeouts + +`ffprobe` takes approximately 0.5 s per file. With a 120 s nginx timeout, sending more +than ~200 files per request risks a **504 Gateway Timeout**. + +* Submit files in small batches from the front-end. +* Retry on 504 - already-processed attachments will be served from the db, so + subsequent attempts complete faster. +* Requests exceeding 200 UIDs are rejected immediately with **400 Bad Request**. + + */ +export type assetsAttachmentsAudioDurationCreateResponse200 = { + data: AssetAttachmentAudioDurationResponse + status: 200 +} + +export type assetsAttachmentsAudioDurationCreateResponseComposite = assetsAttachmentsAudioDurationCreateResponse200; + +export type assetsAttachmentsAudioDurationCreateResponse = assetsAttachmentsAudioDurationCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsAttachmentsAudioDurationCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/attachments/audio-duration/` +} + +export const assetsAttachmentsAudioDurationCreate = async (uidAsset: string, + assetAttachmentAudioDurationRequest: AssetAttachmentAudioDurationRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAttachmentsAudioDurationCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + assetAttachmentAudioDurationRequest,) + } +);} + + + + +export const getAssetsAttachmentsAudioDurationCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: AssetAttachmentAudioDurationRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: AssetAttachmentAudioDurationRequest}, TContext> => { + +const mutationKey = ['assetsAttachmentsAudioDurationCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: AssetAttachmentAudioDurationRequest}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsAttachmentsAudioDurationCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsAttachmentsAudioDurationCreateMutationResult = NonNullable>> + export type AssetsAttachmentsAudioDurationCreateMutationBody = AssetAttachmentAudioDurationRequest + export type AssetsAttachmentsAudioDurationCreateMutationError = unknown + + export const useAssetsAttachmentsAudioDurationCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: AssetAttachmentAudioDurationRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsAttachmentsAudioDurationCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Delete all attachments from a list of submissions + +```curl + curl -X DELETE https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/attachments/bulk/ +``` + +> **Payload** +> +> { +> "submission_root_uuids": [ +> "3ed2e8de-b493-4367-a78d-3463687239dc", +> "ef18fe33-c71d-4638-84d6-dafcbd69c327" +> ] +> } + +* Where: "submission_root_uuids" (required) is a list of submission root uuids on the asset +to delete + + +> **Response** +> +> { +> "message": "{number_of_attachment} attachments deleted" +> } + +* Where: "number_of_attachment" is the number of items that was deleted + + +### !! Due to current DRF-Spectacular limitations with AOS 3.1, DELETE operations do not display request or response bodies in this documentation (as payloads are not typically recommended for DELETE). This means direct testing is unavailable. However, example payloads and responses are provided for reference, and HTTP codes/error messages are accurate. !! + + */ +export type assetsAttachmentsBulkDestroyResponse202 = { + data: void + status: 202 +} + +export type assetsAttachmentsBulkDestroyResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsAttachmentsBulkDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsAttachmentsBulkDestroyResponseComposite = assetsAttachmentsBulkDestroyResponse202 | assetsAttachmentsBulkDestroyResponse400 | assetsAttachmentsBulkDestroyResponse404; + +export type assetsAttachmentsBulkDestroyResponse = assetsAttachmentsBulkDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsAttachmentsBulkDestroyUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/attachments/bulk/` +} + +export const assetsAttachmentsBulkDestroy = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsAttachmentsBulkDestroyUrl(uidAsset), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsAttachmentsBulkDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { + +const mutationKey = ['assetsAttachmentsBulkDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { + const {uidAsset} = props ?? {}; + + return assetsAttachmentsBulkDestroy(uidAsset,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsAttachmentsBulkDestroyMutationResult = NonNullable>> + + export type AssetsAttachmentsBulkDestroyMutationError = ErrorObject | ErrorDetail + + export const useAssetsAttachmentsBulkDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsAttachmentsBulkDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## List of submissions for a specific asset + +By default, JSON format is used, but XML and GeoJSON are also available: + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/ +``` + +### Pagination +Two parameters can be used to control pagination. + +* `start`: Index (zero-based) from which the results start +* `limit`: Number of results per page Maximum results per page cannot exceed **1000**, unless changed by server configuration + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/?start=0&limit=10 +``` + +### Query submitted data +Provides a list of submitted data for a specific form. Use `query` +parameter to apply form data specific, see +http://docs.mongodb.org/manual/reference/operator/query/. + +For more details see +API Parameters. + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/?query={"__version__": "vWvkKzNE8xCtfApJvabfjG"} +curl https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/?query={"_submission_time": {"$gt": "2019-09-01T01:02:03"}} +``` + +### About the GeoJSON format +Requesting the `geojson` format returns a `FeatureCollection` where each +submission is a `Feature`. If your form has multiple geographic questions, +use the `geo_question_name` query parameter to determine which question's +responses populate the `geometry` for each `Feature`; otherwise, the first +geographic question is used. All question/response pairs are included in +the `properties` of each `Feature`, but _repeating groups are omitted_. + +Question types are mapped to GeoJSON geometry types as follows: + +* `geopoint` to `Point`; +* `geotrace` to `LineString`; +* `geoshape` to `Polygon`. + + + +### ⚠️ Note: DRF-Spectacular Limitation + +Due to limitations in **DRF-Spectacular**, the `ACCEPT` headers do not sync properly with the request. As a result, all responses will default to `application/json`, regardless of the specified format. + +This means that while alternative formats (like XML) are technically supported and will work via command-line tools (e.g., `curl`), **they will not work** when trying out the endpoint directly from the documentation page. + +We’ve still included the header to show supported formats, but keep in mind: +**Only `application/json` will be used in the docs UI.** + + */ +export type assetsDataListResponse200 = { + data: PaginatedDataResponseList + status: 200 +} + +export type assetsDataListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataListResponseComposite = assetsDataListResponse200 | assetsDataListResponse404; + +export type assetsDataListResponse = assetsDataListResponseComposite & { + headers: Headers; +} + +export const getAssetsDataListUrl = (uidAsset: string, + params?: AssetsDataListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/data/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/data/` +} + +export const assetsDataList = async (uidAsset: string, + params?: AssetsDataListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataListUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDataListQueryKey = (uidAsset: string, + params?: AssetsDataListParams,) => { + return ['api','v2','assets',uidAsset,'data', ...(params ? [params]: [])] as const; + } + + +export const getAssetsDataListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsDataListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDataListQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDataList(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDataListQueryResult = NonNullable>> +export type AssetsDataListQueryError = ErrorDetail + + + +export function useAssetsDataList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsDataListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDataListQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Get a specific submission + +`{id}` can be: + +- The primary key of the submission +- Its `_uuid` 1 +- Its `rootUuid` (without "uuid:" prefix) + +1 Please note that using the `_uuid` may match **several** submissions, only +the first match will be returned. + + +It is also possible to specify the format. + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid_asset}/data/{id}.xml +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid_asset}/data/{id}.json +``` + +or + +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid_asset}/data/{id}/?format=xml +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid_asset}/data/{id}/?format=json +``` + +### ⚠️ Note: DRF-Spectacular Limitation + +Due to limitations in **DRF-Spectacular**, the `ACCEPT` headers do not sync properly with the request. As a result, all responses will default to `application/json`, regardless of the specified format. + +This means that while alternative formats (like XML) are technically supported and will work via command-line tools (e.g., `curl`), **they will not work** when trying out the endpoint directly from the documentation page. + +We’ve still included the header to show supported formats, but keep in mind: +**Only `application/json` will be used in the docs UI.** + + */ +export type assetsDataRetrieveResponse200 = { + data: DataResponse + status: 200 +} + +export type assetsDataRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataRetrieveResponseComposite = assetsDataRetrieveResponse200 | assetsDataRetrieveResponse404; + +export type assetsDataRetrieveResponse = assetsDataRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsDataRetrieveUrl = (uidAsset: string, + id: string, + params?: AssetsDataRetrieveParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/data/${id}/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/data/${id}/` +} + +export const assetsDataRetrieve = async (uidAsset: string, + id: string, + params?: AssetsDataRetrieveParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataRetrieveUrl(uidAsset,id,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDataRetrieveQueryKey = (uidAsset: string, + id: string, + params?: AssetsDataRetrieveParams,) => { + return ['api','v2','assets',uidAsset,'data',id, ...(params ? [params]: [])] as const; + } + + +export const getAssetsDataRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + id: string, + params?: AssetsDataRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDataRetrieveQueryKey(uidAsset,id,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDataRetrieve(uidAsset,id,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDataRetrieveQueryResult = NonNullable>> +export type AssetsDataRetrieveQueryError = ErrorDetail + + + +export function useAssetsDataRetrieve>, TError = ErrorDetail>( + uidAsset: string, + id: string, + params?: AssetsDataRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDataRetrieveQueryOptions(uidAsset,id,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Deletes current submission + + */ +export type assetsDataDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsDataDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataDestroyResponseComposite = assetsDataDestroyResponse204 | assetsDataDestroyResponse404; + +export type assetsDataDestroyResponse = assetsDataDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsDataDestroyUrl = (uidAsset: string, + id: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${id}/` +} + +export const assetsDataDestroy = async (uidAsset: string, + id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataDestroyUrl(uidAsset,id), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsDataDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext> => { + +const mutationKey = ['assetsDataDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;id: string}> = (props) => { + const {uidAsset,id} = props ?? {}; + + return assetsDataDestroy(uidAsset,id,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDataDestroyMutationResult = NonNullable>> + + export type AssetsDataDestroyMutationError = ErrorDetail + + export const useAssetsDataDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDataDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Duplicate submission + +Duplicates the data of a submission + +`{id}` can be: + +- The primary key of the submission +- Its `_uuid` 1 +- Its `rootUuid` (without "uuid:" prefix) + +1 Please note that using the `_uuid` may match **several** submissions, only +the first match will be returned. + + */ +export type assetsDataDuplicateCreateResponse200 = { + data: DataResponse + status: 200 +} + +export type assetsDataDuplicateCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataDuplicateCreateResponseComposite = assetsDataDuplicateCreateResponse200 | assetsDataDuplicateCreateResponse404; + +export type assetsDataDuplicateCreateResponse = assetsDataDuplicateCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsDataDuplicateCreateUrl = (uidAsset: string, + id: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${id}/duplicate/` +} + +export const assetsDataDuplicateCreate = async (uidAsset: string, + id: string, + dataBulkDelete: DataBulkDelete, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataDuplicateCreateUrl(uidAsset,id), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + dataBulkDelete,) + } +);} + + + + +export const getAssetsDataDuplicateCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string;data: DataBulkDelete}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;id: string;data: DataBulkDelete}, TContext> => { + +const mutationKey = ['assetsDataDuplicateCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;id: string;data: DataBulkDelete}> = (props) => { + const {uidAsset,id,data} = props ?? {}; + + return assetsDataDuplicateCreate(uidAsset,id,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDataDuplicateCreateMutationResult = NonNullable>> + export type AssetsDataDuplicateCreateMutationBody = DataBulkDelete + export type AssetsDataDuplicateCreateMutationError = ErrorDetail + + export const useAssetsDataDuplicateCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string;data: DataBulkDelete}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDataDuplicateCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Get submission url of enketo in edit mode + +`{id}` can be: + +- The primary key of the submission +- Its `_uuid` 1 +- Its `rootUuid` (without "uuid:" prefix) + +1 Please note that using the `_uuid` may match **several** submissions, only +the first match will be returned. + +Note: Some variation of this url exists: + +`/api/v2/assets/{uid_asset}/data/{id}/edit/`: deprecated, use the next one. + +`/api/v2/assets/{uid_asset}/data/{id}/enketo/edit/`: return the url of the enketo submission (as seen in the response example). + +`/api/v2/assets/{uid_asset}/data/{id}/enketo/redirect/edit/`: redirect to the enketo url submission with a 302 HTTP code. + + */ +export type assetsDataEditRetrieveResponse200 = { + data: EnketoEditResponse + status: 200 +} + +export type assetsDataEditRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsDataEditRetrieveResponseComposite = assetsDataEditRetrieveResponse200 | assetsDataEditRetrieveResponse403; + +export type assetsDataEditRetrieveResponse = assetsDataEditRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsDataEditRetrieveUrl = (uidAsset: string, + id: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${id}/edit/` +} + +export const assetsDataEditRetrieve = async (uidAsset: string, + id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataEditRetrieveUrl(uidAsset,id), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDataEditRetrieveQueryKey = (uidAsset: string, + id: string,) => { + return ['api','v2','assets',uidAsset,'data',id,'edit'] as const; + } + + +export const getAssetsDataEditRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDataEditRetrieveQueryKey(uidAsset,id); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDataEditRetrieve(uidAsset,id, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDataEditRetrieveQueryResult = NonNullable>> +export type AssetsDataEditRetrieveQueryError = ErrorDetail + + + +export function useAssetsDataEditRetrieve>, TError = ErrorDetail>( + uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDataEditRetrieveQueryOptions(uidAsset,id,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Get submission url of enketo in edit mode + +`{id}` can be: + +- The primary key of the submission +- Its `_uuid` 1 +- Its `rootUuid` (without "uuid:" prefix) + +1 Please note that using the `_uuid` may match **several** submissions, only +the first match will be returned. + +Note: Some variation of this url exists: + +`/api/v2/assets/{uid_asset}/data/{id}/edit/`: deprecated, use the next one. + +`/api/v2/assets/{uid_asset}/data/{id}/enketo/edit/`: return the url of the enketo submission (as seen in the response example). + +`/api/v2/assets/{uid_asset}/data/{id}/enketo/redirect/edit/`: redirect to the enketo url submission with a 302 HTTP code. + + */ +export type assetsDataEnketoEditRetrieveResponse200 = { + data: EnketoEditResponse + status: 200 +} + +export type assetsDataEnketoEditRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsDataEnketoEditRetrieveResponseComposite = assetsDataEnketoEditRetrieveResponse200 | assetsDataEnketoEditRetrieveResponse403; + +export type assetsDataEnketoEditRetrieveResponse = assetsDataEnketoEditRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsDataEnketoEditRetrieveUrl = (uidAsset: string, + id: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${id}/enketo/edit/` +} + +export const assetsDataEnketoEditRetrieve = async (uidAsset: string, + id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataEnketoEditRetrieveUrl(uidAsset,id), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDataEnketoEditRetrieveQueryKey = (uidAsset: string, + id: string,) => { + return ['api','v2','assets',uidAsset,'data',id,'enketo','edit'] as const; + } + + +export const getAssetsDataEnketoEditRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoEditRetrieveQueryKey(uidAsset,id); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDataEnketoEditRetrieve(uidAsset,id, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDataEnketoEditRetrieveQueryResult = NonNullable>> +export type AssetsDataEnketoEditRetrieveQueryError = ErrorDetail + + + +export function useAssetsDataEnketoEditRetrieve>, TError = ErrorDetail>( + uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDataEnketoEditRetrieveQueryOptions(uidAsset,id,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Get submission url of enketo in edit mode + +`{id}` can be: + +- The primary key of the submission +- Its `_uuid` 1 +- Its `rootUuid` (without "uuid:" prefix) + +1 Please note that using the `_uuid` may match **several** submissions, only +the first match will be returned. + +Note: Some variation of this url exists: + +`/api/v2/assets/{uid_asset}/data/{id}/edit/`: deprecated, use the next one. + +`/api/v2/assets/{uid_asset}/data/{id}/enketo/edit/`: return the url of the enketo submission (as seen in the response example). + +`/api/v2/assets/{uid_asset}/data/{id}/enketo/redirect/edit/`: redirect to the enketo url submission with a 302 HTTP code. + + */ +export type assetsDataEnketoRedirectEditRetrieveResponse200 = { + data: EnketoEditResponse + status: 200 +} + +export type assetsDataEnketoRedirectEditRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsDataEnketoRedirectEditRetrieveResponseComposite = assetsDataEnketoRedirectEditRetrieveResponse200 | assetsDataEnketoRedirectEditRetrieveResponse403; + +export type assetsDataEnketoRedirectEditRetrieveResponse = assetsDataEnketoRedirectEditRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsDataEnketoRedirectEditRetrieveUrl = (uidAsset: string, + id: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${id}/enketo/redirect/edit/` +} + +export const assetsDataEnketoRedirectEditRetrieve = async (uidAsset: string, + id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataEnketoRedirectEditRetrieveUrl(uidAsset,id), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDataEnketoRedirectEditRetrieveQueryKey = (uidAsset: string, + id: string,) => { + return ['api','v2','assets',uidAsset,'data',id,'enketo','redirect','edit'] as const; + } + + +export const getAssetsDataEnketoRedirectEditRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoRedirectEditRetrieveQueryKey(uidAsset,id); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDataEnketoRedirectEditRetrieve(uidAsset,id, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDataEnketoRedirectEditRetrieveQueryResult = NonNullable>> +export type AssetsDataEnketoRedirectEditRetrieveQueryError = ErrorDetail + + + +export function useAssetsDataEnketoRedirectEditRetrieve>, TError = ErrorDetail>( + uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDataEnketoRedirectEditRetrieveQueryOptions(uidAsset,id,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Get submission url of enketo in preview mode + +`{id}` can be: + +- The primary key of the submission +- Its `_uuid` 1 +- Its `rootUuid` (without "uuid:" prefix) + +1 Please note that using the `_uuid` may match **several** submissions, only +the first match will be returned. + +Note: Some variation of this url exists: + +`/api/v2/assets/{uid_asset}/data/{id}/enketo/view/`: return the url of the enketo submission (as seen in the response example). + +`/api/v2/assets/{uid_asset}/data/{id}/enketo/redirect/view/`: redirect to the enketo url submission with a 302 code. + + */ +export type assetsDataEnketoRedirectViewRetrieveResponse200 = { + data: EnketoViewResponse + status: 200 +} + +export type assetsDataEnketoRedirectViewRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsDataEnketoRedirectViewRetrieveResponseComposite = assetsDataEnketoRedirectViewRetrieveResponse200 | assetsDataEnketoRedirectViewRetrieveResponse403; + +export type assetsDataEnketoRedirectViewRetrieveResponse = assetsDataEnketoRedirectViewRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsDataEnketoRedirectViewRetrieveUrl = (uidAsset: string, + id: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${id}/enketo/redirect/view/` +} + +export const assetsDataEnketoRedirectViewRetrieve = async (uidAsset: string, + id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataEnketoRedirectViewRetrieveUrl(uidAsset,id), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDataEnketoRedirectViewRetrieveQueryKey = (uidAsset: string, + id: string,) => { + return ['api','v2','assets',uidAsset,'data',id,'enketo','redirect','view'] as const; + } + + +export const getAssetsDataEnketoRedirectViewRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoRedirectViewRetrieveQueryKey(uidAsset,id); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDataEnketoRedirectViewRetrieve(uidAsset,id, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDataEnketoRedirectViewRetrieveQueryResult = NonNullable>> +export type AssetsDataEnketoRedirectViewRetrieveQueryError = ErrorDetail + + + +export function useAssetsDataEnketoRedirectViewRetrieve>, TError = ErrorDetail>( + uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDataEnketoRedirectViewRetrieveQueryOptions(uidAsset,id,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Get submission url of enketo in preview mode + +`{id}` can be: + +- The primary key of the submission +- Its `_uuid` 1 +- Its `rootUuid` (without "uuid:" prefix) + +1 Please note that using the `_uuid` may match **several** submissions, only +the first match will be returned. + +Note: Some variation of this url exists: + +`/api/v2/assets/{uid_asset}/data/{id}/enketo/view/`: return the url of the enketo submission (as seen in the response example). + +`/api/v2/assets/{uid_asset}/data/{id}/enketo/redirect/view/`: redirect to the enketo url submission with a 302 code. + + */ +export type assetsDataEnketoViewRetrieveResponse200 = { + data: EnketoViewResponse + status: 200 +} + +export type assetsDataEnketoViewRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsDataEnketoViewRetrieveResponseComposite = assetsDataEnketoViewRetrieveResponse200 | assetsDataEnketoViewRetrieveResponse403; + +export type assetsDataEnketoViewRetrieveResponse = assetsDataEnketoViewRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsDataEnketoViewRetrieveUrl = (uidAsset: string, + id: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${id}/enketo/view/` +} + +export const assetsDataEnketoViewRetrieve = async (uidAsset: string, + id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataEnketoViewRetrieveUrl(uidAsset,id), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDataEnketoViewRetrieveQueryKey = (uidAsset: string, + id: string,) => { + return ['api','v2','assets',uidAsset,'data',id,'enketo','view'] as const; + } + + +export const getAssetsDataEnketoViewRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoViewRetrieveQueryKey(uidAsset,id); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDataEnketoViewRetrieve(uidAsset,id, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDataEnketoViewRetrieveQueryResult = NonNullable>> +export type AssetsDataEnketoViewRetrieveQueryError = ErrorDetail + + + +export function useAssetsDataEnketoViewRetrieve>, TError = ErrorDetail>( + uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDataEnketoViewRetrieveQueryOptions(uidAsset,id,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Get validation statuses +Retrieves the validation status of a submission. + + */ +export type assetsDataValidationStatusRetrieveResponse200 = { + data: DataValidationStatusUpdateResponse + status: 200 +} + +export type assetsDataValidationStatusRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataValidationStatusRetrieveResponseComposite = assetsDataValidationStatusRetrieveResponse200 | assetsDataValidationStatusRetrieveResponse404; + +export type assetsDataValidationStatusRetrieveResponse = assetsDataValidationStatusRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsDataValidationStatusRetrieveUrl = (uidAsset: string, + id: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${id}/validation_status/` +} + +export const assetsDataValidationStatusRetrieve = async (uidAsset: string, + id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataValidationStatusRetrieveUrl(uidAsset,id), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDataValidationStatusRetrieveQueryKey = (uidAsset: string, + id: string,) => { + return ['api','v2','assets',uidAsset,'data',id,'validation_status'] as const; + } + + +export const getAssetsDataValidationStatusRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDataValidationStatusRetrieveQueryKey(uidAsset,id); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDataValidationStatusRetrieve(uidAsset,id, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDataValidationStatusRetrieveQueryResult = NonNullable>> +export type AssetsDataValidationStatusRetrieveQueryError = ErrorDetail + + + +export function useAssetsDataValidationStatusRetrieve>, TError = ErrorDetail>( + uidAsset: string, + id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDataValidationStatusRetrieveQueryOptions(uidAsset,id,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update the validation of a submission + +The validation status of the submission can be updated. The `validation_status.uid` should be a `string`, and it must be one of the following values: + +- `validation_status_approved` +- `validation_status_not_approved` +- `validation_status_on_hold` + + */ +export type assetsDataValidationStatusPartialUpdateResponse200 = { + data: DataValidationStatusUpdateResponse + status: 200 +} + +export type assetsDataValidationStatusPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataValidationStatusPartialUpdateResponseComposite = assetsDataValidationStatusPartialUpdateResponse200 | assetsDataValidationStatusPartialUpdateResponse404; + +export type assetsDataValidationStatusPartialUpdateResponse = assetsDataValidationStatusPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsDataValidationStatusPartialUpdateUrl = (uidAsset: string, + id: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${id}/validation_status/` +} + +export const assetsDataValidationStatusPartialUpdate = async (uidAsset: string, + id: string, + patchedDataValidationStatusUpdatePayload: PatchedDataValidationStatusUpdatePayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataValidationStatusPartialUpdateUrl(uidAsset,id), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedDataValidationStatusUpdatePayload,) + } +);} + + + + +export const getAssetsDataValidationStatusPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string;data: PatchedDataValidationStatusUpdatePayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;id: string;data: PatchedDataValidationStatusUpdatePayload}, TContext> => { + +const mutationKey = ['assetsDataValidationStatusPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;id: string;data: PatchedDataValidationStatusUpdatePayload}> = (props) => { + const {uidAsset,id,data} = props ?? {}; + + return assetsDataValidationStatusPartialUpdate(uidAsset,id,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDataValidationStatusPartialUpdateMutationResult = NonNullable>> + export type AssetsDataValidationStatusPartialUpdateMutationBody = PatchedDataValidationStatusUpdatePayload + export type AssetsDataValidationStatusPartialUpdateMutationError = ErrorDetail + + export const useAssetsDataValidationStatusPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string;data: PatchedDataValidationStatusUpdatePayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDataValidationStatusPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Delete validation status + + */ +export type assetsDataValidationStatusDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsDataValidationStatusDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataValidationStatusDestroyResponseComposite = assetsDataValidationStatusDestroyResponse204 | assetsDataValidationStatusDestroyResponse404; + +export type assetsDataValidationStatusDestroyResponse = assetsDataValidationStatusDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsDataValidationStatusDestroyUrl = (uidAsset: string, + id: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${id}/validation_status/` +} + +export const assetsDataValidationStatusDestroy = async (uidAsset: string, + id: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataValidationStatusDestroyUrl(uidAsset,id), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsDataValidationStatusDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext> => { + +const mutationKey = ['assetsDataValidationStatusDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;id: string}> = (props) => { + const {uidAsset,id} = props ?? {}; + + return assetsDataValidationStatusDestroy(uidAsset,id,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDataValidationStatusDestroyMutationResult = NonNullable>> + + export type AssetsDataValidationStatusDestroyMutationError = ErrorDetail + + export const useAssetsDataValidationStatusDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDataValidationStatusDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve submission supplementary data + +This endpoint allows you to retrieve supplementary data attached to a submission. + +The supplementary data may include: + +* NLP actions + * Manual transcription + * Manual translation + * Automatic Google transcription + * Automatic Google translation +* Qualitative analysis - manual or automatic with Bedrock + * Text + * Number + * Single Choice + * Multiple Choice +* Qualitative analysis (manual only) + * Tags + +⚠️ The response examples in this documentation show each action in isolation for +readability. + +In practice, multiple actions can be combined for the same question, and a single +submission may contain multiple questions. + + */ +export type assetsDataSupplementRetrieveResponse200 = { + data: DataSupplementResponse + status: 200 +} + +export type assetsDataSupplementRetrieveResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsDataSupplementRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsDataSupplementRetrieveResponseComposite = assetsDataSupplementRetrieveResponse200 | assetsDataSupplementRetrieveResponse400 | assetsDataSupplementRetrieveResponse401; + +export type assetsDataSupplementRetrieveResponse = assetsDataSupplementRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsDataSupplementRetrieveUrl = (uidAsset: string, + rootUuid: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${rootUuid}/supplement/` +} + +export const assetsDataSupplementRetrieve = async (uidAsset: string, + rootUuid: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataSupplementRetrieveUrl(uidAsset,rootUuid), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDataSupplementRetrieveQueryKey = (uidAsset: string, + rootUuid: string,) => { + return ['api','v2','assets',uidAsset,'data',rootUuid,'supplement'] as const; + } + + +export const getAssetsDataSupplementRetrieveQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidAsset: string, + rootUuid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDataSupplementRetrieveQueryKey(uidAsset,rootUuid); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDataSupplementRetrieve(uidAsset,rootUuid, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && rootUuid), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDataSupplementRetrieveQueryResult = NonNullable>> +export type AssetsDataSupplementRetrieveQueryError = ErrorObject | ErrorDetail + + + +export function useAssetsDataSupplementRetrieve>, TError = ErrorObject | ErrorDetail>( + uidAsset: string, + rootUuid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDataSupplementRetrieveQueryOptions(uidAsset,rootUuid,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update submission supplementary data + +This endpoint allows you to add, update, or delete supplementary data for a submission. + +It supports the same action types as the GET endpoint: + +* NLP actions (manual and automatic transcription / translation) +* Qualitative analysis (manual and automatic) + +The PATCH payload follows the same per-question structure as the GET response. + +To delete a submission supplement, you need to PATCH the submission supplement +with the appropriate null or empty value. + +⚠️ In this documentation, request and response examples present each action in +isolation for clarity. In practice, multiple actions may be combined within the same +payload or response, including for the same question, and a single submission may +contain multiple questions. + + */ +export type assetsDataSupplementPartialUpdateResponse200 = { + data: DataSupplementResponse + status: 200 +} + +export type assetsDataSupplementPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsDataSupplementPartialUpdateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetsDataSupplementPartialUpdateResponseComposite = assetsDataSupplementPartialUpdateResponse200 | assetsDataSupplementPartialUpdateResponse400 | assetsDataSupplementPartialUpdateResponse401; + +export type assetsDataSupplementPartialUpdateResponse = assetsDataSupplementPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsDataSupplementPartialUpdateUrl = (uidAsset: string, + rootUuid: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${rootUuid}/supplement/` +} + +export const assetsDataSupplementPartialUpdate = async (uidAsset: string, + rootUuid: string, + patchedDataSupplementPayload: PatchedDataSupplementPayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataSupplementPartialUpdateUrl(uidAsset,rootUuid), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedDataSupplementPayload,) + } +);} + + + + +export const getAssetsDataSupplementPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;rootUuid: string;data: PatchedDataSupplementPayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;rootUuid: string;data: PatchedDataSupplementPayload}, TContext> => { + +const mutationKey = ['assetsDataSupplementPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;rootUuid: string;data: PatchedDataSupplementPayload}> = (props) => { + const {uidAsset,rootUuid,data} = props ?? {}; + + return assetsDataSupplementPartialUpdate(uidAsset,rootUuid,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDataSupplementPartialUpdateMutationResult = NonNullable>> + export type AssetsDataSupplementPartialUpdateMutationBody = PatchedDataSupplementPayload + export type AssetsDataSupplementPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useAssetsDataSupplementPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;rootUuid: string;data: PatchedDataSupplementPayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDataSupplementPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Get an asset's attachment using xpath + +* `uid_data` can be the primary key of the submission or its `uuid`. +Please note that using the `uuid` may match **several** submissions, only +the first match will be returned. + +Use the `xpath` property to retrieve an attachment. + +```curl +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/?xpath=Upload_a_file +``` + +### Get an MP3 file from an audio or video file +Convert audio and video files. Only conversions to MP3 is supported for this feature + +```curl +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/?xpath=Upload_a_file&format=mp3 +``` + + */ +export type assetsDataAttachmentsListResponse200 = { + data: void + status: 200 +} + +export type assetsDataAttachmentsListResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsDataAttachmentsListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataAttachmentsListResponseComposite = assetsDataAttachmentsListResponse200 | assetsDataAttachmentsListResponse400 | assetsDataAttachmentsListResponse404; + +export type assetsDataAttachmentsListResponse = assetsDataAttachmentsListResponseComposite & { + headers: Headers; +} + +export const getAssetsDataAttachmentsListUrl = (uidAsset: string, + uidData: string, + params: AssetsDataAttachmentsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/` +} + +export const assetsDataAttachmentsList = async (uidAsset: string, + uidData: string, + params: AssetsDataAttachmentsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataAttachmentsListUrl(uidAsset,uidData,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsDataAttachmentsListQueryKey = (uidAsset: string, + uidData: string, + params: AssetsDataAttachmentsListParams,) => { + return ['api','v2','assets',uidAsset,'data',uidData,'attachments', ...(params ? [params]: [])] as const; + } + + +export const getAssetsDataAttachmentsListQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidAsset: string, + uidData: string, + params: AssetsDataAttachmentsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsDataAttachmentsListQueryKey(uidAsset,uidData,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsDataAttachmentsList(uidAsset,uidData,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidData), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsDataAttachmentsListQueryResult = NonNullable>> +export type AssetsDataAttachmentsListQueryError = ErrorObject | ErrorDetail + + + +export function useAssetsDataAttachmentsList>, TError = ErrorObject | ErrorDetail>( + uidAsset: string, + uidData: string, + params: AssetsDataAttachmentsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsDataAttachmentsListQueryOptions(uidAsset,uidData,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Get an asset's attachment using the ID + +* `uid_data` can be the primary key of the submission or its `uuid`. +Please note that using the `uuid` may match **several** submissions, only +the first match will be returned. + +* `id` of attachment can be the primary key of the attachment or its `uid`. + +Both examples works: +```curl +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/1/ +``` +Or, using the `UID`: +```curl +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/attwYwGxdtQPSqgmHk6wS6E6/ +``` + +### Get an MP3 file from an audio or video file +Convert audio and video files. Only conversions to MP3 is supported for this feature + +```curl +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/1/?format=mp3 +``` + + */ +export type attachmentRetrieveResponse200 = { + data: void + status: 200 +} + +export type attachmentRetrieveResponse400 = { + data: ErrorObject + status: 400 +} + +export type attachmentRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type attachmentRetrieveResponseComposite = attachmentRetrieveResponse200 | attachmentRetrieveResponse400 | attachmentRetrieveResponse404; + +export type attachmentRetrieveResponse = attachmentRetrieveResponseComposite & { + headers: Headers; +} + +export const getAttachmentRetrieveUrl = (uidAsset: string, + uidData: string, + id: number, + params?: AttachmentRetrieveParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/` +} + +export const attachmentRetrieve = async (uidAsset: string, + uidData: string, + id: number, + params?: AttachmentRetrieveParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAttachmentRetrieveUrl(uidAsset,uidData,id,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAttachmentRetrieveQueryKey = (uidAsset: string, + uidData: string, + id: number, + params?: AttachmentRetrieveParams,) => { + return ['api','v2','assets',uidAsset,'data',uidData,'attachments',id, ...(params ? [params]: [])] as const; + } + + +export const getAttachmentRetrieveQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidAsset: string, + uidData: string, + id: number, + params?: AttachmentRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAttachmentRetrieveQueryKey(uidAsset,uidData,id,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => attachmentRetrieve(uidAsset,uidData,id,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidData && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AttachmentRetrieveQueryResult = NonNullable>> +export type AttachmentRetrieveQueryError = ErrorObject | ErrorDetail + + + +export function useAttachmentRetrieve>, TError = ErrorObject | ErrorDetail>( + uidAsset: string, + uidData: string, + id: number, + params?: AttachmentRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAttachmentRetrieveQueryOptions(uidAsset,uidData,id,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Get a specific size of the user's attachment (Only for images) + +Available formats: +- `small` +- `medium` +- `large` + +`id` of attachment can be the primary key of the attachment or its `uid`. + +Both examples works: +```curl +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/1/small/ +``` +Or, using the `UID`: +```curl +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/attwYwGxdtQPSqgmHk6wS6E6/medium/ +``` + + */ +export type attachmentThumbnailResponse200 = { + data: void + status: 200 +} + +export type attachmentThumbnailResponse404 = { + data: ErrorDetail + status: 404 +} + +export type attachmentThumbnailResponseComposite = attachmentThumbnailResponse200 | attachmentThumbnailResponse404; + +export type attachmentThumbnailResponse = attachmentThumbnailResponseComposite & { + headers: Headers; +} + +export const getAttachmentThumbnailUrl = (uidAsset: string, + uidData: string, + id: number, + suffix: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/${suffix}/` +} + +export const attachmentThumbnail = async (uidAsset: string, + uidData: string, + id: number, + suffix: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAttachmentThumbnailUrl(uidAsset,uidData,id,suffix), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAttachmentThumbnailQueryKey = (uidAsset: string, + uidData: string, + id: number, + suffix: string,) => { + return ['api','v2','assets',uidAsset,'data',uidData,'attachments',id,suffix] as const; + } + + +export const getAttachmentThumbnailQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidData: string, + id: number, + suffix: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAttachmentThumbnailQueryKey(uidAsset,uidData,id,suffix); + + + + const queryFn: QueryFunction>> = ({ signal }) => attachmentThumbnail(uidAsset,uidData,id,suffix, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidData && id && suffix), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AttachmentThumbnailQueryResult = NonNullable>> +export type AttachmentThumbnailQueryError = ErrorDetail + + + +export function useAttachmentThumbnail>, TError = ErrorDetail>( + uidAsset: string, + uidData: string, + id: number, + suffix: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAttachmentThumbnailQueryOptions(uidAsset,uidData,id,suffix,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Bulk updating of submissions + +Where `` is a string and should be an existing XML field value of the submissions. +If `` is part of a group or nested group, the field must follow the group hierarchy +structure, i.e.: + +If the field is within a group called `group_1`, the field name is `question_1` and the new value is `new value`, +the payload should contain an item with the following structure: + +*"group_1/question_1": "new value"* + + +Similarly, if there are `N` nested groups, the structure will be: + +*"group_1/sub_group_1/.../sub_group_n/question_1": "new value"* + + */ +export type assetsDataBulkPartialUpdateResponse200 = { + data: DataBulkUpdateResponse + status: 200 +} + +export type assetsDataBulkPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataBulkPartialUpdateResponseComposite = assetsDataBulkPartialUpdateResponse200 | assetsDataBulkPartialUpdateResponse404; + +export type assetsDataBulkPartialUpdateResponse = assetsDataBulkPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsDataBulkPartialUpdateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/bulk/` +} + +export const assetsDataBulkPartialUpdate = async (uidAsset: string, + patchedDataBulkUpdate: PatchedDataBulkUpdate, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataBulkPartialUpdateUrl(uidAsset), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedDataBulkUpdate,) + } +);} + + + + +export const getAssetsDataBulkPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataBulkUpdate}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataBulkUpdate}, TContext> => { + +const mutationKey = ['assetsDataBulkPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: PatchedDataBulkUpdate}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsDataBulkPartialUpdate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDataBulkPartialUpdateMutationResult = NonNullable>> + export type AssetsDataBulkPartialUpdateMutationBody = PatchedDataBulkUpdate + export type AssetsDataBulkPartialUpdateMutationError = ErrorDetail + + export const useAssetsDataBulkPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataBulkUpdate}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDataBulkPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Bulk delete submissions + +```curl + curl -X DELETE https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/bulk/ +``` + +**Payload** +```json +{ + "submissions_ids": [ + 1, + 2 + ] + } +``` +* Where: `submissions_ids` (required) is a list of submission root id on the data +to delete + + +**Response** +```json +{ + "detail": "{number_of_submissions} submissions have been deleted" +} +``` +* Where: `number_of_submissions` is the number of items that was deleted + + +_Due to limitations with DRF-Spectacular current version, `DELETE` actions do not support showing a request body OR a response body. This is due to the 'vague' nature of the action which generally does *not* recommend the use of a payload. To still document this endpoint, example for the payload and response will be included but it will not be possible to test this endpoint. The HTTP code and the errors example are, for their part, factual and can be considered when working with the endpoint._ + + */ +export type assetsDataBulkDestroyResponse200 = { + data: void + status: 200 +} + +export type assetsDataBulkDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataBulkDestroyResponseComposite = assetsDataBulkDestroyResponse200 | assetsDataBulkDestroyResponse404; + +export type assetsDataBulkDestroyResponse = assetsDataBulkDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsDataBulkDestroyUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/bulk/` +} + +export const assetsDataBulkDestroy = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataBulkDestroyUrl(uidAsset), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsDataBulkDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { + +const mutationKey = ['assetsDataBulkDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { + const {uidAsset} = props ?? {}; + + return assetsDataBulkDestroy(uidAsset,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDataBulkDestroyMutationResult = NonNullable>> + + export type AssetsDataBulkDestroyMutationError = ErrorDetail + + export const useAssetsDataBulkDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDataBulkDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Bulk accept NLP results + +Accepts transcription or translation results for multiple submissions in a +single request. This is the bulk counterpart of the per-submission acceptance +flow: instead of visiting each submission individually, users can select +multiple submissions and approve all of them at once. + +The `operation` field declares the operation to perform. Currently only `"accept"` +is supported. + +### Transcription example + +```json +{ + "submission_uids": ["", ""], + "question_xpath": "group_name/audio_question", + "action_id": "automatic_google_transcription", + "operation": "accept" +} +``` + +### Translation example + +For translation actions the `language` field is **required**: + +```json +{ + "submission_uids": ["", ""], + "question_xpath": "group_name/audio_question", + "action_id": "automatic_google_translation", + "language": "fr", + "operation": "accept" +} +``` + +### Response + +Returns the number of submission records that were successfully accepted. +Submissions without a completed NLP result for the given question/action are +silently skipped and excluded from the count. + +```json +{ + "accepted_count": 472 +} +``` + + */ +export type assetsDataSupplementsBulkCreateResponse200 = { + data: BulkAcceptResponse + status: 200 +} + +export type assetsDataSupplementsBulkCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsDataSupplementsBulkCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataSupplementsBulkCreateResponseComposite = assetsDataSupplementsBulkCreateResponse200 | assetsDataSupplementsBulkCreateResponse400 | assetsDataSupplementsBulkCreateResponse404; + +export type assetsDataSupplementsBulkCreateResponse = assetsDataSupplementsBulkCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsDataSupplementsBulkCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/supplements/bulk/` +} + +export const assetsDataSupplementsBulkCreate = async (uidAsset: string, + bulkAcceptRequest: BulkAcceptRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataSupplementsBulkCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + bulkAcceptRequest,) + } +);} + + + + +export const getAssetsDataSupplementsBulkCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: BulkAcceptRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: BulkAcceptRequest}, TContext> => { + +const mutationKey = ['assetsDataSupplementsBulkCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: BulkAcceptRequest}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsDataSupplementsBulkCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDataSupplementsBulkCreateMutationResult = NonNullable>> + export type AssetsDataSupplementsBulkCreateMutationBody = BulkAcceptRequest + export type AssetsDataSupplementsBulkCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsDataSupplementsBulkCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: BulkAcceptRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDataSupplementsBulkCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Bulk update submissions status + +* Where: "submissions_ids" (required) is a list of submission root id on the data +to delete +* Where: "validation_status.uid" (required) is a string and can be one of these values: + * `validation_status_approved` + * `validation_status_not_approved` + * `validation_status_on_hold` + +Will return the number of submission updated as such: +> **Response** +> +> { +> "detail": "{number_of_submissions} submissions have been updated" +> } + + */ +export type assetsDataValidationStatusesPartialUpdateResponse200 = { + data: DataStatusesUpdate + status: 200 +} + +export type assetsDataValidationStatusesPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataValidationStatusesPartialUpdateResponseComposite = assetsDataValidationStatusesPartialUpdateResponse200 | assetsDataValidationStatusesPartialUpdateResponse404; + +export type assetsDataValidationStatusesPartialUpdateResponse = assetsDataValidationStatusesPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsDataValidationStatusesPartialUpdateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/validation_statuses/` +} + +export const assetsDataValidationStatusesPartialUpdate = async (uidAsset: string, + patchedDataValidationStatusesUpdatePayload: PatchedDataValidationStatusesUpdatePayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataValidationStatusesPartialUpdateUrl(uidAsset), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedDataValidationStatusesUpdatePayload,) + } +);} + + + + +export const getAssetsDataValidationStatusesPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataValidationStatusesUpdatePayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataValidationStatusesUpdatePayload}, TContext> => { + +const mutationKey = ['assetsDataValidationStatusesPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: PatchedDataValidationStatusesUpdatePayload}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsDataValidationStatusesPartialUpdate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDataValidationStatusesPartialUpdateMutationResult = NonNullable>> + export type AssetsDataValidationStatusesPartialUpdateMutationBody = PatchedDataValidationStatusesUpdatePayload + export type AssetsDataValidationStatusesPartialUpdateMutationError = ErrorDetail + + export const useAssetsDataValidationStatusesPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataValidationStatusesUpdatePayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDataValidationStatusesPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Bulk delete submissions status + +```curl + curl -X DELETE https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/validation_statuses/ +``` + +**Payload** +```json +{ + "payload": { + "submission_ids": [ + 1, + 2 + ], + "validation_status.uid": "validation_status" + } +} +``` +* Where: "submissions_ids" (required) is a list of submission root id on the data +to delete + +The validation status of the submission can be updated. The `validation_status.uid` should be a `string`, and it must be one of the following values: +- `validation_status_approved` +- `validation_status_not_approved` +- `validation_status_on_hold` + +**Response** +```json +{ + "detail": "{number_of_submissions} submissions have been updated" +} +``` + +_Due to limitations with DRF-Spectacular current version, `DELETE` actions do not support showing a request body OR a response body. This is due to the 'vague' nature of the action which generally does *not* recommend the use of a payload. To still document this endpoint, example for the payload and response will be included but it will not be possible to test this endpoint. The HTTP code and the errors example are, for their part, factual and can be considered when working with the endpoint._ + + */ +export type assetsDataValidationStatusesDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsDataValidationStatusesDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsDataValidationStatusesDestroyResponseComposite = assetsDataValidationStatusesDestroyResponse204 | assetsDataValidationStatusesDestroyResponse404; + +export type assetsDataValidationStatusesDestroyResponse = assetsDataValidationStatusesDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsDataValidationStatusesDestroyUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/data/validation_statuses/` +} + +export const assetsDataValidationStatusesDestroy = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsDataValidationStatusesDestroyUrl(uidAsset), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsDataValidationStatusesDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { + +const mutationKey = ['assetsDataValidationStatusesDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { + const {uidAsset} = props ?? {}; + + return assetsDataValidationStatusesDestroy(uidAsset,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsDataValidationStatusesDestroyMutationResult = NonNullable>> + + export type AssetsDataValidationStatusesDestroyMutationError = ErrorDetail + + export const useAssetsDataValidationStatusesDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsDataValidationStatusesDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## List of export settings for a specific asset + +* _Required permissions: `view_submissions` (View submissions)_ + + */ +export type assetsExportSettingsListResponse200 = { + data: PaginatedExportSettingResponseList + status: 200 +} + +export type assetsExportSettingsListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsExportSettingsListResponseComposite = assetsExportSettingsListResponse200 | assetsExportSettingsListResponse404; + +export type assetsExportSettingsListResponse = assetsExportSettingsListResponseComposite & { + headers: Headers; +} + +export const getAssetsExportSettingsListUrl = (uidAsset: string, + params?: AssetsExportSettingsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/export-settings/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/export-settings/` +} + +export const assetsExportSettingsList = async (uidAsset: string, + params?: AssetsExportSettingsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsExportSettingsListUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsExportSettingsListQueryKey = (uidAsset: string, + params?: AssetsExportSettingsListParams,) => { + return ['api','v2','assets',uidAsset,'export-settings', ...(params ? [params]: [])] as const; + } + + +export const getAssetsExportSettingsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsExportSettingsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsExportSettingsListQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsExportSettingsList(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsExportSettingsListQueryResult = NonNullable>> +export type AssetsExportSettingsListQueryError = ErrorDetail + + + +export function useAssetsExportSettingsList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsExportSettingsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsExportSettingsListQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create an export setting for an asset + +* _Required permissions: `manage_asset` (Manage project)_ + +Where: + +* `name` (required) is the name of the export setting displayed in the UI +* `export_settings` (required) is a map of defined settings containing the following valid options: + * `fields` (optional) is an array of column names to be included in the export (including their group hierarchy). Valid inputs include: + * An array containing any string value that matches the XML column name + * An empty array which will result in all columns being included + * If `fields` is not included in the `export_settings`, all columns will be included in the export +* `flatten` (optional) is a boolean value and only relevant when exporting to `geojson` format. +* `fields_from_all_versions` (required) is a boolean to specify whether fields from all form versions will be included in the export. +* `group_sep` (required) is a value used to separate the names in a hierarchy of groups. Valid inputs include: + * Non-empty value +* `hierarchy_in_labels` (required) is a boolean to specify whether the group hierarchy will be displayed in labels +* `multiple_select` (required) is a value to specify the display of multiple-select-type responses. Valid inputs include: + * `both`, + * `summary`, or + * `details` +* `type` (required) specifies the export format. Valid export formats include: + * `csv`, + * `geojson`, + * `spss_labels`, or + * `xls` +* `xls_types_as_text` (optional) is a boolean value that defaults to `false` and only affects `xls` export types. +* `include_media_url` (optional) is a boolean value that defaults to `false` and only affects `xls` and `csv` export types. +* `submission_ids` (optional) is an array of submission ids that will filter exported submissions to only the specified array of ids. Valid inputs include: + * An array containing integer values + * An empty array (no filtering) +* `query` (optional) is a JSON object containing a Mongo filter query for filtering exported submissions. Valid inputs include: + * A JSON object containing a valid Mongo query + * An empty JSON object (no filtering) + +**Note that the following behaviour can be expected when specifying a value for the `multiple_select` field:** + +* `summary`: Includes one column per question, with all selected choices separated by spaces; +* `details`: Expands each multiple-select question to one column per choice, with each of those columns having a binary 1 or 0 to indicate whether that choice was chosen; +* `both`: Includes the format of `summary` _and_ `details` in the export + + */ +export type assetsExportSettingsCreateResponse201 = { + data: ExportSettingResponse + status: 201 +} + +export type assetsExportSettingsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsExportSettingsCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsExportSettingsCreateResponseComposite = assetsExportSettingsCreateResponse201 | assetsExportSettingsCreateResponse400 | assetsExportSettingsCreateResponse404; + +export type assetsExportSettingsCreateResponse = assetsExportSettingsCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsExportSettingsCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/export-settings/` +} + +export const assetsExportSettingsCreate = async (uidAsset: string, + exportSettingCreatePayload: ExportSettingCreatePayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsExportSettingsCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + exportSettingCreatePayload,) + } +);} + + + + +export const getAssetsExportSettingsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: ExportSettingCreatePayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: ExportSettingCreatePayload}, TContext> => { + +const mutationKey = ['assetsExportSettingsCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: ExportSettingCreatePayload}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsExportSettingsCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsExportSettingsCreateMutationResult = NonNullable>> + export type AssetsExportSettingsCreateMutationBody = ExportSettingCreatePayload + export type AssetsExportSettingsCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsExportSettingsCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: ExportSettingCreatePayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsExportSettingsCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve a specific export setting + +* _Required permissions: `view_submissions` (View submissions)_ + + */ +export type assetsExportSettingsRetrieveResponse200 = { + data: ExportSettingResponse + status: 200 +} + +export type assetsExportSettingsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsExportSettingsRetrieveResponseComposite = assetsExportSettingsRetrieveResponse200 | assetsExportSettingsRetrieveResponse404; + +export type assetsExportSettingsRetrieveResponse = assetsExportSettingsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsExportSettingsRetrieveUrl = (uidAsset: string, + uidExportSetting: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/` +} + +export const assetsExportSettingsRetrieve = async (uidAsset: string, + uidExportSetting: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsExportSettingsRetrieveUrl(uidAsset,uidExportSetting), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsExportSettingsRetrieveQueryKey = (uidAsset: string, + uidExportSetting: string,) => { + return ['api','v2','assets',uidAsset,'export-settings',uidExportSetting] as const; + } + + +export const getAssetsExportSettingsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidExportSetting: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsExportSettingsRetrieveQueryKey(uidAsset,uidExportSetting); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsExportSettingsRetrieve(uidAsset,uidExportSetting, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidExportSetting), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsExportSettingsRetrieveQueryResult = NonNullable>> +export type AssetsExportSettingsRetrieveQueryError = ErrorDetail + + + +export function useAssetsExportSettingsRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidExportSetting: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsExportSettingsRetrieveQueryOptions(uidAsset,uidExportSetting,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update the current export setting + +* _Required permissions: `manage_asset` (Manage project)_ + + */ +export type assetsExportSettingsPartialUpdateResponse200 = { + data: ExportSettingResponse + status: 200 +} + +export type assetsExportSettingsPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsExportSettingsPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsExportSettingsPartialUpdateResponseComposite = assetsExportSettingsPartialUpdateResponse200 | assetsExportSettingsPartialUpdateResponse400 | assetsExportSettingsPartialUpdateResponse404; + +export type assetsExportSettingsPartialUpdateResponse = assetsExportSettingsPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsExportSettingsPartialUpdateUrl = (uidAsset: string, + uidExportSetting: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/` +} + +export const assetsExportSettingsPartialUpdate = async (uidAsset: string, + uidExportSetting: string, + patchedExportSettingUpdatePayload: PatchedExportSettingUpdatePayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsExportSettingsPartialUpdateUrl(uidAsset,uidExportSetting), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedExportSettingUpdatePayload,) + } +);} + + + + +export const getAssetsExportSettingsPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string;data: PatchedExportSettingUpdatePayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string;data: PatchedExportSettingUpdatePayload}, TContext> => { + +const mutationKey = ['assetsExportSettingsPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidExportSetting: string;data: PatchedExportSettingUpdatePayload}> = (props) => { + const {uidAsset,uidExportSetting,data} = props ?? {}; + + return assetsExportSettingsPartialUpdate(uidAsset,uidExportSetting,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsExportSettingsPartialUpdateMutationResult = NonNullable>> + export type AssetsExportSettingsPartialUpdateMutationBody = PatchedExportSettingUpdatePayload + export type AssetsExportSettingsPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useAssetsExportSettingsPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string;data: PatchedExportSettingUpdatePayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsExportSettingsPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Delete current export setting + +* _Required permissions: `manage_asset` (Manage project)_ + + + */ +export type assetsExportSettingsDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsExportSettingsDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsExportSettingsDestroyResponseComposite = assetsExportSettingsDestroyResponse204 | assetsExportSettingsDestroyResponse404; + +export type assetsExportSettingsDestroyResponse = assetsExportSettingsDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsExportSettingsDestroyUrl = (uidAsset: string, + uidExportSetting: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/` +} + +export const assetsExportSettingsDestroy = async (uidAsset: string, + uidExportSetting: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsExportSettingsDestroyUrl(uidAsset,uidExportSetting), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsExportSettingsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string}, TContext> => { + +const mutationKey = ['assetsExportSettingsDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidExportSetting: string}> = (props) => { + const {uidAsset,uidExportSetting} = props ?? {}; + + return assetsExportSettingsDestroy(uidAsset,uidExportSetting,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsExportSettingsDestroyMutationResult = NonNullable>> + + export type AssetsExportSettingsDestroyMutationError = ErrorDetail + + export const useAssetsExportSettingsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsExportSettingsDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Synchronously export data + +To retrieve data synchronously in CSV and XLSX format according to a +particular instance of export settings. + +Processing time of synchronous exports is substantially limited compared to +asynchronous exports, which are available at `/api/v2/assets/{asset_uid}/exports/`. + + */ +export type assetsExportSettingsDataRetrieveResponse200 = { + data: void + status: 200 +} + +export type assetsExportSettingsDataRetrieveResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsExportSettingsDataRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsExportSettingsDataRetrieveResponseComposite = assetsExportSettingsDataRetrieveResponse200 | assetsExportSettingsDataRetrieveResponse400 | assetsExportSettingsDataRetrieveResponse404; + +export type assetsExportSettingsDataRetrieveResponse = assetsExportSettingsDataRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsExportSettingsDataRetrieveUrl = (uidAsset: string, + uidExportSetting: string, + params: AssetsExportSettingsDataRetrieveParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/data/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/data/` +} + +export const assetsExportSettingsDataRetrieve = async (uidAsset: string, + uidExportSetting: string, + params: AssetsExportSettingsDataRetrieveParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsExportSettingsDataRetrieveUrl(uidAsset,uidExportSetting,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsExportSettingsDataRetrieveQueryKey = (uidAsset: string, + uidExportSetting: string, + params: AssetsExportSettingsDataRetrieveParams,) => { + return ['api','v2','assets',uidAsset,'export-settings',uidExportSetting,'data', ...(params ? [params]: [])] as const; + } + + +export const getAssetsExportSettingsDataRetrieveQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidAsset: string, + uidExportSetting: string, + params: AssetsExportSettingsDataRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsExportSettingsDataRetrieveQueryKey(uidAsset,uidExportSetting,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsExportSettingsDataRetrieve(uidAsset,uidExportSetting,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidExportSetting), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsExportSettingsDataRetrieveQueryResult = NonNullable>> +export type AssetsExportSettingsDataRetrieveQueryError = ErrorObject | ErrorDetail + + + +export function useAssetsExportSettingsDataRetrieve>, TError = ErrorObject | ErrorDetail>( + uidAsset: string, + uidExportSetting: string, + params: AssetsExportSettingsDataRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsExportSettingsDataRetrieveQueryOptions(uidAsset,uidExportSetting,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List of export tasks endpoints + +Lists the export tasks accessible to requesting user, for anonymous access +nothing is returned. + +* _Required permissions: `view_submissions` (View submissions)_ + +Otherwise, the search can be more specific: + +**Exports matching `uid`s:** +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{asset_uid}/exports/?q=uid__in:ehZUwRctkhp9QfJgvEWGg OR uid__in:ehZUwRctkhp9QfJgvDnjud +``` + + */ +export type assetsExportsListResponse200 = { + data: PaginatedExportResponseList + status: 200 +} + +export type assetsExportsListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsExportsListResponseComposite = assetsExportsListResponse200 | assetsExportsListResponse403; + +export type assetsExportsListResponse = assetsExportsListResponseComposite & { + headers: Headers; +} + +export const getAssetsExportsListUrl = (uidAsset: string, + params?: AssetsExportsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/exports/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/exports/` +} + +export const assetsExportsList = async (uidAsset: string, + params?: AssetsExportsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsExportsListUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsExportsListQueryKey = (uidAsset: string, + params?: AssetsExportsListParams,) => { + return ['api','v2','assets',uidAsset,'exports', ...(params ? [params]: [])] as const; + } + + +export const getAssetsExportsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsExportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsExportsListQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsExportsList(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsExportsListQueryResult = NonNullable>> +export type AssetsExportsListQueryError = ErrorDetail + + + +export function useAssetsExportsList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsExportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsExportsListQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Creates an export task + +Where: +* `fields_from_all_versions` (required) is a boolean to specify whether fields from all form versions will be included in the export. + * `group_sep` (required) is a value used to separate the names in a hierarchy of groups. Valid inputs include: + * Non-empty value + * `hierarchy_in_labels` (required) is a boolean to specify whether the group hierarchy will be displayed in labels + * `lang` (required) is a string that can be set to: + * `_xml` to have XML values and headers, or + * Any translation specified in the form such as `English (en)`, etc. + * `multiple_select` (required) is a value to specify the display of `multiple_select-type` responses. Valid inputs include: + * `both`, + * `summary`, or + * `details` + * "`type`" (required) specifies the export format. Valid export formats include: + * `csv`, + * `geojson`, + * `spss_labels`, or + * `xls` + * `fields` (optional) is an array of column names to be included in the export (including their group hierarchy). Valid inputs include: + * An array containing any string value that matches the XML column name + * An empty array which will result in all columns being included + * If `fields` is not included in the `export_settings`, all columns will be included in the export + * `flatten` (optional) is a boolean value and only relevant when exporting to "geojson" format. + * `xls_types_as_text` (optional) is a boolean value that defaults to `false` and only affects `xls` export types. + * `include_media_url` (optional) is a boolean value that defaults to `false` and only affects `xls` and "csv" export types. This will include an additional column for media-type questions (`question_name_URL`) with the URL link to the hosted file. + * `submission_ids` (optional) is an array of submission ids that will filter exported submissions to only the specified array of ids. Valid inputs include: + * An array containing integer values + * An empty array (no filtering) + * `query` (optional) is a JSON object containing a Mongo filter query for filtering exported submissions. Valid inputs include: + * A JSON object containing a valid Mongo query + * An empty JSON object (no filtering) + + */ +export type assetsExportsCreateResponse201 = { + data: ExportResponse + status: 201 +} + +export type assetsExportsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsExportsCreateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsExportsCreateResponseComposite = assetsExportsCreateResponse201 | assetsExportsCreateResponse400 | assetsExportsCreateResponse403; + +export type assetsExportsCreateResponse = assetsExportsCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsExportsCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/exports/` +} + +export const assetsExportsCreate = async (uidAsset: string, + exportCreatePayload: ExportCreatePayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsExportsCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + exportCreatePayload,) + } +);} + + + + +export const getAssetsExportsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: ExportCreatePayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: ExportCreatePayload}, TContext> => { + +const mutationKey = ['assetsExportsCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: ExportCreatePayload}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsExportsCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsExportsCreateMutationResult = NonNullable>> + export type AssetsExportsCreateMutationBody = ExportCreatePayload + export type AssetsExportsCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsExportsCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: ExportCreatePayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsExportsCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieves current export task + + */ +export type assetsExportsRetrieveResponse200 = { + data: ExportResponse + status: 200 +} + +export type assetsExportsRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsExportsRetrieveResponseComposite = assetsExportsRetrieveResponse200 | assetsExportsRetrieveResponse403; + +export type assetsExportsRetrieveResponse = assetsExportsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsExportsRetrieveUrl = (uidAsset: string, + uidExport: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/exports/${uidExport}/` +} + +export const assetsExportsRetrieve = async (uidAsset: string, + uidExport: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsExportsRetrieveUrl(uidAsset,uidExport), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsExportsRetrieveQueryKey = (uidAsset: string, + uidExport: string,) => { + return ['api','v2','assets',uidAsset,'exports',uidExport] as const; + } + + +export const getAssetsExportsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidExport: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsExportsRetrieveQueryKey(uidAsset,uidExport); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsExportsRetrieve(uidAsset,uidExport, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidExport), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsExportsRetrieveQueryResult = NonNullable>> +export type AssetsExportsRetrieveQueryError = ErrorDetail + + + +export function useAssetsExportsRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidExport: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsExportsRetrieveQueryOptions(uidAsset,uidExport,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Deletes current export task + + */ +export type assetsExportsDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsExportsDestroyResponse403 = { + data: ErrorDetail + status: 403 +} + +export type assetsExportsDestroyResponseComposite = assetsExportsDestroyResponse204 | assetsExportsDestroyResponse403; + +export type assetsExportsDestroyResponse = assetsExportsDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsExportsDestroyUrl = (uidAsset: string, + uidExport: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/exports/${uidExport}/` +} + +export const assetsExportsDestroy = async (uidAsset: string, + uidExport: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsExportsDestroyUrl(uidAsset,uidExport), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsExportsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExport: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidExport: string}, TContext> => { + +const mutationKey = ['assetsExportsDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidExport: string}> = (props) => { + const {uidAsset,uidExport} = props ?? {}; + + return assetsExportsDestroy(uidAsset,uidExport,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsExportsDestroyMutationResult = NonNullable>> + + export type AssetsExportsDestroyMutationError = ErrorDetail + + export const useAssetsExportsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExport: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsExportsDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve current asset files + +Results can be narrowed down with a filter by type: +```shell +curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/files/?collections_first=true&ordering=-name +``` + + */ +export type assetsFilesListResponse200 = { + data: PaginatedFilesResponseList + status: 200 +} + +export type assetsFilesListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsFilesListResponseComposite = assetsFilesListResponse200 | assetsFilesListResponse404; + +export type assetsFilesListResponse = assetsFilesListResponseComposite & { + headers: Headers; +} + +export const getAssetsFilesListUrl = (uidAsset: string, + params?: AssetsFilesListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/files/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/files/` +} + +export const assetsFilesList = async (uidAsset: string, + params?: AssetsFilesListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsFilesListUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsFilesListQueryKey = (uidAsset: string, + params?: AssetsFilesListParams,) => { + return ['api','v2','assets',uidAsset,'files', ...(params ? [params]: [])] as const; + } + + +export const getAssetsFilesListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsFilesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsFilesListQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsFilesList(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsFilesListQueryResult = NonNullable>> +export type AssetsFilesListQueryError = ErrorDetail + + + +export function useAssetsFilesList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsFilesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsFilesListQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create a new file on current asset + +Fields: + +- `asset` (required) +- `user` (required) +- `description` (required) +- `file_type` (required) +- `content` (as binary) (optional) +- `metadata` JSON (optional) + +_Notes:_ + +1. Files can have different types: + - `map_layer` + - `form_media` +2. Files can be created with three different ways + - `POST` a file with `content` parameter + - `POST` a base64 encoded string with `base64Encoded` parameter1 + - `POST` an URL with `metadata` parameter2 + +1) `metadata` becomes mandatory and must contain `filename` property
+2) `metadata` becomes mandatory and must contain `redirect_url` property + +**Files with `form_media` type must have unique `filename` per asset** + + */ +export type assetsFilesCreateResponse201 = { + data: FilesResponse + status: 201 +} + +export type assetsFilesCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsFilesCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsFilesCreateResponseComposite = assetsFilesCreateResponse201 | assetsFilesCreateResponse400 | assetsFilesCreateResponse404; + +export type assetsFilesCreateResponse = assetsFilesCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsFilesCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/files/` +} + +export const assetsFilesCreate = async (uidAsset: string, + createFilePayload: CreateFilePayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsFilesCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + createFilePayload,) + } +);} + + + + +export const getAssetsFilesCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: CreateFilePayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: CreateFilePayload}, TContext> => { + +const mutationKey = ['assetsFilesCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: CreateFilePayload}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsFilesCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsFilesCreateMutationResult = NonNullable>> + export type AssetsFilesCreateMutationBody = CreateFilePayload + export type AssetsFilesCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsFilesCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: CreateFilePayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsFilesCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve a file from current asset + + */ +export type assetsFilesRetrieveResponse200 = { + data: FilesResponse + status: 200 +} + +export type assetsFilesRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsFilesRetrieveResponseComposite = assetsFilesRetrieveResponse200 | assetsFilesRetrieveResponse404; + +export type assetsFilesRetrieveResponse = assetsFilesRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsFilesRetrieveUrl = (uidAsset: string, + uidFile: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/files/${uidFile}/` +} + +export const assetsFilesRetrieve = async (uidAsset: string, + uidFile: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsFilesRetrieveUrl(uidAsset,uidFile), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsFilesRetrieveQueryKey = (uidAsset: string, + uidFile: string,) => { + return ['api','v2','assets',uidAsset,'files',uidFile] as const; + } + + +export const getAssetsFilesRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidFile: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsFilesRetrieveQueryKey(uidAsset,uidFile); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsFilesRetrieve(uidAsset,uidFile, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidFile), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsFilesRetrieveQueryResult = NonNullable>> +export type AssetsFilesRetrieveQueryError = ErrorDetail + + + +export function useAssetsFilesRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidFile: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsFilesRetrieveQueryOptions(uidAsset,uidFile,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Delete a file from current asset + + */ +export type assetsFilesDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsFilesDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsFilesDestroyResponseComposite = assetsFilesDestroyResponse204 | assetsFilesDestroyResponse404; + +export type assetsFilesDestroyResponse = assetsFilesDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsFilesDestroyUrl = (uidAsset: string, + uidFile: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/files/${uidFile}/` +} + +export const assetsFilesDestroy = async (uidAsset: string, + uidFile: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsFilesDestroyUrl(uidAsset,uidFile), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsFilesDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidFile: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidFile: string}, TContext> => { + +const mutationKey = ['assetsFilesDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidFile: string}> = (props) => { + const {uidAsset,uidFile} = props ?? {}; + + return assetsFilesDestroy(uidAsset,uidFile,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsFilesDestroyMutationResult = NonNullable>> + + export type AssetsFilesDestroyMutationError = ErrorDetail + + export const useAssetsFilesDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidFile: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsFilesDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Download the asset file + + */ +export type assetsFilesContentRetrieveResponse200 = { + data: void + status: 200 +} + +export type assetsFilesContentRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsFilesContentRetrieveResponseComposite = assetsFilesContentRetrieveResponse200 | assetsFilesContentRetrieveResponse404; + +export type assetsFilesContentRetrieveResponse = assetsFilesContentRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsFilesContentRetrieveUrl = (uidAsset: string, + uidFile: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/files/${uidFile}/content/` +} + +export const assetsFilesContentRetrieve = async (uidAsset: string, + uidFile: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsFilesContentRetrieveUrl(uidAsset,uidFile), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsFilesContentRetrieveQueryKey = (uidAsset: string, + uidFile: string,) => { + return ['api','v2','assets',uidAsset,'files',uidFile,'content'] as const; + } + + +export const getAssetsFilesContentRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidFile: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsFilesContentRetrieveQueryKey(uidAsset,uidFile); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsFilesContentRetrieve(uidAsset,uidFile, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidFile), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsFilesContentRetrieveQueryResult = NonNullable>> +export type AssetsFilesContentRetrieveQueryError = ErrorDetail + + + +export function useAssetsFilesContentRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidFile: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsFilesContentRetrieveQueryOptions(uidAsset,uidFile,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List paired project endpoints + +This endpoint is paginated and accepts these parameters: +- `offset`: The initial index from which to return the results +- `limit`: Number of results to return per page + + */ +export type assetsPairedDataListResponse200 = { + data: PaginatedPairedDataResponseList + status: 200 +} + +export type assetsPairedDataListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsPairedDataListResponseComposite = assetsPairedDataListResponse200 | assetsPairedDataListResponse404; + +export type assetsPairedDataListResponse = assetsPairedDataListResponseComposite & { + headers: Headers; +} + +export const getAssetsPairedDataListUrl = (uidAsset: string, + params?: AssetsPairedDataListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/paired-data/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/paired-data/` +} + +export const assetsPairedDataList = async (uidAsset: string, + params?: AssetsPairedDataListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPairedDataListUrl(uidAsset,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsPairedDataListQueryKey = (uidAsset: string, + params?: AssetsPairedDataListParams,) => { + return ['api','v2','assets',uidAsset,'paired-data', ...(params ? [params]: [])] as const; + } + + +export const getAssetsPairedDataListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + params?: AssetsPairedDataListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataListQueryKey(uidAsset,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsPairedDataList(uidAsset,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsPairedDataListQueryResult = NonNullable>> +export type AssetsPairedDataListQueryError = ErrorDetail + + + +export function useAssetsPairedDataList>, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsPairedDataListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsPairedDataListQueryOptions(uidAsset,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create a connection between two projects + +* `fields`: Optional. List of questions whose responses will be retrieved + from the source data. If missing or empty, all responses will be + retrieved. Questions must be identified by full group path separated by + slashes, e.g. `group/subgroup/question_name`. +* `filename`: Must be unique among all asset files. Only accepts letters, numbers and '-'. + + */ +export type assetsPairedDataCreateResponse201 = { + data: PairedDataResponse + status: 201 +} + +export type assetsPairedDataCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsPairedDataCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsPairedDataCreateResponseComposite = assetsPairedDataCreateResponse201 | assetsPairedDataCreateResponse400 | assetsPairedDataCreateResponse404; + +export type assetsPairedDataCreateResponse = assetsPairedDataCreateResponseComposite & { + headers: Headers; +} + +export const getAssetsPairedDataCreateUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/paired-data/` +} + +export const assetsPairedDataCreate = async (uidAsset: string, + pairedData: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPairedDataCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + pairedData,) + } +);} + + + + +export const getAssetsPairedDataCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext> => { + +const mutationKey = ['assetsPairedDataCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;data: NonReadonly}> = (props) => { + const {uidAsset,data} = props ?? {}; + + return assetsPairedDataCreate(uidAsset,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsPairedDataCreateMutationResult = NonNullable>> + export type AssetsPairedDataCreateMutationBody = NonReadonly + export type AssetsPairedDataCreateMutationError = ErrorObject | ErrorDetail + + export const useAssetsPairedDataCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsPairedDataCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve a connection between two projects + + */ +export type assetsPairedDataRetrieveResponse200 = { + data: PairedDataResponse + status: 200 +} + +export type assetsPairedDataRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsPairedDataRetrieveResponseComposite = assetsPairedDataRetrieveResponse200 | assetsPairedDataRetrieveResponse404; + +export type assetsPairedDataRetrieveResponse = assetsPairedDataRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsPairedDataRetrieveUrl = (uidAsset: string, + uidPairedData: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/` +} + +export const assetsPairedDataRetrieve = async (uidAsset: string, + uidPairedData: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPairedDataRetrieveUrl(uidAsset,uidPairedData), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsPairedDataRetrieveQueryKey = (uidAsset: string, + uidPairedData: string,) => { + return ['api','v2','assets',uidAsset,'paired-data',uidPairedData] as const; + } + + +export const getAssetsPairedDataRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidPairedData: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataRetrieveQueryKey(uidAsset,uidPairedData); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsPairedDataRetrieve(uidAsset,uidPairedData, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidPairedData), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsPairedDataRetrieveQueryResult = NonNullable>> +export type AssetsPairedDataRetrieveQueryError = ErrorDetail + + + +export function useAssetsPairedDataRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidPairedData: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsPairedDataRetrieveQueryOptions(uidAsset,uidPairedData,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update a connection between two projects + +_Notes: `source` cannot be changed_ + + */ +export type assetsPairedDataPartialUpdateResponse200 = { + data: PairedDataResponse + status: 200 +} + +export type assetsPairedDataPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type assetsPairedDataPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsPairedDataPartialUpdateResponseComposite = assetsPairedDataPartialUpdateResponse200 | assetsPairedDataPartialUpdateResponse400 | assetsPairedDataPartialUpdateResponse404; + +export type assetsPairedDataPartialUpdateResponse = assetsPairedDataPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getAssetsPairedDataPartialUpdateUrl = (uidAsset: string, + uidPairedData: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/` +} + +export const assetsPairedDataPartialUpdate = async (uidAsset: string, + uidPairedData: string, + patchedPairedDataPatchPayload: PatchedPairedDataPatchPayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPairedDataPartialUpdateUrl(uidAsset,uidPairedData), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedPairedDataPatchPayload,) + } +);} + + + + +export const getAssetsPairedDataPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string;data: PatchedPairedDataPatchPayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string;data: PatchedPairedDataPatchPayload}, TContext> => { + +const mutationKey = ['assetsPairedDataPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidPairedData: string;data: PatchedPairedDataPatchPayload}> = (props) => { + const {uidAsset,uidPairedData,data} = props ?? {}; + + return assetsPairedDataPartialUpdate(uidAsset,uidPairedData,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsPairedDataPartialUpdateMutationResult = NonNullable>> + export type AssetsPairedDataPartialUpdateMutationBody = PatchedPairedDataPatchPayload + export type AssetsPairedDataPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useAssetsPairedDataPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string;data: PatchedPairedDataPatchPayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsPairedDataPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Remove a connection between two projects + + */ +export type assetsPairedDataDestroyResponse204 = { + data: void + status: 204 +} + +export type assetsPairedDataDestroyResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsPairedDataDestroyResponseComposite = assetsPairedDataDestroyResponse204 | assetsPairedDataDestroyResponse404; + +export type assetsPairedDataDestroyResponse = assetsPairedDataDestroyResponseComposite & { + headers: Headers; +} + +export const getAssetsPairedDataDestroyUrl = (uidAsset: string, + uidPairedData: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/` +} + +export const assetsPairedDataDestroy = async (uidAsset: string, + uidPairedData: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPairedDataDestroyUrl(uidAsset,uidPairedData), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getAssetsPairedDataDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string}, TContext> => { + +const mutationKey = ['assetsPairedDataDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidAsset: string;uidPairedData: string}> = (props) => { + const {uidAsset,uidPairedData} = props ?? {}; + + return assetsPairedDataDestroy(uidAsset,uidPairedData,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type AssetsPairedDataDestroyMutationResult = NonNullable>> + + export type AssetsPairedDataDestroyMutationError = ErrorDetail + + export const useAssetsPairedDataDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getAssetsPairedDataDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Return an XML which contains data submitted to paired asset + +Creates the endpoints +- /api/v2/assets//paired-data//external/ +- /api/v2/assets//paired-data//external.xml/ + + */ +export type assetsPairedDataExternalRetrieveResponse200 = { + data: ExternalResponse + status: 200 +} + +export type assetsPairedDataExternalRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsPairedDataExternalRetrieveResponseComposite = assetsPairedDataExternalRetrieveResponse200 | assetsPairedDataExternalRetrieveResponse404; + +export type assetsPairedDataExternalRetrieveResponse = assetsPairedDataExternalRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsPairedDataExternalRetrieveUrl = (uidAsset: string, + uidPairedData: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/external/` +} + +export const assetsPairedDataExternalRetrieve = async (uidAsset: string, + uidPairedData: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsPairedDataExternalRetrieveUrl(uidAsset,uidPairedData), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsPairedDataExternalRetrieveQueryKey = (uidAsset: string, + uidPairedData: string,) => { + return ['api','v2','assets',uidAsset,'paired-data',uidPairedData,'external'] as const; + } + + +export const getAssetsPairedDataExternalRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, + uidPairedData: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataExternalRetrieveQueryKey(uidAsset,uidPairedData); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsPairedDataExternalRetrieve(uidAsset,uidPairedData, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset && uidPairedData), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsPairedDataExternalRetrieveQueryResult = NonNullable>> +export type AssetsPairedDataExternalRetrieveQueryError = ErrorDetail + + + +export function useAssetsPairedDataExternalRetrieve>, TError = ErrorDetail>( + uidAsset: string, + uidPairedData: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsPairedDataExternalRetrieveQueryOptions(uidAsset,uidPairedData,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Report of a user's asset + +Returns the submission data for all deployments of a survey. +This data is grouped by answers, and does not show the data for individual submissions. +The endpoint will return a **404 NOT FOUND** error if the asset is not deployed and will only return the data for the most recently deployed version. + + */ +export type assetsReportsRetrieveResponse200 = { + data: ReportResponse + status: 200 +} + +export type assetsReportsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type assetsReportsRetrieveResponseComposite = assetsReportsRetrieveResponse200 | assetsReportsRetrieveResponse404; + +export type assetsReportsRetrieveResponse = assetsReportsRetrieveResponseComposite & { + headers: Headers; +} + +export const getAssetsReportsRetrieveUrl = (uidAsset: string,) => { + + + + + return `/api/v2/assets/${uidAsset}/reports/` +} + +export const assetsReportsRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetsReportsRetrieveUrl(uidAsset), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetsReportsRetrieveQueryKey = (uidAsset: string,) => { + return ['api','v2','assets',uidAsset,'reports'] as const; + } + + +export const getAssetsReportsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetsReportsRetrieveQueryKey(uidAsset); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetsReportsRetrieve(uidAsset, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetsReportsRetrieveQueryResult = NonNullable>> +export type AssetsReportsRetrieveQueryError = ErrorDetail + + + +export function useAssetsReportsRetrieve>, TError = ErrorDetail>( + uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetsReportsRetrieveQueryOptions(uidAsset,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + diff --git a/jsapp/js/api/react-query/survey-data/msw.ts b/jsapp/js/api/react-query/survey-data/msw.ts new file mode 100644 index 0000000000..0b12355e22 --- /dev/null +++ b/jsapp/js/api/react-query/survey-data/msw.ts @@ -0,0 +1,1023 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import { + ActionEnum +} from '../../models/actionEnum'; + +import { + ActionIdEnum +} from '../../models/actionIdEnum'; + +import type { + AdvancedFeatureCreateResponse +} from '../../models/advancedFeatureCreateResponse'; + +import type { + AdvancedFeatureResponse +} from '../../models/advancedFeatureResponse'; + +import type { + AssetAttachmentAudioDurationResponse +} from '../../models/assetAttachmentAudioDurationResponse'; + +import type { + BulkAcceptResponse +} from '../../models/bulkAcceptResponse'; + +import type { + BulkActionCreateResponse +} from '../../models/bulkActionCreateResponse'; + +import type { + BulkActionListResponse +} from '../../models/bulkActionListResponse'; + +import type { + BulkActionResponse +} from '../../models/bulkActionResponse'; + +import { + BulkActionResponseStatusEnum +} from '../../models/bulkActionResponseStatusEnum'; + +import { + BulkActionSubmissionStatusResponseStatusEnum +} from '../../models/bulkActionSubmissionStatusResponseStatusEnum'; + +import type { + DataBulkUpdateResponse +} from '../../models/dataBulkUpdateResponse'; + +import type { + DataResponse +} from '../../models/dataResponse'; + +import type { + DataStatusesUpdate +} from '../../models/dataStatusesUpdate'; + +import type { + DataSupplementAutomaticQualDataIntegerResponse +} from '../../models/dataSupplementAutomaticQualDataIntegerResponse'; + +import type { + DataSupplementAutomaticQualDataSelectMultipleResponse +} from '../../models/dataSupplementAutomaticQualDataSelectMultipleResponse'; + +import type { + DataSupplementAutomaticQualDataSelectOneResponse +} from '../../models/dataSupplementAutomaticQualDataSelectOneResponse'; + +import type { + DataSupplementAutomaticQualDataTextResponse +} from '../../models/dataSupplementAutomaticQualDataTextResponse'; + +import type { + DataSupplementManualQualDataInteger +} from '../../models/dataSupplementManualQualDataInteger'; + +import type { + DataSupplementManualQualDataSelectMultiple +} from '../../models/dataSupplementManualQualDataSelectMultiple'; + +import type { + DataSupplementManualQualDataSelectOne +} from '../../models/dataSupplementManualQualDataSelectOne'; + +import type { + DataSupplementManualQualDataTags +} from '../../models/dataSupplementManualQualDataTags'; + +import type { + DataSupplementManualQualDataText +} from '../../models/dataSupplementManualQualDataText'; + +import type { + DataSupplementResponse +} from '../../models/dataSupplementResponse'; + +import type { + DataValidationStatus +} from '../../models/dataValidationStatus'; + +import { + DataValidationStatusLabelEnum +} from '../../models/dataValidationStatusLabelEnum'; + +import { + DataValidationStatusUidEnum +} from '../../models/dataValidationStatusUidEnum'; + +import type { + DataValidationStatusUpdateResponse +} from '../../models/dataValidationStatusUpdateResponse'; + +import type { + EnketoEditResponse +} from '../../models/enketoEditResponse'; + +import type { + EnketoViewResponse +} from '../../models/enketoViewResponse'; + +import type { + ExportResponse +} from '../../models/exportResponse'; + +import type { + ExportSettingResponse +} from '../../models/exportSettingResponse'; + +import type { + ExternalResponse +} from '../../models/externalResponse'; + +import type { + FilesResponse +} from '../../models/filesResponse'; + +import type { + PaginatedDataResponseList +} from '../../models/paginatedDataResponseList'; + +import type { + PaginatedExportResponseList +} from '../../models/paginatedExportResponseList'; + +import type { + PaginatedExportSettingResponseList +} from '../../models/paginatedExportSettingResponseList'; + +import type { + PaginatedFilesResponseList +} from '../../models/paginatedFilesResponseList'; + +import type { + PaginatedPairedDataResponseList +} from '../../models/paginatedPairedDataResponseList'; + +import type { + PairedDataResponse +} from '../../models/pairedDataResponse'; + +import { + QualSelectQuestionParamsTypeEnum +} from '../../models/qualSelectQuestionParamsTypeEnum'; + +import { + QualSimpleQuestionParamsTypeEnum +} from '../../models/qualSimpleQuestionParamsTypeEnum'; + +import type { + ReportResponse +} from '../../models/reportResponse'; + +import type { + SupplementalDataContentAutomaticComplete +} from '../../models/supplementalDataContentAutomaticComplete'; + +import type { + SupplementalDataContentAutomaticDeleted +} from '../../models/supplementalDataContentAutomaticDeleted'; + +import type { + SupplementalDataContentAutomaticFailed +} from '../../models/supplementalDataContentAutomaticFailed'; + +import type { + SupplementalDataContentAutomaticInProgress +} from '../../models/supplementalDataContentAutomaticInProgress'; + + +export const getApiV2AssetsAdvancedFeaturesListResponseMock = (): AdvancedFeatureResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.helpers.arrayElement(Object.values(ActionEnum)), params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{language: faker.string.alpha({length: {min: 10, max: 20}})},faker.helpers.arrayElement([{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.uuid(), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])})), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},]),{uuid: faker.string.uuid()},]))), uid: faker.string.alpha({length: {min: 10, max: 20}})}))) + +export const getApiV2AssetsAdvancedFeaturesCreateResponseMock = (overrideResponse: Partial< AdvancedFeatureCreateResponse > = {}): AdvancedFeatureCreateResponse => ({question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.helpers.arrayElement(Object.values(ActionEnum)), params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{language: faker.string.alpha({length: {min: 10, max: 20}})},faker.helpers.arrayElement([{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, hint: faker.helpers.arrayElement([{}, undefined])},{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.uuid(), hint: faker.helpers.arrayElement([{}, undefined])})), hint: faker.helpers.arrayElement([{}, undefined])},]),{uuid: faker.string.uuid()},]))), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsAdvancedFeaturesRetrieveResponseMock = (overrideResponse: Partial< AdvancedFeatureResponse > = {}): AdvancedFeatureResponse => ({question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.helpers.arrayElement(Object.values(ActionEnum)), params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{language: faker.string.alpha({length: {min: 10, max: 20}})},faker.helpers.arrayElement([{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.uuid(), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])})), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},]),{uuid: faker.string.uuid()},]))), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock = (overrideResponse: Partial< AdvancedFeatureResponse > = {}): AdvancedFeatureResponse => ({question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.helpers.arrayElement(Object.values(ActionEnum)), params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{language: faker.string.alpha({length: {min: 10, max: 20}})},faker.helpers.arrayElement([{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.uuid(), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])})), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},]),{uuid: faker.string.uuid()},]))), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock = (overrideResponse: Partial< BulkActionListResponse > = {}): BulkActionListResponse => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), params: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, progress: faker.number.int({min: 0, max: 100, multipleOf: undefined}), created_by: {username: faker.string.alpha({length: {min: 10, max: 20}})}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, cancelled_by: faker.helpers.arrayElement([{...{username: faker.string.alpha({length: {min: 10, max: 20}})},}, undefined])})), ...overrideResponse}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock = (overrideResponse: Partial< BulkActionCreateResponse > = {}): BulkActionCreateResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), params: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, progress: faker.number.int({min: 0, max: 100, multipleOf: undefined}), created_by: {username: faker.string.alpha({length: {min: 10, max: 20}})}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, cancelled_by: faker.helpers.arrayElement([{...{username: faker.string.alpha({length: {min: 10, max: 20}})},}, undefined]), skipped_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock = (overrideResponse: Partial< BulkActionResponse > = {}): BulkActionResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), params: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, progress: faker.number.int({min: 0, max: 100, multipleOf: undefined}), created_by: {username: faker.string.alpha({length: {min: 10, max: 20}})}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, cancelled_by: faker.helpers.arrayElement([{...{username: faker.string.alpha({length: {min: 10, max: 20}})},}, undefined]), ...overrideResponse}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock = (overrideResponse: Partial< BulkActionResponse > = {}): BulkActionResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), params: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, progress: faker.number.int({min: 0, max: 100, multipleOf: undefined}), created_by: {username: faker.string.alpha({length: {min: 10, max: 20}})}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, cancelled_by: faker.helpers.arrayElement([{...{username: faker.string.alpha({length: {min: 10, max: 20}})},}, undefined]), ...overrideResponse}) + +export const getApiV2AssetsAttachmentsAudioDurationCreateResponseMock = (overrideResponse: Partial< AssetAttachmentAudioDurationResponse > = {}): AssetAttachmentAudioDurationResponse => ({attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), seconds: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null])})), total: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), ...overrideResponse}) + +export const getApiV2AssetsDataListResponseDataValidationStatusMock = (overrideResponse: Partial = {}): DataValidationStatus => ({...{timestamp: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), by_whom: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum))}, ...overrideResponse}); + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticInProgress => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'in_progress'}, ...overrideResponse}); + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticFailed => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticComplete => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'complete', value: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticDeleted => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'deleted', value: null}, ...overrideResponse}); + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataInteger => ({...{value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataText => ({...{value: faker.string.alpha({length: {min: 10, max: 20}}), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectOne => ({...{value: faker.string.uuid(), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectMultiple => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataTags => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataIntegerResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataTextResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.alpha({length: {min: 10, max: 20}}), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectOneResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectMultipleResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataListResponseMock = (overrideResponse: Partial< PaginatedDataResponseList > = {}): PaginatedDataResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), __version__: faker.string.alpha({length: {min: 10, max: 20}}), 'meta/instanceID': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/rootUuid': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), _xform_id_string: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.alpha({length: {min: 10, max: 20}}), _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({download_url: faker.internet.url(), download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), mimetype: faker.string.alpha({length: {min: 10, max: 20}}), media_file_basename: faker.string.alpha({length: {min: 10, max: 20}}), filename: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}}), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])})), _status: faker.string.alpha({length: {min: 10, max: 20}}), _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}),null,]))), _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, _validation_status: faker.helpers.arrayElement([{...getApiV2AssetsDataListResponseDataValidationStatusMock()},]), _submitted_by: faker.string.alpha({length: {min: 10, max: 20}}), _supplementalDetails: faker.helpers.arrayElement([faker.helpers.arrayElement([{ + [faker.string.alphanumeric(5)]: {manual_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))}} + },{ + [faker.string.alphanumeric(5)]: {manual_translation: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))} + }} + },{ + [faker.string.alphanumeric(5)]: {automatic_google_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _data: faker.helpers.arrayElement([{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock()},])}))}} + },{ + [faker.string.alphanumeric(5)]: {automatic_google_translation: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: faker.helpers.arrayElement([{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock()},])}))} + }} + },{ + [faker.string.alphanumeric(5)]: {manual_qual: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock()},{...getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock()},{...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock()},{...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock()},{...getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} + }} + },{ + [faker.string.alphanumeric(5)]: {automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock()},{...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock()},{...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock()},{...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), _dependency: faker.helpers.arrayElement([{_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, undefined]), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} + }} + },]), undefined])})), ...overrideResponse}) + +export const getApiV2AssetsDataRetrieveResponseDataValidationStatusMock = (overrideResponse: Partial = {}): DataValidationStatus => ({...{timestamp: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), by_whom: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum))}, ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticInProgress => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'in_progress'}, ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticFailed => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticComplete => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'complete', value: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticDeleted => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'deleted', value: null}, ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataInteger => ({...{value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataText => ({...{value: faker.string.alpha({length: {min: 10, max: 20}}), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectOne => ({...{value: faker.string.uuid(), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectMultiple => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataTags => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataIntegerResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataTextResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.alpha({length: {min: 10, max: 20}}), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectOneResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectMultipleResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataRetrieveResponseMock = (overrideResponse: Partial< DataResponse > = {}): DataResponse => ({_id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), __version__: faker.string.alpha({length: {min: 10, max: 20}}), 'meta/instanceID': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/rootUuid': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), _xform_id_string: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.alpha({length: {min: 10, max: 20}}), _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({download_url: faker.internet.url(), download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), mimetype: faker.string.alpha({length: {min: 10, max: 20}}), media_file_basename: faker.string.alpha({length: {min: 10, max: 20}}), filename: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}}), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])})), _status: faker.string.alpha({length: {min: 10, max: 20}}), _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}),null,]))), _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, _validation_status: faker.helpers.arrayElement([{...getApiV2AssetsDataRetrieveResponseDataValidationStatusMock()},]), _submitted_by: faker.string.alpha({length: {min: 10, max: 20}}), _supplementalDetails: faker.helpers.arrayElement([faker.helpers.arrayElement([{ + [faker.string.alphanumeric(5)]: {manual_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))}} + },{ + [faker.string.alphanumeric(5)]: {manual_translation: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))} + }} + },{ + [faker.string.alphanumeric(5)]: {automatic_google_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _data: faker.helpers.arrayElement([{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock()},])}))}} + },{ + [faker.string.alphanumeric(5)]: {automatic_google_translation: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: faker.helpers.arrayElement([{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock()},])}))} + }} + },{ + [faker.string.alphanumeric(5)]: {manual_qual: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} + }} + },{ + [faker.string.alphanumeric(5)]: {automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), _dependency: faker.helpers.arrayElement([{_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, undefined]), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} + }} + },]), undefined]), ...overrideResponse}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock = (overrideResponse: Partial = {}): DataValidationStatus => ({...{timestamp: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), by_whom: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum))}, ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticInProgress => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'in_progress'}, ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticFailed => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticComplete => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'complete', value: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticDeleted => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'deleted', value: null}, ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataInteger => ({...{value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataText => ({...{value: faker.string.alpha({length: {min: 10, max: 20}}), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectOne => ({...{value: faker.string.uuid(), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectMultiple => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataTags => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), uuid: faker.string.uuid()}, ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataIntegerResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataTextResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.alpha({length: {min: 10, max: 20}}), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectOneResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectMultipleResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); + +export const getApiV2AssetsDataDuplicateCreateResponseMock = (overrideResponse: Partial< DataResponse > = {}): DataResponse => ({_id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), __version__: faker.string.alpha({length: {min: 10, max: 20}}), 'meta/instanceID': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/rootUuid': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), _xform_id_string: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.alpha({length: {min: 10, max: 20}}), _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({download_url: faker.internet.url(), download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), mimetype: faker.string.alpha({length: {min: 10, max: 20}}), media_file_basename: faker.string.alpha({length: {min: 10, max: 20}}), filename: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}}), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])})), _status: faker.string.alpha({length: {min: 10, max: 20}}), _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}),null,]))), _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, _validation_status: faker.helpers.arrayElement([{...getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock()},]), _submitted_by: faker.string.alpha({length: {min: 10, max: 20}}), _supplementalDetails: faker.helpers.arrayElement([faker.helpers.arrayElement([{ + [faker.string.alphanumeric(5)]: {manual_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))}} + },{ + [faker.string.alphanumeric(5)]: {manual_translation: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))} + }} + },{ + [faker.string.alphanumeric(5)]: {automatic_google_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _data: faker.helpers.arrayElement([{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock()},])}))}} + },{ + [faker.string.alphanumeric(5)]: {automatic_google_translation: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: faker.helpers.arrayElement([{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock()},])}))} + }} + },{ + [faker.string.alphanumeric(5)]: {manual_qual: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} + }} + },{ + [faker.string.alphanumeric(5)]: {automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), _dependency: faker.helpers.arrayElement([{_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, undefined]), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} + }} + },]), undefined]), ...overrideResponse}) + +export const getApiV2AssetsDataEditRetrieveResponseMock = (overrideResponse: Partial< EnketoEditResponse > = {}): EnketoEditResponse => ({url: faker.internet.url(), version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsDataEnketoEditRetrieveResponseMock = (overrideResponse: Partial< EnketoEditResponse > = {}): EnketoEditResponse => ({url: faker.internet.url(), version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock = (overrideResponse: Partial< EnketoEditResponse > = {}): EnketoEditResponse => ({url: faker.internet.url(), version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock = (overrideResponse: Partial< EnketoViewResponse > = {}): EnketoViewResponse => ({url: faker.internet.url(), version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsDataEnketoViewRetrieveResponseMock = (overrideResponse: Partial< EnketoViewResponse > = {}): EnketoViewResponse => ({url: faker.internet.url(), version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsDataValidationStatusRetrieveResponseMock = (overrideResponse: Partial< DataValidationStatusUpdateResponse > = {}): DataValidationStatusUpdateResponse => ({timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, uid: faker.string.alpha({length: {min: 10, max: 20}}), by_whom: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsDataValidationStatusPartialUpdateResponseMock = (overrideResponse: Partial< DataValidationStatusUpdateResponse > = {}): DataValidationStatusUpdateResponse => ({timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, uid: faker.string.alpha({length: {min: 10, max: 20}}), by_whom: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsDataSupplementRetrieveResponseMock = (overrideResponse: Partial< DataSupplementResponse > = {}): DataSupplementResponse => ({_version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsDataSupplementPartialUpdateResponseMock = (overrideResponse: Partial< DataSupplementResponse > = {}): DataSupplementResponse => ({_version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsDataBulkPartialUpdateResponseMock = (overrideResponse: Partial< DataBulkUpdateResponse > = {}): DataBulkUpdateResponse => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), successes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), failures: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status_code: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), message: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), ...overrideResponse}) + +export const getApiV2AssetsDataSupplementsBulkCreateResponseMock = (overrideResponse: Partial< BulkAcceptResponse > = {}): BulkAcceptResponse => ({accepted_count: faker.number.int({min: 0, max: undefined, multipleOf: undefined}), ...overrideResponse}) + +export const getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock = (overrideResponse: Partial< DataStatusesUpdate > = {}): DataStatusesUpdate => ({detail: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2AssetsExportSettingsListResponseMock = (overrideResponse: Partial< PaginatedExportSettingResponseList > = {}): PaginatedExportSettingResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), data_url_csv: faker.internet.url(), data_url_xlsx: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}})), ...overrideResponse}) + +export const getApiV2AssetsExportSettingsCreateResponseMock = (overrideResponse: Partial< ExportSettingResponse > = {}): ExportSettingResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), data_url_csv: faker.internet.url(), data_url_xlsx: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, ...overrideResponse}) + +export const getApiV2AssetsExportSettingsRetrieveResponseMock = (overrideResponse: Partial< ExportSettingResponse > = {}): ExportSettingResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), data_url_csv: faker.internet.url(), data_url_xlsx: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, ...overrideResponse}) + +export const getApiV2AssetsExportSettingsPartialUpdateResponseMock = (overrideResponse: Partial< ExportSettingResponse > = {}): ExportSettingResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), data_url_csv: faker.internet.url(), data_url_xlsx: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, ...overrideResponse}) + +export const getApiV2AssetsExportsListResponseMock = (overrideResponse: Partial< PaginatedExportResponseList > = {}): PaginatedExportResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), message: {}, uid: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, result: faker.internet.url(), data: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), source: faker.helpers.arrayElement([faker.internet.url(), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), processing_time_seconds: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}})), ...overrideResponse}) + +export const getApiV2AssetsExportsCreateResponseMock = (overrideResponse: Partial< ExportResponse > = {}): ExportResponse => ({url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), message: {}, uid: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, result: faker.internet.url(), data: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), source: faker.helpers.arrayElement([faker.internet.url(), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), processing_time_seconds: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, ...overrideResponse}) + +export const getApiV2AssetsExportsRetrieveResponseMock = (overrideResponse: Partial< ExportResponse > = {}): ExportResponse => ({url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), message: {}, uid: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, result: faker.internet.url(), data: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), source: faker.helpers.arrayElement([faker.internet.url(), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), processing_time_seconds: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, ...overrideResponse}) + +export const getApiV2AssetsFilesListResponseMock = (overrideResponse: Partial< PaginatedFilesResponseList > = {}): PaginatedFilesResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), asset: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), file_type: faker.string.alpha({length: {min: 10, max: 20}}), description: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, content: faker.internet.url(), metadata: {hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), mimetype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}})), ...overrideResponse}) + +export const getApiV2AssetsFilesCreateResponseMock = (overrideResponse: Partial< FilesResponse > = {}): FilesResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), asset: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), file_type: faker.string.alpha({length: {min: 10, max: 20}}), description: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, content: faker.internet.url(), metadata: {hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), mimetype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, ...overrideResponse}) + +export const getApiV2AssetsFilesRetrieveResponseMock = (overrideResponse: Partial< FilesResponse > = {}): FilesResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), asset: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), file_type: faker.string.alpha({length: {min: 10, max: 20}}), description: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, content: faker.internet.url(), metadata: {hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), mimetype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, ...overrideResponse}) + +export const getApiV2AssetsPairedDataListResponseMock = (overrideResponse: Partial< PaginatedPairedDataResponseList > = {}): PaginatedPairedDataResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({source: faker.internet.url(), source__name: faker.string.alpha({length: {min: 10, max: 20}}), fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), filename: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url()})), ...overrideResponse}) + +export const getApiV2AssetsPairedDataCreateResponseMock = (overrideResponse: Partial< PairedDataResponse > = {}): PairedDataResponse => ({source: faker.internet.url(), source__name: faker.string.alpha({length: {min: 10, max: 20}}), fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), filename: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) + +export const getApiV2AssetsPairedDataRetrieveResponseMock = (overrideResponse: Partial< PairedDataResponse > = {}): PairedDataResponse => ({source: faker.internet.url(), source__name: faker.string.alpha({length: {min: 10, max: 20}}), fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), filename: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) + +export const getApiV2AssetsPairedDataPartialUpdateResponseMock = (overrideResponse: Partial< PairedDataResponse > = {}): PairedDataResponse => ({source: faker.internet.url(), source__name: faker.string.alpha({length: {min: 10, max: 20}}), fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), filename: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) + +export const getApiV2AssetsPairedDataExternalRetrieveResponseMock = (overrideResponse: Partial< ExternalResponse > = {}): ExternalResponse => ({root: {data: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), field_value_1: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), field_value_2: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined])}, ...overrideResponse}) + +export const getApiV2AssetsReportsRetrieveResponseMock = (overrideResponse: Partial< ReportResponse > = {}): ReportResponse => ({url: faker.internet.url(), count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), list: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), row: faker.helpers.arrayElement([{type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), data: faker.helpers.arrayElement([{total_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), not_provided: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), provided: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), show_graph: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), kuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([{}, undefined])})), ...overrideResponse}) + + +export const getApiV2AssetsAdvancedFeaturesListMockHandler = (overrideResponse?: AdvancedFeatureResponse[] | ((info: Parameters[1]>[0]) => Promise | AdvancedFeatureResponse[])) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsAdvancedFeaturesListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsAdvancedFeaturesCreateMockHandler = (overrideResponse?: AdvancedFeatureCreateResponse | ((info: Parameters[1]>[0]) => Promise | AdvancedFeatureCreateResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsAdvancedFeaturesCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsAdvancedFeaturesRetrieveMockHandler = (overrideResponse?: AdvancedFeatureResponse | ((info: Parameters[1]>[0]) => Promise | AdvancedFeatureResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsAdvancedFeaturesRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler = (overrideResponse?: AdvancedFeatureResponse | ((info: Parameters[1]>[0]) => Promise | AdvancedFeatureResponse)) => { + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler = (overrideResponse?: BulkActionListResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionListResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler = (overrideResponse?: BulkActionCreateResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionCreateResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler = (overrideResponse?: BulkActionResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = (overrideResponse?: BulkActionResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse)) => { + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsAttachmentsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/attachments/:id/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = (overrideResponse?: AssetAttachmentAudioDurationResponse | ((info: Parameters[1]>[0]) => Promise | AssetAttachmentAudioDurationResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsAttachmentsAudioDurationCreateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsAttachmentsBulkDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 202, + + }) + }) +} + +export const getApiV2AssetsDataListMockHandler = (overrideResponse?: PaginatedDataResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedDataResponseList)) => { + return http.get('*/api/v2/assets/:uidAsset/data/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataRetrieveMockHandler = (overrideResponse?: DataResponse | ((info: Parameters[1]>[0]) => Promise | DataResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/data/:id/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsDataDuplicateCreateMockHandler = (overrideResponse?: DataResponse | ((info: Parameters[1]>[0]) => Promise | DataResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataDuplicateCreateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataEditRetrieveMockHandler = (overrideResponse?: EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/edit/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataEditRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataEnketoEditRetrieveMockHandler = (overrideResponse?: EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataEnketoEditRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler = (overrideResponse?: EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler = (overrideResponse?: EnketoViewResponse | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataEnketoViewRetrieveMockHandler = (overrideResponse?: EnketoViewResponse | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataEnketoViewRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataValidationStatusRetrieveMockHandler = (overrideResponse?: DataValidationStatusUpdateResponse | ((info: Parameters[1]>[0]) => Promise | DataValidationStatusUpdateResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataValidationStatusRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = (overrideResponse?: DataValidationStatusUpdateResponse | ((info: Parameters[1]>[0]) => Promise | DataValidationStatusUpdateResponse)) => { + return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataValidationStatusPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataValidationStatusDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsDataSupplementRetrieveMockHandler = (overrideResponse?: DataSupplementResponse | ((info: Parameters[1]>[0]) => Promise | DataSupplementResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataSupplementRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = (overrideResponse?: DataSupplementResponse | ((info: Parameters[1]>[0]) => Promise | DataSupplementResponse)) => { + return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataSupplementPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataAttachmentsListMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getAttachmentRetrieveMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getAttachmentThumbnailMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AssetsDataBulkPartialUpdateMockHandler = (overrideResponse?: DataBulkUpdateResponse | ((info: Parameters[1]>[0]) => Promise | DataBulkUpdateResponse)) => { + return http.patch('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataBulkPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataBulkDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AssetsDataSupplementsBulkCreateMockHandler = (overrideResponse?: BulkAcceptResponse | ((info: Parameters[1]>[0]) => Promise | BulkAcceptResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataSupplementsBulkCreateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = (overrideResponse?: DataStatusesUpdate | ((info: Parameters[1]>[0]) => Promise | DataStatusesUpdate)) => { + return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsDataValidationStatusesDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsExportSettingsListMockHandler = (overrideResponse?: PaginatedExportSettingResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedExportSettingResponseList)) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsExportSettingsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsExportSettingsCreateMockHandler = (overrideResponse?: ExportSettingResponse | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/export-settings/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsExportSettingsCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsExportSettingsRetrieveMockHandler = (overrideResponse?: ExportSettingResponse | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsExportSettingsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = (overrideResponse?: ExportSettingResponse | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse)) => { + return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsExportSettingsPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsExportSettingsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsExportSettingsDataRetrieveMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AssetsExportsListMockHandler = (overrideResponse?: PaginatedExportResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedExportResponseList)) => { + return http.get('*/api/v2/assets/:uidAsset/exports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsExportsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsExportsCreateMockHandler = (overrideResponse?: ExportResponse | ((info: Parameters[1]>[0]) => Promise | ExportResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/exports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsExportsCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsExportsRetrieveMockHandler = (overrideResponse?: ExportResponse | ((info: Parameters[1]>[0]) => Promise | ExportResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsExportsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsExportsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsFilesListMockHandler = (overrideResponse?: PaginatedFilesResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedFilesResponseList)) => { + return http.get('*/api/v2/assets/:uidAsset/files/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsFilesListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsFilesCreateMockHandler = (overrideResponse?: FilesResponse | ((info: Parameters[1]>[0]) => Promise | FilesResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/files/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsFilesCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsFilesRetrieveMockHandler = (overrideResponse?: FilesResponse | ((info: Parameters[1]>[0]) => Promise | FilesResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsFilesRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsFilesDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsFilesContentRetrieveMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 200, + + }) + }) +} + +export const getApiV2AssetsPairedDataListMockHandler = (overrideResponse?: PaginatedPairedDataResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedPairedDataResponseList)) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPairedDataListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsPairedDataCreateMockHandler = (overrideResponse?: PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse)) => { + return http.post('*/api/v2/assets/:uidAsset/paired-data/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPairedDataCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsPairedDataRetrieveMockHandler = (overrideResponse?: PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPairedDataRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsPairedDataPartialUpdateMockHandler = (overrideResponse?: PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse)) => { + return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPairedDataPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsPairedDataDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = (overrideResponse?: ExternalResponse | ((info: Parameters[1]>[0]) => Promise | ExternalResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsPairedDataExternalRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2AssetsReportsRetrieveMockHandler = (overrideResponse?: ReportResponse | ((info: Parameters[1]>[0]) => Promise | ReportResponse)) => { + return http.get('*/api/v2/assets/:uidAsset/reports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetsReportsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} +export const getSurveyDataMock = () => [ + getApiV2AssetsAdvancedFeaturesListMockHandler(), + getApiV2AssetsAdvancedFeaturesCreateMockHandler(), + getApiV2AssetsAdvancedFeaturesRetrieveMockHandler(), + getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler(), + getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler(), + getApiV2AssetsAttachmentsDestroyMockHandler(), + getApiV2AssetsAttachmentsAudioDurationCreateMockHandler(), + getApiV2AssetsAttachmentsBulkDestroyMockHandler(), + getApiV2AssetsDataListMockHandler(), + getApiV2AssetsDataRetrieveMockHandler(), + getApiV2AssetsDataDestroyMockHandler(), + getApiV2AssetsDataDuplicateCreateMockHandler(), + getApiV2AssetsDataEditRetrieveMockHandler(), + getApiV2AssetsDataEnketoEditRetrieveMockHandler(), + getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler(), + getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler(), + getApiV2AssetsDataEnketoViewRetrieveMockHandler(), + getApiV2AssetsDataValidationStatusRetrieveMockHandler(), + getApiV2AssetsDataValidationStatusPartialUpdateMockHandler(), + getApiV2AssetsDataValidationStatusDestroyMockHandler(), + getApiV2AssetsDataSupplementRetrieveMockHandler(), + getApiV2AssetsDataSupplementPartialUpdateMockHandler(), + getApiV2AssetsDataAttachmentsListMockHandler(), + getAttachmentRetrieveMockHandler(), + getAttachmentThumbnailMockHandler(), + getApiV2AssetsDataBulkPartialUpdateMockHandler(), + getApiV2AssetsDataBulkDestroyMockHandler(), + getApiV2AssetsDataSupplementsBulkCreateMockHandler(), + getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler(), + getApiV2AssetsDataValidationStatusesDestroyMockHandler(), + getApiV2AssetsExportSettingsListMockHandler(), + getApiV2AssetsExportSettingsCreateMockHandler(), + getApiV2AssetsExportSettingsRetrieveMockHandler(), + getApiV2AssetsExportSettingsPartialUpdateMockHandler(), + getApiV2AssetsExportSettingsDestroyMockHandler(), + getApiV2AssetsExportSettingsDataRetrieveMockHandler(), + getApiV2AssetsExportsListMockHandler(), + getApiV2AssetsExportsCreateMockHandler(), + getApiV2AssetsExportsRetrieveMockHandler(), + getApiV2AssetsExportsDestroyMockHandler(), + getApiV2AssetsFilesListMockHandler(), + getApiV2AssetsFilesCreateMockHandler(), + getApiV2AssetsFilesRetrieveMockHandler(), + getApiV2AssetsFilesDestroyMockHandler(), + getApiV2AssetsFilesContentRetrieveMockHandler(), + getApiV2AssetsPairedDataListMockHandler(), + getApiV2AssetsPairedDataCreateMockHandler(), + getApiV2AssetsPairedDataRetrieveMockHandler(), + getApiV2AssetsPairedDataPartialUpdateMockHandler(), + getApiV2AssetsPairedDataDestroyMockHandler(), + getApiV2AssetsPairedDataExternalRetrieveMockHandler(), + getApiV2AssetsReportsRetrieveMockHandler() +] diff --git a/jsapp/js/api/react-query/survey-data/survey-data.msw.ts b/jsapp/js/api/react-query/survey-data/survey-data.msw.ts deleted file mode 100644 index 081c1eb882..0000000000 --- a/jsapp/js/api/react-query/survey-data/survey-data.msw.ts +++ /dev/null @@ -1,3020 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import { ActionEnum } from '../../models/actionEnum' - -import { ActionIdEnum } from '../../models/actionIdEnum' - -import type { AdvancedFeatureCreateResponse } from '../../models/advancedFeatureCreateResponse' - -import type { AdvancedFeatureResponse } from '../../models/advancedFeatureResponse' - -import type { AssetAttachmentAudioDurationResponse } from '../../models/assetAttachmentAudioDurationResponse' - -import type { BulkAcceptResponse } from '../../models/bulkAcceptResponse' - -import type { BulkActionCreateResponse } from '../../models/bulkActionCreateResponse' - -import type { BulkActionListResponse } from '../../models/bulkActionListResponse' - -import type { BulkActionResponse } from '../../models/bulkActionResponse' - -import { BulkActionResponseStatusEnum } from '../../models/bulkActionResponseStatusEnum' - -import { BulkActionSubmissionStatusResponseStatusEnum } from '../../models/bulkActionSubmissionStatusResponseStatusEnum' - -import type { DataBulkUpdateResponse } from '../../models/dataBulkUpdateResponse' - -import type { DataResponse } from '../../models/dataResponse' - -import type { DataStatusesUpdate } from '../../models/dataStatusesUpdate' - -import type { DataSupplementAutomaticQualDataIntegerResponse } from '../../models/dataSupplementAutomaticQualDataIntegerResponse' - -import type { DataSupplementAutomaticQualDataSelectMultipleResponse } from '../../models/dataSupplementAutomaticQualDataSelectMultipleResponse' - -import type { DataSupplementAutomaticQualDataSelectOneResponse } from '../../models/dataSupplementAutomaticQualDataSelectOneResponse' - -import type { DataSupplementAutomaticQualDataTextResponse } from '../../models/dataSupplementAutomaticQualDataTextResponse' - -import type { DataSupplementManualQualDataInteger } from '../../models/dataSupplementManualQualDataInteger' - -import type { DataSupplementManualQualDataSelectMultiple } from '../../models/dataSupplementManualQualDataSelectMultiple' - -import type { DataSupplementManualQualDataSelectOne } from '../../models/dataSupplementManualQualDataSelectOne' - -import type { DataSupplementManualQualDataTags } from '../../models/dataSupplementManualQualDataTags' - -import type { DataSupplementManualQualDataText } from '../../models/dataSupplementManualQualDataText' - -import type { DataSupplementResponse } from '../../models/dataSupplementResponse' - -import type { DataValidationStatus } from '../../models/dataValidationStatus' - -import { DataValidationStatusLabelEnum } from '../../models/dataValidationStatusLabelEnum' - -import { DataValidationStatusUidEnum } from '../../models/dataValidationStatusUidEnum' - -import type { DataValidationStatusUpdateResponse } from '../../models/dataValidationStatusUpdateResponse' - -import type { EnketoEditResponse } from '../../models/enketoEditResponse' - -import type { EnketoViewResponse } from '../../models/enketoViewResponse' - -import type { ExportResponse } from '../../models/exportResponse' - -import type { ExportSettingResponse } from '../../models/exportSettingResponse' - -import type { ExternalResponse } from '../../models/externalResponse' - -import type { FilesResponse } from '../../models/filesResponse' - -import type { PaginatedDataResponseList } from '../../models/paginatedDataResponseList' - -import type { PaginatedExportResponseList } from '../../models/paginatedExportResponseList' - -import type { PaginatedExportSettingResponseList } from '../../models/paginatedExportSettingResponseList' - -import type { PaginatedFilesResponseList } from '../../models/paginatedFilesResponseList' - -import type { PaginatedPairedDataResponseList } from '../../models/paginatedPairedDataResponseList' - -import type { PairedDataResponse } from '../../models/pairedDataResponse' - -import { QualSelectQuestionParamsTypeEnum } from '../../models/qualSelectQuestionParamsTypeEnum' - -import { QualSimpleQuestionParamsTypeEnum } from '../../models/qualSimpleQuestionParamsTypeEnum' - -import type { ReportResponse } from '../../models/reportResponse' - -import type { SupplementalDataContentAutomaticComplete } from '../../models/supplementalDataContentAutomaticComplete' - -import type { SupplementalDataContentAutomaticDeleted } from '../../models/supplementalDataContentAutomaticDeleted' - -import type { SupplementalDataContentAutomaticFailed } from '../../models/supplementalDataContentAutomaticFailed' - -import type { SupplementalDataContentAutomaticInProgress } from '../../models/supplementalDataContentAutomaticInProgress' - -export const getApiV2AssetsAdvancedFeaturesListResponseMock = (): AdvancedFeatureResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.helpers.arrayElement(Object.values(ActionEnum)), - params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.uuid(), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - })), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - ]), - { uuid: faker.string.uuid() }, - ]), - ), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2AssetsAdvancedFeaturesCreateResponseMock = ( - overrideResponse: Partial = {}, -): AdvancedFeatureCreateResponse => ({ - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.helpers.arrayElement(Object.values(ActionEnum)), - params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - hint: faker.helpers.arrayElement([{}, undefined]), - }, - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.uuid(), - hint: faker.helpers.arrayElement([{}, undefined]), - })), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - ]), - { uuid: faker.string.uuid() }, - ]), - ), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AdvancedFeatureResponse => ({ - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.helpers.arrayElement(Object.values(ActionEnum)), - params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.uuid(), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - })), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - ]), - { uuid: faker.string.uuid() }, - ]), - ), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): AdvancedFeatureResponse => ({ - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - action: faker.helpers.arrayElement(Object.values(ActionEnum)), - params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([ - { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - { - uuid: faker.string.uuid(), - type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.uuid(), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - })), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - hint: faker.helpers.arrayElement([{}, undefined]), - }, - ]), - { uuid: faker.string.uuid() }, - ]), - ), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock = ( - overrideResponse: Partial = {}, -): BulkActionListResponse => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - previous: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), - action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - params: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), - created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - cancelled_by: faker.helpers.arrayElement([ - { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock = ( - overrideResponse: Partial = {}, -): BulkActionCreateResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), - action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - params: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), - created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - cancelled_by: faker.helpers.arrayElement([ - { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, - undefined, - ]), - skipped_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): BulkActionResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), - action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - params: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), - created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - cancelled_by: faker.helpers.arrayElement([ - { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): BulkActionResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), - action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), - error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - params: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), - created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - cancelled_by: faker.helpers.arrayElement([ - { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsAttachmentsAudioDurationCreateResponseMock = ( - overrideResponse: Partial = {}, -): AssetAttachmentAudioDurationResponse => ({ - attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - seconds: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - })), - total: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataValidationStatusMock = ( - overrideResponse: Partial = {}, -): DataValidationStatus => ({ - ...{ - timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), - by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticInProgress => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'in_progress', - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticFailed => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'failed', - error: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticComplete => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'complete', - value: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticDeleted => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'deleted', - value: null, - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataInteger => ({ - ...{ - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataText => ({ - ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectOne => ({ - ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectMultiple => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataTags => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataIntegerResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataTextResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectOneResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedDataResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - download_url: faker.internet.url(), - download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), - media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - _status: faker.string.alpha({ length: { min: 10, max: 20 } }), - _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), - ), - _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - _validation_status: faker.helpers.arrayElement([{ ...getApiV2AssetsDataListResponseDataValidationStatusMock() }]), - _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), - _supplementalDetails: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - { - [faker.string.alphanumeric(5)]: { - manual_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock() }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_bedrock_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock() }, - { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock() }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - _dependency: faker.helpers.arrayElement([ - { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, - undefined, - ]), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - ]), - undefined, - ]), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataValidationStatusMock = ( - overrideResponse: Partial = {}, -): DataValidationStatus => ({ - ...{ - timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), - by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticInProgress => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'in_progress', - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticFailed => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'failed', - error: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticComplete => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'complete', - value: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticDeleted => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'deleted', - value: null, - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataInteger => ({ - ...{ - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataText => ({ - ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectOne => ({ - ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectMultiple => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataTags => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataIntegerResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataTextResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectOneResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataRetrieveResponseMock = (overrideResponse: Partial = {}): DataResponse => ({ - _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - download_url: faker.internet.url(), - download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), - media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - _status: faker.string.alpha({ length: { min: 10, max: 20 } }), - _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), - ), - _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - _validation_status: faker.helpers.arrayElement([{ ...getApiV2AssetsDataRetrieveResponseDataValidationStatusMock() }]), - _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), - _supplementalDetails: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - { - [faker.string.alphanumeric(5)]: { - manual_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock() }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_bedrock_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock() }, - { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock() }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - _dependency: faker.helpers.arrayElement([ - { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, - undefined, - ]), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - ]), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock = ( - overrideResponse: Partial = {}, -): DataValidationStatus => ({ - ...{ - timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), - by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticInProgress => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'in_progress', - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticFailed => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'failed', - error: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticComplete => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'complete', - value: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock = ( - overrideResponse: Partial = {}, -): SupplementalDataContentAutomaticDeleted => ({ - ...{ - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status: 'deleted', - value: null, - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataInteger => ({ - ...{ - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataText => ({ - ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectOne => ({ - ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataSelectMultiple => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock = ( - overrideResponse: Partial = {}, -): DataSupplementManualQualDataTags => ({ - ...{ - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - uuid: faker.string.uuid(), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataIntegerResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - null, - ]), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataTextResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectOneResponse => ({ - ...faker.helpers.arrayElement([ - { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( - overrideResponse: Omit, 'status'> = {}, -): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ - ...faker.helpers.arrayElement([ - { - uuid: faker.string.uuid(), - value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.uuid(), - ), - status: 'complete', - }, - { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataDuplicateCreateResponseMock = ( - overrideResponse: Partial = {}, -): DataResponse => ({ - _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), - 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - download_url: faker.internet.url(), - download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), - media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - _status: faker.string.alpha({ length: { min: 10, max: 20 } }), - _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), - ), - _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - _validation_status: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock() }, - ]), - _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), - _supplementalDetails: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - { - [faker.string.alphanumeric(5)]: { - manual_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: { - language: faker.string.alpha({ length: { min: 10, max: 20 } }), - locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - }, - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_transcription: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_google_translation: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _uuid: faker.string.uuid(), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dependency: { - _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), - _uuid: faker.string.uuid(), - }, - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock() }, - ]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - manual_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock() }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - { - [faker.string.alphanumeric(5)]: { - automatic_bedrock_qual: { - [faker.string.alphanumeric(5)]: { - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, - _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - _data: faker.helpers.arrayElement([ - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, - { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock() }, - { - ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock(), - }, - { - ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock(), - }, - ]), - _dateAccepted: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, - _dateVerified: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - undefined, - ]), - _uuid: faker.string.uuid(), - _dependency: faker.helpers.arrayElement([ - { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, - undefined, - ]), - verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - })), - }, - }, - }, - }, - ]), - undefined, - ]), - ...overrideResponse, -}) - -export const getApiV2AssetsDataEditRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnketoEditResponse => ({ - url: faker.internet.url(), - version: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataEnketoEditRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnketoEditResponse => ({ - url: faker.internet.url(), - version: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnketoEditResponse => ({ - url: faker.internet.url(), - version: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnketoViewResponse => ({ - url: faker.internet.url(), - version: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataEnketoViewRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): EnketoViewResponse => ({ - url: faker.internet.url(), - version: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataValidationStatusRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): DataValidationStatusUpdateResponse => ({ - timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataValidationStatusPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): DataValidationStatusUpdateResponse => ({ - timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataSupplementRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2AssetsDataSupplementPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2AssetsDataBulkPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): DataBulkUpdateResponse => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - successes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - failures: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - status_code: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsDataSupplementsBulkCreateResponseMock = ( - overrideResponse: Partial = {}, -): BulkAcceptResponse => ({ - accepted_count: faker.number.int({ min: 0, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): DataStatusesUpdate => ({ detail: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) - -export const getApiV2AssetsExportSettingsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedExportSettingResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - data_url_csv: faker.internet.url(), - data_url_xlsx: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsExportSettingsCreateResponseMock = ( - overrideResponse: Partial = {}, -): ExportSettingResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - data_url_csv: faker.internet.url(), - data_url_xlsx: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsExportSettingsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ExportSettingResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - data_url_csv: faker.internet.url(), - data_url_xlsx: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsExportSettingsPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): ExportSettingResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - data_url_csv: faker.internet.url(), - data_url_xlsx: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsExportsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedExportResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - message: {}, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - result: faker.internet.url(), - data: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - source: faker.helpers.arrayElement([faker.internet.url(), undefined]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - processing_time_seconds: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsExportsCreateResponseMock = ( - overrideResponse: Partial = {}, -): ExportResponse => ({ - url: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - message: {}, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - result: faker.internet.url(), - data: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - source: faker.helpers.arrayElement([faker.internet.url(), undefined]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - processing_time_seconds: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsExportsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ExportResponse => ({ - url: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - message: {}, - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - result: faker.internet.url(), - data: { - lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - source: faker.helpers.arrayElement([faker.internet.url(), undefined]), - group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - processing_time_seconds: faker.helpers.arrayElement([ - faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), - undefined, - ]), - fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsFilesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedFilesResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - asset: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), - description: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - content: faker.internet.url(), - metadata: { - hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2AssetsFilesCreateResponseMock = ( - overrideResponse: Partial = {}, -): FilesResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - asset: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), - description: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - content: faker.internet.url(), - metadata: { - hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsFilesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): FilesResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - asset: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), - description: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - content: faker.internet.url(), - metadata: { - hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsPairedDataListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedPairedDataResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - source: faker.internet.url(), - source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsPairedDataCreateResponseMock = ( - overrideResponse: Partial = {}, -): PairedDataResponse => ({ - source: faker.internet.url(), - source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsPairedDataRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PairedDataResponse => ({ - source: faker.internet.url(), - source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsPairedDataPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): PairedDataResponse => ({ - source: faker.internet.url(), - source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - filename: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2AssetsPairedDataExternalRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ExternalResponse => ({ - root: { - data: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - field_value_1: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - field_value_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - }, - ...overrideResponse, -}) - -export const getApiV2AssetsReportsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ReportResponse => ({ - url: faker.internet.url(), - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - list: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - row: faker.helpers.arrayElement([ - { type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, - undefined, - ]), - data: faker.helpers.arrayElement([ - { - total_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - not_provided: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - provided: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - show_graph: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - }, - undefined, - ]), - kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([{}, undefined]), - })), - ...overrideResponse, -}) - -export const getApiV2AssetsAdvancedFeaturesListMockHandler = ( - overrideResponse?: - | AdvancedFeatureResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | AdvancedFeatureResponse[]), -) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesCreateMockHandler = ( - overrideResponse?: - | AdvancedFeatureCreateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AdvancedFeatureCreateResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesRetrieveMockHandler = ( - overrideResponse?: - | AdvancedFeatureResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AdvancedFeatureResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler = ( - overrideResponse?: - | AdvancedFeatureResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AdvancedFeatureResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler = ( - overrideResponse?: - | BulkActionListResponse - | (( - info: Parameters[1]>[0], - ) => Promise | BulkActionListResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler = ( - overrideResponse?: - | BulkActionCreateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | BulkActionCreateResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler = ( - overrideResponse?: - | BulkActionResponse - | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = ( - overrideResponse?: - | BulkActionResponse - | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAttachmentsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/attachments/:id/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = ( - overrideResponse?: - | AssetAttachmentAudioDurationResponse - | (( - info: Parameters[1]>[0], - ) => Promise | AssetAttachmentAudioDurationResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsAttachmentsAudioDurationCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsAttachmentsBulkDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 202 }) - }) -} - -export const getApiV2AssetsDataListMockHandler = ( - overrideResponse?: - | PaginatedDataResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedDataResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataRetrieveMockHandler = ( - overrideResponse?: - | DataResponse - | ((info: Parameters[1]>[0]) => Promise | DataResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsDataDuplicateCreateMockHandler = ( - overrideResponse?: - | DataResponse - | ((info: Parameters[1]>[0]) => Promise | DataResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataDuplicateCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataEditRetrieveMockHandler = ( - overrideResponse?: - | EnketoEditResponse - | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/edit/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataEditRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataEnketoEditRetrieveMockHandler = ( - overrideResponse?: - | EnketoEditResponse - | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataEnketoEditRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler = ( - overrideResponse?: - | EnketoEditResponse - | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler = ( - overrideResponse?: - | EnketoViewResponse - | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataEnketoViewRetrieveMockHandler = ( - overrideResponse?: - | EnketoViewResponse - | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataEnketoViewRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataValidationStatusRetrieveMockHandler = ( - overrideResponse?: - | DataValidationStatusUpdateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | DataValidationStatusUpdateResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataValidationStatusRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = ( - overrideResponse?: - | DataValidationStatusUpdateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | DataValidationStatusUpdateResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataValidationStatusPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataValidationStatusDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsDataSupplementRetrieveMockHandler = ( - overrideResponse?: - | DataSupplementResponse - | (( - info: Parameters[1]>[0], - ) => Promise | DataSupplementResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataSupplementRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = ( - overrideResponse?: - | DataSupplementResponse - | (( - info: Parameters[1]>[0], - ) => Promise | DataSupplementResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataSupplementPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataAttachmentsListMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getAttachmentRetrieveMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getAttachmentThumbnailMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AssetsDataBulkPartialUpdateMockHandler = ( - overrideResponse?: - | DataBulkUpdateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | DataBulkUpdateResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataBulkPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataBulkDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AssetsDataSupplementsBulkCreateMockHandler = ( - overrideResponse?: - | BulkAcceptResponse - | ((info: Parameters[1]>[0]) => Promise | BulkAcceptResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataSupplementsBulkCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = ( - overrideResponse?: - | DataStatusesUpdate - | ((info: Parameters[1]>[0]) => Promise | DataStatusesUpdate), -) => { - return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsDataValidationStatusesDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsExportSettingsListMockHandler = ( - overrideResponse?: - | PaginatedExportSettingResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedExportSettingResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportSettingsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportSettingsCreateMockHandler = ( - overrideResponse?: - | ExportSettingResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ExportSettingResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportSettingsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportSettingsRetrieveMockHandler = ( - overrideResponse?: - | ExportSettingResponse - | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportSettingsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = ( - overrideResponse?: - | ExportSettingResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ExportSettingResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportSettingsPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportSettingsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsExportSettingsDataRetrieveMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AssetsExportsListMockHandler = ( - overrideResponse?: - | PaginatedExportResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedExportResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/exports/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportsCreateMockHandler = ( - overrideResponse?: - | ExportResponse - | ((info: Parameters[1]>[0]) => Promise | ExportResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/exports/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportsRetrieveMockHandler = ( - overrideResponse?: - | ExportResponse - | ((info: Parameters[1]>[0]) => Promise | ExportResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsExportsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsExportsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsFilesListMockHandler = ( - overrideResponse?: - | PaginatedFilesResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedFilesResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/files/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsFilesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsFilesCreateMockHandler = ( - overrideResponse?: - | FilesResponse - | ((info: Parameters[1]>[0]) => Promise | FilesResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/files/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsFilesCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsFilesRetrieveMockHandler = ( - overrideResponse?: - | FilesResponse - | ((info: Parameters[1]>[0]) => Promise | FilesResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsFilesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsFilesDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsFilesContentRetrieveMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 200 }) - }) -} - -export const getApiV2AssetsPairedDataListMockHandler = ( - overrideResponse?: - | PaginatedPairedDataResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedPairedDataResponseList), -) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPairedDataListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPairedDataCreateMockHandler = ( - overrideResponse?: - | PairedDataResponse - | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), -) => { - return http.post('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPairedDataCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPairedDataRetrieveMockHandler = ( - overrideResponse?: - | PairedDataResponse - | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPairedDataRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPairedDataPartialUpdateMockHandler = ( - overrideResponse?: - | PairedDataResponse - | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), -) => { - return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPairedDataPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsPairedDataDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = ( - overrideResponse?: - | ExternalResponse - | ((info: Parameters[1]>[0]) => Promise | ExternalResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsPairedDataExternalRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2AssetsReportsRetrieveMockHandler = ( - overrideResponse?: - | ReportResponse - | ((info: Parameters[1]>[0]) => Promise | ReportResponse), -) => { - return http.get('*/api/v2/assets/:uidAsset/reports/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetsReportsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} -export const getSurveyDataMock = () => [ - getApiV2AssetsAdvancedFeaturesListMockHandler(), - getApiV2AssetsAdvancedFeaturesCreateMockHandler(), - getApiV2AssetsAdvancedFeaturesRetrieveMockHandler(), - getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler(), - getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler(), - getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler(), - getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler(), - getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler(), - getApiV2AssetsAttachmentsDestroyMockHandler(), - getApiV2AssetsAttachmentsAudioDurationCreateMockHandler(), - getApiV2AssetsAttachmentsBulkDestroyMockHandler(), - getApiV2AssetsDataListMockHandler(), - getApiV2AssetsDataRetrieveMockHandler(), - getApiV2AssetsDataDestroyMockHandler(), - getApiV2AssetsDataDuplicateCreateMockHandler(), - getApiV2AssetsDataEditRetrieveMockHandler(), - getApiV2AssetsDataEnketoEditRetrieveMockHandler(), - getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler(), - getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler(), - getApiV2AssetsDataEnketoViewRetrieveMockHandler(), - getApiV2AssetsDataValidationStatusRetrieveMockHandler(), - getApiV2AssetsDataValidationStatusPartialUpdateMockHandler(), - getApiV2AssetsDataValidationStatusDestroyMockHandler(), - getApiV2AssetsDataSupplementRetrieveMockHandler(), - getApiV2AssetsDataSupplementPartialUpdateMockHandler(), - getApiV2AssetsDataAttachmentsListMockHandler(), - getAttachmentRetrieveMockHandler(), - getAttachmentThumbnailMockHandler(), - getApiV2AssetsDataBulkPartialUpdateMockHandler(), - getApiV2AssetsDataBulkDestroyMockHandler(), - getApiV2AssetsDataSupplementsBulkCreateMockHandler(), - getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler(), - getApiV2AssetsDataValidationStatusesDestroyMockHandler(), - getApiV2AssetsExportSettingsListMockHandler(), - getApiV2AssetsExportSettingsCreateMockHandler(), - getApiV2AssetsExportSettingsRetrieveMockHandler(), - getApiV2AssetsExportSettingsPartialUpdateMockHandler(), - getApiV2AssetsExportSettingsDestroyMockHandler(), - getApiV2AssetsExportSettingsDataRetrieveMockHandler(), - getApiV2AssetsExportsListMockHandler(), - getApiV2AssetsExportsCreateMockHandler(), - getApiV2AssetsExportsRetrieveMockHandler(), - getApiV2AssetsExportsDestroyMockHandler(), - getApiV2AssetsFilesListMockHandler(), - getApiV2AssetsFilesCreateMockHandler(), - getApiV2AssetsFilesRetrieveMockHandler(), - getApiV2AssetsFilesDestroyMockHandler(), - getApiV2AssetsFilesContentRetrieveMockHandler(), - getApiV2AssetsPairedDataListMockHandler(), - getApiV2AssetsPairedDataCreateMockHandler(), - getApiV2AssetsPairedDataRetrieveMockHandler(), - getApiV2AssetsPairedDataPartialUpdateMockHandler(), - getApiV2AssetsPairedDataDestroyMockHandler(), - getApiV2AssetsPairedDataExternalRetrieveMockHandler(), - getApiV2AssetsReportsRetrieveMockHandler(), -] diff --git a/jsapp/js/api/react-query/survey-data/survey-data.ts b/jsapp/js/api/react-query/survey-data/survey-data.ts deleted file mode 100644 index a5852dc26e..0000000000 --- a/jsapp/js/api/react-query/survey-data/survey-data.ts +++ /dev/null @@ -1,6157 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { AdvancedFeatureCreateResponse } from '../../models/advancedFeatureCreateResponse' - -import type { AdvancedFeaturePostRequest } from '../../models/advancedFeaturePostRequest' - -import type { AdvancedFeatureResponse } from '../../models/advancedFeatureResponse' - -import type { AssetAttachmentAudioDurationRequest } from '../../models/assetAttachmentAudioDurationRequest' - -import type { AssetAttachmentAudioDurationResponse } from '../../models/assetAttachmentAudioDurationResponse' - -import type { AssetsAdvancedFeaturesBulkActionsListParams } from '../../models/assetsAdvancedFeaturesBulkActionsListParams' - -import type { AssetsDataAttachmentsListParams } from '../../models/assetsDataAttachmentsListParams' - -import type { AssetsDataListParams } from '../../models/assetsDataListParams' - -import type { AssetsDataRetrieveParams } from '../../models/assetsDataRetrieveParams' - -import type { AssetsExportSettingsDataRetrieveParams } from '../../models/assetsExportSettingsDataRetrieveParams' - -import type { AssetsExportSettingsListParams } from '../../models/assetsExportSettingsListParams' - -import type { AssetsExportsListParams } from '../../models/assetsExportsListParams' - -import type { AssetsFilesListParams } from '../../models/assetsFilesListParams' - -import type { AssetsPairedDataListParams } from '../../models/assetsPairedDataListParams' - -import type { AttachmentRetrieveParams } from '../../models/attachmentRetrieveParams' - -import type { BulkAcceptRequest } from '../../models/bulkAcceptRequest' - -import type { BulkAcceptResponse } from '../../models/bulkAcceptResponse' - -import type { BulkActionCreateRequest } from '../../models/bulkActionCreateRequest' - -import type { BulkActionCreateResponse } from '../../models/bulkActionCreateResponse' - -import type { BulkActionListResponse } from '../../models/bulkActionListResponse' - -import type { BulkActionResponse } from '../../models/bulkActionResponse' - -import type { CreateFilePayload } from '../../models/createFilePayload' - -import type { DataBulkDelete } from '../../models/dataBulkDelete' - -import type { DataBulkUpdateResponse } from '../../models/dataBulkUpdateResponse' - -import type { DataResponse } from '../../models/dataResponse' - -import type { DataStatusesUpdate } from '../../models/dataStatusesUpdate' - -import type { DataSupplementResponse } from '../../models/dataSupplementResponse' - -import type { DataValidationStatusUpdateResponse } from '../../models/dataValidationStatusUpdateResponse' - -import type { EnketoEditResponse } from '../../models/enketoEditResponse' - -import type { EnketoViewResponse } from '../../models/enketoViewResponse' - -import type { ErrorDetail } from '../../models/errorDetail' - -import type { ErrorObject } from '../../models/errorObject' - -import type { ExportCreatePayload } from '../../models/exportCreatePayload' - -import type { ExportResponse } from '../../models/exportResponse' - -import type { ExportSettingCreatePayload } from '../../models/exportSettingCreatePayload' - -import type { ExportSettingResponse } from '../../models/exportSettingResponse' - -import type { ExternalResponse } from '../../models/externalResponse' - -import type { FilesResponse } from '../../models/filesResponse' - -import type { PaginatedDataResponseList } from '../../models/paginatedDataResponseList' - -import type { PaginatedExportResponseList } from '../../models/paginatedExportResponseList' - -import type { PaginatedExportSettingResponseList } from '../../models/paginatedExportSettingResponseList' - -import type { PaginatedFilesResponseList } from '../../models/paginatedFilesResponseList' - -import type { PaginatedPairedDataResponseList } from '../../models/paginatedPairedDataResponseList' - -import type { PairedData } from '../../models/pairedData' - -import type { PairedDataResponse } from '../../models/pairedDataResponse' - -import type { PatchedAdvancedFeaturePatchRequest } from '../../models/patchedAdvancedFeaturePatchRequest' - -import type { PatchedBulkActionPatchRequest } from '../../models/patchedBulkActionPatchRequest' - -import type { PatchedDataBulkUpdate } from '../../models/patchedDataBulkUpdate' - -import type { PatchedDataSupplementPayload } from '../../models/patchedDataSupplementPayload' - -import type { PatchedDataValidationStatusUpdatePayload } from '../../models/patchedDataValidationStatusUpdatePayload' - -import type { PatchedDataValidationStatusesUpdatePayload } from '../../models/patchedDataValidationStatusesUpdatePayload' - -import type { PatchedExportSettingUpdatePayload } from '../../models/patchedExportSettingUpdatePayload' - -import type { PatchedPairedDataPatchPayload } from '../../models/patchedPairedDataPatchPayload' - -import type { ReportResponse } from '../../models/reportResponse' - -import { fetchWithAuth } from '../../orval.mutator' - -// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B - -type WritableKeys = { - [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P> -}[keyof T] - -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never - -type Writable = Pick> -type NonReadonly = [T] extends [UnionToIntersection] - ? { - [P in keyof Writable]: T[P] extends object ? NonReadonly> : T[P] - } - : DistributeReadOnlyOverUnions - -type SecondParameter unknown> = Parameters[1] - -/** - * ## List all advanced features on an asset - -Lists all advanced features on all questions in an asset. Examples show one type at a time, but the response may contain multiple advanced features items. - - */ -export type assetsAdvancedFeaturesListResponse200 = { - data: AdvancedFeatureResponse[] - status: 200 -} - -export type assetsAdvancedFeaturesListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsAdvancedFeaturesListResponseComposite = - | assetsAdvancedFeaturesListResponse200 - | assetsAdvancedFeaturesListResponse404 - -export type assetsAdvancedFeaturesListResponse = assetsAdvancedFeaturesListResponseComposite & { - headers: Headers -} - -export const getAssetsAdvancedFeaturesListUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/advanced-features/` -} - -export const assetsAdvancedFeaturesList = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsAdvancedFeaturesListUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsAdvancedFeaturesListQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'advanced-features'] as const -} - -export const getAssetsAdvancedFeaturesListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesListQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsAdvancedFeaturesList(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsAdvancedFeaturesListQueryResult = NonNullable>> -export type AssetsAdvancedFeaturesListQueryError = ErrorDetail - -export function useAssetsAdvancedFeaturesList< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsAdvancedFeaturesListQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Add an advanced action to an asset - -Enables a new type of advanced action on a question in the asset. -* `action`, `params`, and `question_xpath` are required -* `params` must match the expected param_schema of the `action` - -Accepted `action`s include: -* `manual_transcription` -* `automatic_google_transcription` -* `manual_translation` -* `automatic_google_translation` -* `manual_qual` - - - */ -export type assetsAdvancedFeaturesCreateResponse201 = { - data: AdvancedFeatureCreateResponse - status: 201 -} - -export type assetsAdvancedFeaturesCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsAdvancedFeaturesCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsAdvancedFeaturesCreateResponseComposite = - | assetsAdvancedFeaturesCreateResponse201 - | assetsAdvancedFeaturesCreateResponse400 - | assetsAdvancedFeaturesCreateResponse404 - -export type assetsAdvancedFeaturesCreateResponse = assetsAdvancedFeaturesCreateResponseComposite & { - headers: Headers -} - -export const getAssetsAdvancedFeaturesCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/advanced-features/` -} - -export const assetsAdvancedFeaturesCreate = async ( - uidAsset: string, - advancedFeaturePostRequest: AdvancedFeaturePostRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsAdvancedFeaturesCreateUrl(uidAsset), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(advancedFeaturePostRequest), - }) -} - -export const getAssetsAdvancedFeaturesCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: AdvancedFeaturePostRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: AdvancedFeaturePostRequest }, - TContext -> => { - const mutationKey = ['assetsAdvancedFeaturesCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: AdvancedFeaturePostRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsAdvancedFeaturesCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsAdvancedFeaturesCreateMutationResult = NonNullable< - Awaited> -> -export type AssetsAdvancedFeaturesCreateMutationBody = AdvancedFeaturePostRequest -export type AssetsAdvancedFeaturesCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsAdvancedFeaturesCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: AdvancedFeaturePostRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsAdvancedFeaturesCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve advanced feature configuration for a question on an asset - -Gets the params for one advanced action for one question in an asset - - */ -export type assetsAdvancedFeaturesRetrieveResponse200 = { - data: AdvancedFeatureResponse - status: 200 -} - -export type assetsAdvancedFeaturesRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsAdvancedFeaturesRetrieveResponseComposite = - | assetsAdvancedFeaturesRetrieveResponse200 - | assetsAdvancedFeaturesRetrieveResponse404 - -export type assetsAdvancedFeaturesRetrieveResponse = assetsAdvancedFeaturesRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsAdvancedFeaturesRetrieveUrl = (uidAsset: string, uidAdvancedFeature: string) => { - return `/api/v2/assets/${uidAsset}/advanced-features/${uidAdvancedFeature}/` -} - -export const assetsAdvancedFeaturesRetrieve = async ( - uidAsset: string, - uidAdvancedFeature: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsAdvancedFeaturesRetrieveUrl(uidAsset, uidAdvancedFeature), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetsAdvancedFeaturesRetrieveQueryKey = (uidAsset: string, uidAdvancedFeature: string) => { - return ['api', 'v2', 'assets', uidAsset, 'advanced-features', uidAdvancedFeature] as const -} - -export const getAssetsAdvancedFeaturesRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidAdvancedFeature: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesRetrieveQueryKey(uidAsset, uidAdvancedFeature) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsAdvancedFeaturesRetrieve(uidAsset, uidAdvancedFeature, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidAdvancedFeature), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsAdvancedFeaturesRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsAdvancedFeaturesRetrieveQueryError = ErrorDetail - -export function useAssetsAdvancedFeaturesRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidAdvancedFeature: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsAdvancedFeaturesRetrieveQueryOptions(uidAsset, uidAdvancedFeature, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update an advanced action on an asset - -Update the params of an advanced action on a question in the asset. -`params` are always additive. That means that if you PATCH a feature with a new param array, the new ones -will be added to the existing ones. You cannot delete a param via the API. - -In the case of NLP actions, this means you can only add languages, not delete. -In the case of QA analysis questions, you should send the full set questions and choices in the desired order. Any existing -choices or questions in the existing params not present in the new ones will be marked as deleted, but not actually removed from the data. -Deleted questions and choices will be placed at the end of the relevant list. - -* `params` is required -* `params` must match the expected param_schema of the action being updated - - - - */ -export type assetsAdvancedFeaturesPartialUpdateResponse200 = { - data: AdvancedFeatureResponse - status: 200 -} - -export type assetsAdvancedFeaturesPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsAdvancedFeaturesPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsAdvancedFeaturesPartialUpdateResponseComposite = - | assetsAdvancedFeaturesPartialUpdateResponse200 - | assetsAdvancedFeaturesPartialUpdateResponse400 - | assetsAdvancedFeaturesPartialUpdateResponse404 - -export type assetsAdvancedFeaturesPartialUpdateResponse = assetsAdvancedFeaturesPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsAdvancedFeaturesPartialUpdateUrl = (uidAsset: string, uidAdvancedFeature: string) => { - return `/api/v2/assets/${uidAsset}/advanced-features/${uidAdvancedFeature}/` -} - -export const assetsAdvancedFeaturesPartialUpdate = async ( - uidAsset: string, - uidAdvancedFeature: string, - patchedAdvancedFeaturePatchRequest: PatchedAdvancedFeaturePatchRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsAdvancedFeaturesPartialUpdateUrl(uidAsset, uidAdvancedFeature), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedAdvancedFeaturePatchRequest), - }, - ) -} - -export const getAssetsAdvancedFeaturesPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidAdvancedFeature: string; data: PatchedAdvancedFeaturePatchRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidAdvancedFeature: string; data: PatchedAdvancedFeaturePatchRequest }, - TContext -> => { - const mutationKey = ['assetsAdvancedFeaturesPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidAdvancedFeature: string; data: PatchedAdvancedFeaturePatchRequest } - > = (props) => { - const { uidAsset, uidAdvancedFeature, data } = props ?? {} - - return assetsAdvancedFeaturesPartialUpdate(uidAsset, uidAdvancedFeature, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsAdvancedFeaturesPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsAdvancedFeaturesPartialUpdateMutationBody = PatchedAdvancedFeaturePatchRequest -export type AssetsAdvancedFeaturesPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useAssetsAdvancedFeaturesPartialUpdate = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidAdvancedFeature: string; data: PatchedAdvancedFeaturePatchRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsAdvancedFeaturesPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## List bulk processing jobs on an asset - -Returns paginated bulk processing jobs associated with the specified asset. Each -job is organized around one action, one question, and many submissions. - -Use this endpoint to monitor recently-created bulk transcription and translation -jobs. Each result includes the parent job status, per-submission statuses, the -original deterministic params, the user who created the job, cancellation -metadata, and integer `progress` from `0` to `100`. - -Job statuses: - -* `pending`: the job exists but has not started. -* `in_progress`: one or more child submissions are still active. -* `complete`: every child submission has reached a terminal state. -* `cancelled`: the job was cancelled. - -Child submission statuses: - -* `pending` -* `in_progress` -* `complete` -* `failed` -* `cancelled` - - */ -export type assetsAdvancedFeaturesBulkActionsListResponse200 = { - data: BulkActionListResponse - status: 200 -} - -export type assetsAdvancedFeaturesBulkActionsListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsAdvancedFeaturesBulkActionsListResponseComposite = - | assetsAdvancedFeaturesBulkActionsListResponse200 - | assetsAdvancedFeaturesBulkActionsListResponse404 - -export type assetsAdvancedFeaturesBulkActionsListResponse = assetsAdvancedFeaturesBulkActionsListResponseComposite & { - headers: Headers -} - -export const getAssetsAdvancedFeaturesBulkActionsListUrl = ( - uidAsset: string, - params?: AssetsAdvancedFeaturesBulkActionsListParams, -) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/` -} - -export const assetsAdvancedFeaturesBulkActionsList = async ( - uidAsset: string, - params?: AssetsAdvancedFeaturesBulkActionsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsAdvancedFeaturesBulkActionsListUrl(uidAsset, params), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetsAdvancedFeaturesBulkActionsListQueryKey = ( - uidAsset: string, - params?: AssetsAdvancedFeaturesBulkActionsListParams, -) => { - return ['api', 'v2', 'assets', uidAsset, 'advanced-features', 'bulk-actions', ...(params ? [params] : [])] as const -} - -export const getAssetsAdvancedFeaturesBulkActionsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsAdvancedFeaturesBulkActionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesBulkActionsListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsAdvancedFeaturesBulkActionsList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsAdvancedFeaturesBulkActionsListQueryResult = NonNullable< - Awaited> -> -export type AssetsAdvancedFeaturesBulkActionsListQueryError = ErrorDetail - -export function useAssetsAdvancedFeaturesBulkActionsList< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsAdvancedFeaturesBulkActionsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsAdvancedFeaturesBulkActionsListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create a bulk processing job - -Creates and starts a bulk processing job for one question across multiple -submissions. - -Supported actions: - -* `automatic_google_transcription` -* `automatic_google_translation` - -The request must include the target `question_xpath`, the submission root UUIDs -to process, and deterministic `params`. `params.language` is required. For -transcription, `params.locale` may also be supplied when a more specific Google -Speech locale is needed. - -Creation is atomic. If any selected submission is unknown, already has matching -results, or already has an active matching bulk action, no job or child items are -created. - -The response is the created job. Its initial status is `in_progress` because -creation immediately starts background processing. - - */ -export type assetsAdvancedFeaturesBulkActionsCreateResponse201 = { - data: BulkActionCreateResponse - status: 201 -} - -export type assetsAdvancedFeaturesBulkActionsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsAdvancedFeaturesBulkActionsCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsAdvancedFeaturesBulkActionsCreateResponseComposite = - | assetsAdvancedFeaturesBulkActionsCreateResponse201 - | assetsAdvancedFeaturesBulkActionsCreateResponse400 - | assetsAdvancedFeaturesBulkActionsCreateResponse404 - -export type assetsAdvancedFeaturesBulkActionsCreateResponse = - assetsAdvancedFeaturesBulkActionsCreateResponseComposite & { - headers: Headers - } - -export const getAssetsAdvancedFeaturesBulkActionsCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/` -} - -export const assetsAdvancedFeaturesBulkActionsCreate = async ( - uidAsset: string, - bulkActionCreateRequest: BulkActionCreateRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsAdvancedFeaturesBulkActionsCreateUrl(uidAsset), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(bulkActionCreateRequest), - }, - ) -} - -export const getAssetsAdvancedFeaturesBulkActionsCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: BulkActionCreateRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: BulkActionCreateRequest }, - TContext -> => { - const mutationKey = ['assetsAdvancedFeaturesBulkActionsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: BulkActionCreateRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsAdvancedFeaturesBulkActionsCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsAdvancedFeaturesBulkActionsCreateMutationResult = NonNullable< - Awaited> -> -export type AssetsAdvancedFeaturesBulkActionsCreateMutationBody = BulkActionCreateRequest -export type AssetsAdvancedFeaturesBulkActionsCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsAdvancedFeaturesBulkActionsCreate = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: BulkActionCreateRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsAdvancedFeaturesBulkActionsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve a bulk processing job - -Returns detailed information about a single bulk processing job, including its -current status, per-submission status, processing params, creator, cancellation -metadata, timestamps, and integer `progress` from `0` to `100`. - -The response shape is identical to the item returned by the bulk job creation -endpoint and to each item in the paginated list response. - - */ -export type assetsAdvancedFeaturesBulkActionsRetrieveResponse200 = { - data: BulkActionResponse - status: 200 -} - -export type assetsAdvancedFeaturesBulkActionsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsAdvancedFeaturesBulkActionsRetrieveResponseComposite = - | assetsAdvancedFeaturesBulkActionsRetrieveResponse200 - | assetsAdvancedFeaturesBulkActionsRetrieveResponse404 - -export type assetsAdvancedFeaturesBulkActionsRetrieveResponse = - assetsAdvancedFeaturesBulkActionsRetrieveResponseComposite & { - headers: Headers - } - -export const getAssetsAdvancedFeaturesBulkActionsRetrieveUrl = (uidAsset: string, actionUid: string) => { - return `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/${actionUid}/` -} - -export const assetsAdvancedFeaturesBulkActionsRetrieve = async ( - uidAsset: string, - actionUid: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsAdvancedFeaturesBulkActionsRetrieveUrl(uidAsset, actionUid), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetsAdvancedFeaturesBulkActionsRetrieveQueryKey = (uidAsset: string, actionUid: string) => { - return ['api', 'v2', 'assets', uidAsset, 'advanced-features', 'bulk-actions', actionUid] as const -} - -export const getAssetsAdvancedFeaturesBulkActionsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - actionUid: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesBulkActionsRetrieveQueryKey(uidAsset, actionUid) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsAdvancedFeaturesBulkActionsRetrieve(uidAsset, actionUid, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && actionUid), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsAdvancedFeaturesBulkActionsRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsAdvancedFeaturesBulkActionsRetrieveQueryError = ErrorDetail - -export function useAssetsAdvancedFeaturesBulkActionsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - actionUid: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsAdvancedFeaturesBulkActionsRetrieveQueryOptions(uidAsset, actionUid, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update a bulk processing job - -Cancels a single bulk processing job for an asset. This endpoint currently only -supports cancellation. - -Request body: - -```json -{ - "status": "cancelled" -} -``` - -Cancellation is idempotent. Cancelling an already-cancelled job returns the -current cancelled job. Completed jobs cannot be cancelled. - -When a job is cancelled, pending and in-progress child items are marked -`cancelled`; terminal child items are not modified. The response is the updated -job, including `cancelled_by`. - - */ -export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponse200 = { - data: BulkActionResponse - status: 200 -} - -export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponseComposite = - | assetsAdvancedFeaturesBulkActionsPartialUpdateResponse200 - | assetsAdvancedFeaturesBulkActionsPartialUpdateResponse404 - -export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponse = - assetsAdvancedFeaturesBulkActionsPartialUpdateResponseComposite & { - headers: Headers - } - -export const getAssetsAdvancedFeaturesBulkActionsPartialUpdateUrl = (uidAsset: string, actionUid: string) => { - return `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/${actionUid}/` -} - -export const assetsAdvancedFeaturesBulkActionsPartialUpdate = async ( - uidAsset: string, - actionUid: string, - patchedBulkActionPatchRequest: PatchedBulkActionPatchRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsAdvancedFeaturesBulkActionsPartialUpdateUrl(uidAsset, actionUid), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedBulkActionPatchRequest), - }, - ) -} - -export const getAssetsAdvancedFeaturesBulkActionsPartialUpdateMutationOptions = < - TError = ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; actionUid: string; data: PatchedBulkActionPatchRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; actionUid: string; data: PatchedBulkActionPatchRequest }, - TContext -> => { - const mutationKey = ['assetsAdvancedFeaturesBulkActionsPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; actionUid: string; data: PatchedBulkActionPatchRequest } - > = (props) => { - const { uidAsset, actionUid, data } = props ?? {} - - return assetsAdvancedFeaturesBulkActionsPartialUpdate(uidAsset, actionUid, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationBody = PatchedBulkActionPatchRequest -export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationError = ErrorDetail - -export const useAssetsAdvancedFeaturesBulkActionsPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; actionUid: string; data: PatchedBulkActionPatchRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsAdvancedFeaturesBulkActionsPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete a specific attachment of an Asset - -* `id` can only be the uid of attachment to be deleted - - */ -export type assetsAttachmentsDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsAttachmentsDestroyResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsAttachmentsDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsAttachmentsDestroyResponseComposite = - | assetsAttachmentsDestroyResponse204 - | assetsAttachmentsDestroyResponse400 - | assetsAttachmentsDestroyResponse404 - -export type assetsAttachmentsDestroyResponse = assetsAttachmentsDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsAttachmentsDestroyUrl = (uidAsset: string, id: number) => { - return `/api/v2/assets/${uidAsset}/attachments/${id}/` -} - -export const assetsAttachmentsDestroy = async ( - uidAsset: string, - id: number, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsAttachmentsDestroyUrl(uidAsset, id), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetsAttachmentsDestroyMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: number }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: number }, - TContext -> => { - const mutationKey = ['assetsAttachmentsDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; id: number } - > = (props) => { - const { uidAsset, id } = props ?? {} - - return assetsAttachmentsDestroy(uidAsset, id, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsAttachmentsDestroyMutationResult = NonNullable>> - -export type AssetsAttachmentsDestroyMutationError = ErrorObject | ErrorDetail - -export const useAssetsAttachmentsDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: number }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsAttachmentsDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Get total audio duration for a list of attachments - -```curl - curl -X POST https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/attachments/audio-duration/ -``` - -> **Payload** -> -> { -> "attachment_uids": [ -> "attXXXXXXXXXXXXXXXXX", -> "attYYYYYYYYYYYYYYYYY" -> ] -> } - -* Where: `attachment_uids` (required) is a list of attachment UIDs whose audio duration to retrieve. Maximum 200 UIDs per request. - - -> **Response** -> -> { -> "attachments": [ -> { "uid": "attXXXXXXXXXXXXXXXXX", "seconds": 42 }, -> { "uid": "attYYYYYYYYYYYYYYYYY", "seconds": null } -> ], -> "total": 42 -> } - -* `attachments` - one entry per recognised, accessible UID in the order submitted. - Unrecognised or inaccessible UIDs are silently omitted. -* `seconds` - integer duration, or `null` when `ffprobe` could not determine the duration (corrupt file, unsupported format, etc.). -* `total` - sum of all non-null `seconds` values. - - -### Batching and timeouts - -`ffprobe` takes approximately 0.5 s per file. With a 120 s nginx timeout, sending more -than ~200 files per request risks a **504 Gateway Timeout**. - -* Submit files in small batches from the front-end. -* Retry on 504 - already-processed attachments will be served from the db, so - subsequent attempts complete faster. -* Requests exceeding 200 UIDs are rejected immediately with **400 Bad Request**. - - */ -export type assetsAttachmentsAudioDurationCreateResponse200 = { - data: AssetAttachmentAudioDurationResponse - status: 200 -} - -export type assetsAttachmentsAudioDurationCreateResponseComposite = assetsAttachmentsAudioDurationCreateResponse200 - -export type assetsAttachmentsAudioDurationCreateResponse = assetsAttachmentsAudioDurationCreateResponseComposite & { - headers: Headers -} - -export const getAssetsAttachmentsAudioDurationCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/attachments/audio-duration/` -} - -export const assetsAttachmentsAudioDurationCreate = async ( - uidAsset: string, - assetAttachmentAudioDurationRequest: AssetAttachmentAudioDurationRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsAttachmentsAudioDurationCreateUrl(uidAsset), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(assetAttachmentAudioDurationRequest), - }, - ) -} - -export const getAssetsAttachmentsAudioDurationCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: AssetAttachmentAudioDurationRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: AssetAttachmentAudioDurationRequest }, - TContext -> => { - const mutationKey = ['assetsAttachmentsAudioDurationCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: AssetAttachmentAudioDurationRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsAttachmentsAudioDurationCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsAttachmentsAudioDurationCreateMutationResult = NonNullable< - Awaited> -> -export type AssetsAttachmentsAudioDurationCreateMutationBody = AssetAttachmentAudioDurationRequest -export type AssetsAttachmentsAudioDurationCreateMutationError = unknown - -export const useAssetsAttachmentsAudioDurationCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: AssetAttachmentAudioDurationRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsAttachmentsAudioDurationCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete all attachments from a list of submissions - -```curl - curl -X DELETE https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/attachments/bulk/ -``` - -> **Payload** -> -> { -> "submission_root_uuids": [ -> "3ed2e8de-b493-4367-a78d-3463687239dc", -> "ef18fe33-c71d-4638-84d6-dafcbd69c327" -> ] -> } - -* Where: "submission_root_uuids" (required) is a list of submission root uuids on the asset -to delete - - -> **Response** -> -> { -> "message": "{number_of_attachment} attachments deleted" -> } - -* Where: "number_of_attachment" is the number of items that was deleted - - -### !! Due to current DRF-Spectacular limitations with AOS 3.1, DELETE operations do not display request or response bodies in this documentation (as payloads are not typically recommended for DELETE). This means direct testing is unavailable. However, example payloads and responses are provided for reference, and HTTP codes/error messages are accurate. !! - - */ -export type assetsAttachmentsBulkDestroyResponse202 = { - data: void - status: 202 -} - -export type assetsAttachmentsBulkDestroyResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsAttachmentsBulkDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsAttachmentsBulkDestroyResponseComposite = - | assetsAttachmentsBulkDestroyResponse202 - | assetsAttachmentsBulkDestroyResponse400 - | assetsAttachmentsBulkDestroyResponse404 - -export type assetsAttachmentsBulkDestroyResponse = assetsAttachmentsBulkDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsAttachmentsBulkDestroyUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/attachments/bulk/` -} - -export const assetsAttachmentsBulkDestroy = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsAttachmentsBulkDestroyUrl(uidAsset), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetsAttachmentsBulkDestroyMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext -> => { - const mutationKey = ['assetsAttachmentsBulkDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { uidAsset: string }> = ( - props, - ) => { - const { uidAsset } = props ?? {} - - return assetsAttachmentsBulkDestroy(uidAsset, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsAttachmentsBulkDestroyMutationResult = NonNullable< - Awaited> -> - -export type AssetsAttachmentsBulkDestroyMutationError = ErrorObject | ErrorDetail - -export const useAssetsAttachmentsBulkDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsAttachmentsBulkDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## List of submissions for a specific asset - -By default, JSON format is used, but XML and GeoJSON are also available: - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/ -``` - -### Pagination -Two parameters can be used to control pagination. - -* `start`: Index (zero-based) from which the results start -* `limit`: Number of results per page Maximum results per page cannot exceed **1000**, unless changed by server configuration - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/?start=0&limit=10 -``` - -### Query submitted data -Provides a list of submitted data for a specific form. Use `query` -parameter to apply form data specific, see -http://docs.mongodb.org/manual/reference/operator/query/. - -For more details see -API Parameters. - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/?query={"__version__": "vWvkKzNE8xCtfApJvabfjG"} -curl https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/?query={"_submission_time": {"$gt": "2019-09-01T01:02:03"}} -``` - -### About the GeoJSON format -Requesting the `geojson` format returns a `FeatureCollection` where each -submission is a `Feature`. If your form has multiple geographic questions, -use the `geo_question_name` query parameter to determine which question's -responses populate the `geometry` for each `Feature`; otherwise, the first -geographic question is used. All question/response pairs are included in -the `properties` of each `Feature`, but _repeating groups are omitted_. - -Question types are mapped to GeoJSON geometry types as follows: - -* `geopoint` to `Point`; -* `geotrace` to `LineString`; -* `geoshape` to `Polygon`. - - - -### ⚠️ Note: DRF-Spectacular Limitation - -Due to limitations in **DRF-Spectacular**, the `ACCEPT` headers do not sync properly with the request. As a result, all responses will default to `application/json`, regardless of the specified format. - -This means that while alternative formats (like XML) are technically supported and will work via command-line tools (e.g., `curl`), **they will not work** when trying out the endpoint directly from the documentation page. - -We’ve still included the header to show supported formats, but keep in mind: -**Only `application/json` will be used in the docs UI.** - - */ -export type assetsDataListResponse200 = { - data: PaginatedDataResponseList - status: 200 -} - -export type assetsDataListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataListResponseComposite = assetsDataListResponse200 | assetsDataListResponse404 - -export type assetsDataListResponse = assetsDataListResponseComposite & { - headers: Headers -} - -export const getAssetsDataListUrl = (uidAsset: string, params?: AssetsDataListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/data/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/data/` -} - -export const assetsDataList = async ( - uidAsset: string, - params?: AssetsDataListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsDataListQueryKey = (uidAsset: string, params?: AssetsDataListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'data', ...(params ? [params] : [])] as const -} - -export const getAssetsDataListQueryOptions = >, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsDataListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDataListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDataList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDataListQueryResult = NonNullable>> -export type AssetsDataListQueryError = ErrorDetail - -export function useAssetsDataList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsDataListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDataListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get a specific submission - -`{id}` can be: - -- The primary key of the submission -- Its `_uuid` 1 -- Its `rootUuid` (without "uuid:" prefix) - -1 Please note that using the `_uuid` may match **several** submissions, only -the first match will be returned. - - -It is also possible to specify the format. - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid_asset}/data/{id}.xml -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid_asset}/data/{id}.json -``` - -or - -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid_asset}/data/{id}/?format=xml -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid_asset}/data/{id}/?format=json -``` - -### ⚠️ Note: DRF-Spectacular Limitation - -Due to limitations in **DRF-Spectacular**, the `ACCEPT` headers do not sync properly with the request. As a result, all responses will default to `application/json`, regardless of the specified format. - -This means that while alternative formats (like XML) are technically supported and will work via command-line tools (e.g., `curl`), **they will not work** when trying out the endpoint directly from the documentation page. - -We’ve still included the header to show supported formats, but keep in mind: -**Only `application/json` will be used in the docs UI.** - - */ -export type assetsDataRetrieveResponse200 = { - data: DataResponse - status: 200 -} - -export type assetsDataRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataRetrieveResponseComposite = assetsDataRetrieveResponse200 | assetsDataRetrieveResponse404 - -export type assetsDataRetrieveResponse = assetsDataRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsDataRetrieveUrl = (uidAsset: string, id: string, params?: AssetsDataRetrieveParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/data/${id}/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/data/${id}/` -} - -export const assetsDataRetrieve = async ( - uidAsset: string, - id: string, - params?: AssetsDataRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataRetrieveUrl(uidAsset, id, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsDataRetrieveQueryKey = (uidAsset: string, id: string, params?: AssetsDataRetrieveParams) => { - return ['api', 'v2', 'assets', uidAsset, 'data', id, ...(params ? [params] : [])] as const -} - -export const getAssetsDataRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - params?: AssetsDataRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDataRetrieveQueryKey(uidAsset, id, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDataRetrieve(uidAsset, id, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDataRetrieveQueryResult = NonNullable>> -export type AssetsDataRetrieveQueryError = ErrorDetail - -export function useAssetsDataRetrieve>, TError = ErrorDetail>( - uidAsset: string, - id: string, - params?: AssetsDataRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDataRetrieveQueryOptions(uidAsset, id, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Deletes current submission - - */ -export type assetsDataDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsDataDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataDestroyResponseComposite = assetsDataDestroyResponse204 | assetsDataDestroyResponse404 - -export type assetsDataDestroyResponse = assetsDataDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsDataDestroyUrl = (uidAsset: string, id: string) => { - return `/api/v2/assets/${uidAsset}/data/${id}/` -} - -export const assetsDataDestroy = async ( - uidAsset: string, - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataDestroyUrl(uidAsset, id), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetsDataDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string }, - TContext -> => { - const mutationKey = ['assetsDataDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; id: string } - > = (props) => { - const { uidAsset, id } = props ?? {} - - return assetsDataDestroy(uidAsset, id, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDataDestroyMutationResult = NonNullable>> - -export type AssetsDataDestroyMutationError = ErrorDetail - -export const useAssetsDataDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDataDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Duplicate submission - -Duplicates the data of a submission - -`{id}` can be: - -- The primary key of the submission -- Its `_uuid` 1 -- Its `rootUuid` (without "uuid:" prefix) - -1 Please note that using the `_uuid` may match **several** submissions, only -the first match will be returned. - - */ -export type assetsDataDuplicateCreateResponse200 = { - data: DataResponse - status: 200 -} - -export type assetsDataDuplicateCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataDuplicateCreateResponseComposite = - | assetsDataDuplicateCreateResponse200 - | assetsDataDuplicateCreateResponse404 - -export type assetsDataDuplicateCreateResponse = assetsDataDuplicateCreateResponseComposite & { - headers: Headers -} - -export const getAssetsDataDuplicateCreateUrl = (uidAsset: string, id: string) => { - return `/api/v2/assets/${uidAsset}/data/${id}/duplicate/` -} - -export const assetsDataDuplicateCreate = async ( - uidAsset: string, - id: string, - dataBulkDelete: DataBulkDelete, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataDuplicateCreateUrl(uidAsset, id), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(dataBulkDelete), - }) -} - -export const getAssetsDataDuplicateCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string; data: DataBulkDelete }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string; data: DataBulkDelete }, - TContext -> => { - const mutationKey = ['assetsDataDuplicateCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; id: string; data: DataBulkDelete } - > = (props) => { - const { uidAsset, id, data } = props ?? {} - - return assetsDataDuplicateCreate(uidAsset, id, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDataDuplicateCreateMutationResult = NonNullable>> -export type AssetsDataDuplicateCreateMutationBody = DataBulkDelete -export type AssetsDataDuplicateCreateMutationError = ErrorDetail - -export const useAssetsDataDuplicateCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string; data: DataBulkDelete }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDataDuplicateCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Get submission url of enketo in edit mode - -`{id}` can be: - -- The primary key of the submission -- Its `_uuid` 1 -- Its `rootUuid` (without "uuid:" prefix) - -1 Please note that using the `_uuid` may match **several** submissions, only -the first match will be returned. - -Note: Some variation of this url exists: - -`/api/v2/assets/{uid_asset}/data/{id}/edit/`: deprecated, use the next one. - -`/api/v2/assets/{uid_asset}/data/{id}/enketo/edit/`: return the url of the enketo submission (as seen in the response example). - -`/api/v2/assets/{uid_asset}/data/{id}/enketo/redirect/edit/`: redirect to the enketo url submission with a 302 HTTP code. - - */ -export type assetsDataEditRetrieveResponse200 = { - data: EnketoEditResponse - status: 200 -} - -export type assetsDataEditRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsDataEditRetrieveResponseComposite = - | assetsDataEditRetrieveResponse200 - | assetsDataEditRetrieveResponse403 - -export type assetsDataEditRetrieveResponse = assetsDataEditRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsDataEditRetrieveUrl = (uidAsset: string, id: string) => { - return `/api/v2/assets/${uidAsset}/data/${id}/edit/` -} - -export const assetsDataEditRetrieve = async ( - uidAsset: string, - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataEditRetrieveUrl(uidAsset, id), { - ...options, - method: 'GET', - }) -} - -export const getAssetsDataEditRetrieveQueryKey = (uidAsset: string, id: string) => { - return ['api', 'v2', 'assets', uidAsset, 'data', id, 'edit'] as const -} - -export const getAssetsDataEditRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDataEditRetrieveQueryKey(uidAsset, id) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDataEditRetrieve(uidAsset, id, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDataEditRetrieveQueryResult = NonNullable>> -export type AssetsDataEditRetrieveQueryError = ErrorDetail - -export function useAssetsDataEditRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDataEditRetrieveQueryOptions(uidAsset, id, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get submission url of enketo in edit mode - -`{id}` can be: - -- The primary key of the submission -- Its `_uuid` 1 -- Its `rootUuid` (without "uuid:" prefix) - -1 Please note that using the `_uuid` may match **several** submissions, only -the first match will be returned. - -Note: Some variation of this url exists: - -`/api/v2/assets/{uid_asset}/data/{id}/edit/`: deprecated, use the next one. - -`/api/v2/assets/{uid_asset}/data/{id}/enketo/edit/`: return the url of the enketo submission (as seen in the response example). - -`/api/v2/assets/{uid_asset}/data/{id}/enketo/redirect/edit/`: redirect to the enketo url submission with a 302 HTTP code. - - */ -export type assetsDataEnketoEditRetrieveResponse200 = { - data: EnketoEditResponse - status: 200 -} - -export type assetsDataEnketoEditRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsDataEnketoEditRetrieveResponseComposite = - | assetsDataEnketoEditRetrieveResponse200 - | assetsDataEnketoEditRetrieveResponse403 - -export type assetsDataEnketoEditRetrieveResponse = assetsDataEnketoEditRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsDataEnketoEditRetrieveUrl = (uidAsset: string, id: string) => { - return `/api/v2/assets/${uidAsset}/data/${id}/enketo/edit/` -} - -export const assetsDataEnketoEditRetrieve = async ( - uidAsset: string, - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataEnketoEditRetrieveUrl(uidAsset, id), { - ...options, - method: 'GET', - }) -} - -export const getAssetsDataEnketoEditRetrieveQueryKey = (uidAsset: string, id: string) => { - return ['api', 'v2', 'assets', uidAsset, 'data', id, 'enketo', 'edit'] as const -} - -export const getAssetsDataEnketoEditRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoEditRetrieveQueryKey(uidAsset, id) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDataEnketoEditRetrieve(uidAsset, id, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDataEnketoEditRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsDataEnketoEditRetrieveQueryError = ErrorDetail - -export function useAssetsDataEnketoEditRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDataEnketoEditRetrieveQueryOptions(uidAsset, id, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get submission url of enketo in edit mode - -`{id}` can be: - -- The primary key of the submission -- Its `_uuid` 1 -- Its `rootUuid` (without "uuid:" prefix) - -1 Please note that using the `_uuid` may match **several** submissions, only -the first match will be returned. - -Note: Some variation of this url exists: - -`/api/v2/assets/{uid_asset}/data/{id}/edit/`: deprecated, use the next one. - -`/api/v2/assets/{uid_asset}/data/{id}/enketo/edit/`: return the url of the enketo submission (as seen in the response example). - -`/api/v2/assets/{uid_asset}/data/{id}/enketo/redirect/edit/`: redirect to the enketo url submission with a 302 HTTP code. - - */ -export type assetsDataEnketoRedirectEditRetrieveResponse200 = { - data: EnketoEditResponse - status: 200 -} - -export type assetsDataEnketoRedirectEditRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsDataEnketoRedirectEditRetrieveResponseComposite = - | assetsDataEnketoRedirectEditRetrieveResponse200 - | assetsDataEnketoRedirectEditRetrieveResponse403 - -export type assetsDataEnketoRedirectEditRetrieveResponse = assetsDataEnketoRedirectEditRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsDataEnketoRedirectEditRetrieveUrl = (uidAsset: string, id: string) => { - return `/api/v2/assets/${uidAsset}/data/${id}/enketo/redirect/edit/` -} - -export const assetsDataEnketoRedirectEditRetrieve = async ( - uidAsset: string, - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsDataEnketoRedirectEditRetrieveUrl(uidAsset, id), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetsDataEnketoRedirectEditRetrieveQueryKey = (uidAsset: string, id: string) => { - return ['api', 'v2', 'assets', uidAsset, 'data', id, 'enketo', 'redirect', 'edit'] as const -} - -export const getAssetsDataEnketoRedirectEditRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoRedirectEditRetrieveQueryKey(uidAsset, id) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDataEnketoRedirectEditRetrieve(uidAsset, id, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDataEnketoRedirectEditRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsDataEnketoRedirectEditRetrieveQueryError = ErrorDetail - -export function useAssetsDataEnketoRedirectEditRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDataEnketoRedirectEditRetrieveQueryOptions(uidAsset, id, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get submission url of enketo in preview mode - -`{id}` can be: - -- The primary key of the submission -- Its `_uuid` 1 -- Its `rootUuid` (without "uuid:" prefix) - -1 Please note that using the `_uuid` may match **several** submissions, only -the first match will be returned. - -Note: Some variation of this url exists: - -`/api/v2/assets/{uid_asset}/data/{id}/enketo/view/`: return the url of the enketo submission (as seen in the response example). - -`/api/v2/assets/{uid_asset}/data/{id}/enketo/redirect/view/`: redirect to the enketo url submission with a 302 code. - - */ -export type assetsDataEnketoRedirectViewRetrieveResponse200 = { - data: EnketoViewResponse - status: 200 -} - -export type assetsDataEnketoRedirectViewRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsDataEnketoRedirectViewRetrieveResponseComposite = - | assetsDataEnketoRedirectViewRetrieveResponse200 - | assetsDataEnketoRedirectViewRetrieveResponse403 - -export type assetsDataEnketoRedirectViewRetrieveResponse = assetsDataEnketoRedirectViewRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsDataEnketoRedirectViewRetrieveUrl = (uidAsset: string, id: string) => { - return `/api/v2/assets/${uidAsset}/data/${id}/enketo/redirect/view/` -} - -export const assetsDataEnketoRedirectViewRetrieve = async ( - uidAsset: string, - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsDataEnketoRedirectViewRetrieveUrl(uidAsset, id), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetsDataEnketoRedirectViewRetrieveQueryKey = (uidAsset: string, id: string) => { - return ['api', 'v2', 'assets', uidAsset, 'data', id, 'enketo', 'redirect', 'view'] as const -} - -export const getAssetsDataEnketoRedirectViewRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoRedirectViewRetrieveQueryKey(uidAsset, id) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDataEnketoRedirectViewRetrieve(uidAsset, id, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDataEnketoRedirectViewRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsDataEnketoRedirectViewRetrieveQueryError = ErrorDetail - -export function useAssetsDataEnketoRedirectViewRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDataEnketoRedirectViewRetrieveQueryOptions(uidAsset, id, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get submission url of enketo in preview mode - -`{id}` can be: - -- The primary key of the submission -- Its `_uuid` 1 -- Its `rootUuid` (without "uuid:" prefix) - -1 Please note that using the `_uuid` may match **several** submissions, only -the first match will be returned. - -Note: Some variation of this url exists: - -`/api/v2/assets/{uid_asset}/data/{id}/enketo/view/`: return the url of the enketo submission (as seen in the response example). - -`/api/v2/assets/{uid_asset}/data/{id}/enketo/redirect/view/`: redirect to the enketo url submission with a 302 code. - - */ -export type assetsDataEnketoViewRetrieveResponse200 = { - data: EnketoViewResponse - status: 200 -} - -export type assetsDataEnketoViewRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsDataEnketoViewRetrieveResponseComposite = - | assetsDataEnketoViewRetrieveResponse200 - | assetsDataEnketoViewRetrieveResponse403 - -export type assetsDataEnketoViewRetrieveResponse = assetsDataEnketoViewRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsDataEnketoViewRetrieveUrl = (uidAsset: string, id: string) => { - return `/api/v2/assets/${uidAsset}/data/${id}/enketo/view/` -} - -export const assetsDataEnketoViewRetrieve = async ( - uidAsset: string, - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataEnketoViewRetrieveUrl(uidAsset, id), { - ...options, - method: 'GET', - }) -} - -export const getAssetsDataEnketoViewRetrieveQueryKey = (uidAsset: string, id: string) => { - return ['api', 'v2', 'assets', uidAsset, 'data', id, 'enketo', 'view'] as const -} - -export const getAssetsDataEnketoViewRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoViewRetrieveQueryKey(uidAsset, id) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDataEnketoViewRetrieve(uidAsset, id, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDataEnketoViewRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsDataEnketoViewRetrieveQueryError = ErrorDetail - -export function useAssetsDataEnketoViewRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDataEnketoViewRetrieveQueryOptions(uidAsset, id, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get validation statuses -Retrieves the validation status of a submission. - - */ -export type assetsDataValidationStatusRetrieveResponse200 = { - data: DataValidationStatusUpdateResponse - status: 200 -} - -export type assetsDataValidationStatusRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataValidationStatusRetrieveResponseComposite = - | assetsDataValidationStatusRetrieveResponse200 - | assetsDataValidationStatusRetrieveResponse404 - -export type assetsDataValidationStatusRetrieveResponse = assetsDataValidationStatusRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsDataValidationStatusRetrieveUrl = (uidAsset: string, id: string) => { - return `/api/v2/assets/${uidAsset}/data/${id}/validation_status/` -} - -export const assetsDataValidationStatusRetrieve = async ( - uidAsset: string, - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsDataValidationStatusRetrieveUrl(uidAsset, id), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetsDataValidationStatusRetrieveQueryKey = (uidAsset: string, id: string) => { - return ['api', 'v2', 'assets', uidAsset, 'data', id, 'validation_status'] as const -} - -export const getAssetsDataValidationStatusRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDataValidationStatusRetrieveQueryKey(uidAsset, id) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDataValidationStatusRetrieve(uidAsset, id, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDataValidationStatusRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsDataValidationStatusRetrieveQueryError = ErrorDetail - -export function useAssetsDataValidationStatusRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - id: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDataValidationStatusRetrieveQueryOptions(uidAsset, id, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update the validation of a submission - -The validation status of the submission can be updated. The `validation_status.uid` should be a `string`, and it must be one of the following values: - -- `validation_status_approved` -- `validation_status_not_approved` -- `validation_status_on_hold` - - */ -export type assetsDataValidationStatusPartialUpdateResponse200 = { - data: DataValidationStatusUpdateResponse - status: 200 -} - -export type assetsDataValidationStatusPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataValidationStatusPartialUpdateResponseComposite = - | assetsDataValidationStatusPartialUpdateResponse200 - | assetsDataValidationStatusPartialUpdateResponse404 - -export type assetsDataValidationStatusPartialUpdateResponse = - assetsDataValidationStatusPartialUpdateResponseComposite & { - headers: Headers - } - -export const getAssetsDataValidationStatusPartialUpdateUrl = (uidAsset: string, id: string) => { - return `/api/v2/assets/${uidAsset}/data/${id}/validation_status/` -} - -export const assetsDataValidationStatusPartialUpdate = async ( - uidAsset: string, - id: string, - patchedDataValidationStatusUpdatePayload: PatchedDataValidationStatusUpdatePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsDataValidationStatusPartialUpdateUrl(uidAsset, id), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedDataValidationStatusUpdatePayload), - }, - ) -} - -export const getAssetsDataValidationStatusPartialUpdateMutationOptions = < - TError = ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string; data: PatchedDataValidationStatusUpdatePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string; data: PatchedDataValidationStatusUpdatePayload }, - TContext -> => { - const mutationKey = ['assetsDataValidationStatusPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; id: string; data: PatchedDataValidationStatusUpdatePayload } - > = (props) => { - const { uidAsset, id, data } = props ?? {} - - return assetsDataValidationStatusPartialUpdate(uidAsset, id, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDataValidationStatusPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsDataValidationStatusPartialUpdateMutationBody = PatchedDataValidationStatusUpdatePayload -export type AssetsDataValidationStatusPartialUpdateMutationError = ErrorDetail - -export const useAssetsDataValidationStatusPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string; data: PatchedDataValidationStatusUpdatePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDataValidationStatusPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete validation status - - */ -export type assetsDataValidationStatusDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsDataValidationStatusDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataValidationStatusDestroyResponseComposite = - | assetsDataValidationStatusDestroyResponse204 - | assetsDataValidationStatusDestroyResponse404 - -export type assetsDataValidationStatusDestroyResponse = assetsDataValidationStatusDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsDataValidationStatusDestroyUrl = (uidAsset: string, id: string) => { - return `/api/v2/assets/${uidAsset}/data/${id}/validation_status/` -} - -export const assetsDataValidationStatusDestroy = async ( - uidAsset: string, - id: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsDataValidationStatusDestroyUrl(uidAsset, id), - { - ...options, - method: 'DELETE', - }, - ) -} - -export const getAssetsDataValidationStatusDestroyMutationOptions = < - TError = ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string }, - TContext -> => { - const mutationKey = ['assetsDataValidationStatusDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; id: string } - > = (props) => { - const { uidAsset, id } = props ?? {} - - return assetsDataValidationStatusDestroy(uidAsset, id, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDataValidationStatusDestroyMutationResult = NonNullable< - Awaited> -> - -export type AssetsDataValidationStatusDestroyMutationError = ErrorDetail - -export const useAssetsDataValidationStatusDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; id: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDataValidationStatusDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve submission supplementary data - -This endpoint allows you to retrieve supplementary data attached to a submission. - -The supplementary data may include: - -* NLP actions - * Manual transcription - * Manual translation - * Automatic Google transcription - * Automatic Google translation -* Qualitative analysis - manual or automatic with Bedrock - * Text - * Number - * Single Choice - * Multiple Choice -* Qualitative analysis (manual only) - * Tags - -⚠️ The response examples in this documentation show each action in isolation for -readability. - -In practice, multiple actions can be combined for the same question, and a single -submission may contain multiple questions. - - */ -export type assetsDataSupplementRetrieveResponse200 = { - data: DataSupplementResponse - status: 200 -} - -export type assetsDataSupplementRetrieveResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsDataSupplementRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsDataSupplementRetrieveResponseComposite = - | assetsDataSupplementRetrieveResponse200 - | assetsDataSupplementRetrieveResponse400 - | assetsDataSupplementRetrieveResponse401 - -export type assetsDataSupplementRetrieveResponse = assetsDataSupplementRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsDataSupplementRetrieveUrl = (uidAsset: string, rootUuid: string) => { - return `/api/v2/assets/${uidAsset}/data/${rootUuid}/supplement/` -} - -export const assetsDataSupplementRetrieve = async ( - uidAsset: string, - rootUuid: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataSupplementRetrieveUrl(uidAsset, rootUuid), { - ...options, - method: 'GET', - }) -} - -export const getAssetsDataSupplementRetrieveQueryKey = (uidAsset: string, rootUuid: string) => { - return ['api', 'v2', 'assets', uidAsset, 'data', rootUuid, 'supplement'] as const -} - -export const getAssetsDataSupplementRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidAsset: string, - rootUuid: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDataSupplementRetrieveQueryKey(uidAsset, rootUuid) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDataSupplementRetrieve(uidAsset, rootUuid, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && rootUuid), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDataSupplementRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsDataSupplementRetrieveQueryError = ErrorObject | ErrorDetail - -export function useAssetsDataSupplementRetrieve< - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidAsset: string, - rootUuid: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDataSupplementRetrieveQueryOptions(uidAsset, rootUuid, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update submission supplementary data - -This endpoint allows you to add, update, or delete supplementary data for a submission. - -It supports the same action types as the GET endpoint: - -* NLP actions (manual and automatic transcription / translation) -* Qualitative analysis (manual and automatic) - -The PATCH payload follows the same per-question structure as the GET response. - -To delete a submission supplement, you need to PATCH the submission supplement -with the appropriate null or empty value. - -⚠️ In this documentation, request and response examples present each action in -isolation for clarity. In practice, multiple actions may be combined within the same -payload or response, including for the same question, and a single submission may -contain multiple questions. - - */ -export type assetsDataSupplementPartialUpdateResponse200 = { - data: DataSupplementResponse - status: 200 -} - -export type assetsDataSupplementPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsDataSupplementPartialUpdateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetsDataSupplementPartialUpdateResponseComposite = - | assetsDataSupplementPartialUpdateResponse200 - | assetsDataSupplementPartialUpdateResponse400 - | assetsDataSupplementPartialUpdateResponse401 - -export type assetsDataSupplementPartialUpdateResponse = assetsDataSupplementPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsDataSupplementPartialUpdateUrl = (uidAsset: string, rootUuid: string) => { - return `/api/v2/assets/${uidAsset}/data/${rootUuid}/supplement/` -} - -export const assetsDataSupplementPartialUpdate = async ( - uidAsset: string, - rootUuid: string, - patchedDataSupplementPayload: PatchedDataSupplementPayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsDataSupplementPartialUpdateUrl(uidAsset, rootUuid), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedDataSupplementPayload), - }, - ) -} - -export const getAssetsDataSupplementPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; rootUuid: string; data: PatchedDataSupplementPayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; rootUuid: string; data: PatchedDataSupplementPayload }, - TContext -> => { - const mutationKey = ['assetsDataSupplementPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; rootUuid: string; data: PatchedDataSupplementPayload } - > = (props) => { - const { uidAsset, rootUuid, data } = props ?? {} - - return assetsDataSupplementPartialUpdate(uidAsset, rootUuid, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDataSupplementPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsDataSupplementPartialUpdateMutationBody = PatchedDataSupplementPayload -export type AssetsDataSupplementPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useAssetsDataSupplementPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; rootUuid: string; data: PatchedDataSupplementPayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDataSupplementPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Get an asset's attachment using xpath - -* `uid_data` can be the primary key of the submission or its `uuid`. -Please note that using the `uuid` may match **several** submissions, only -the first match will be returned. - -Use the `xpath` property to retrieve an attachment. - -```curl -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/?xpath=Upload_a_file -``` - -### Get an MP3 file from an audio or video file -Convert audio and video files. Only conversions to MP3 is supported for this feature - -```curl -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/?xpath=Upload_a_file&format=mp3 -``` - - */ -export type assetsDataAttachmentsListResponse200 = { - data: void - status: 200 -} - -export type assetsDataAttachmentsListResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsDataAttachmentsListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataAttachmentsListResponseComposite = - | assetsDataAttachmentsListResponse200 - | assetsDataAttachmentsListResponse400 - | assetsDataAttachmentsListResponse404 - -export type assetsDataAttachmentsListResponse = assetsDataAttachmentsListResponseComposite & { - headers: Headers -} - -export const getAssetsDataAttachmentsListUrl = ( - uidAsset: string, - uidData: string, - params: AssetsDataAttachmentsListParams, -) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/` -} - -export const assetsDataAttachmentsList = async ( - uidAsset: string, - uidData: string, - params: AssetsDataAttachmentsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataAttachmentsListUrl(uidAsset, uidData, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsDataAttachmentsListQueryKey = ( - uidAsset: string, - uidData: string, - params: AssetsDataAttachmentsListParams, -) => { - return ['api', 'v2', 'assets', uidAsset, 'data', uidData, 'attachments', ...(params ? [params] : [])] as const -} - -export const getAssetsDataAttachmentsListQueryOptions = < - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidAsset: string, - uidData: string, - params: AssetsDataAttachmentsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsDataAttachmentsListQueryKey(uidAsset, uidData, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsDataAttachmentsList(uidAsset, uidData, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidData), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsDataAttachmentsListQueryResult = NonNullable>> -export type AssetsDataAttachmentsListQueryError = ErrorObject | ErrorDetail - -export function useAssetsDataAttachmentsList< - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidAsset: string, - uidData: string, - params: AssetsDataAttachmentsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsDataAttachmentsListQueryOptions(uidAsset, uidData, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get an asset's attachment using the ID - -* `uid_data` can be the primary key of the submission or its `uuid`. -Please note that using the `uuid` may match **several** submissions, only -the first match will be returned. - -* `id` of attachment can be the primary key of the attachment or its `uid`. - -Both examples works: -```curl -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/1/ -``` -Or, using the `UID`: -```curl -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/attwYwGxdtQPSqgmHk6wS6E6/ -``` - -### Get an MP3 file from an audio or video file -Convert audio and video files. Only conversions to MP3 is supported for this feature - -```curl -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/1/?format=mp3 -``` - - */ -export type attachmentRetrieveResponse200 = { - data: void - status: 200 -} - -export type attachmentRetrieveResponse400 = { - data: ErrorObject - status: 400 -} - -export type attachmentRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type attachmentRetrieveResponseComposite = - | attachmentRetrieveResponse200 - | attachmentRetrieveResponse400 - | attachmentRetrieveResponse404 - -export type attachmentRetrieveResponse = attachmentRetrieveResponseComposite & { - headers: Headers -} - -export const getAttachmentRetrieveUrl = ( - uidAsset: string, - uidData: string, - id: number, - params?: AttachmentRetrieveParams, -) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/` -} - -export const attachmentRetrieve = async ( - uidAsset: string, - uidData: string, - id: number, - params?: AttachmentRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAttachmentRetrieveUrl(uidAsset, uidData, id, params), { - ...options, - method: 'GET', - }) -} - -export const getAttachmentRetrieveQueryKey = ( - uidAsset: string, - uidData: string, - id: number, - params?: AttachmentRetrieveParams, -) => { - return ['api', 'v2', 'assets', uidAsset, 'data', uidData, 'attachments', id, ...(params ? [params] : [])] as const -} - -export const getAttachmentRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidAsset: string, - uidData: string, - id: number, - params?: AttachmentRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAttachmentRetrieveQueryKey(uidAsset, uidData, id, params) - - const queryFn: QueryFunction>> = ({ signal }) => - attachmentRetrieve(uidAsset, uidData, id, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidData && id), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AttachmentRetrieveQueryResult = NonNullable>> -export type AttachmentRetrieveQueryError = ErrorObject | ErrorDetail - -export function useAttachmentRetrieve< - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidAsset: string, - uidData: string, - id: number, - params?: AttachmentRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAttachmentRetrieveQueryOptions(uidAsset, uidData, id, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Get a specific size of the user's attachment (Only for images) - -Available formats: -- `small` -- `medium` -- `large` - -`id` of attachment can be the primary key of the attachment or its `uid`. - -Both examples works: -```curl -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/1/small/ -``` -Or, using the `UID`: -```curl -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/451/attachment/attwYwGxdtQPSqgmHk6wS6E6/medium/ -``` - - */ -export type attachmentThumbnailResponse200 = { - data: void - status: 200 -} - -export type attachmentThumbnailResponse404 = { - data: ErrorDetail - status: 404 -} - -export type attachmentThumbnailResponseComposite = attachmentThumbnailResponse200 | attachmentThumbnailResponse404 - -export type attachmentThumbnailResponse = attachmentThumbnailResponseComposite & { - headers: Headers -} - -export const getAttachmentThumbnailUrl = (uidAsset: string, uidData: string, id: number, suffix: string) => { - return `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/${suffix}/` -} - -export const attachmentThumbnail = async ( - uidAsset: string, - uidData: string, - id: number, - suffix: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAttachmentThumbnailUrl(uidAsset, uidData, id, suffix), { - ...options, - method: 'GET', - }) -} - -export const getAttachmentThumbnailQueryKey = (uidAsset: string, uidData: string, id: number, suffix: string) => { - return ['api', 'v2', 'assets', uidAsset, 'data', uidData, 'attachments', id, suffix] as const -} - -export const getAttachmentThumbnailQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidData: string, - id: number, - suffix: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAttachmentThumbnailQueryKey(uidAsset, uidData, id, suffix) - - const queryFn: QueryFunction>> = ({ signal }) => - attachmentThumbnail(uidAsset, uidData, id, suffix, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidData && id && suffix), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AttachmentThumbnailQueryResult = NonNullable>> -export type AttachmentThumbnailQueryError = ErrorDetail - -export function useAttachmentThumbnail>, TError = ErrorDetail>( - uidAsset: string, - uidData: string, - id: number, - suffix: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAttachmentThumbnailQueryOptions(uidAsset, uidData, id, suffix, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Bulk updating of submissions - -Where `` is a string and should be an existing XML field value of the submissions. -If `` is part of a group or nested group, the field must follow the group hierarchy -structure, i.e.: - -If the field is within a group called `group_1`, the field name is `question_1` and the new value is `new value`, -the payload should contain an item with the following structure: - -*"group_1/question_1": "new value"* - - -Similarly, if there are `N` nested groups, the structure will be: - -*"group_1/sub_group_1/.../sub_group_n/question_1": "new value"* - - */ -export type assetsDataBulkPartialUpdateResponse200 = { - data: DataBulkUpdateResponse - status: 200 -} - -export type assetsDataBulkPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataBulkPartialUpdateResponseComposite = - | assetsDataBulkPartialUpdateResponse200 - | assetsDataBulkPartialUpdateResponse404 - -export type assetsDataBulkPartialUpdateResponse = assetsDataBulkPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsDataBulkPartialUpdateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/data/bulk/` -} - -export const assetsDataBulkPartialUpdate = async ( - uidAsset: string, - patchedDataBulkUpdate: PatchedDataBulkUpdate, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataBulkPartialUpdateUrl(uidAsset), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedDataBulkUpdate), - }) -} - -export const getAssetsDataBulkPartialUpdateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDataBulkUpdate }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDataBulkUpdate }, - TContext -> => { - const mutationKey = ['assetsDataBulkPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: PatchedDataBulkUpdate } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsDataBulkPartialUpdate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDataBulkPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsDataBulkPartialUpdateMutationBody = PatchedDataBulkUpdate -export type AssetsDataBulkPartialUpdateMutationError = ErrorDetail - -export const useAssetsDataBulkPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDataBulkUpdate }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDataBulkPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Bulk delete submissions - -```curl - curl -X DELETE https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/bulk/ -``` - -**Payload** -```json -{ - "submissions_ids": [ - 1, - 2 - ] - } -``` -* Where: `submissions_ids` (required) is a list of submission root id on the data -to delete - - -**Response** -```json -{ - "detail": "{number_of_submissions} submissions have been deleted" -} -``` -* Where: `number_of_submissions` is the number of items that was deleted - - -_Due to limitations with DRF-Spectacular current version, `DELETE` actions do not support showing a request body OR a response body. This is due to the 'vague' nature of the action which generally does *not* recommend the use of a payload. To still document this endpoint, example for the payload and response will be included but it will not be possible to test this endpoint. The HTTP code and the errors example are, for their part, factual and can be considered when working with the endpoint._ - - */ -export type assetsDataBulkDestroyResponse200 = { - data: void - status: 200 -} - -export type assetsDataBulkDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataBulkDestroyResponseComposite = assetsDataBulkDestroyResponse200 | assetsDataBulkDestroyResponse404 - -export type assetsDataBulkDestroyResponse = assetsDataBulkDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsDataBulkDestroyUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/data/bulk/` -} - -export const assetsDataBulkDestroy = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataBulkDestroyUrl(uidAsset), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetsDataBulkDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions>, TError, { uidAsset: string }, TContext> => { - const mutationKey = ['assetsDataBulkDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { uidAsset: string }> = ( - props, - ) => { - const { uidAsset } = props ?? {} - - return assetsDataBulkDestroy(uidAsset, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDataBulkDestroyMutationResult = NonNullable>> - -export type AssetsDataBulkDestroyMutationError = ErrorDetail - -export const useAssetsDataBulkDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDataBulkDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Bulk accept NLP results - -Accepts transcription or translation results for multiple submissions in a -single request. This is the bulk counterpart of the per-submission acceptance -flow: instead of visiting each submission individually, users can select -multiple submissions and approve all of them at once. - -The `operation` field declares the operation to perform. Currently only `"accept"` -is supported. - -### Transcription example - -```json -{ - "submission_uids": ["", ""], - "question_xpath": "group_name/audio_question", - "action_id": "automatic_google_transcription", - "operation": "accept" -} -``` - -### Translation example - -For translation actions the `language` field is **required**: - -```json -{ - "submission_uids": ["", ""], - "question_xpath": "group_name/audio_question", - "action_id": "automatic_google_translation", - "language": "fr", - "operation": "accept" -} -``` - -### Response - -Returns the number of submission records that were successfully accepted. -Submissions without a completed NLP result for the given question/action are -silently skipped and excluded from the count. - -```json -{ - "accepted_count": 472 -} -``` - - */ -export type assetsDataSupplementsBulkCreateResponse200 = { - data: BulkAcceptResponse - status: 200 -} - -export type assetsDataSupplementsBulkCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsDataSupplementsBulkCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataSupplementsBulkCreateResponseComposite = - | assetsDataSupplementsBulkCreateResponse200 - | assetsDataSupplementsBulkCreateResponse400 - | assetsDataSupplementsBulkCreateResponse404 - -export type assetsDataSupplementsBulkCreateResponse = assetsDataSupplementsBulkCreateResponseComposite & { - headers: Headers -} - -export const getAssetsDataSupplementsBulkCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/data/supplements/bulk/` -} - -export const assetsDataSupplementsBulkCreate = async ( - uidAsset: string, - bulkAcceptRequest: BulkAcceptRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsDataSupplementsBulkCreateUrl(uidAsset), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(bulkAcceptRequest), - }) -} - -export const getAssetsDataSupplementsBulkCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: BulkAcceptRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: BulkAcceptRequest }, - TContext -> => { - const mutationKey = ['assetsDataSupplementsBulkCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: BulkAcceptRequest } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsDataSupplementsBulkCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDataSupplementsBulkCreateMutationResult = NonNullable< - Awaited> -> -export type AssetsDataSupplementsBulkCreateMutationBody = BulkAcceptRequest -export type AssetsDataSupplementsBulkCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsDataSupplementsBulkCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: BulkAcceptRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDataSupplementsBulkCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Bulk update submissions status - -* Where: "submissions_ids" (required) is a list of submission root id on the data -to delete -* Where: "validation_status.uid" (required) is a string and can be one of these values: - * `validation_status_approved` - * `validation_status_not_approved` - * `validation_status_on_hold` - -Will return the number of submission updated as such: -> **Response** -> -> { -> "detail": "{number_of_submissions} submissions have been updated" -> } - - */ -export type assetsDataValidationStatusesPartialUpdateResponse200 = { - data: DataStatusesUpdate - status: 200 -} - -export type assetsDataValidationStatusesPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataValidationStatusesPartialUpdateResponseComposite = - | assetsDataValidationStatusesPartialUpdateResponse200 - | assetsDataValidationStatusesPartialUpdateResponse404 - -export type assetsDataValidationStatusesPartialUpdateResponse = - assetsDataValidationStatusesPartialUpdateResponseComposite & { - headers: Headers - } - -export const getAssetsDataValidationStatusesPartialUpdateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/data/validation_statuses/` -} - -export const assetsDataValidationStatusesPartialUpdate = async ( - uidAsset: string, - patchedDataValidationStatusesUpdatePayload: PatchedDataValidationStatusesUpdatePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsDataValidationStatusesPartialUpdateUrl(uidAsset), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedDataValidationStatusesUpdatePayload), - }, - ) -} - -export const getAssetsDataValidationStatusesPartialUpdateMutationOptions = < - TError = ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDataValidationStatusesUpdatePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDataValidationStatusesUpdatePayload }, - TContext -> => { - const mutationKey = ['assetsDataValidationStatusesPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: PatchedDataValidationStatusesUpdatePayload } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsDataValidationStatusesPartialUpdate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDataValidationStatusesPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsDataValidationStatusesPartialUpdateMutationBody = PatchedDataValidationStatusesUpdatePayload -export type AssetsDataValidationStatusesPartialUpdateMutationError = ErrorDetail - -export const useAssetsDataValidationStatusesPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: PatchedDataValidationStatusesUpdatePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDataValidationStatusesPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Bulk delete submissions status - -```curl - curl -X DELETE https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/validation_statuses/ -``` - -**Payload** -```json -{ - "payload": { - "submission_ids": [ - 1, - 2 - ], - "validation_status.uid": "validation_status" - } -} -``` -* Where: "submissions_ids" (required) is a list of submission root id on the data -to delete - -The validation status of the submission can be updated. The `validation_status.uid` should be a `string`, and it must be one of the following values: -- `validation_status_approved` -- `validation_status_not_approved` -- `validation_status_on_hold` - -**Response** -```json -{ - "detail": "{number_of_submissions} submissions have been updated" -} -``` - -_Due to limitations with DRF-Spectacular current version, `DELETE` actions do not support showing a request body OR a response body. This is due to the 'vague' nature of the action which generally does *not* recommend the use of a payload. To still document this endpoint, example for the payload and response will be included but it will not be possible to test this endpoint. The HTTP code and the errors example are, for their part, factual and can be considered when working with the endpoint._ - - */ -export type assetsDataValidationStatusesDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsDataValidationStatusesDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataValidationStatusesDestroyResponseComposite = - | assetsDataValidationStatusesDestroyResponse204 - | assetsDataValidationStatusesDestroyResponse404 - -export type assetsDataValidationStatusesDestroyResponse = assetsDataValidationStatusesDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsDataValidationStatusesDestroyUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/data/validation_statuses/` -} - -export const assetsDataValidationStatusesDestroy = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsDataValidationStatusesDestroyUrl(uidAsset), - { - ...options, - method: 'DELETE', - }, - ) -} - -export const getAssetsDataValidationStatusesDestroyMutationOptions = < - TError = ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext -> => { - const mutationKey = ['assetsDataValidationStatusesDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string } - > = (props) => { - const { uidAsset } = props ?? {} - - return assetsDataValidationStatusesDestroy(uidAsset, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsDataValidationStatusesDestroyMutationResult = NonNullable< - Awaited> -> - -export type AssetsDataValidationStatusesDestroyMutationError = ErrorDetail - -export const useAssetsDataValidationStatusesDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsDataValidationStatusesDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## List of export settings for a specific asset - -* _Required permissions: `view_submissions` (View submissions)_ - - */ -export type assetsExportSettingsListResponse200 = { - data: PaginatedExportSettingResponseList - status: 200 -} - -export type assetsExportSettingsListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsExportSettingsListResponseComposite = - | assetsExportSettingsListResponse200 - | assetsExportSettingsListResponse404 - -export type assetsExportSettingsListResponse = assetsExportSettingsListResponseComposite & { - headers: Headers -} - -export const getAssetsExportSettingsListUrl = (uidAsset: string, params?: AssetsExportSettingsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/export-settings/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/export-settings/` -} - -export const assetsExportSettingsList = async ( - uidAsset: string, - params?: AssetsExportSettingsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsExportSettingsListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsExportSettingsListQueryKey = (uidAsset: string, params?: AssetsExportSettingsListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'export-settings', ...(params ? [params] : [])] as const -} - -export const getAssetsExportSettingsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsExportSettingsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsExportSettingsListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsExportSettingsList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsExportSettingsListQueryResult = NonNullable>> -export type AssetsExportSettingsListQueryError = ErrorDetail - -export function useAssetsExportSettingsList< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsExportSettingsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsExportSettingsListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create an export setting for an asset - -* _Required permissions: `manage_asset` (Manage project)_ - -Where: - -* `name` (required) is the name of the export setting displayed in the UI -* `export_settings` (required) is a map of defined settings containing the following valid options: - * `fields` (optional) is an array of column names to be included in the export (including their group hierarchy). Valid inputs include: - * An array containing any string value that matches the XML column name - * An empty array which will result in all columns being included - * If `fields` is not included in the `export_settings`, all columns will be included in the export -* `flatten` (optional) is a boolean value and only relevant when exporting to `geojson` format. -* `fields_from_all_versions` (required) is a boolean to specify whether fields from all form versions will be included in the export. -* `group_sep` (required) is a value used to separate the names in a hierarchy of groups. Valid inputs include: - * Non-empty value -* `hierarchy_in_labels` (required) is a boolean to specify whether the group hierarchy will be displayed in labels -* `multiple_select` (required) is a value to specify the display of multiple-select-type responses. Valid inputs include: - * `both`, - * `summary`, or - * `details` -* `type` (required) specifies the export format. Valid export formats include: - * `csv`, - * `geojson`, - * `spss_labels`, or - * `xls` -* `xls_types_as_text` (optional) is a boolean value that defaults to `false` and only affects `xls` export types. -* `include_media_url` (optional) is a boolean value that defaults to `false` and only affects `xls` and `csv` export types. -* `submission_ids` (optional) is an array of submission ids that will filter exported submissions to only the specified array of ids. Valid inputs include: - * An array containing integer values - * An empty array (no filtering) -* `query` (optional) is a JSON object containing a Mongo filter query for filtering exported submissions. Valid inputs include: - * A JSON object containing a valid Mongo query - * An empty JSON object (no filtering) - -**Note that the following behaviour can be expected when specifying a value for the `multiple_select` field:** - -* `summary`: Includes one column per question, with all selected choices separated by spaces; -* `details`: Expands each multiple-select question to one column per choice, with each of those columns having a binary 1 or 0 to indicate whether that choice was chosen; -* `both`: Includes the format of `summary` _and_ `details` in the export - - */ -export type assetsExportSettingsCreateResponse201 = { - data: ExportSettingResponse - status: 201 -} - -export type assetsExportSettingsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsExportSettingsCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsExportSettingsCreateResponseComposite = - | assetsExportSettingsCreateResponse201 - | assetsExportSettingsCreateResponse400 - | assetsExportSettingsCreateResponse404 - -export type assetsExportSettingsCreateResponse = assetsExportSettingsCreateResponseComposite & { - headers: Headers -} - -export const getAssetsExportSettingsCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/export-settings/` -} - -export const assetsExportSettingsCreate = async ( - uidAsset: string, - exportSettingCreatePayload: ExportSettingCreatePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsExportSettingsCreateUrl(uidAsset), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(exportSettingCreatePayload), - }) -} - -export const getAssetsExportSettingsCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: ExportSettingCreatePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: ExportSettingCreatePayload }, - TContext -> => { - const mutationKey = ['assetsExportSettingsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: ExportSettingCreatePayload } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsExportSettingsCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsExportSettingsCreateMutationResult = NonNullable< - Awaited> -> -export type AssetsExportSettingsCreateMutationBody = ExportSettingCreatePayload -export type AssetsExportSettingsCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsExportSettingsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: ExportSettingCreatePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsExportSettingsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve a specific export setting - -* _Required permissions: `view_submissions` (View submissions)_ - - */ -export type assetsExportSettingsRetrieveResponse200 = { - data: ExportSettingResponse - status: 200 -} - -export type assetsExportSettingsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsExportSettingsRetrieveResponseComposite = - | assetsExportSettingsRetrieveResponse200 - | assetsExportSettingsRetrieveResponse404 - -export type assetsExportSettingsRetrieveResponse = assetsExportSettingsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsExportSettingsRetrieveUrl = (uidAsset: string, uidExportSetting: string) => { - return `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/` -} - -export const assetsExportSettingsRetrieve = async ( - uidAsset: string, - uidExportSetting: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsExportSettingsRetrieveUrl(uidAsset, uidExportSetting), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetsExportSettingsRetrieveQueryKey = (uidAsset: string, uidExportSetting: string) => { - return ['api', 'v2', 'assets', uidAsset, 'export-settings', uidExportSetting] as const -} - -export const getAssetsExportSettingsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidExportSetting: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsExportSettingsRetrieveQueryKey(uidAsset, uidExportSetting) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsExportSettingsRetrieve(uidAsset, uidExportSetting, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidExportSetting), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsExportSettingsRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsExportSettingsRetrieveQueryError = ErrorDetail - -export function useAssetsExportSettingsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidExportSetting: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsExportSettingsRetrieveQueryOptions(uidAsset, uidExportSetting, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update the current export setting - -* _Required permissions: `manage_asset` (Manage project)_ - - */ -export type assetsExportSettingsPartialUpdateResponse200 = { - data: ExportSettingResponse - status: 200 -} - -export type assetsExportSettingsPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsExportSettingsPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsExportSettingsPartialUpdateResponseComposite = - | assetsExportSettingsPartialUpdateResponse200 - | assetsExportSettingsPartialUpdateResponse400 - | assetsExportSettingsPartialUpdateResponse404 - -export type assetsExportSettingsPartialUpdateResponse = assetsExportSettingsPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsExportSettingsPartialUpdateUrl = (uidAsset: string, uidExportSetting: string) => { - return `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/` -} - -export const assetsExportSettingsPartialUpdate = async ( - uidAsset: string, - uidExportSetting: string, - patchedExportSettingUpdatePayload: PatchedExportSettingUpdatePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsExportSettingsPartialUpdateUrl(uidAsset, uidExportSetting), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedExportSettingUpdatePayload), - }, - ) -} - -export const getAssetsExportSettingsPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidExportSetting: string; data: PatchedExportSettingUpdatePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidExportSetting: string; data: PatchedExportSettingUpdatePayload }, - TContext -> => { - const mutationKey = ['assetsExportSettingsPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidExportSetting: string; data: PatchedExportSettingUpdatePayload } - > = (props) => { - const { uidAsset, uidExportSetting, data } = props ?? {} - - return assetsExportSettingsPartialUpdate(uidAsset, uidExportSetting, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsExportSettingsPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsExportSettingsPartialUpdateMutationBody = PatchedExportSettingUpdatePayload -export type AssetsExportSettingsPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useAssetsExportSettingsPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidExportSetting: string; data: PatchedExportSettingUpdatePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsExportSettingsPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete current export setting - -* _Required permissions: `manage_asset` (Manage project)_ - - - */ -export type assetsExportSettingsDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsExportSettingsDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsExportSettingsDestroyResponseComposite = - | assetsExportSettingsDestroyResponse204 - | assetsExportSettingsDestroyResponse404 - -export type assetsExportSettingsDestroyResponse = assetsExportSettingsDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsExportSettingsDestroyUrl = (uidAsset: string, uidExportSetting: string) => { - return `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/` -} - -export const assetsExportSettingsDestroy = async ( - uidAsset: string, - uidExportSetting: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsExportSettingsDestroyUrl(uidAsset, uidExportSetting), - { - ...options, - method: 'DELETE', - }, - ) -} - -export const getAssetsExportSettingsDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidExportSetting: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidExportSetting: string }, - TContext -> => { - const mutationKey = ['assetsExportSettingsDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidExportSetting: string } - > = (props) => { - const { uidAsset, uidExportSetting } = props ?? {} - - return assetsExportSettingsDestroy(uidAsset, uidExportSetting, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsExportSettingsDestroyMutationResult = NonNullable< - Awaited> -> - -export type AssetsExportSettingsDestroyMutationError = ErrorDetail - -export const useAssetsExportSettingsDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidExportSetting: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsExportSettingsDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Synchronously export data - -To retrieve data synchronously in CSV and XLSX format according to a -particular instance of export settings. - -Processing time of synchronous exports is substantially limited compared to -asynchronous exports, which are available at `/api/v2/assets/{asset_uid}/exports/`. - - */ -export type assetsExportSettingsDataRetrieveResponse200 = { - data: void - status: 200 -} - -export type assetsExportSettingsDataRetrieveResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsExportSettingsDataRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsExportSettingsDataRetrieveResponseComposite = - | assetsExportSettingsDataRetrieveResponse200 - | assetsExportSettingsDataRetrieveResponse400 - | assetsExportSettingsDataRetrieveResponse404 - -export type assetsExportSettingsDataRetrieveResponse = assetsExportSettingsDataRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsExportSettingsDataRetrieveUrl = ( - uidAsset: string, - uidExportSetting: string, - params: AssetsExportSettingsDataRetrieveParams, -) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/data/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/data/` -} - -export const assetsExportSettingsDataRetrieve = async ( - uidAsset: string, - uidExportSetting: string, - params: AssetsExportSettingsDataRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsExportSettingsDataRetrieveUrl(uidAsset, uidExportSetting, params), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetsExportSettingsDataRetrieveQueryKey = ( - uidAsset: string, - uidExportSetting: string, - params: AssetsExportSettingsDataRetrieveParams, -) => { - return [ - 'api', - 'v2', - 'assets', - uidAsset, - 'export-settings', - uidExportSetting, - 'data', - ...(params ? [params] : []), - ] as const -} - -export const getAssetsExportSettingsDataRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidAsset: string, - uidExportSetting: string, - params: AssetsExportSettingsDataRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = - queryOptions?.queryKey ?? getAssetsExportSettingsDataRetrieveQueryKey(uidAsset, uidExportSetting, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsExportSettingsDataRetrieve(uidAsset, uidExportSetting, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidExportSetting), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsExportSettingsDataRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsExportSettingsDataRetrieveQueryError = ErrorObject | ErrorDetail - -export function useAssetsExportSettingsDataRetrieve< - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidAsset: string, - uidExportSetting: string, - params: AssetsExportSettingsDataRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsExportSettingsDataRetrieveQueryOptions(uidAsset, uidExportSetting, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List of export tasks endpoints - -Lists the export tasks accessible to requesting user, for anonymous access -nothing is returned. - -* _Required permissions: `view_submissions` (View submissions)_ - -Otherwise, the search can be more specific: - -**Exports matching `uid`s:** -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{asset_uid}/exports/?q=uid__in:ehZUwRctkhp9QfJgvEWGg OR uid__in:ehZUwRctkhp9QfJgvDnjud -``` - - */ -export type assetsExportsListResponse200 = { - data: PaginatedExportResponseList - status: 200 -} - -export type assetsExportsListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsExportsListResponseComposite = assetsExportsListResponse200 | assetsExportsListResponse403 - -export type assetsExportsListResponse = assetsExportsListResponseComposite & { - headers: Headers -} - -export const getAssetsExportsListUrl = (uidAsset: string, params?: AssetsExportsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/exports/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/exports/` -} - -export const assetsExportsList = async ( - uidAsset: string, - params?: AssetsExportsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsExportsListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsExportsListQueryKey = (uidAsset: string, params?: AssetsExportsListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'exports', ...(params ? [params] : [])] as const -} - -export const getAssetsExportsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsExportsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsExportsListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsExportsList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsExportsListQueryResult = NonNullable>> -export type AssetsExportsListQueryError = ErrorDetail - -export function useAssetsExportsList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsExportsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsExportsListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Creates an export task - -Where: -* `fields_from_all_versions` (required) is a boolean to specify whether fields from all form versions will be included in the export. - * `group_sep` (required) is a value used to separate the names in a hierarchy of groups. Valid inputs include: - * Non-empty value - * `hierarchy_in_labels` (required) is a boolean to specify whether the group hierarchy will be displayed in labels - * `lang` (required) is a string that can be set to: - * `_xml` to have XML values and headers, or - * Any translation specified in the form such as `English (en)`, etc. - * `multiple_select` (required) is a value to specify the display of `multiple_select-type` responses. Valid inputs include: - * `both`, - * `summary`, or - * `details` - * "`type`" (required) specifies the export format. Valid export formats include: - * `csv`, - * `geojson`, - * `spss_labels`, or - * `xls` - * `fields` (optional) is an array of column names to be included in the export (including their group hierarchy). Valid inputs include: - * An array containing any string value that matches the XML column name - * An empty array which will result in all columns being included - * If `fields` is not included in the `export_settings`, all columns will be included in the export - * `flatten` (optional) is a boolean value and only relevant when exporting to "geojson" format. - * `xls_types_as_text` (optional) is a boolean value that defaults to `false` and only affects `xls` export types. - * `include_media_url` (optional) is a boolean value that defaults to `false` and only affects `xls` and "csv" export types. This will include an additional column for media-type questions (`question_name_URL`) with the URL link to the hosted file. - * `submission_ids` (optional) is an array of submission ids that will filter exported submissions to only the specified array of ids. Valid inputs include: - * An array containing integer values - * An empty array (no filtering) - * `query` (optional) is a JSON object containing a Mongo filter query for filtering exported submissions. Valid inputs include: - * A JSON object containing a valid Mongo query - * An empty JSON object (no filtering) - - */ -export type assetsExportsCreateResponse201 = { - data: ExportResponse - status: 201 -} - -export type assetsExportsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsExportsCreateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsExportsCreateResponseComposite = - | assetsExportsCreateResponse201 - | assetsExportsCreateResponse400 - | assetsExportsCreateResponse403 - -export type assetsExportsCreateResponse = assetsExportsCreateResponseComposite & { - headers: Headers -} - -export const getAssetsExportsCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/exports/` -} - -export const assetsExportsCreate = async ( - uidAsset: string, - exportCreatePayload: ExportCreatePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsExportsCreateUrl(uidAsset), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(exportCreatePayload), - }) -} - -export const getAssetsExportsCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: ExportCreatePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: ExportCreatePayload }, - TContext -> => { - const mutationKey = ['assetsExportsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: ExportCreatePayload } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsExportsCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsExportsCreateMutationResult = NonNullable>> -export type AssetsExportsCreateMutationBody = ExportCreatePayload -export type AssetsExportsCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsExportsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: ExportCreatePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsExportsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieves current export task - - */ -export type assetsExportsRetrieveResponse200 = { - data: ExportResponse - status: 200 -} - -export type assetsExportsRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsExportsRetrieveResponseComposite = assetsExportsRetrieveResponse200 | assetsExportsRetrieveResponse403 - -export type assetsExportsRetrieveResponse = assetsExportsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsExportsRetrieveUrl = (uidAsset: string, uidExport: string) => { - return `/api/v2/assets/${uidAsset}/exports/${uidExport}/` -} - -export const assetsExportsRetrieve = async ( - uidAsset: string, - uidExport: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsExportsRetrieveUrl(uidAsset, uidExport), { - ...options, - method: 'GET', - }) -} - -export const getAssetsExportsRetrieveQueryKey = (uidAsset: string, uidExport: string) => { - return ['api', 'v2', 'assets', uidAsset, 'exports', uidExport] as const -} - -export const getAssetsExportsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidExport: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsExportsRetrieveQueryKey(uidAsset, uidExport) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsExportsRetrieve(uidAsset, uidExport, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidExport), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsExportsRetrieveQueryResult = NonNullable>> -export type AssetsExportsRetrieveQueryError = ErrorDetail - -export function useAssetsExportsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidExport: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsExportsRetrieveQueryOptions(uidAsset, uidExport, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Deletes current export task - - */ -export type assetsExportsDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsExportsDestroyResponse403 = { - data: ErrorDetail - status: 403 -} - -export type assetsExportsDestroyResponseComposite = assetsExportsDestroyResponse204 | assetsExportsDestroyResponse403 - -export type assetsExportsDestroyResponse = assetsExportsDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsExportsDestroyUrl = (uidAsset: string, uidExport: string) => { - return `/api/v2/assets/${uidAsset}/exports/${uidExport}/` -} - -export const assetsExportsDestroy = async ( - uidAsset: string, - uidExport: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsExportsDestroyUrl(uidAsset, uidExport), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetsExportsDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidExport: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidExport: string }, - TContext -> => { - const mutationKey = ['assetsExportsDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidExport: string } - > = (props) => { - const { uidAsset, uidExport } = props ?? {} - - return assetsExportsDestroy(uidAsset, uidExport, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsExportsDestroyMutationResult = NonNullable>> - -export type AssetsExportsDestroyMutationError = ErrorDetail - -export const useAssetsExportsDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidExport: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsExportsDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve current asset files - -Results can be narrowed down with a filter by type: -```shell -curl -X GET https://kf.kobotoolbox.org/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/files/?collections_first=true&ordering=-name -``` - - */ -export type assetsFilesListResponse200 = { - data: PaginatedFilesResponseList - status: 200 -} - -export type assetsFilesListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsFilesListResponseComposite = assetsFilesListResponse200 | assetsFilesListResponse404 - -export type assetsFilesListResponse = assetsFilesListResponseComposite & { - headers: Headers -} - -export const getAssetsFilesListUrl = (uidAsset: string, params?: AssetsFilesListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/files/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/files/` -} - -export const assetsFilesList = async ( - uidAsset: string, - params?: AssetsFilesListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsFilesListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsFilesListQueryKey = (uidAsset: string, params?: AssetsFilesListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'files', ...(params ? [params] : [])] as const -} - -export const getAssetsFilesListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsFilesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsFilesListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsFilesList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsFilesListQueryResult = NonNullable>> -export type AssetsFilesListQueryError = ErrorDetail - -export function useAssetsFilesList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsFilesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsFilesListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create a new file on current asset - -Fields: - -- `asset` (required) -- `user` (required) -- `description` (required) -- `file_type` (required) -- `content` (as binary) (optional) -- `metadata` JSON (optional) - -_Notes:_ - -1. Files can have different types: - - `map_layer` - - `form_media` -2. Files can be created with three different ways - - `POST` a file with `content` parameter - - `POST` a base64 encoded string with `base64Encoded` parameter1 - - `POST` an URL with `metadata` parameter2 - -1) `metadata` becomes mandatory and must contain `filename` property
-2) `metadata` becomes mandatory and must contain `redirect_url` property - -**Files with `form_media` type must have unique `filename` per asset** - - */ -export type assetsFilesCreateResponse201 = { - data: FilesResponse - status: 201 -} - -export type assetsFilesCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsFilesCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsFilesCreateResponseComposite = - | assetsFilesCreateResponse201 - | assetsFilesCreateResponse400 - | assetsFilesCreateResponse404 - -export type assetsFilesCreateResponse = assetsFilesCreateResponseComposite & { - headers: Headers -} - -export const getAssetsFilesCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/files/` -} - -export const assetsFilesCreate = async ( - uidAsset: string, - createFilePayload: CreateFilePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsFilesCreateUrl(uidAsset), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(createFilePayload), - }) -} - -export const getAssetsFilesCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: CreateFilePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: CreateFilePayload }, - TContext -> => { - const mutationKey = ['assetsFilesCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: CreateFilePayload } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsFilesCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsFilesCreateMutationResult = NonNullable>> -export type AssetsFilesCreateMutationBody = CreateFilePayload -export type AssetsFilesCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsFilesCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: CreateFilePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsFilesCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve a file from current asset - - */ -export type assetsFilesRetrieveResponse200 = { - data: FilesResponse - status: 200 -} - -export type assetsFilesRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsFilesRetrieveResponseComposite = assetsFilesRetrieveResponse200 | assetsFilesRetrieveResponse404 - -export type assetsFilesRetrieveResponse = assetsFilesRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsFilesRetrieveUrl = (uidAsset: string, uidFile: string) => { - return `/api/v2/assets/${uidAsset}/files/${uidFile}/` -} - -export const assetsFilesRetrieve = async ( - uidAsset: string, - uidFile: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsFilesRetrieveUrl(uidAsset, uidFile), { - ...options, - method: 'GET', - }) -} - -export const getAssetsFilesRetrieveQueryKey = (uidAsset: string, uidFile: string) => { - return ['api', 'v2', 'assets', uidAsset, 'files', uidFile] as const -} - -export const getAssetsFilesRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidFile: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsFilesRetrieveQueryKey(uidAsset, uidFile) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsFilesRetrieve(uidAsset, uidFile, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidFile), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsFilesRetrieveQueryResult = NonNullable>> -export type AssetsFilesRetrieveQueryError = ErrorDetail - -export function useAssetsFilesRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidFile: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsFilesRetrieveQueryOptions(uidAsset, uidFile, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Delete a file from current asset - - */ -export type assetsFilesDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsFilesDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsFilesDestroyResponseComposite = assetsFilesDestroyResponse204 | assetsFilesDestroyResponse404 - -export type assetsFilesDestroyResponse = assetsFilesDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsFilesDestroyUrl = (uidAsset: string, uidFile: string) => { - return `/api/v2/assets/${uidAsset}/files/${uidFile}/` -} - -export const assetsFilesDestroy = async ( - uidAsset: string, - uidFile: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsFilesDestroyUrl(uidAsset, uidFile), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetsFilesDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidFile: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidFile: string }, - TContext -> => { - const mutationKey = ['assetsFilesDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidFile: string } - > = (props) => { - const { uidAsset, uidFile } = props ?? {} - - return assetsFilesDestroy(uidAsset, uidFile, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsFilesDestroyMutationResult = NonNullable>> - -export type AssetsFilesDestroyMutationError = ErrorDetail - -export const useAssetsFilesDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidFile: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsFilesDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Download the asset file - - */ -export type assetsFilesContentRetrieveResponse200 = { - data: void - status: 200 -} - -export type assetsFilesContentRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsFilesContentRetrieveResponseComposite = - | assetsFilesContentRetrieveResponse200 - | assetsFilesContentRetrieveResponse404 - -export type assetsFilesContentRetrieveResponse = assetsFilesContentRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsFilesContentRetrieveUrl = (uidAsset: string, uidFile: string) => { - return `/api/v2/assets/${uidAsset}/files/${uidFile}/content/` -} - -export const assetsFilesContentRetrieve = async ( - uidAsset: string, - uidFile: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsFilesContentRetrieveUrl(uidAsset, uidFile), { - ...options, - method: 'GET', - }) -} - -export const getAssetsFilesContentRetrieveQueryKey = (uidAsset: string, uidFile: string) => { - return ['api', 'v2', 'assets', uidAsset, 'files', uidFile, 'content'] as const -} - -export const getAssetsFilesContentRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidFile: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsFilesContentRetrieveQueryKey(uidAsset, uidFile) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsFilesContentRetrieve(uidAsset, uidFile, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidFile), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsFilesContentRetrieveQueryResult = NonNullable>> -export type AssetsFilesContentRetrieveQueryError = ErrorDetail - -export function useAssetsFilesContentRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidFile: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsFilesContentRetrieveQueryOptions(uidAsset, uidFile, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List paired project endpoints - -This endpoint is paginated and accepts these parameters: -- `offset`: The initial index from which to return the results -- `limit`: Number of results to return per page - - */ -export type assetsPairedDataListResponse200 = { - data: PaginatedPairedDataResponseList - status: 200 -} - -export type assetsPairedDataListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsPairedDataListResponseComposite = assetsPairedDataListResponse200 | assetsPairedDataListResponse404 - -export type assetsPairedDataListResponse = assetsPairedDataListResponseComposite & { - headers: Headers -} - -export const getAssetsPairedDataListUrl = (uidAsset: string, params?: AssetsPairedDataListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/assets/${uidAsset}/paired-data/?${stringifiedParams}` - : `/api/v2/assets/${uidAsset}/paired-data/` -} - -export const assetsPairedDataList = async ( - uidAsset: string, - params?: AssetsPairedDataListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsPairedDataListUrl(uidAsset, params), { - ...options, - method: 'GET', - }) -} - -export const getAssetsPairedDataListQueryKey = (uidAsset: string, params?: AssetsPairedDataListParams) => { - return ['api', 'v2', 'assets', uidAsset, 'paired-data', ...(params ? [params] : [])] as const -} - -export const getAssetsPairedDataListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - params?: AssetsPairedDataListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataListQueryKey(uidAsset, params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsPairedDataList(uidAsset, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsPairedDataListQueryResult = NonNullable>> -export type AssetsPairedDataListQueryError = ErrorDetail - -export function useAssetsPairedDataList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsPairedDataListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsPairedDataListQueryOptions(uidAsset, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create a connection between two projects - -* `fields`: Optional. List of questions whose responses will be retrieved - from the source data. If missing or empty, all responses will be - retrieved. Questions must be identified by full group path separated by - slashes, e.g. `group/subgroup/question_name`. -* `filename`: Must be unique among all asset files. Only accepts letters, numbers and '-'. - - */ -export type assetsPairedDataCreateResponse201 = { - data: PairedDataResponse - status: 201 -} - -export type assetsPairedDataCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsPairedDataCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsPairedDataCreateResponseComposite = - | assetsPairedDataCreateResponse201 - | assetsPairedDataCreateResponse400 - | assetsPairedDataCreateResponse404 - -export type assetsPairedDataCreateResponse = assetsPairedDataCreateResponseComposite & { - headers: Headers -} - -export const getAssetsPairedDataCreateUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/paired-data/` -} - -export const assetsPairedDataCreate = async ( - uidAsset: string, - pairedData: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsPairedDataCreateUrl(uidAsset), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(pairedData), - }) -} - -export const getAssetsPairedDataCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: NonReadonly }, - TContext -> => { - const mutationKey = ['assetsPairedDataCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; data: NonReadonly } - > = (props) => { - const { uidAsset, data } = props ?? {} - - return assetsPairedDataCreate(uidAsset, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsPairedDataCreateMutationResult = NonNullable>> -export type AssetsPairedDataCreateMutationBody = NonReadonly -export type AssetsPairedDataCreateMutationError = ErrorObject | ErrorDetail - -export const useAssetsPairedDataCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsPairedDataCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve a connection between two projects - - */ -export type assetsPairedDataRetrieveResponse200 = { - data: PairedDataResponse - status: 200 -} - -export type assetsPairedDataRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsPairedDataRetrieveResponseComposite = - | assetsPairedDataRetrieveResponse200 - | assetsPairedDataRetrieveResponse404 - -export type assetsPairedDataRetrieveResponse = assetsPairedDataRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsPairedDataRetrieveUrl = (uidAsset: string, uidPairedData: string) => { - return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/` -} - -export const assetsPairedDataRetrieve = async ( - uidAsset: string, - uidPairedData: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsPairedDataRetrieveUrl(uidAsset, uidPairedData), { - ...options, - method: 'GET', - }) -} - -export const getAssetsPairedDataRetrieveQueryKey = (uidAsset: string, uidPairedData: string) => { - return ['api', 'v2', 'assets', uidAsset, 'paired-data', uidPairedData] as const -} - -export const getAssetsPairedDataRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidPairedData: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataRetrieveQueryKey(uidAsset, uidPairedData) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsPairedDataRetrieve(uidAsset, uidPairedData, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidPairedData), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsPairedDataRetrieveQueryResult = NonNullable>> -export type AssetsPairedDataRetrieveQueryError = ErrorDetail - -export function useAssetsPairedDataRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidPairedData: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsPairedDataRetrieveQueryOptions(uidAsset, uidPairedData, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update a connection between two projects - -_Notes: `source` cannot be changed_ - - */ -export type assetsPairedDataPartialUpdateResponse200 = { - data: PairedDataResponse - status: 200 -} - -export type assetsPairedDataPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type assetsPairedDataPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsPairedDataPartialUpdateResponseComposite = - | assetsPairedDataPartialUpdateResponse200 - | assetsPairedDataPartialUpdateResponse400 - | assetsPairedDataPartialUpdateResponse404 - -export type assetsPairedDataPartialUpdateResponse = assetsPairedDataPartialUpdateResponseComposite & { - headers: Headers -} - -export const getAssetsPairedDataPartialUpdateUrl = (uidAsset: string, uidPairedData: string) => { - return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/` -} - -export const assetsPairedDataPartialUpdate = async ( - uidAsset: string, - uidPairedData: string, - patchedPairedDataPatchPayload: PatchedPairedDataPatchPayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsPairedDataPartialUpdateUrl(uidAsset, uidPairedData), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedPairedDataPatchPayload), - }, - ) -} - -export const getAssetsPairedDataPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidPairedData: string; data: PatchedPairedDataPatchPayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidPairedData: string; data: PatchedPairedDataPatchPayload }, - TContext -> => { - const mutationKey = ['assetsPairedDataPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidPairedData: string; data: PatchedPairedDataPatchPayload } - > = (props) => { - const { uidAsset, uidPairedData, data } = props ?? {} - - return assetsPairedDataPartialUpdate(uidAsset, uidPairedData, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsPairedDataPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type AssetsPairedDataPartialUpdateMutationBody = PatchedPairedDataPatchPayload -export type AssetsPairedDataPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useAssetsPairedDataPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidPairedData: string; data: PatchedPairedDataPatchPayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsPairedDataPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Remove a connection between two projects - - */ -export type assetsPairedDataDestroyResponse204 = { - data: void - status: 204 -} - -export type assetsPairedDataDestroyResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsPairedDataDestroyResponseComposite = - | assetsPairedDataDestroyResponse204 - | assetsPairedDataDestroyResponse404 - -export type assetsPairedDataDestroyResponse = assetsPairedDataDestroyResponseComposite & { - headers: Headers -} - -export const getAssetsPairedDataDestroyUrl = (uidAsset: string, uidPairedData: string) => { - return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/` -} - -export const assetsPairedDataDestroy = async ( - uidAsset: string, - uidPairedData: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsPairedDataDestroyUrl(uidAsset, uidPairedData), { - ...options, - method: 'DELETE', - }) -} - -export const getAssetsPairedDataDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidPairedData: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidPairedData: string }, - TContext -> => { - const mutationKey = ['assetsPairedDataDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidAsset: string; uidPairedData: string } - > = (props) => { - const { uidAsset, uidPairedData } = props ?? {} - - return assetsPairedDataDestroy(uidAsset, uidPairedData, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type AssetsPairedDataDestroyMutationResult = NonNullable>> - -export type AssetsPairedDataDestroyMutationError = ErrorDetail - -export const useAssetsPairedDataDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidAsset: string; uidPairedData: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getAssetsPairedDataDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Return an XML which contains data submitted to paired asset - -Creates the endpoints -- /api/v2/assets//paired-data//external/ -- /api/v2/assets//paired-data//external.xml/ - - */ -export type assetsPairedDataExternalRetrieveResponse200 = { - data: ExternalResponse - status: 200 -} - -export type assetsPairedDataExternalRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsPairedDataExternalRetrieveResponseComposite = - | assetsPairedDataExternalRetrieveResponse200 - | assetsPairedDataExternalRetrieveResponse404 - -export type assetsPairedDataExternalRetrieveResponse = assetsPairedDataExternalRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsPairedDataExternalRetrieveUrl = (uidAsset: string, uidPairedData: string) => { - return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/external/` -} - -export const assetsPairedDataExternalRetrieve = async ( - uidAsset: string, - uidPairedData: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getAssetsPairedDataExternalRetrieveUrl(uidAsset, uidPairedData), - { - ...options, - method: 'GET', - }, - ) -} - -export const getAssetsPairedDataExternalRetrieveQueryKey = (uidAsset: string, uidPairedData: string) => { - return ['api', 'v2', 'assets', uidAsset, 'paired-data', uidPairedData, 'external'] as const -} - -export const getAssetsPairedDataExternalRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidPairedData: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataExternalRetrieveQueryKey(uidAsset, uidPairedData) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsPairedDataExternalRetrieve(uidAsset, uidPairedData, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidAsset && uidPairedData), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsPairedDataExternalRetrieveQueryResult = NonNullable< - Awaited> -> -export type AssetsPairedDataExternalRetrieveQueryError = ErrorDetail - -export function useAssetsPairedDataExternalRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - uidPairedData: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsPairedDataExternalRetrieveQueryOptions(uidAsset, uidPairedData, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Report of a user's asset - -Returns the submission data for all deployments of a survey. -This data is grouped by answers, and does not show the data for individual submissions. -The endpoint will return a **404 NOT FOUND** error if the asset is not deployed and will only return the data for the most recently deployed version. - - */ -export type assetsReportsRetrieveResponse200 = { - data: ReportResponse - status: 200 -} - -export type assetsReportsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsReportsRetrieveResponseComposite = assetsReportsRetrieveResponse200 | assetsReportsRetrieveResponse404 - -export type assetsReportsRetrieveResponse = assetsReportsRetrieveResponseComposite & { - headers: Headers -} - -export const getAssetsReportsRetrieveUrl = (uidAsset: string) => { - return `/api/v2/assets/${uidAsset}/reports/` -} - -export const assetsReportsRetrieve = async ( - uidAsset: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetsReportsRetrieveUrl(uidAsset), { - ...options, - method: 'GET', - }) -} - -export const getAssetsReportsRetrieveQueryKey = (uidAsset: string) => { - return ['api', 'v2', 'assets', uidAsset, 'reports'] as const -} - -export const getAssetsReportsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetsReportsRetrieveQueryKey(uidAsset) - - const queryFn: QueryFunction>> = ({ signal }) => - assetsReportsRetrieve(uidAsset, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetsReportsRetrieveQueryResult = NonNullable>> -export type AssetsReportsRetrieveQueryError = ErrorDetail - -export function useAssetsReportsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidAsset: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetsReportsRetrieveQueryOptions(uidAsset, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} diff --git a/jsapp/js/api/react-query/user-team-organization-usage/index.ts b/jsapp/js/api/react-query/user-team-organization-usage/index.ts new file mode 100644 index 0000000000..260ecdf21c --- /dev/null +++ b/jsapp/js/api/react-query/user-team-organization-usage/index.ts @@ -0,0 +1,3640 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + useMutation, + useQuery +} from '@tanstack/react-query'; +import type { + MutationFunction, + QueryFunction, + QueryKey, + UseMutationOptions, + UseQueryOptions, + UseQueryResult +} from '@tanstack/react-query'; + +import type { + AssetListCount +} from '../../models/assetListCount'; + +import type { + AssetUsageListParams +} from '../../models/assetUsageListParams'; + +import type { + EmailAddress +} from '../../models/emailAddress'; + +import type { + EmailRequestPayload +} from '../../models/emailRequestPayload'; + +import type { + ErrorDetail +} from '../../models/errorDetail'; + +import type { + ErrorObject +} from '../../models/errorObject'; + +import type { + InviteCreatePayload +} from '../../models/inviteCreatePayload'; + +import type { + InviteCreateResponse +} from '../../models/inviteCreateResponse'; + +import type { + InviteResponse +} from '../../models/inviteResponse'; + +import type { + MeEmailsListParams +} from '../../models/meEmailsListParams'; + +import type { + MeListResponse +} from '../../models/meListResponse'; + +import type { + MeSocialAccountsListParams +} from '../../models/meSocialAccountsListParams'; + +import type { + MemberListResponse +} from '../../models/memberListResponse'; + +import type { + OrganizationResponse +} from '../../models/organizationResponse'; + +import type { + OrganizationServiceUsageResponse +} from '../../models/organizationServiceUsageResponse'; + +import type { + OrganizationsAssetUsageListParams +} from '../../models/organizationsAssetUsageListParams'; + +import type { + OrganizationsAssetsMinimalListRetrieveParams +} from '../../models/organizationsAssetsMinimalListRetrieveParams'; + +import type { + OrganizationsInvitesListParams +} from '../../models/organizationsInvitesListParams'; + +import type { + OrganizationsListParams +} from '../../models/organizationsListParams'; + +import type { + OrganizationsMembersListParams +} from '../../models/organizationsMembersListParams'; + +import type { + PaginatedAssetList +} from '../../models/paginatedAssetList'; + +import type { + PaginatedAssetMinimalListList +} from '../../models/paginatedAssetMinimalListList'; + +import type { + PaginatedAssetUsageResponseList +} from '../../models/paginatedAssetUsageResponseList'; + +import type { + PaginatedCustomAssetUsageList +} from '../../models/paginatedCustomAssetUsageList'; + +import type { + PaginatedEmailAddressList +} from '../../models/paginatedEmailAddressList'; + +import type { + PaginatedInviteResponseList +} from '../../models/paginatedInviteResponseList'; + +import type { + PaginatedMemberListResponseList +} from '../../models/paginatedMemberListResponseList'; + +import type { + PaginatedOrganizationResponseList +} from '../../models/paginatedOrganizationResponseList'; + +import type { + PaginatedProjectViewAssetResponseList +} from '../../models/paginatedProjectViewAssetResponseList'; + +import type { + PaginatedProjectViewListResponseList +} from '../../models/paginatedProjectViewListResponseList'; + +import type { + PaginatedProjectViewUserResponseList +} from '../../models/paginatedProjectViewUserResponseList'; + +import type { + PaginatedSocialAccountList +} from '../../models/paginatedSocialAccountList'; + +import type { + PaginatedUserListResponseList +} from '../../models/paginatedUserListResponseList'; + +import type { + PatchedCurrentUser +} from '../../models/patchedCurrentUser'; + +import type { + PatchedInvitePatchPayload +} from '../../models/patchedInvitePatchPayload'; + +import type { + PatchedMemberPatchRequest +} from '../../models/patchedMemberPatchRequest'; + +import type { + PatchedOrganizationPatchPayload +} from '../../models/patchedOrganizationPatchPayload'; + +import type { + ProjectViewExportCreateResponse +} from '../../models/projectViewExportCreateResponse'; + +import type { + ProjectViewExportResponse +} from '../../models/projectViewExportResponse'; + +import type { + ProjectViewListResponse +} from '../../models/projectViewListResponse'; + +import type { + ProjectViewsAssetsMinimalListRetrieveParams +} from '../../models/projectViewsAssetsMinimalListRetrieveParams'; + +import type { + ProjectViewsAssetsRetrieveParams +} from '../../models/projectViewsAssetsRetrieveParams'; + +import type { + ProjectViewsListParams +} from '../../models/projectViewsListParams'; + +import type { + ProjectViewsUsersRetrieveParams +} from '../../models/projectViewsUsersRetrieveParams'; + +import type { + ServiceUsageResponse +} from '../../models/serviceUsageResponse'; + +import type { + SocialAccount +} from '../../models/socialAccount'; + +import type { + UserRetrieveResponse +} from '../../models/userRetrieveResponse'; + +import type { + UsersListParams +} from '../../models/usersListParams'; + +import { fetchWithAuth } from '../../orval.mutator'; + +// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 +type IfEquals = (() => T extends X ? 1 : 2) extends < +T, +>() => T extends Y ? 1 : 2 +? A +: B; + +type WritableKeys = { +[P in keyof T]-?: IfEquals< + { [Q in P]: T[P] }, + { -readonly [Q in P]: T[P] }, + P +>; +}[keyof T]; + +type UnionToIntersection = + (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never; +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; + +type Writable = Pick>; +type NonReadonly = [T] extends [UnionToIntersection] ? { + [P in keyof Writable]: T[P] extends object + ? NonReadonly> + : T[P]; +} : DistributeReadOnlyOverUnions; + + + +type SecondParameter unknown> = Parameters[1]; + + + +/** + * ## Get user's asset usage + + */ +export type assetUsageListResponse200 = { + data: PaginatedAssetUsageResponseList + status: 200 +} + +export type assetUsageListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type assetUsageListResponseComposite = assetUsageListResponse200 | assetUsageListResponse401; + +export type assetUsageListResponse = assetUsageListResponseComposite & { + headers: Headers; +} + +export const getAssetUsageListUrl = (params?: AssetUsageListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/asset_usage/?${stringifiedParams}` : `/api/v2/asset_usage/` +} + +export const assetUsageList = async (params?: AssetUsageListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getAssetUsageListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getAssetUsageListQueryKey = (params?: AssetUsageListParams,) => { + return ['api','v2','asset_usage', ...(params ? [params]: [])] as const; + } + + +export const getAssetUsageListQueryOptions = >, TError = ErrorDetail>(params?: AssetUsageListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getAssetUsageListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => assetUsageList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type AssetUsageListQueryResult = NonNullable>> +export type AssetUsageListQueryError = ErrorDetail + + + +export function useAssetUsageList>, TError = ErrorDetail>( + params?: AssetUsageListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getAssetUsageListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List user's organizations + + */ +export type organizationsListResponse200 = { + data: PaginatedOrganizationResponseList + status: 200 +} + +export type organizationsListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsListResponseComposite = organizationsListResponse200 | organizationsListResponse404; + +export type organizationsListResponse = organizationsListResponseComposite & { + headers: Headers; +} + +export const getOrganizationsListUrl = (params?: OrganizationsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/organizations/?${stringifiedParams}` : `/api/v2/organizations/` +} + +export const organizationsList = async (params?: OrganizationsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsListQueryKey = (params?: OrganizationsListParams,) => { + return ['api','v2','organizations', ...(params ? [params]: [])] as const; + } + + +export const getOrganizationsListQueryOptions = >, TError = ErrorDetail>(params?: OrganizationsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsListQueryResult = NonNullable>> +export type OrganizationsListQueryError = ErrorDetail + + + +export function useOrganizationsList>, TError = ErrorDetail>( + params?: OrganizationsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve organization's details + + */ +export type organizationsRetrieveResponse200 = { + data: OrganizationResponse + status: 200 +} + +export type organizationsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsRetrieveResponseComposite = organizationsRetrieveResponse200 | organizationsRetrieveResponse404; + +export type organizationsRetrieveResponse = organizationsRetrieveResponseComposite & { + headers: Headers; +} + +export const getOrganizationsRetrieveUrl = (uidOrganization: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/` +} + +export const organizationsRetrieve = async (uidOrganization: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsRetrieveUrl(uidOrganization), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsRetrieveQueryKey = (uidOrganization: string,) => { + return ['api','v2','organizations',uidOrganization] as const; + } + + +export const getOrganizationsRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsRetrieveQueryKey(uidOrganization); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsRetrieve(uidOrganization, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsRetrieveQueryResult = NonNullable>> +export type OrganizationsRetrieveQueryError = ErrorDetail + + + +export function useOrganizationsRetrieve>, TError = ErrorDetail>( + uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsRetrieveQueryOptions(uidOrganization,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update organization's details + + */ +export type organizationsPartialUpdateResponse200 = { + data: OrganizationResponse + status: 200 +} + +export type organizationsPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type organizationsPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsPartialUpdateResponseComposite = organizationsPartialUpdateResponse200 | organizationsPartialUpdateResponse400 | organizationsPartialUpdateResponse404; + +export type organizationsPartialUpdateResponse = organizationsPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getOrganizationsPartialUpdateUrl = (uidOrganization: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/` +} + +export const organizationsPartialUpdate = async (uidOrganization: string, + patchedOrganizationPatchPayload: PatchedOrganizationPatchPayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsPartialUpdateUrl(uidOrganization), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedOrganizationPatchPayload,) + } +);} + + + + +export const getOrganizationsPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;data: PatchedOrganizationPatchPayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidOrganization: string;data: PatchedOrganizationPatchPayload}, TContext> => { + +const mutationKey = ['organizationsPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidOrganization: string;data: PatchedOrganizationPatchPayload}> = (props) => { + const {uidOrganization,data} = props ?? {}; + + return organizationsPartialUpdate(uidOrganization,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type OrganizationsPartialUpdateMutationResult = NonNullable>> + export type OrganizationsPartialUpdateMutationBody = PatchedOrganizationPatchPayload + export type OrganizationsPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useOrganizationsPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;data: PatchedOrganizationPatchPayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getOrganizationsPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve organization asset usage tracker + +Tracks the total usage of each asset for the user in the given organization + + */ +export type organizationsAssetUsageListResponse200 = { + data: PaginatedCustomAssetUsageList + status: 200 +} + +export type organizationsAssetUsageListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsAssetUsageListResponseComposite = organizationsAssetUsageListResponse200 | organizationsAssetUsageListResponse404; + +export type organizationsAssetUsageListResponse = organizationsAssetUsageListResponseComposite & { + headers: Headers; +} + +export const getOrganizationsAssetUsageListUrl = (uidOrganization: string, + params?: OrganizationsAssetUsageListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/organizations/${uidOrganization}/asset_usage/?${stringifiedParams}` : `/api/v2/organizations/${uidOrganization}/asset_usage/` +} + +export const organizationsAssetUsageList = async (uidOrganization: string, + params?: OrganizationsAssetUsageListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsAssetUsageListUrl(uidOrganization,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsAssetUsageListQueryKey = (uidOrganization: string, + params?: OrganizationsAssetUsageListParams,) => { + return ['api','v2','organizations',uidOrganization,'asset_usage', ...(params ? [params]: [])] as const; + } + + +export const getOrganizationsAssetUsageListQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, + params?: OrganizationsAssetUsageListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetUsageListQueryKey(uidOrganization,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsAssetUsageList(uidOrganization,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsAssetUsageListQueryResult = NonNullable>> +export type OrganizationsAssetUsageListQueryError = ErrorDetail + + + +export function useOrganizationsAssetUsageList>, TError = ErrorDetail>( + uidOrganization: string, + params?: OrganizationsAssetUsageListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsAssetUsageListQueryOptions(uidOrganization,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve Organization Assets + +This endpoint returns all assets associated with a specific organization. +The assets listed here are restricted to those owned by the specified +organization. + +Only the owner or administrators of the organization can access this endpoint. + +### Additional Information +For more details, please refer to `/api/v2/assets/`. + + */ +export type organizationsAssetsRetrieveResponse200 = { + data: PaginatedAssetList + status: 200 +} + +export type organizationsAssetsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsAssetsRetrieveResponseComposite = organizationsAssetsRetrieveResponse200 | organizationsAssetsRetrieveResponse404; + +export type organizationsAssetsRetrieveResponse = organizationsAssetsRetrieveResponseComposite & { + headers: Headers; +} + +export const getOrganizationsAssetsRetrieveUrl = (uidOrganization: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/assets/` +} + +export const organizationsAssetsRetrieve = async (uidOrganization: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsAssetsRetrieveUrl(uidOrganization), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsAssetsRetrieveQueryKey = (uidOrganization: string,) => { + return ['api','v2','organizations',uidOrganization,'assets'] as const; + } + + +export const getOrganizationsAssetsRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsRetrieveQueryKey(uidOrganization); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsAssetsRetrieve(uidOrganization, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsAssetsRetrieveQueryResult = NonNullable>> +export type OrganizationsAssetsRetrieveQueryError = ErrorDetail + + + +export function useOrganizationsAssetsRetrieve>, TError = ErrorDetail>( + uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsAssetsRetrieveQueryOptions(uidOrganization,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Return counts of deployed, archived, and draft assets owned by the organization + + */ +export type organizationsAssetsCountsRetrieveResponse200 = { + data: AssetListCount + status: 200 +} + +export type organizationsAssetsCountsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsAssetsCountsRetrieveResponseComposite = organizationsAssetsCountsRetrieveResponse200 | organizationsAssetsCountsRetrieveResponse404; + +export type organizationsAssetsCountsRetrieveResponse = organizationsAssetsCountsRetrieveResponseComposite & { + headers: Headers; +} + +export const getOrganizationsAssetsCountsRetrieveUrl = (uidOrganization: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/assets/counts/` +} + +export const organizationsAssetsCountsRetrieve = async (uidOrganization: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsAssetsCountsRetrieveUrl(uidOrganization), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsAssetsCountsRetrieveQueryKey = (uidOrganization: string,) => { + return ['api','v2','organizations',uidOrganization,'assets','counts'] as const; + } + + +export const getOrganizationsAssetsCountsRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsCountsRetrieveQueryKey(uidOrganization); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsAssetsCountsRetrieve(uidOrganization, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsAssetsCountsRetrieveQueryResult = NonNullable>> +export type OrganizationsAssetsCountsRetrieveQueryError = ErrorDetail + + + +export function useOrganizationsAssetsCountsRetrieve>, TError = ErrorDetail>( + uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsAssetsCountsRetrieveQueryOptions(uidOrganization,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Return a minimal listing of assets in an organization + +Returns a paginated list of assets owned by the organization, including only `uid`, `name`, and `deployment_status` (`draft`, `deployed`, or `archived`). + +Use the `q` query parameter to filter by asset type (e.g. `?q=asset_type:survey`). + +Responses do not include a `count` field. Use the `next` and `previous` links to paginate through results. + + */ +export type organizationsAssetsMinimalListRetrieveResponse200 = { + data: PaginatedAssetMinimalListList + status: 200 +} + +export type organizationsAssetsMinimalListRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsAssetsMinimalListRetrieveResponseComposite = organizationsAssetsMinimalListRetrieveResponse200 | organizationsAssetsMinimalListRetrieveResponse404; + +export type organizationsAssetsMinimalListRetrieveResponse = organizationsAssetsMinimalListRetrieveResponseComposite & { + headers: Headers; +} + +export const getOrganizationsAssetsMinimalListRetrieveUrl = (uidOrganization: string, + params?: OrganizationsAssetsMinimalListRetrieveParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/organizations/${uidOrganization}/assets/minimal-list/?${stringifiedParams}` : `/api/v2/organizations/${uidOrganization}/assets/minimal-list/` +} + +export const organizationsAssetsMinimalListRetrieve = async (uidOrganization: string, + params?: OrganizationsAssetsMinimalListRetrieveParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsAssetsMinimalListRetrieveUrl(uidOrganization,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsAssetsMinimalListRetrieveQueryKey = (uidOrganization: string, + params?: OrganizationsAssetsMinimalListRetrieveParams,) => { + return ['api','v2','organizations',uidOrganization,'assets','minimal-list', ...(params ? [params]: [])] as const; + } + + +export const getOrganizationsAssetsMinimalListRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, + params?: OrganizationsAssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsMinimalListRetrieveQueryKey(uidOrganization,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsAssetsMinimalListRetrieve(uidOrganization,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsAssetsMinimalListRetrieveQueryResult = NonNullable>> +export type OrganizationsAssetsMinimalListRetrieveQueryError = ErrorDetail + + + +export function useOrganizationsAssetsMinimalListRetrieve>, TError = ErrorDetail>( + uidOrganization: string, + params?: OrganizationsAssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsAssetsMinimalListRetrieveQueryOptions(uidOrganization,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List organization invites + + */ +export type organizationsInvitesListResponse200 = { + data: PaginatedInviteResponseList + status: 200 +} + +export type organizationsInvitesListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsInvitesListResponseComposite = organizationsInvitesListResponse200 | organizationsInvitesListResponse404; + +export type organizationsInvitesListResponse = organizationsInvitesListResponseComposite & { + headers: Headers; +} + +export const getOrganizationsInvitesListUrl = (uidOrganization: string, + params?: OrganizationsInvitesListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/organizations/${uidOrganization}/invites/?${stringifiedParams}` : `/api/v2/organizations/${uidOrganization}/invites/` +} + +export const organizationsInvitesList = async (uidOrganization: string, + params?: OrganizationsInvitesListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsInvitesListUrl(uidOrganization,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsInvitesListQueryKey = (uidOrganization: string, + params?: OrganizationsInvitesListParams,) => { + return ['api','v2','organizations',uidOrganization,'invites', ...(params ? [params]: [])] as const; + } + + +export const getOrganizationsInvitesListQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, + params?: OrganizationsInvitesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsInvitesListQueryKey(uidOrganization,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsInvitesList(uidOrganization,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsInvitesListQueryResult = NonNullable>> +export type OrganizationsInvitesListQueryError = ErrorDetail + + + +export function useOrganizationsInvitesList>, TError = ErrorDetail>( + uidOrganization: string, + params?: OrganizationsInvitesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsInvitesListQueryOptions(uidOrganization,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create Organization Invite + +* Create organization invites for registered and unregistered users. +* Set the role for which the user is being invited - +(Choices: `member`, `admin`). Default is `member`. + + */ +export type organizationsInvitesCreateResponse201 = { + data: InviteCreateResponse + status: 201 +} + +export type organizationsInvitesCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type organizationsInvitesCreateResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsInvitesCreateResponseComposite = organizationsInvitesCreateResponse201 | organizationsInvitesCreateResponse400 | organizationsInvitesCreateResponse404; + +export type organizationsInvitesCreateResponse = organizationsInvitesCreateResponseComposite & { + headers: Headers; +} + +export const getOrganizationsInvitesCreateUrl = (uidOrganization: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/invites/` +} + +export const organizationsInvitesCreate = async (uidOrganization: string, + inviteCreatePayload: InviteCreatePayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsInvitesCreateUrl(uidOrganization), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + inviteCreatePayload,) + } +);} + + + + +export const getOrganizationsInvitesCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;data: InviteCreatePayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidOrganization: string;data: InviteCreatePayload}, TContext> => { + +const mutationKey = ['organizationsInvitesCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidOrganization: string;data: InviteCreatePayload}> = (props) => { + const {uidOrganization,data} = props ?? {}; + + return organizationsInvitesCreate(uidOrganization,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type OrganizationsInvitesCreateMutationResult = NonNullable>> + export type OrganizationsInvitesCreateMutationBody = InviteCreatePayload + export type OrganizationsInvitesCreateMutationError = ErrorObject | ErrorDetail + + export const useOrganizationsInvitesCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;data: InviteCreatePayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getOrganizationsInvitesCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve organization invite + + */ +export type organizationsInvitesRetrieveResponse200 = { + data: InviteResponse + status: 200 +} + +export type organizationsInvitesRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsInvitesRetrieveResponseComposite = organizationsInvitesRetrieveResponse200 | organizationsInvitesRetrieveResponse404; + +export type organizationsInvitesRetrieveResponse = organizationsInvitesRetrieveResponseComposite & { + headers: Headers; +} + +export const getOrganizationsInvitesRetrieveUrl = (uidOrganization: string, + guid: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/invites/${guid}/` +} + +export const organizationsInvitesRetrieve = async (uidOrganization: string, + guid: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsInvitesRetrieveUrl(uidOrganization,guid), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsInvitesRetrieveQueryKey = (uidOrganization: string, + guid: string,) => { + return ['api','v2','organizations',uidOrganization,'invites',guid] as const; + } + + +export const getOrganizationsInvitesRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, + guid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsInvitesRetrieveQueryKey(uidOrganization,guid); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsInvitesRetrieve(uidOrganization,guid, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidOrganization && guid), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsInvitesRetrieveQueryResult = NonNullable>> +export type OrganizationsInvitesRetrieveQueryError = ErrorDetail + + + +export function useOrganizationsInvitesRetrieve>, TError = ErrorDetail>( + uidOrganization: string, + guid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsInvitesRetrieveQueryOptions(uidOrganization,guid,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update Organization Invite + +* Update an organization invite to accept, decline, cancel, expire, or resend. +* Update the role of the invitee to `admin` or `member`. Only the owner or admin can update the role. + + + */ +export type organizationsInvitesPartialUpdateResponse200 = { + data: InviteResponse + status: 200 +} + +export type organizationsInvitesPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type organizationsInvitesPartialUpdateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type organizationsInvitesPartialUpdateResponseComposite = organizationsInvitesPartialUpdateResponse200 | organizationsInvitesPartialUpdateResponse400 | organizationsInvitesPartialUpdateResponse403; + +export type organizationsInvitesPartialUpdateResponse = organizationsInvitesPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getOrganizationsInvitesPartialUpdateUrl = (uidOrganization: string, + guid: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/invites/${guid}/` +} + +export const organizationsInvitesPartialUpdate = async (uidOrganization: string, + guid: string, + patchedInvitePatchPayload: PatchedInvitePatchPayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsInvitesPartialUpdateUrl(uidOrganization,guid), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedInvitePatchPayload,) + } +);} + + + + +export const getOrganizationsInvitesPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;guid: string;data: PatchedInvitePatchPayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidOrganization: string;guid: string;data: PatchedInvitePatchPayload}, TContext> => { + +const mutationKey = ['organizationsInvitesPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidOrganization: string;guid: string;data: PatchedInvitePatchPayload}> = (props) => { + const {uidOrganization,guid,data} = props ?? {}; + + return organizationsInvitesPartialUpdate(uidOrganization,guid,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type OrganizationsInvitesPartialUpdateMutationResult = NonNullable>> + export type OrganizationsInvitesPartialUpdateMutationBody = PatchedInvitePatchPayload + export type OrganizationsInvitesPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useOrganizationsInvitesPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;guid: string;data: PatchedInvitePatchPayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getOrganizationsInvitesPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Delete Organization Invite + +* Organization owner or admin can delete an organization invite. + + */ +export type organizationsInvitesDestroyResponse204 = { + data: void + status: 204 +} + +export type organizationsInvitesDestroyResponse403 = { + data: ErrorDetail + status: 403 +} + +export type organizationsInvitesDestroyResponseComposite = organizationsInvitesDestroyResponse204 | organizationsInvitesDestroyResponse403; + +export type organizationsInvitesDestroyResponse = organizationsInvitesDestroyResponseComposite & { + headers: Headers; +} + +export const getOrganizationsInvitesDestroyUrl = (uidOrganization: string, + guid: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/invites/${guid}/` +} + +export const organizationsInvitesDestroy = async (uidOrganization: string, + guid: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsInvitesDestroyUrl(uidOrganization,guid), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getOrganizationsInvitesDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;guid: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidOrganization: string;guid: string}, TContext> => { + +const mutationKey = ['organizationsInvitesDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidOrganization: string;guid: string}> = (props) => { + const {uidOrganization,guid} = props ?? {}; + + return organizationsInvitesDestroy(uidOrganization,guid,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type OrganizationsInvitesDestroyMutationResult = NonNullable>> + + export type OrganizationsInvitesDestroyMutationError = ErrorDetail + + export const useOrganizationsInvitesDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;guid: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getOrganizationsInvitesDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## List Members + +Retrieves all members in the specified organization. + + */ +export type organizationsMembersListResponse200 = { + data: PaginatedMemberListResponseList + status: 200 +} + +export type organizationsMembersListResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsMembersListResponseComposite = organizationsMembersListResponse200 | organizationsMembersListResponse404; + +export type organizationsMembersListResponse = organizationsMembersListResponseComposite & { + headers: Headers; +} + +export const getOrganizationsMembersListUrl = (uidOrganization: string, + params?: OrganizationsMembersListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/organizations/${uidOrganization}/members/?${stringifiedParams}` : `/api/v2/organizations/${uidOrganization}/members/` +} + +export const organizationsMembersList = async (uidOrganization: string, + params?: OrganizationsMembersListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsMembersListUrl(uidOrganization,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsMembersListQueryKey = (uidOrganization: string, + params?: OrganizationsMembersListParams,) => { + return ['api','v2','organizations',uidOrganization,'members', ...(params ? [params]: [])] as const; + } + + +export const getOrganizationsMembersListQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, + params?: OrganizationsMembersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsMembersListQueryKey(uidOrganization,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsMembersList(uidOrganization,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsMembersListQueryResult = NonNullable>> +export type OrganizationsMembersListQueryError = ErrorDetail + + + +export function useOrganizationsMembersList>, TError = ErrorDetail>( + uidOrganization: string, + params?: OrganizationsMembersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsMembersListQueryOptions(uidOrganization,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve Member Details + +Retrieves the details of a specific member within an organization by username. + + */ +export type organizationsMembersRetrieveResponse200 = { + data: MemberListResponse + status: 200 +} + +export type organizationsMembersRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsMembersRetrieveResponseComposite = organizationsMembersRetrieveResponse200 | organizationsMembersRetrieveResponse404; + +export type organizationsMembersRetrieveResponse = organizationsMembersRetrieveResponseComposite & { + headers: Headers; +} + +export const getOrganizationsMembersRetrieveUrl = (uidOrganization: string, + username: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/members/${username}/` +} + +export const organizationsMembersRetrieve = async (uidOrganization: string, + username: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsMembersRetrieveUrl(uidOrganization,username), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsMembersRetrieveQueryKey = (uidOrganization: string, + username: string,) => { + return ['api','v2','organizations',uidOrganization,'members',username] as const; + } + + +export const getOrganizationsMembersRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, + username: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsMembersRetrieveQueryKey(uidOrganization,username); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsMembersRetrieve(uidOrganization,username, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidOrganization && username), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsMembersRetrieveQueryResult = NonNullable>> +export type OrganizationsMembersRetrieveQueryError = ErrorDetail + + + +export function useOrganizationsMembersRetrieve>, TError = ErrorDetail>( + uidOrganization: string, + username: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsMembersRetrieveQueryOptions(uidOrganization,username,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update Member Role + +Updates the role of a member within the organization to `admin` or +`member`. + +- **admin**: Grants the member admin privileges within the organization +- **member**: Revokes admin privileges, setting the member as a regular user + + */ +export type organizationsMembersPartialUpdateResponse200 = { + data: MemberListResponse + status: 200 +} + +export type organizationsMembersPartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type organizationsMembersPartialUpdateResponse403 = { + data: ErrorDetail + status: 403 +} + +export type organizationsMembersPartialUpdateResponseComposite = organizationsMembersPartialUpdateResponse200 | organizationsMembersPartialUpdateResponse400 | organizationsMembersPartialUpdateResponse403; + +export type organizationsMembersPartialUpdateResponse = organizationsMembersPartialUpdateResponseComposite & { + headers: Headers; +} + +export const getOrganizationsMembersPartialUpdateUrl = (uidOrganization: string, + username: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/members/${username}/` +} + +export const organizationsMembersPartialUpdate = async (uidOrganization: string, + username: string, + patchedMemberPatchRequest: PatchedMemberPatchRequest, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsMembersPartialUpdateUrl(uidOrganization,username), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedMemberPatchRequest,) + } +);} + + + + +export const getOrganizationsMembersPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;username: string;data: PatchedMemberPatchRequest}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidOrganization: string;username: string;data: PatchedMemberPatchRequest}, TContext> => { + +const mutationKey = ['organizationsMembersPartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidOrganization: string;username: string;data: PatchedMemberPatchRequest}> = (props) => { + const {uidOrganization,username,data} = props ?? {}; + + return organizationsMembersPartialUpdate(uidOrganization,username,data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type OrganizationsMembersPartialUpdateMutationResult = NonNullable>> + export type OrganizationsMembersPartialUpdateMutationBody = PatchedMemberPatchRequest + export type OrganizationsMembersPartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useOrganizationsMembersPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;username: string;data: PatchedMemberPatchRequest}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getOrganizationsMembersPartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Remove Member + +Delete an organization member. + + */ +export type organizationsMembersDestroyResponse204 = { + data: void + status: 204 +} + +export type organizationsMembersDestroyResponse403 = { + data: ErrorDetail + status: 403 +} + +export type organizationsMembersDestroyResponseComposite = organizationsMembersDestroyResponse204 | organizationsMembersDestroyResponse403; + +export type organizationsMembersDestroyResponse = organizationsMembersDestroyResponseComposite & { + headers: Headers; +} + +export const getOrganizationsMembersDestroyUrl = (uidOrganization: string, + username: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/members/${username}/` +} + +export const organizationsMembersDestroy = async (uidOrganization: string, + username: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsMembersDestroyUrl(uidOrganization,username), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getOrganizationsMembersDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;username: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidOrganization: string;username: string}, TContext> => { + +const mutationKey = ['organizationsMembersDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidOrganization: string;username: string}> = (props) => { + const {uidOrganization,username} = props ?? {}; + + return organizationsMembersDestroy(uidOrganization,username,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type OrganizationsMembersDestroyMutationResult = NonNullable>> + + export type OrganizationsMembersDestroyMutationError = ErrorDetail + + export const useOrganizationsMembersDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;username: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getOrganizationsMembersDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Organization Usage Tracker + +- Tracks the total usage of different services for each account in an organization +- Tracks the submissions and NLP seconds/characters for the current month/year/all time +- Tracks the current total storage used +- Includes a detailed list of balances relative to a user's usage limits +- If no organization is found with the provided ID, returns the usage for the logged-in user + +**This endpoint is cached for an amount of time determined by ENDPOINT_CACHE_DURATION** + + */ +export type organizationsServiceUsageRetrieveResponse200 = { + data: OrganizationServiceUsageResponse + status: 200 +} + +export type organizationsServiceUsageRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type organizationsServiceUsageRetrieveResponseComposite = organizationsServiceUsageRetrieveResponse200 | organizationsServiceUsageRetrieveResponse404; + +export type organizationsServiceUsageRetrieveResponse = organizationsServiceUsageRetrieveResponseComposite & { + headers: Headers; +} + +export const getOrganizationsServiceUsageRetrieveUrl = (uidOrganization: string,) => { + + + + + return `/api/v2/organizations/${uidOrganization}/service_usage/` +} + +export const organizationsServiceUsageRetrieve = async (uidOrganization: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getOrganizationsServiceUsageRetrieveUrl(uidOrganization), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getOrganizationsServiceUsageRetrieveQueryKey = (uidOrganization: string,) => { + return ['api','v2','organizations',uidOrganization,'service_usage'] as const; + } + + +export const getOrganizationsServiceUsageRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getOrganizationsServiceUsageRetrieveQueryKey(uidOrganization); + + + + const queryFn: QueryFunction>> = ({ signal }) => organizationsServiceUsageRetrieve(uidOrganization, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type OrganizationsServiceUsageRetrieveQueryResult = NonNullable>> +export type OrganizationsServiceUsageRetrieveQueryError = ErrorDetail + + + +export function useOrganizationsServiceUsageRetrieve>, TError = ErrorDetail>( + uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getOrganizationsServiceUsageRetrieveQueryOptions(uidOrganization,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List project views for current user + + */ +export type projectViewsListResponse200 = { + data: PaginatedProjectViewListResponseList + status: 200 +} + +export type projectViewsListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectViewsListResponseComposite = projectViewsListResponse200 | projectViewsListResponse403; + +export type projectViewsListResponse = projectViewsListResponseComposite & { + headers: Headers; +} + +export const getProjectViewsListUrl = (params?: ProjectViewsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/project-views/?${stringifiedParams}` : `/api/v2/project-views/` +} + +export const projectViewsList = async (params?: ProjectViewsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectViewsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getProjectViewsListQueryKey = (params?: ProjectViewsListParams,) => { + return ['api','v2','project-views', ...(params ? [params]: [])] as const; + } + + +export const getProjectViewsListQueryOptions = >, TError = ErrorDetail>(params?: ProjectViewsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectViewsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => projectViewsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ProjectViewsListQueryResult = NonNullable>> +export type ProjectViewsListQueryError = ErrorDetail + + + +export function useProjectViewsList>, TError = ErrorDetail>( + params?: ProjectViewsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectViewsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve project view of a shared project to current user + + */ +export type projectViewsRetrieveResponse200 = { + data: ProjectViewListResponse + status: 200 +} + +export type projectViewsRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectViewsRetrieveResponseComposite = projectViewsRetrieveResponse200 | projectViewsRetrieveResponse403; + +export type projectViewsRetrieveResponse = projectViewsRetrieveResponseComposite & { + headers: Headers; +} + +export const getProjectViewsRetrieveUrl = (uidProjectView: string,) => { + + + + + return `/api/v2/project-views/${uidProjectView}/` +} + +export const projectViewsRetrieve = async (uidProjectView: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectViewsRetrieveUrl(uidProjectView), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getProjectViewsRetrieveQueryKey = (uidProjectView: string,) => { + return ['api','v2','project-views',uidProjectView] as const; + } + + +export const getProjectViewsRetrieveQueryOptions = >, TError = ErrorDetail>(uidProjectView: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectViewsRetrieveQueryKey(uidProjectView); + + + + const queryFn: QueryFunction>> = ({ signal }) => projectViewsRetrieve(uidProjectView, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidProjectView), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ProjectViewsRetrieveQueryResult = NonNullable>> +export type ProjectViewsRetrieveQueryError = ErrorDetail + + + +export function useProjectViewsRetrieve>, TError = ErrorDetail>( + uidProjectView: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectViewsRetrieveQueryOptions(uidProjectView,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve an export for the requested object + +* Note: `{obj_type}` can either be `users` or `assets` + + + */ +export type projectViewsExportRetrieveResponse200 = { + data: ProjectViewExportResponse + status: 200 +} + +export type projectViewsExportRetrieveResponse400 = { + data: ErrorObject + status: 400 +} + +export type projectViewsExportRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type projectViewsExportRetrieveResponseComposite = projectViewsExportRetrieveResponse200 | projectViewsExportRetrieveResponse400 | projectViewsExportRetrieveResponse401; + +export type projectViewsExportRetrieveResponse = projectViewsExportRetrieveResponseComposite & { + headers: Headers; +} + +export const getProjectViewsExportRetrieveUrl = (uidProjectView: string, + objType: string,) => { + + + + + return `/api/v2/project-views/${uidProjectView}/${objType}/export/` +} + +export const projectViewsExportRetrieve = async (uidProjectView: string, + objType: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectViewsExportRetrieveUrl(uidProjectView,objType), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getProjectViewsExportRetrieveQueryKey = (uidProjectView: string, + objType: string,) => { + return ['api','v2','project-views',uidProjectView,objType,'export'] as const; + } + + +export const getProjectViewsExportRetrieveQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidProjectView: string, + objType: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectViewsExportRetrieveQueryKey(uidProjectView,objType); + + + + const queryFn: QueryFunction>> = ({ signal }) => projectViewsExportRetrieve(uidProjectView,objType, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidProjectView && objType), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ProjectViewsExportRetrieveQueryResult = NonNullable>> +export type ProjectViewsExportRetrieveQueryError = ErrorObject | ErrorDetail + + + +export function useProjectViewsExportRetrieve>, TError = ErrorObject | ErrorDetail>( + uidProjectView: string, + objType: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectViewsExportRetrieveQueryOptions(uidProjectView,objType,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Create an export for the requested object + +* Note: `{obj_type}` can either be `users` or `assets` + + */ +export type projectViewsExportCreateResponse200 = { + data: ProjectViewExportCreateResponse + status: 200 +} + +export type projectViewsExportCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type projectViewsExportCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type projectViewsExportCreateResponseComposite = projectViewsExportCreateResponse200 | projectViewsExportCreateResponse400 | projectViewsExportCreateResponse401; + +export type projectViewsExportCreateResponse = projectViewsExportCreateResponseComposite & { + headers: Headers; +} + +export const getProjectViewsExportCreateUrl = (uidProjectView: string, + objType: string,) => { + + + + + return `/api/v2/project-views/${uidProjectView}/${objType}/export/` +} + +export const projectViewsExportCreate = async (uidProjectView: string, + objType: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectViewsExportCreateUrl(uidProjectView,objType), + { + ...options, + method: 'POST' + + + } +);} + + + + +export const getProjectViewsExportCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidProjectView: string;objType: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{uidProjectView: string;objType: string}, TContext> => { + +const mutationKey = ['projectViewsExportCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {uidProjectView: string;objType: string}> = (props) => { + const {uidProjectView,objType} = props ?? {}; + + return projectViewsExportCreate(uidProjectView,objType,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type ProjectViewsExportCreateMutationResult = NonNullable>> + + export type ProjectViewsExportCreateMutationError = ErrorObject | ErrorDetail + + export const useProjectViewsExportCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidProjectView: string;objType: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getProjectViewsExportCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Retrieve assets available in project view + + */ +export type projectViewsAssetsRetrieveResponse200 = { + data: PaginatedProjectViewAssetResponseList + status: 200 +} + +export type projectViewsAssetsRetrieveResponse400 = { + data: ErrorObject + status: 400 +} + +export type projectViewsAssetsRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type projectViewsAssetsRetrieveResponseComposite = projectViewsAssetsRetrieveResponse200 | projectViewsAssetsRetrieveResponse400 | projectViewsAssetsRetrieveResponse401; + +export type projectViewsAssetsRetrieveResponse = projectViewsAssetsRetrieveResponseComposite & { + headers: Headers; +} + +export const getProjectViewsAssetsRetrieveUrl = (uidProjectView: string, + params?: ProjectViewsAssetsRetrieveParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/project-views/${uidProjectView}/assets/?${stringifiedParams}` : `/api/v2/project-views/${uidProjectView}/assets/` +} + +export const projectViewsAssetsRetrieve = async (uidProjectView: string, + params?: ProjectViewsAssetsRetrieveParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectViewsAssetsRetrieveUrl(uidProjectView,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getProjectViewsAssetsRetrieveQueryKey = (uidProjectView: string, + params?: ProjectViewsAssetsRetrieveParams,) => { + return ['api','v2','project-views',uidProjectView,'assets', ...(params ? [params]: [])] as const; + } + + +export const getProjectViewsAssetsRetrieveQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidProjectView: string, + params?: ProjectViewsAssetsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsRetrieveQueryKey(uidProjectView,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => projectViewsAssetsRetrieve(uidProjectView,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidProjectView), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ProjectViewsAssetsRetrieveQueryResult = NonNullable>> +export type ProjectViewsAssetsRetrieveQueryError = ErrorObject | ErrorDetail + + + +export function useProjectViewsAssetsRetrieve>, TError = ErrorObject | ErrorDetail>( + uidProjectView: string, + params?: ProjectViewsAssetsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectViewsAssetsRetrieveQueryOptions(uidProjectView,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Return counts of deployed, archived, and draft assets in the project view + + */ +export type projectViewsAssetsCountsRetrieveResponse200 = { + data: AssetListCount + status: 200 +} + +export type projectViewsAssetsCountsRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type projectViewsAssetsCountsRetrieveResponseComposite = projectViewsAssetsCountsRetrieveResponse200 | projectViewsAssetsCountsRetrieveResponse404; + +export type projectViewsAssetsCountsRetrieveResponse = projectViewsAssetsCountsRetrieveResponseComposite & { + headers: Headers; +} + +export const getProjectViewsAssetsCountsRetrieveUrl = (uidProjectView: string,) => { + + + + + return `/api/v2/project-views/${uidProjectView}/assets/counts/` +} + +export const projectViewsAssetsCountsRetrieve = async (uidProjectView: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectViewsAssetsCountsRetrieveUrl(uidProjectView), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getProjectViewsAssetsCountsRetrieveQueryKey = (uidProjectView: string,) => { + return ['api','v2','project-views',uidProjectView,'assets','counts'] as const; + } + + +export const getProjectViewsAssetsCountsRetrieveQueryOptions = >, TError = ErrorDetail>(uidProjectView: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsCountsRetrieveQueryKey(uidProjectView); + + + + const queryFn: QueryFunction>> = ({ signal }) => projectViewsAssetsCountsRetrieve(uidProjectView, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidProjectView), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ProjectViewsAssetsCountsRetrieveQueryResult = NonNullable>> +export type ProjectViewsAssetsCountsRetrieveQueryError = ErrorDetail + + + +export function useProjectViewsAssetsCountsRetrieve>, TError = ErrorDetail>( + uidProjectView: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectViewsAssetsCountsRetrieveQueryOptions(uidProjectView,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Return a minimal listing of assets in a project view + +Returns a paginated list of assets visible within the project view, including only `uid`, `name`, and `deployment_status` (`draft`, `deployed`, or `archived`). + +Use the `q` query parameter to filter by asset type (e.g. `?q=asset_type:survey`). + +Responses do not include a `count` field. Use the `next` and `previous` links to paginate through results. + + */ +export type projectViewsAssetsMinimalListRetrieveResponse200 = { + data: PaginatedAssetMinimalListList + status: 200 +} + +export type projectViewsAssetsMinimalListRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type projectViewsAssetsMinimalListRetrieveResponseComposite = projectViewsAssetsMinimalListRetrieveResponse200 | projectViewsAssetsMinimalListRetrieveResponse404; + +export type projectViewsAssetsMinimalListRetrieveResponse = projectViewsAssetsMinimalListRetrieveResponseComposite & { + headers: Headers; +} + +export const getProjectViewsAssetsMinimalListRetrieveUrl = (uidProjectView: string, + params?: ProjectViewsAssetsMinimalListRetrieveParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/project-views/${uidProjectView}/assets/minimal-list/?${stringifiedParams}` : `/api/v2/project-views/${uidProjectView}/assets/minimal-list/` +} + +export const projectViewsAssetsMinimalListRetrieve = async (uidProjectView: string, + params?: ProjectViewsAssetsMinimalListRetrieveParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectViewsAssetsMinimalListRetrieveUrl(uidProjectView,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getProjectViewsAssetsMinimalListRetrieveQueryKey = (uidProjectView: string, + params?: ProjectViewsAssetsMinimalListRetrieveParams,) => { + return ['api','v2','project-views',uidProjectView,'assets','minimal-list', ...(params ? [params]: [])] as const; + } + + +export const getProjectViewsAssetsMinimalListRetrieveQueryOptions = >, TError = ErrorDetail>(uidProjectView: string, + params?: ProjectViewsAssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsMinimalListRetrieveQueryKey(uidProjectView,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => projectViewsAssetsMinimalListRetrieve(uidProjectView,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidProjectView), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ProjectViewsAssetsMinimalListRetrieveQueryResult = NonNullable>> +export type ProjectViewsAssetsMinimalListRetrieveQueryError = ErrorDetail + + + +export function useProjectViewsAssetsMinimalListRetrieve>, TError = ErrorDetail>( + uidProjectView: string, + params?: ProjectViewsAssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectViewsAssetsMinimalListRetrieveQueryOptions(uidProjectView,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve users available in project view + + */ +export type projectViewsUsersRetrieveResponse200 = { + data: PaginatedProjectViewUserResponseList + status: 200 +} + +export type projectViewsUsersRetrieveResponse403 = { + data: ErrorDetail + status: 403 +} + +export type projectViewsUsersRetrieveResponseComposite = projectViewsUsersRetrieveResponse200 | projectViewsUsersRetrieveResponse403; + +export type projectViewsUsersRetrieveResponse = projectViewsUsersRetrieveResponseComposite & { + headers: Headers; +} + +export const getProjectViewsUsersRetrieveUrl = (uidProjectView: string, + params?: ProjectViewsUsersRetrieveParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/project-views/${uidProjectView}/users/?${stringifiedParams}` : `/api/v2/project-views/${uidProjectView}/users/` +} + +export const projectViewsUsersRetrieve = async (uidProjectView: string, + params?: ProjectViewsUsersRetrieveParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getProjectViewsUsersRetrieveUrl(uidProjectView,params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getProjectViewsUsersRetrieveQueryKey = (uidProjectView: string, + params?: ProjectViewsUsersRetrieveParams,) => { + return ['api','v2','project-views',uidProjectView,'users', ...(params ? [params]: [])] as const; + } + + +export const getProjectViewsUsersRetrieveQueryOptions = >, TError = ErrorDetail>(uidProjectView: string, + params?: ProjectViewsUsersRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getProjectViewsUsersRetrieveQueryKey(uidProjectView,params); + + + + const queryFn: QueryFunction>> = ({ signal }) => projectViewsUsersRetrieve(uidProjectView,params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(uidProjectView), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ProjectViewsUsersRetrieveQueryResult = NonNullable>> +export type ProjectViewsUsersRetrieveQueryError = ErrorDetail + + + +export function useProjectViewsUsersRetrieve>, TError = ErrorDetail>( + uidProjectView: string, + params?: ProjectViewsUsersRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getProjectViewsUsersRetrieveQueryOptions(uidProjectView,params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ⚠️ Deprecated +## Track Service Usage + +Tracks the total usage of different services for the logged-in user.
+Tracks the submissions and NLP seconds/characters for the current month/year/all time.
+Tracks the current total storage used.
+Note: this endpoint is not currently used by the frontend to display usage information.
+See `/api/v2/organizations/{organization_id}/service_usage/` for the endpoint we use on the Usage page.
+ + */ +export type serviceUsageListResponse200 = { + data: ServiceUsageResponse[] + status: 200 +} + +export type serviceUsageListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type serviceUsageListResponseComposite = serviceUsageListResponse200 | serviceUsageListResponse401; + +export type serviceUsageListResponse = serviceUsageListResponseComposite & { + headers: Headers; +} + +export const getServiceUsageListUrl = () => { + + + + + return `/api/v2/service_usage/` +} + +export const serviceUsageList = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getServiceUsageListUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getServiceUsageListQueryKey = () => { + return ['api','v2','service_usage'] as const; + } + + +export const getServiceUsageListQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getServiceUsageListQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => serviceUsageList({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type ServiceUsageListQueryResult = NonNullable>> +export type ServiceUsageListQueryError = ErrorDetail + + + +export function useServiceUsageList>, TError = ErrorDetail>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getServiceUsageListQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## List users + +⚠️ _Only available to superusers_ + +Search can be made with `q` parameter. + +Allowed fields are: + +- `username` +- `is_active` +- `email` +- `date_joined` +- `last_login` +- `extra_details__data__` + + */ +export type usersListResponse200 = { + data: PaginatedUserListResponseList + status: 200 +} + +export type usersListResponse403 = { + data: ErrorDetail + status: 403 +} + +export type usersListResponseComposite = usersListResponse200 | usersListResponse403; + +export type usersListResponse = usersListResponseComposite & { + headers: Headers; +} + +export const getUsersListUrl = (params?: UsersListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/api/v2/users/?${stringifiedParams}` : `/api/v2/users/` +} + +export const usersList = async (params?: UsersListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getUsersListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getUsersListQueryKey = (params?: UsersListParams,) => { + return ['api','v2','users', ...(params ? [params]: [])] as const; + } + + +export const getUsersListQueryOptions = >, TError = ErrorDetail>(params?: UsersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getUsersListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => usersList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type UsersListQueryResult = NonNullable>> +export type UsersListQueryError = ErrorDetail + + + +export function useUsersList>, TError = ErrorDetail>( + params?: UsersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getUsersListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve a user + +⚠️ _Regular users have access to active users only_ + + */ +export type usersRetrieveResponse200 = { + data: UserRetrieveResponse + status: 200 +} + +export type usersRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} + +export type usersRetrieveResponseComposite = usersRetrieveResponse200 | usersRetrieveResponse404; + +export type usersRetrieveResponse = usersRetrieveResponseComposite & { + headers: Headers; +} + +export const getUsersRetrieveUrl = (username: string,) => { + + + + + return `/api/v2/users/${username}/` +} + +export const usersRetrieve = async (username: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getUsersRetrieveUrl(username), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getUsersRetrieveQueryKey = (username: string,) => { + return ['api','v2','users',username] as const; + } + + +export const getUsersRetrieveQueryOptions = >, TError = ErrorDetail>(username: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getUsersRetrieveQueryKey(username); + + + + const queryFn: QueryFunction>> = ({ signal }) => usersRetrieve(username, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(username), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type UsersRetrieveQueryResult = NonNullable>> +export type UsersRetrieveQueryError = ErrorDetail + + + +export function useUsersRetrieve>, TError = ErrorDetail>( + username: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getUsersRetrieveQueryOptions(username,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve current user profile + + */ +export type meRetrieveResponse200 = { + data: MeListResponse + status: 200 +} + +export type meRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type meRetrieveResponseComposite = meRetrieveResponse200 | meRetrieveResponse401; + +export type meRetrieveResponse = meRetrieveResponseComposite & { + headers: Headers; +} + +export const getMeRetrieveUrl = () => { + + + + + return `/me/` +} + +export const meRetrieve = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getMeRetrieveUrl(), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getMeRetrieveQueryKey = () => { + return ['me'] as const; + } + + +export const getMeRetrieveQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getMeRetrieveQueryKey(); + + + + const queryFn: QueryFunction>> = ({ signal }) => meRetrieve({ signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type MeRetrieveQueryResult = NonNullable>> +export type MeRetrieveQueryError = ErrorDetail + + + +export function useMeRetrieve>, TError = ErrorDetail>( + options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getMeRetrieveQueryOptions(options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Update current user infos + + */ +export type mePartialUpdateResponse200 = { + data: MeListResponse + status: 200 +} + +export type mePartialUpdateResponse400 = { + data: ErrorObject + status: 400 +} + +export type mePartialUpdateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type mePartialUpdateResponseComposite = mePartialUpdateResponse200 | mePartialUpdateResponse400 | mePartialUpdateResponse401; + +export type mePartialUpdateResponse = mePartialUpdateResponseComposite & { + headers: Headers; +} + +export const getMePartialUpdateUrl = () => { + + + + + return `/me/` +} + +export const mePartialUpdate = async (patchedCurrentUser: NonReadonly, options?: RequestInit): Promise => { + + return fetchWithAuth(getMePartialUpdateUrl(), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + patchedCurrentUser,) + } +);} + + + + +export const getMePartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: NonReadonly}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: NonReadonly}, TContext> => { + +const mutationKey = ['mePartialUpdate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: NonReadonly}> = (props) => { + const {data} = props ?? {}; + + return mePartialUpdate(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type MePartialUpdateMutationResult = NonNullable>> + export type MePartialUpdateMutationBody = NonReadonly + export type MePartialUpdateMutationError = ErrorObject | ErrorDetail + + export const useMePartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{data: NonReadonly}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getMePartialUpdateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## Delete current user + +> Payload Example: +> +> { +> "confirm": "user__extra_details__uid", +> } + + +### !! Due to current DRF-Spectacular limitations with AOS 3.1, DELETE operations do not display request or response bodies in this documentation (as payloads are not typically recommended for DELETE). This means direct testing is unavailable. However, example payloads and responses are provided for reference, and HTTP codes/error messages are accurate. !! + + */ +export type meDestroyResponse204 = { + data: void + status: 204 +} + +export type meDestroyResponse400 = { + data: ErrorObject + status: 400 +} + +export type meDestroyResponse401 = { + data: ErrorDetail + status: 401 +} + +export type meDestroyResponseComposite = meDestroyResponse204 | meDestroyResponse400 | meDestroyResponse401; + +export type meDestroyResponse = meDestroyResponseComposite & { + headers: Headers; +} + +export const getMeDestroyUrl = () => { + + + + + return `/me/` +} + +export const meDestroy = async ( options?: RequestInit): Promise => { + + return fetchWithAuth(getMeDestroyUrl(), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getMeDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,void, TContext> => { + +const mutationKey = ['meDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, void> = () => { + + + return meDestroy(requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type MeDestroyMutationResult = NonNullable>> + + export type MeDestroyMutationError = ErrorObject | ErrorDetail + + export const useMeDestroy = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getMeDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## View current user's email + + */ +export type meEmailsListResponse200 = { + data: PaginatedEmailAddressList + status: 200 +} + +export type meEmailsListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type meEmailsListResponseComposite = meEmailsListResponse200 | meEmailsListResponse401; + +export type meEmailsListResponse = meEmailsListResponseComposite & { + headers: Headers; +} + +export const getMeEmailsListUrl = (params?: MeEmailsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/me/emails/?${stringifiedParams}` : `/me/emails/` +} + +export const meEmailsList = async (params?: MeEmailsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getMeEmailsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getMeEmailsListQueryKey = (params?: MeEmailsListParams,) => { + return ['me','emails', ...(params ? [params]: [])] as const; + } + + +export const getMeEmailsListQueryOptions = >, TError = ErrorDetail>(params?: MeEmailsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getMeEmailsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => meEmailsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type MeEmailsListQueryResult = NonNullable>> +export type MeEmailsListQueryError = ErrorDetail + + + +export function useMeEmailsList>, TError = ErrorDetail>( + params?: MeEmailsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getMeEmailsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Set a new email + +The new email will be unverified and replace existing unverified, non-primary emails. +New email is not usable until verified. + + */ +export type meEmailsCreateResponse201 = { + data: EmailAddress + status: 201 +} + +export type meEmailsCreateResponse400 = { + data: ErrorObject + status: 400 +} + +export type meEmailsCreateResponse401 = { + data: ErrorDetail + status: 401 +} + +export type meEmailsCreateResponseComposite = meEmailsCreateResponse201 | meEmailsCreateResponse400 | meEmailsCreateResponse401; + +export type meEmailsCreateResponse = meEmailsCreateResponseComposite & { + headers: Headers; +} + +export const getMeEmailsCreateUrl = () => { + + + + + return `/me/emails/` +} + +export const meEmailsCreate = async (emailRequestPayload: EmailRequestPayload, options?: RequestInit): Promise => { + + return fetchWithAuth(getMeEmailsCreateUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + emailRequestPayload,) + } +);} + + + + +export const getMeEmailsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailRequestPayload}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{data: EmailRequestPayload}, TContext> => { + +const mutationKey = ['meEmailsCreate']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {data: EmailRequestPayload}> = (props) => { + const {data} = props ?? {}; + + return meEmailsCreate(data,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type MeEmailsCreateMutationResult = NonNullable>> + export type MeEmailsCreateMutationBody = EmailRequestPayload + export type MeEmailsCreateMutationError = ErrorObject | ErrorDetail + + export const useMeEmailsCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailRequestPayload}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getMeEmailsCreateMutationOptions(options); + + return useMutation(mutationOptions ); + } + /** + * ## List user's social accounts + + */ +export type meSocialAccountsListResponse200 = { + data: PaginatedSocialAccountList + status: 200 +} + +export type meSocialAccountsListResponse401 = { + data: ErrorDetail + status: 401 +} + +export type meSocialAccountsListResponseComposite = meSocialAccountsListResponse200 | meSocialAccountsListResponse401; + +export type meSocialAccountsListResponse = meSocialAccountsListResponseComposite & { + headers: Headers; +} + +export const getMeSocialAccountsListUrl = (params?: MeSocialAccountsListParams,) => { + const normalizedParams = new URLSearchParams(); + + Object.entries(params || {}).forEach(([key, value]) => { + + if (value !== undefined) { + normalizedParams.append(key, value === null ? 'null' : value.toString()) + } + }); + + const stringifiedParams = normalizedParams.toString(); + + return stringifiedParams.length > 0 ? `/me/social-accounts/?${stringifiedParams}` : `/me/social-accounts/` +} + +export const meSocialAccountsList = async (params?: MeSocialAccountsListParams, options?: RequestInit): Promise => { + + return fetchWithAuth(getMeSocialAccountsListUrl(params), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getMeSocialAccountsListQueryKey = (params?: MeSocialAccountsListParams,) => { + return ['me','social-accounts', ...(params ? [params]: [])] as const; + } + + +export const getMeSocialAccountsListQueryOptions = >, TError = ErrorDetail>(params?: MeSocialAccountsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getMeSocialAccountsListQueryKey(params); + + + + const queryFn: QueryFunction>> = ({ signal }) => meSocialAccountsList(params, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type MeSocialAccountsListQueryResult = NonNullable>> +export type MeSocialAccountsListQueryError = ErrorDetail + + + +export function useMeSocialAccountsList>, TError = ErrorDetail>( + params?: MeSocialAccountsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getMeSocialAccountsListQueryOptions(params,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Retrieve a social account provider + + */ +export type meSocialAccountsRetrieveResponse200 = { + data: SocialAccount + status: 200 +} + +export type meSocialAccountsRetrieveResponse401 = { + data: ErrorDetail + status: 401 +} + +export type meSocialAccountsRetrieveResponseComposite = meSocialAccountsRetrieveResponse200 | meSocialAccountsRetrieveResponse401; + +export type meSocialAccountsRetrieveResponse = meSocialAccountsRetrieveResponseComposite & { + headers: Headers; +} + +export const getMeSocialAccountsRetrieveUrl = (provider: string, + uidSocialAccount: string,) => { + + + + + return `/me/social-accounts/${provider}/${uidSocialAccount}/` +} + +export const meSocialAccountsRetrieve = async (provider: string, + uidSocialAccount: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getMeSocialAccountsRetrieveUrl(provider,uidSocialAccount), + { + ...options, + method: 'GET' + + + } +);} + + + +export const getMeSocialAccountsRetrieveQueryKey = (provider: string, + uidSocialAccount: string,) => { + return ['me','social-accounts',provider,uidSocialAccount] as const; + } + + +export const getMeSocialAccountsRetrieveQueryOptions = >, TError = ErrorDetail>(provider: string, + uidSocialAccount: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getMeSocialAccountsRetrieveQueryKey(provider,uidSocialAccount); + + + + const queryFn: QueryFunction>> = ({ signal }) => meSocialAccountsRetrieve(provider,uidSocialAccount, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(provider && uidSocialAccount), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type MeSocialAccountsRetrieveQueryResult = NonNullable>> +export type MeSocialAccountsRetrieveQueryError = ErrorDetail + + + +export function useMeSocialAccountsRetrieve>, TError = ErrorDetail>( + provider: string, + uidSocialAccount: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } { + + const queryOptions = getMeSocialAccountsRetrieveQueryOptions(provider,uidSocialAccount,options) + + const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + +/** + * ## Delete a social account provider + + */ +export type meSocialAccountsDestroyResponse204 = { + data: void + status: 204 +} + +export type meSocialAccountsDestroyResponse401 = { + data: ErrorDetail + status: 401 +} + +export type meSocialAccountsDestroyResponseComposite = meSocialAccountsDestroyResponse204 | meSocialAccountsDestroyResponse401; + +export type meSocialAccountsDestroyResponse = meSocialAccountsDestroyResponseComposite & { + headers: Headers; +} + +export const getMeSocialAccountsDestroyUrl = (provider: string, + uidSocialAccount: string,) => { + + + + + return `/me/social-accounts/${provider}/${uidSocialAccount}/` +} + +export const meSocialAccountsDestroy = async (provider: string, + uidSocialAccount: string, options?: RequestInit): Promise => { + + return fetchWithAuth(getMeSocialAccountsDestroyUrl(provider,uidSocialAccount), + { + ...options, + method: 'DELETE' + + + } +);} + + + + +export const getMeSocialAccountsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{provider: string;uidSocialAccount: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{provider: string;uidSocialAccount: string}, TContext> => { + +const mutationKey = ['meSocialAccountsDestroy']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {provider: string;uidSocialAccount: string}> = (props) => { + const {provider,uidSocialAccount} = props ?? {}; + + return meSocialAccountsDestroy(provider,uidSocialAccount,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type MeSocialAccountsDestroyMutationResult = NonNullable>> + + export type MeSocialAccountsDestroyMutationError = ErrorDetail + + export const useMeSocialAccountsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{provider: string;uidSocialAccount: string}, TContext>, request?: SecondParameter} + ) => { + + const mutationOptions = getMeSocialAccountsDestroyMutationOptions(options); + + return useMutation(mutationOptions ); + } + \ No newline at end of file diff --git a/jsapp/js/api/react-query/user-team-organization-usage/msw.ts b/jsapp/js/api/react-query/user-team-organization-usage/msw.ts new file mode 100644 index 0000000000..cfe585d0f3 --- /dev/null +++ b/jsapp/js/api/react-query/user-team-organization-usage/msw.ts @@ -0,0 +1,640 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import { + faker +} from '@faker-js/faker'; + +import { HttpResponse, + http } from 'msw'; + +import { + AssetDeploymentStatusEnum +} from '../../models/assetDeploymentStatusEnum'; + +import type { + AssetListCount +} from '../../models/assetListCount'; + +import { + AssetTypeEnum +} from '../../models/assetTypeEnum'; + +import { + CustomAssetUsageDeploymentStatusEnum +} from '../../models/customAssetUsageDeploymentStatusEnum'; + +import type { + EmailAddress +} from '../../models/emailAddress'; + +import type { + InviteCreateResponse +} from '../../models/inviteCreateResponse'; + +import type { + InviteResponse +} from '../../models/inviteResponse'; + +import { + InviteStatusChoicesEnum +} from '../../models/inviteStatusChoicesEnum'; + +import { + InviteeRoleEnum +} from '../../models/inviteeRoleEnum'; + +import type { + MeListResponse +} from '../../models/meListResponse'; + +import type { + MemberListResponse +} from '../../models/memberListResponse'; + +import { + MemberRoleEnum +} from '../../models/memberRoleEnum'; + +import type { + OrganizationResponse +} from '../../models/organizationResponse'; + +import type { + OrganizationServiceUsageResponse +} from '../../models/organizationServiceUsageResponse'; + +import { + OrganizationTypeEnum +} from '../../models/organizationTypeEnum'; + +import type { + PaginatedAssetList +} from '../../models/paginatedAssetList'; + +import type { + PaginatedAssetMinimalListList +} from '../../models/paginatedAssetMinimalListList'; + +import type { + PaginatedAssetUsageResponseList +} from '../../models/paginatedAssetUsageResponseList'; + +import type { + PaginatedCustomAssetUsageList +} from '../../models/paginatedCustomAssetUsageList'; + +import type { + PaginatedEmailAddressList +} from '../../models/paginatedEmailAddressList'; + +import type { + PaginatedInviteResponseList +} from '../../models/paginatedInviteResponseList'; + +import type { + PaginatedMemberListResponseList +} from '../../models/paginatedMemberListResponseList'; + +import type { + PaginatedOrganizationResponseList +} from '../../models/paginatedOrganizationResponseList'; + +import type { + PaginatedProjectViewAssetResponseList +} from '../../models/paginatedProjectViewAssetResponseList'; + +import type { + PaginatedProjectViewListResponseList +} from '../../models/paginatedProjectViewListResponseList'; + +import type { + PaginatedProjectViewUserResponseList +} from '../../models/paginatedProjectViewUserResponseList'; + +import type { + PaginatedSocialAccountList +} from '../../models/paginatedSocialAccountList'; + +import type { + PaginatedUserListResponseList +} from '../../models/paginatedUserListResponseList'; + +import type { + ProjectViewExportCreateResponse +} from '../../models/projectViewExportCreateResponse'; + +import type { + ProjectViewExportResponse +} from '../../models/projectViewExportResponse'; + +import type { + ProjectViewListResponse +} from '../../models/projectViewListResponse'; + +import type { + ServiceUsageBalanceData +} from '../../models/serviceUsageBalanceData'; + +import type { + ServiceUsageResponse +} from '../../models/serviceUsageResponse'; + +import type { + SocialAccount +} from '../../models/socialAccount'; + +import type { + UserRetrieveResponse +} from '../../models/userRetrieveResponse'; + + +export const getApiV2AssetUsageListResponseMock = (overrideResponse: Partial< PaginatedAssetUsageResponseList > = {}): PaginatedAssetUsageResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({asset: faker.internet.url(), asset__name: faker.string.alpha({length: {min: 10, max: 20}}), nlp_usage_current_period: {total_nlp_asr_seconds: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_mt_characters: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_llm_requests: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, nlp_usage_all_time: {total_nlp_asr_seconds: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_mt_characters: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_llm_requests: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, storage_bytes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), submission_count_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), submission_count_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})})), ...overrideResponse}) + +export const getApiV2OrganizationsListResponseMock = (overrideResponse: Partial< PaginatedOrganizationResponseList > = {}): PaginatedOrganizationResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 200}}), website: faker.string.alpha({length: {min: 10, max: 255}}), organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, is_owner: faker.datatype.boolean(), is_mmo: faker.datatype.boolean(), request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), members: faker.internet.url(), assets: faker.internet.url(), service_usage: faker.internet.url(), asset_usage: faker.internet.url()})), ...overrideResponse}) + +export const getApiV2OrganizationsRetrieveResponseMock = (overrideResponse: Partial< OrganizationResponse > = {}): OrganizationResponse => ({id: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 200}}), website: faker.string.alpha({length: {min: 10, max: 255}}), organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, is_owner: faker.datatype.boolean(), is_mmo: faker.datatype.boolean(), request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), members: faker.internet.url(), assets: faker.internet.url(), service_usage: faker.internet.url(), asset_usage: faker.internet.url(), ...overrideResponse}) + +export const getApiV2OrganizationsPartialUpdateResponseMock = (overrideResponse: Partial< OrganizationResponse > = {}): OrganizationResponse => ({id: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 200}}), website: faker.string.alpha({length: {min: 10, max: 255}}), organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, is_owner: faker.datatype.boolean(), is_mmo: faker.datatype.boolean(), request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), members: faker.internet.url(), assets: faker.internet.url(), service_usage: faker.internet.url(), asset_usage: faker.internet.url(), ...overrideResponse}) + +export const getApiV2OrganizationsAssetUsageListResponseMock = (overrideResponse: Partial< PaginatedCustomAssetUsageList > = {}): PaginatedCustomAssetUsageList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({asset: faker.internet.url(), asset__name: faker.string.alpha({length: {min: 10, max: 20}}), nlp_usage_current_period: {...{total_nlp_asr_seconds: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_llm_requests: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_mt_characters: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},}, nlp_usage_all_time: {...{total_nlp_asr_seconds: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_llm_requests: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_mt_characters: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},}, storage_bytes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), submission_count_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), submission_count_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment_status: faker.helpers.arrayElement(Object.values(CustomAssetUsageDeploymentStatusEnum))})), ...overrideResponse}) + +export const getApiV2OrganizationsAssetsRetrieveResponseMock = (overrideResponse: Partial< PaginatedAssetList > = {}): PaginatedAssetList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {} + })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { + [faker.string.alphanumeric(5)]: {} + }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { + [faker.string.alphanumeric(5)]: {} + }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), ...overrideResponse}) + +export const getApiV2OrganizationsAssetsCountsRetrieveResponseMock = (overrideResponse: Partial< AssetListCount > = {}): AssetListCount => ({deployed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), archived_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), draft_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), ...overrideResponse}) + +export const getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock = (overrideResponse: Partial< PaginatedAssetMinimalListList > = {}): PaginatedAssetMinimalListList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 22}}), name: faker.string.alpha({length: {min: 10, max: 20}}), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum))})), ...overrideResponse}) + +export const getApiV2OrganizationsInvitesListResponseMock = (overrideResponse: Partial< PaginatedInviteResponseList > = {}): PaginatedInviteResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) + +export const getApiV2OrganizationsInvitesCreateResponseMock = (): InviteCreateResponse => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), invited_by: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), invitee_role: faker.helpers.arrayElement(['admin','member'] as const), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}})}))) + +export const getApiV2OrganizationsInvitesRetrieveResponseMock = (overrideResponse: Partial< InviteResponse > = {}): InviteResponse => ({invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2OrganizationsInvitesPartialUpdateResponseMock = (overrideResponse: Partial< InviteResponse > = {}): InviteResponse => ({invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getApiV2OrganizationsMembersListResponseMock = (overrideResponse: Partial< PaginatedMemberListResponseList > = {}): PaginatedMemberListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), url: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), user__email: faker.internet.email(), user__extra_details__name: faker.string.alpha({length: {min: 10, max: 20}}), user__has_mfa_enabled: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, user__is_active: faker.datatype.boolean(), invite: {...{invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}})},}})), ...overrideResponse}) + +export const getApiV2OrganizationsMembersRetrieveResponseMock = (overrideResponse: Partial< MemberListResponse > = {}): MemberListResponse => ({role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), url: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), user__email: faker.internet.email(), user__extra_details__name: faker.string.alpha({length: {min: 10, max: 20}}), user__has_mfa_enabled: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, user__is_active: faker.datatype.boolean(), invite: {...{invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}})},}, ...overrideResponse}) + +export const getApiV2OrganizationsMembersPartialUpdateResponseMock = (overrideResponse: Partial< MemberListResponse > = {}): MemberListResponse => ({role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), url: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), user__email: faker.internet.email(), user__extra_details__name: faker.string.alpha({length: {min: 10, max: 20}}), user__has_mfa_enabled: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, user__is_active: faker.datatype.boolean(), invite: {...{invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}})},}, ...overrideResponse}) + +export const getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock = (overrideResponse: Partial = {}): ServiceUsageBalanceData => ({...{effective_limit: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_value: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_percent: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), exceeded: faker.datatype.boolean()}, ...overrideResponse}); + +export const getApiV2OrganizationsServiceUsageRetrieveResponseMock = (overrideResponse: Partial< OrganizationServiceUsageResponse > = {}): OrganizationServiceUsageResponse => ({total_nlp_usage: {asr_seconds_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), asr_seconds_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, total_storage_bytes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_submission_count: {all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, balances: {submission: faker.helpers.arrayElement([{...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock()},null,]), storage_bytes: faker.helpers.arrayElement([{...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock()},null,]), asr_seconds: faker.helpers.arrayElement([{...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock()},null,]), mt_characters: faker.helpers.arrayElement([{...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock()},null,]), llm_requests: faker.helpers.arrayElement([{...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock()},null,])}, current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, ...overrideResponse}) + +export const getApiV2ProjectViewsListResponseMock = (overrideResponse: Partial< PaginatedProjectViewListResponseList > = {}): PaginatedProjectViewListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 32}}), name: faker.internet.url(), url: faker.internet.url(), assets: faker.internet.url(), assets_export: faker.internet.url(), users: faker.internet.url(), users_export: faker.internet.url(), countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}})))})), ...overrideResponse}) + +export const getApiV2ProjectViewsRetrieveResponseMock = (overrideResponse: Partial< ProjectViewListResponse > = {}): ProjectViewListResponse => ({uid: faker.string.alpha({length: {min: 10, max: 32}}), name: faker.internet.url(), url: faker.internet.url(), assets: faker.internet.url(), assets_export: faker.internet.url(), users: faker.internet.url(), users_export: faker.internet.url(), countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) + +export const getApiV2ProjectViewsExportRetrieveResponseMock = (overrideResponse: Partial< ProjectViewExportResponse > = {}): ProjectViewExportResponse => ({status: faker.string.alpha({length: {min: 10, max: 32}}), result: faker.internet.url(), ...overrideResponse}) + +export const getApiV2ProjectViewsExportCreateResponseMock = (overrideResponse: Partial< ProjectViewExportCreateResponse > = {}): ProjectViewExportCreateResponse => ({status: faker.string.alpha({length: {min: 10, max: 32}}), ...overrideResponse}) + +export const getApiV2ProjectViewsAssetsRetrieveResponseMock = (overrideResponse: Partial< PaginatedProjectViewAssetResponseList > = {}): PaginatedProjectViewAssetResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), owner__email: faker.internet.email(), owner__name: faker.string.alpha({length: {min: 10, max: 20}}), owner__organization: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), settings: {sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), has_deployment: faker.datatype.boolean(), deployment__active: faker.datatype.boolean(), deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment_status: faker.string.alpha({length: {min: 10, max: 20}}), asset_type: faker.string.alpha({length: {min: 10, max: 20}}), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.internet.url(), undefined])})), owner_label: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) + +export const getApiV2ProjectViewsAssetsCountsRetrieveResponseMock = (overrideResponse: Partial< AssetListCount > = {}): AssetListCount => ({deployed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), archived_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), draft_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), ...overrideResponse}) + +export const getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock = (overrideResponse: Partial< PaginatedAssetMinimalListList > = {}): PaginatedAssetMinimalListList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 22}}), name: faker.string.alpha({length: {min: 10, max: 20}}), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum))})), ...overrideResponse}) + +export const getApiV2ProjectViewsUsersRetrieveResponseMock = (overrideResponse: Partial< PaginatedProjectViewUserResponseList > = {}): PaginatedProjectViewUserResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), username: faker.string.alpha({length: {min: 10, max: 20}}), is_superuser: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, is_active: faker.datatype.boolean(), email: faker.internet.email(), asset_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), metadata: {city: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), sector: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_ui_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_website: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_view_settings: faker.helpers.arrayElement([{my_project_view_name: faker.helpers.arrayElement([{order: faker.helpers.arrayElement([{}, undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}})), ...overrideResponse}) + +export const getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock = (overrideResponse: Partial = {}): ServiceUsageBalanceData => ({...{effective_limit: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_value: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_percent: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), exceeded: faker.datatype.boolean()}, ...overrideResponse}); + +export const getApiV2ServiceUsageListResponseMock = (): ServiceUsageResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({total_nlp_usage: {asr_seconds_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), asr_seconds_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, total_storage_bytes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_submission_count: {all_time: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), current_period: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, balances: {submission: faker.helpers.arrayElement([{...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock()},null,]), storage_bytes: faker.helpers.arrayElement([{...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock()},null,]), asr_seconds: faker.helpers.arrayElement([{...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock()},null,]), mt_characters: faker.helpers.arrayElement([{...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock()},null,]), llm_requests: faker.helpers.arrayElement([{...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock()},null,])}, current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`}))) + +export const getApiV2UsersListResponseMock = (overrideResponse: Partial< PaginatedUserListResponseList > = {}): PaginatedUserListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), username: faker.string.alpha({length: {min: 10, max: 20}}), is_superuser: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, is_active: faker.datatype.boolean(), email: faker.internet.email(), asset_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), metadata: {name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), sector: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_ui_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_website: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_views_settings: faker.helpers.arrayElement([{kobo_my_project: faker.helpers.arrayElement([{order: faker.helpers.arrayElement([{}, undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}})), ...overrideResponse}) + +export const getApiV2UsersRetrieveResponseMock = (overrideResponse: Partial< UserRetrieveResponse > = {}): UserRetrieveResponse => ({url: faker.internet.url(), username: faker.string.alpha({length: {min: 10, max: 20}}), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, public_collection_subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), public_collections_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), ...overrideResponse}) + +export const getMeRetrieveResponseMock = (overrideResponse: Partial< MeListResponse > = {}): MeListResponse => ({username: faker.string.alpha({length: {min: 10, max: 20}}), first_name: faker.string.alpha({length: {min: 10, max: 20}}), last_name: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.internet.email(), server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, projects_url: faker.internet.url(), gravatar: faker.internet.url(), last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), extra_details: {bio: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), city: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), sector: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), twitter: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), linkedin: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), instagram: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_ui_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_website: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_views_settings: faker.helpers.arrayElement([{}, undefined]), require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), newsletter_subscription: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, git_rev: faker.helpers.arrayElement([faker.datatype.boolean(),{short: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), long: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), branch: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), tag: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined])},]), social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({provider: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), email: faker.helpers.arrayElement([faker.internet.email(), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), validated_password: faker.datatype.boolean(), accepted_tos: faker.datatype.boolean(), organization: {url: faker.helpers.arrayElement([faker.internet.url(), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, extra_details__uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getMePartialUpdateResponseMock = (overrideResponse: Partial< MeListResponse > = {}): MeListResponse => ({username: faker.string.alpha({length: {min: 10, max: 20}}), first_name: faker.string.alpha({length: {min: 10, max: 20}}), last_name: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.internet.email(), server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, projects_url: faker.internet.url(), gravatar: faker.internet.url(), last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), extra_details: {bio: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), city: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), sector: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), twitter: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), linkedin: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), instagram: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_ui_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_website: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_views_settings: faker.helpers.arrayElement([{}, undefined]), require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), newsletter_subscription: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, git_rev: faker.helpers.arrayElement([faker.datatype.boolean(),{short: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), long: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), branch: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), tag: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined])},]), social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({provider: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), email: faker.helpers.arrayElement([faker.internet.email(), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), validated_password: faker.datatype.boolean(), accepted_tos: faker.datatype.boolean(), organization: {url: faker.helpers.arrayElement([faker.internet.url(), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, extra_details__uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + +export const getMeEmailsListResponseMock = (overrideResponse: Partial< PaginatedEmailAddressList > = {}): PaginatedEmailAddressList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) + +export const getMeEmailsCreateResponseMock = (overrideResponse: Partial< EmailAddress > = {}): EmailAddress => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean(), ...overrideResponse}) + +export const getMeSocialAccountsListResponseMock = (overrideResponse: Partial< PaginatedSocialAccountList > = {}): PaginatedSocialAccountList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({provider: faker.string.alpha({length: {min: 10, max: 200}}), uid: faker.string.alpha({length: {min: 10, max: 191}}), last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, email: faker.internet.email(), username: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) + +export const getMeSocialAccountsRetrieveResponseMock = (overrideResponse: Partial< SocialAccount > = {}): SocialAccount => ({provider: faker.string.alpha({length: {min: 10, max: 200}}), uid: faker.string.alpha({length: {min: 10, max: 191}}), last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, email: faker.internet.email(), username: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) + + +export const getApiV2AssetUsageListMockHandler = (overrideResponse?: PaginatedAssetUsageResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetUsageResponseList)) => { + return http.get('*/api/v2/asset_usage/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2AssetUsageListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsListMockHandler = (overrideResponse?: PaginatedOrganizationResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedOrganizationResponseList)) => { + return http.get('*/api/v2/organizations/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsRetrieveMockHandler = (overrideResponse?: OrganizationResponse | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse)) => { + return http.get('*/api/v2/organizations/:uidOrganization/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsPartialUpdateMockHandler = (overrideResponse?: OrganizationResponse | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse)) => { + return http.patch('*/api/v2/organizations/:uidOrganization/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsAssetUsageListMockHandler = (overrideResponse?: PaginatedCustomAssetUsageList | ((info: Parameters[1]>[0]) => Promise | PaginatedCustomAssetUsageList)) => { + return http.get('*/api/v2/organizations/:uidOrganization/asset_usage/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsAssetUsageListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsAssetsRetrieveMockHandler = (overrideResponse?: PaginatedAssetList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList)) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsAssetsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsAssetsCountsRetrieveMockHandler = (overrideResponse?: AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount)) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/counts/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsAssetsCountsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler = (overrideResponse?: PaginatedAssetMinimalListList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetMinimalListList)) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsInvitesListMockHandler = (overrideResponse?: PaginatedInviteResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedInviteResponseList)) => { + return http.get('*/api/v2/organizations/:uidOrganization/invites/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsInvitesListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsInvitesCreateMockHandler = (overrideResponse?: InviteCreateResponse | ((info: Parameters[1]>[0]) => Promise | InviteCreateResponse)) => { + return http.post('*/api/v2/organizations/:uidOrganization/invites/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsInvitesCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsInvitesRetrieveMockHandler = (overrideResponse?: InviteResponse | ((info: Parameters[1]>[0]) => Promise | InviteResponse)) => { + return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsInvitesRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = (overrideResponse?: InviteResponse | ((info: Parameters[1]>[0]) => Promise | InviteResponse)) => { + return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsInvitesPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsInvitesDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2OrganizationsMembersListMockHandler = (overrideResponse?: PaginatedMemberListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedMemberListResponseList)) => { + return http.get('*/api/v2/organizations/:uidOrganization/members/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsMembersListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsMembersRetrieveMockHandler = (overrideResponse?: MemberListResponse | ((info: Parameters[1]>[0]) => Promise | MemberListResponse)) => { + return http.get('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsMembersRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsMembersPartialUpdateMockHandler = (overrideResponse?: MemberListResponse | ((info: Parameters[1]>[0]) => Promise | MemberListResponse)) => { + return http.patch('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsMembersPartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2OrganizationsMembersDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getApiV2OrganizationsServiceUsageRetrieveMockHandler = (overrideResponse?: OrganizationServiceUsageResponse | ((info: Parameters[1]>[0]) => Promise | OrganizationServiceUsageResponse)) => { + return http.get('*/api/v2/organizations/:uidOrganization/service_usage/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2OrganizationsServiceUsageRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectViewsListMockHandler = (overrideResponse?: PaginatedProjectViewListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedProjectViewListResponseList)) => { + return http.get('*/api/v2/project-views/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectViewsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectViewsRetrieveMockHandler = (overrideResponse?: ProjectViewListResponse | ((info: Parameters[1]>[0]) => Promise | ProjectViewListResponse)) => { + return http.get('*/api/v2/project-views/:uidProjectView/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectViewsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectViewsExportRetrieveMockHandler = (overrideResponse?: ProjectViewExportResponse | ((info: Parameters[1]>[0]) => Promise | ProjectViewExportResponse)) => { + return http.get('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectViewsExportRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectViewsExportCreateMockHandler = (overrideResponse?: ProjectViewExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ProjectViewExportCreateResponse)) => { + return http.post('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectViewsExportCreateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectViewsAssetsRetrieveMockHandler = (overrideResponse?: PaginatedProjectViewAssetResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedProjectViewAssetResponseList)) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectViewsAssetsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectViewsAssetsCountsRetrieveMockHandler = (overrideResponse?: AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount)) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/counts/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectViewsAssetsCountsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler = (overrideResponse?: PaginatedAssetMinimalListList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetMinimalListList)) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ProjectViewsUsersRetrieveMockHandler = (overrideResponse?: PaginatedProjectViewUserResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedProjectViewUserResponseList)) => { + return http.get('*/api/v2/project-views/:uidProjectView/users/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ProjectViewsUsersRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2ServiceUsageListMockHandler = (overrideResponse?: ServiceUsageResponse[] | ((info: Parameters[1]>[0]) => Promise | ServiceUsageResponse[])) => { + return http.get('*/api/v2/service_usage/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2ServiceUsageListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2UsersListMockHandler = (overrideResponse?: PaginatedUserListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedUserListResponseList)) => { + return http.get('*/api/v2/users/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2UsersListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getApiV2UsersRetrieveMockHandler = (overrideResponse?: UserRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | UserRetrieveResponse)) => { + return http.get('*/api/v2/users/:username/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getApiV2UsersRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getMeRetrieveMockHandler = (overrideResponse?: MeListResponse | ((info: Parameters[1]>[0]) => Promise | MeListResponse)) => { + return http.get('*/me/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getMeRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getMePartialUpdateMockHandler = (overrideResponse?: MeListResponse | ((info: Parameters[1]>[0]) => Promise | MeListResponse)) => { + return http.patch('*/me/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getMePartialUpdateResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getMeDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/me/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} + +export const getMeEmailsListMockHandler = (overrideResponse?: PaginatedEmailAddressList | ((info: Parameters[1]>[0]) => Promise | PaginatedEmailAddressList)) => { + return http.get('*/me/emails/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getMeEmailsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getMeEmailsCreateMockHandler = (overrideResponse?: EmailAddress | ((info: Parameters[1]>[0]) => Promise | EmailAddress)) => { + return http.post('*/me/emails/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getMeEmailsCreateResponseMock()), + { status: 201, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getMeSocialAccountsListMockHandler = (overrideResponse?: PaginatedSocialAccountList | ((info: Parameters[1]>[0]) => Promise | PaginatedSocialAccountList)) => { + return http.get('*/me/social-accounts/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getMeSocialAccountsListResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getMeSocialAccountsRetrieveMockHandler = (overrideResponse?: SocialAccount | ((info: Parameters[1]>[0]) => Promise | SocialAccount)) => { + return http.get('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined + ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) + : getMeSocialAccountsRetrieveResponseMock()), + { status: 200, + headers: { 'Content-Type': 'application/json' } + }) + }) +} + +export const getMeSocialAccountsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { + return http.delete('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } + return new HttpResponse(null, + { status: 204, + + }) + }) +} +export const getUserTeamOrganizationUsageMock = () => [ + getApiV2AssetUsageListMockHandler(), + getApiV2OrganizationsListMockHandler(), + getApiV2OrganizationsRetrieveMockHandler(), + getApiV2OrganizationsPartialUpdateMockHandler(), + getApiV2OrganizationsAssetUsageListMockHandler(), + getApiV2OrganizationsAssetsRetrieveMockHandler(), + getApiV2OrganizationsAssetsCountsRetrieveMockHandler(), + getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler(), + getApiV2OrganizationsInvitesListMockHandler(), + getApiV2OrganizationsInvitesCreateMockHandler(), + getApiV2OrganizationsInvitesRetrieveMockHandler(), + getApiV2OrganizationsInvitesPartialUpdateMockHandler(), + getApiV2OrganizationsInvitesDestroyMockHandler(), + getApiV2OrganizationsMembersListMockHandler(), + getApiV2OrganizationsMembersRetrieveMockHandler(), + getApiV2OrganizationsMembersPartialUpdateMockHandler(), + getApiV2OrganizationsMembersDestroyMockHandler(), + getApiV2OrganizationsServiceUsageRetrieveMockHandler(), + getApiV2ProjectViewsListMockHandler(), + getApiV2ProjectViewsRetrieveMockHandler(), + getApiV2ProjectViewsExportRetrieveMockHandler(), + getApiV2ProjectViewsExportCreateMockHandler(), + getApiV2ProjectViewsAssetsRetrieveMockHandler(), + getApiV2ProjectViewsAssetsCountsRetrieveMockHandler(), + getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler(), + getApiV2ProjectViewsUsersRetrieveMockHandler(), + getApiV2ServiceUsageListMockHandler(), + getApiV2UsersListMockHandler(), + getApiV2UsersRetrieveMockHandler(), + getMeRetrieveMockHandler(), + getMePartialUpdateMockHandler(), + getMeDestroyMockHandler(), + getMeEmailsListMockHandler(), + getMeEmailsCreateMockHandler(), + getMeSocialAccountsListMockHandler(), + getMeSocialAccountsRetrieveMockHandler(), + getMeSocialAccountsDestroyMockHandler() +] diff --git a/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.msw.ts b/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.msw.ts deleted file mode 100644 index 1acb66798f..0000000000 --- a/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.msw.ts +++ /dev/null @@ -1,2287 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { faker } from '@faker-js/faker' - -import { http, HttpResponse } from 'msw' - -import { AssetDeploymentStatusEnum } from '../../models/assetDeploymentStatusEnum' - -import type { AssetListCount } from '../../models/assetListCount' - -import { AssetTypeEnum } from '../../models/assetTypeEnum' - -import { CustomAssetUsageDeploymentStatusEnum } from '../../models/customAssetUsageDeploymentStatusEnum' - -import type { EmailAddress } from '../../models/emailAddress' - -import type { InviteCreateResponse } from '../../models/inviteCreateResponse' - -import type { InviteResponse } from '../../models/inviteResponse' - -import { InviteStatusChoicesEnum } from '../../models/inviteStatusChoicesEnum' - -import { InviteeRoleEnum } from '../../models/inviteeRoleEnum' - -import type { MeListResponse } from '../../models/meListResponse' - -import type { MemberListResponse } from '../../models/memberListResponse' - -import { MemberRoleEnum } from '../../models/memberRoleEnum' - -import type { OrganizationResponse } from '../../models/organizationResponse' - -import type { OrganizationServiceUsageResponse } from '../../models/organizationServiceUsageResponse' - -import { OrganizationTypeEnum } from '../../models/organizationTypeEnum' - -import type { PaginatedAssetList } from '../../models/paginatedAssetList' - -import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' - -import type { PaginatedAssetUsageResponseList } from '../../models/paginatedAssetUsageResponseList' - -import type { PaginatedCustomAssetUsageList } from '../../models/paginatedCustomAssetUsageList' - -import type { PaginatedEmailAddressList } from '../../models/paginatedEmailAddressList' - -import type { PaginatedInviteResponseList } from '../../models/paginatedInviteResponseList' - -import type { PaginatedMemberListResponseList } from '../../models/paginatedMemberListResponseList' - -import type { PaginatedOrganizationResponseList } from '../../models/paginatedOrganizationResponseList' - -import type { PaginatedProjectViewAssetResponseList } from '../../models/paginatedProjectViewAssetResponseList' - -import type { PaginatedProjectViewListResponseList } from '../../models/paginatedProjectViewListResponseList' - -import type { PaginatedProjectViewUserResponseList } from '../../models/paginatedProjectViewUserResponseList' - -import type { PaginatedSocialAccountList } from '../../models/paginatedSocialAccountList' - -import type { PaginatedUserListResponseList } from '../../models/paginatedUserListResponseList' - -import type { ProjectViewExportCreateResponse } from '../../models/projectViewExportCreateResponse' - -import type { ProjectViewExportResponse } from '../../models/projectViewExportResponse' - -import type { ProjectViewListResponse } from '../../models/projectViewListResponse' - -import type { ServiceUsageBalanceData } from '../../models/serviceUsageBalanceData' - -import type { ServiceUsageResponse } from '../../models/serviceUsageResponse' - -import type { SocialAccount } from '../../models/socialAccount' - -import type { UserRetrieveResponse } from '../../models/userRetrieveResponse' - -export const getApiV2AssetUsageListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetUsageResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - asset: faker.internet.url(), - asset__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - nlp_usage_current_period: { - total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - nlp_usage_all_time: { - total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - submission_count_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - submission_count_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedOrganizationResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - website: faker.string.alpha({ length: { min: 10, max: 255 } }), - organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_owner: faker.datatype.boolean(), - is_mmo: faker.datatype.boolean(), - request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - members: faker.internet.url(), - assets: faker.internet.url(), - service_usage: faker.internet.url(), - asset_usage: faker.internet.url(), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): OrganizationResponse => ({ - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - website: faker.string.alpha({ length: { min: 10, max: 255 } }), - organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_owner: faker.datatype.boolean(), - is_mmo: faker.datatype.boolean(), - request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - members: faker.internet.url(), - assets: faker.internet.url(), - service_usage: faker.internet.url(), - asset_usage: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2OrganizationsPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): OrganizationResponse => ({ - id: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - name: faker.string.alpha({ length: { min: 10, max: 200 } }), - website: faker.string.alpha({ length: { min: 10, max: 255 } }), - organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_owner: faker.datatype.boolean(), - is_mmo: faker.datatype.boolean(), - request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - members: faker.internet.url(), - assets: faker.internet.url(), - service_usage: faker.internet.url(), - asset_usage: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2OrganizationsAssetUsageListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedCustomAssetUsageList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - asset: faker.internet.url(), - asset__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - nlp_usage_current_period: { - ...{ - total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - nlp_usage_all_time: { - ...{ - total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - }, - storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - submission_count_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - submission_count_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment_status: faker.helpers.arrayElement(Object.values(CustomAssetUsageDeploymentStatusEnum)), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - settings: faker.helpers.arrayElement([ - { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - organization: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - }, - undefined, - ]), - asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), - files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - metadata: faker.helpers.arrayElement([{}, undefined]), - })), - summary: { - geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - labels: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - columns: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - row_count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - name_quality: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - bad: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - good: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - total: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - firsts: faker.helpers.arrayElement([ - { - ok: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - bad: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - index: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - default_translation: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - naming_conflicts: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_deployed: faker.helpers.arrayElement([ - faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - undefined, - ]), - version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - has_deployment: faker.datatype.boolean(), - deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployed_versions: { - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.internet.url(), - content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - })), - }, - deployment__links: {}, - deployment__active: faker.datatype.boolean(), - deployment__data_download_links: { - csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls: faker.string.alpha({ length: { min: 10, max: 20 } }), - zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment__last_submission_time: faker.helpers.arrayElement([ - `${faker.date.past().toISOString().split('.')[0]}Z`, - null, - ]), - deployment__encrypted: faker.datatype.boolean(), - deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - report_styles: faker.helpers.arrayElement([ - { - default: faker.helpers.arrayElement([ - { - groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - report_colors: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translationIndex: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - graphWidth: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - undefined, - ]), - specified: faker.helpers.arrayElement([{}, undefined]), - kuid_names: faker.helpers.arrayElement([{}, undefined]), - }, - undefined, - ]), - report_custom: faker.helpers.arrayElement([{}, undefined]), - advanced_features: faker.helpers.arrayElement([ - { - transcript: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - translation: faker.helpers.arrayElement([ - { - values: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - languages: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - qual: faker.helpers.arrayElement([ - { - qual_survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - scope: faker.string.alpha({ length: { min: 10, max: 20 } }), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - options: faker.helpers.arrayElement([ - { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, - undefined, - ]), - })), - undefined, - ]), - })), - undefined, - ]), - }, - undefined, - ]), - _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_styles: faker.helpers.arrayElement([ - { - colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - map_custom: faker.helpers.arrayElement([{}, undefined]), - content: faker.helpers.arrayElement([ - { - schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - survey: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.string.alpha({ length: { min: 10, max: 20 } }), - $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - hint: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--matrix_list': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-constraint-message': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--rank-items': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--score-choices': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - tags: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - select_from_list_name: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - 'body::accept': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - })), - undefined, - ]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), - $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - 'media::image': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - settings: faker.helpers.arrayElement([ - { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - 'kobo--locking-profile': faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - default_language: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - }, - undefined, - ]), - translated: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - translations: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - ), - undefined, - ]), - translations_0: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - undefined, - ]), - 'kobo--locking-profiles': faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {}, - })), - undefined, - ]), - }, - undefined, - ]), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - analysis_form_json: { - additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - source: faker.string.alpha({ length: { min: 10, max: 20 } }), - type: faker.helpers.arrayElement([ - 'transcript', - 'translation', - 'qualVerification', - 'qualSource', - 'qualInteger', - 'qualTags', - 'qualText', - 'qualNote', - 'qualAutoKeywordCount', - 'qualSelectMultiple', - 'qualSelectOne', - ] as const), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - choices: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), - labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, - })), - undefined, - ]), - })), - }, - xform_link: faker.internet.url(), - hooks_link: faker.internet.url(), - tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - kind: faker.string.alpha({ length: { min: 10, max: 20 } }), - xls_link: faker.internet.url(), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), - assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - label: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - })), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - user: faker.string.alpha({ length: { min: 10, max: 20 } }), - permission: faker.string.alpha({ length: { min: 10, max: 20 } }), - partial_permissions: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), - undefined, - ]), - })), - undefined, - ]), - label: faker.helpers.arrayElement([ - faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - { - default: faker.string.alpha({ length: { min: 10, max: 20 } }), - view_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - change_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - delete_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - validate_submissions: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - ]), - undefined, - ]), - })), - effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - exports: faker.internet.url(), - export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - url: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), - data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - export_settings: { - [faker.string.alphanumeric(5)]: {}, - }, - })), - data: faker.internet.url(), - children: { - count: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - data_sharing: faker.helpers.arrayElement([{}, undefined]), - paired_data: faker.internet.url(), - project_ownership: { - [faker.string.alphanumeric(5)]: {}, - }, - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsAssetsCountsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetListCount => ({ - deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetMinimalListList => ({ - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 22 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsInvitesListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedInviteResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsInvitesCreateResponseMock = (): InviteCreateResponse => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - invited_by: faker.internet.url(), - status: faker.string.alpha({ length: { min: 10, max: 20 } }), - invitee_role: faker.helpers.arrayElement(['admin', 'member'] as const), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - })) - -export const getApiV2OrganizationsInvitesRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): InviteResponse => ({ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2OrganizationsInvitesPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): InviteResponse => ({ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2OrganizationsMembersListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedMemberListResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - url: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__email: faker.internet.email(), - user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__has_mfa_enabled: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - user__is_active: faker.datatype.boolean(), - invite: { - ...{ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - })), - ...overrideResponse, -}) - -export const getApiV2OrganizationsMembersRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): MemberListResponse => ({ - role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - url: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__email: faker.internet.email(), - user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__has_mfa_enabled: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - user__is_active: faker.datatype.boolean(), - invite: { - ...{ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2OrganizationsMembersPartialUpdateResponseMock = ( - overrideResponse: Partial = {}, -): MemberListResponse => ({ - role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), - url: faker.internet.url(), - user: faker.internet.url(), - user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__email: faker.internet.email(), - user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - user__has_mfa_enabled: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - user__is_active: faker.datatype.boolean(), - invite: { - ...{ - invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), - status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), - url: faker.internet.url(), - invited_by: faker.internet.url(), - organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - created: `${faker.date.past().toISOString().split('.')[0]}Z`, - modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), - }, - }, - ...overrideResponse, -}) - -export const getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock = ( - overrideResponse: Partial = {}, -): ServiceUsageBalanceData => ({ - ...{ - effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - exceeded: faker.datatype.boolean(), - }, - ...overrideResponse, -}) - -export const getApiV2OrganizationsServiceUsageRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): OrganizationServiceUsageResponse => ({ - total_nlp_usage: { - asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_submission_count: { - all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - balances: { - submission: faker.helpers.arrayElement([ - { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, - null, - ]), - storage_bytes: faker.helpers.arrayElement([ - { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, - null, - ]), - asr_seconds: faker.helpers.arrayElement([ - { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, - null, - ]), - mt_characters: faker.helpers.arrayElement([ - { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, - null, - ]), - llm_requests: faker.helpers.arrayElement([ - { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, - null, - ]), - }, - current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, - current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, - ...overrideResponse, -}) - -export const getApiV2ProjectViewsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedProjectViewListResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 32 } }), - name: faker.internet.url(), - url: faker.internet.url(), - assets: faker.internet.url(), - assets_export: faker.internet.url(), - users: faker.internet.url(), - users_export: faker.internet.url(), - countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ProjectViewListResponse => ({ - uid: faker.string.alpha({ length: { min: 10, max: 32 } }), - name: faker.internet.url(), - url: faker.internet.url(), - assets: faker.internet.url(), - assets_export: faker.internet.url(), - users: faker.internet.url(), - users_export: faker.internet.url(), - countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsExportRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): ProjectViewExportResponse => ({ - status: faker.string.alpha({ length: { min: 10, max: 32 } }), - result: faker.internet.url(), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsExportCreateResponseMock = ( - overrideResponse: Partial = {}, -): ProjectViewExportCreateResponse => ({ - status: faker.string.alpha({ length: { min: 10, max: 32 } }), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsAssetsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedProjectViewAssetResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - url: faker.internet.url(), - date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, - owner: faker.internet.url(), - owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), - owner__email: faker.internet.email(), - owner__name: faker.string.alpha({ length: { min: 10, max: 20 } }), - owner__organization: faker.string.alpha({ length: { min: 10, max: 20 } }), - uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - settings: { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), - description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country_codes: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - operational_purpose: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - has_deployment: faker.datatype.boolean(), - deployment__active: faker.datatype.boolean(), - deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - deployment_status: faker.string.alpha({ length: { min: 10, max: 20 } }), - asset_type: faker.string.alpha({ length: { min: 10, max: 20 } }), - downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - })), - owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsAssetsCountsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): AssetListCount => ({ - deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedAssetMinimalListList => ({ - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - uid: faker.string.alpha({ length: { min: 10, max: 22 } }), - name: faker.string.alpha({ length: { min: 10, max: 20 } }), - deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), - })), - ...overrideResponse, -}) - -export const getApiV2ProjectViewsUsersRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedProjectViewUserResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_superuser: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_active: faker.datatype.boolean(), - email: faker.internet.email(), - asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - metadata: { - city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_website: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - project_view_settings: faker.helpers.arrayElement([ - { - my_project_view_name: faker.helpers.arrayElement([ - { - order: faker.helpers.arrayElement([{}, undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock = ( - overrideResponse: Partial = {}, -): ServiceUsageBalanceData => ({ - ...{ - effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - exceeded: faker.datatype.boolean(), - }, - ...overrideResponse, -}) - -export const getApiV2ServiceUsageListResponseMock = (): ServiceUsageResponse[] => - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - total_nlp_usage: { - asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - }, - total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - total_submission_count: { - all_time: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - current_period: faker.helpers.arrayElement([ - faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - undefined, - ]), - }, - balances: { - submission: faker.helpers.arrayElement([ - { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, - null, - ]), - storage_bytes: faker.helpers.arrayElement([ - { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, - null, - ]), - asr_seconds: faker.helpers.arrayElement([ - { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, - null, - ]), - mt_characters: faker.helpers.arrayElement([ - { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, - null, - ]), - llm_requests: faker.helpers.arrayElement([ - { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, - null, - ]), - }, - current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, - current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, - })) - -export const getApiV2UsersListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedUserListResponseList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - is_superuser: faker.datatype.boolean(), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, - is_active: faker.datatype.boolean(), - email: faker.internet.email(), - asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - metadata: { - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_website: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - project_views_settings: faker.helpers.arrayElement([ - { - kobo_my_project: faker.helpers.arrayElement([ - { - order: faker.helpers.arrayElement([{}, undefined]), - fields: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - filters: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), - undefined, - ]), - }, - undefined, - ]), - }, - undefined, - ]), - }, - })), - ...overrideResponse, -}) - -export const getApiV2UsersRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): UserRetrieveResponse => ({ - url: faker.internet.url(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - public_collection_subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - public_collections_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - ...overrideResponse, -}) - -export const getMeRetrieveResponseMock = (overrideResponse: Partial = {}): MeListResponse => ({ - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.internet.email(), - server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - projects_url: faker.internet.url(), - gravatar: faker.internet.url(), - last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - extra_details: { - bio: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - twitter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - linkedin: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - instagram: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_website: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - project_views_settings: faker.helpers.arrayElement([{}, undefined]), - require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - newsletter_subscription: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - git_rev: faker.helpers.arrayElement([ - faker.datatype.boolean(), - { - short: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - long: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - branch: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - tag: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - }, - ]), - social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - email: faker.helpers.arrayElement([faker.internet.email(), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - validated_password: faker.datatype.boolean(), - accepted_tos: faker.datatype.boolean(), - organization: { - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - extra_details__uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getMePartialUpdateResponseMock = (overrideResponse: Partial = {}): MeListResponse => ({ - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), - email: faker.internet.email(), - server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - projects_url: faker.internet.url(), - gravatar: faker.internet.url(), - last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), - extra_details: { - bio: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - twitter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - linkedin: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - instagram: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - organization_website: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - project_views_settings: faker.helpers.arrayElement([{}, undefined]), - require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), - newsletter_subscription: faker.helpers.arrayElement([ - faker.string.alpha({ length: { min: 10, max: 20 } }), - undefined, - ]), - }, - git_rev: faker.helpers.arrayElement([ - faker.datatype.boolean(), - { - short: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - long: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - branch: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - tag: faker.helpers.arrayElement([ - faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), - undefined, - ]), - }, - ]), - social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), - email: faker.helpers.arrayElement([faker.internet.email(), undefined]), - username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - validated_password: faker.datatype.boolean(), - accepted_tos: faker.datatype.boolean(), - organization: { - url: faker.helpers.arrayElement([faker.internet.url(), undefined]), - name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - extra_details__uid: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getMeEmailsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedEmailAddressList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - })), - ...overrideResponse, -}) - -export const getMeEmailsCreateResponseMock = (overrideResponse: Partial = {}): EmailAddress => ({ - email: faker.string.alpha({ length: { min: 10, max: 20 } }), - primary: faker.datatype.boolean(), - verified: faker.datatype.boolean(), - ...overrideResponse, -}) - -export const getMeSocialAccountsListResponseMock = ( - overrideResponse: Partial = {}, -): PaginatedSocialAccountList => ({ - count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), - next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), - results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - provider: faker.string.alpha({ length: { min: 10, max: 200 } }), - uid: faker.string.alpha({ length: { min: 10, max: 191 } }), - last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - email: faker.internet.email(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - })), - ...overrideResponse, -}) - -export const getMeSocialAccountsRetrieveResponseMock = ( - overrideResponse: Partial = {}, -): SocialAccount => ({ - provider: faker.string.alpha({ length: { min: 10, max: 200 } }), - uid: faker.string.alpha({ length: { min: 10, max: 191 } }), - last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, - date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, - email: faker.internet.email(), - username: faker.string.alpha({ length: { min: 10, max: 20 } }), - ...overrideResponse, -}) - -export const getApiV2AssetUsageListMockHandler = ( - overrideResponse?: - | PaginatedAssetUsageResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetUsageResponseList), -) => { - return http.get('*/api/v2/asset_usage/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2AssetUsageListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsListMockHandler = ( - overrideResponse?: - | PaginatedOrganizationResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedOrganizationResponseList), -) => { - return http.get('*/api/v2/organizations/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsRetrieveMockHandler = ( - overrideResponse?: - | OrganizationResponse - | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsPartialUpdateMockHandler = ( - overrideResponse?: - | OrganizationResponse - | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), -) => { - return http.patch('*/api/v2/organizations/:uidOrganization/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsAssetUsageListMockHandler = ( - overrideResponse?: - | PaginatedCustomAssetUsageList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedCustomAssetUsageList), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/asset_usage/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsAssetUsageListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsAssetsRetrieveMockHandler = ( - overrideResponse?: - | PaginatedAssetList - | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsAssetsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsAssetsCountsRetrieveMockHandler = ( - overrideResponse?: - | AssetListCount - | ((info: Parameters[1]>[0]) => Promise | AssetListCount), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/counts/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsAssetsCountsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler = ( - overrideResponse?: - | PaginatedAssetMinimalListList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetMinimalListList), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsInvitesListMockHandler = ( - overrideResponse?: - | PaginatedInviteResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedInviteResponseList), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsInvitesListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsInvitesCreateMockHandler = ( - overrideResponse?: - | InviteCreateResponse - | ((info: Parameters[1]>[0]) => Promise | InviteCreateResponse), -) => { - return http.post('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsInvitesCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsInvitesRetrieveMockHandler = ( - overrideResponse?: - | InviteResponse - | ((info: Parameters[1]>[0]) => Promise | InviteResponse), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsInvitesRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = ( - overrideResponse?: - | InviteResponse - | ((info: Parameters[1]>[0]) => Promise | InviteResponse), -) => { - return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsInvitesPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsInvitesDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2OrganizationsMembersListMockHandler = ( - overrideResponse?: - | PaginatedMemberListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedMemberListResponseList), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/members/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsMembersListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsMembersRetrieveMockHandler = ( - overrideResponse?: - | MemberListResponse - | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsMembersRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsMembersPartialUpdateMockHandler = ( - overrideResponse?: - | MemberListResponse - | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), -) => { - return http.patch('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsMembersPartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2OrganizationsMembersDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getApiV2OrganizationsServiceUsageRetrieveMockHandler = ( - overrideResponse?: - | OrganizationServiceUsageResponse - | (( - info: Parameters[1]>[0], - ) => Promise | OrganizationServiceUsageResponse), -) => { - return http.get('*/api/v2/organizations/:uidOrganization/service_usage/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2OrganizationsServiceUsageRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsListMockHandler = ( - overrideResponse?: - | PaginatedProjectViewListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedProjectViewListResponseList), -) => { - return http.get('*/api/v2/project-views/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsRetrieveMockHandler = ( - overrideResponse?: - | ProjectViewListResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProjectViewListResponse), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsExportRetrieveMockHandler = ( - overrideResponse?: - | ProjectViewExportResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProjectViewExportResponse), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsExportRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsExportCreateMockHandler = ( - overrideResponse?: - | ProjectViewExportCreateResponse - | (( - info: Parameters[1]>[0], - ) => Promise | ProjectViewExportCreateResponse), -) => { - return http.post('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsExportCreateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsAssetsRetrieveMockHandler = ( - overrideResponse?: - | PaginatedProjectViewAssetResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedProjectViewAssetResponseList), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsAssetsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsAssetsCountsRetrieveMockHandler = ( - overrideResponse?: - | AssetListCount - | ((info: Parameters[1]>[0]) => Promise | AssetListCount), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/counts/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsAssetsCountsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler = ( - overrideResponse?: - | PaginatedAssetMinimalListList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedAssetMinimalListList), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ProjectViewsUsersRetrieveMockHandler = ( - overrideResponse?: - | PaginatedProjectViewUserResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedProjectViewUserResponseList), -) => { - return http.get('*/api/v2/project-views/:uidProjectView/users/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ProjectViewsUsersRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2ServiceUsageListMockHandler = ( - overrideResponse?: - | ServiceUsageResponse[] - | (( - info: Parameters[1]>[0], - ) => Promise | ServiceUsageResponse[]), -) => { - return http.get('*/api/v2/service_usage/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2ServiceUsageListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2UsersListMockHandler = ( - overrideResponse?: - | PaginatedUserListResponseList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedUserListResponseList), -) => { - return http.get('*/api/v2/users/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2UsersListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getApiV2UsersRetrieveMockHandler = ( - overrideResponse?: - | UserRetrieveResponse - | ((info: Parameters[1]>[0]) => Promise | UserRetrieveResponse), -) => { - return http.get('*/api/v2/users/:username/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getApiV2UsersRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeRetrieveMockHandler = ( - overrideResponse?: - | MeListResponse - | ((info: Parameters[1]>[0]) => Promise | MeListResponse), -) => { - return http.get('*/me/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMeRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMePartialUpdateMockHandler = ( - overrideResponse?: - | MeListResponse - | ((info: Parameters[1]>[0]) => Promise | MeListResponse), -) => { - return http.patch('*/me/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMePartialUpdateResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/me/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} - -export const getMeEmailsListMockHandler = ( - overrideResponse?: - | PaginatedEmailAddressList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedEmailAddressList), -) => { - return http.get('*/me/emails/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMeEmailsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeEmailsCreateMockHandler = ( - overrideResponse?: - | EmailAddress - | ((info: Parameters[1]>[0]) => Promise | EmailAddress), -) => { - return http.post('*/me/emails/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMeEmailsCreateResponseMock(), - ), - { status: 201, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeSocialAccountsListMockHandler = ( - overrideResponse?: - | PaginatedSocialAccountList - | (( - info: Parameters[1]>[0], - ) => Promise | PaginatedSocialAccountList), -) => { - return http.get('*/me/social-accounts/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMeSocialAccountsListResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeSocialAccountsRetrieveMockHandler = ( - overrideResponse?: - | SocialAccount - | ((info: Parameters[1]>[0]) => Promise | SocialAccount), -) => { - return http.get('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { - return new HttpResponse( - JSON.stringify( - overrideResponse !== undefined - ? typeof overrideResponse === 'function' - ? await overrideResponse(info) - : overrideResponse - : getMeSocialAccountsRetrieveResponseMock(), - ), - { status: 200, headers: { 'Content-Type': 'application/json' } }, - ) - }) -} - -export const getMeSocialAccountsDestroyMockHandler = ( - overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), -) => { - return http.delete('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { - if (typeof overrideResponse === 'function') { - await overrideResponse(info) - } - return new HttpResponse(null, { status: 204 }) - }) -} -export const getUserTeamOrganizationUsageMock = () => [ - getApiV2AssetUsageListMockHandler(), - getApiV2OrganizationsListMockHandler(), - getApiV2OrganizationsRetrieveMockHandler(), - getApiV2OrganizationsPartialUpdateMockHandler(), - getApiV2OrganizationsAssetUsageListMockHandler(), - getApiV2OrganizationsAssetsRetrieveMockHandler(), - getApiV2OrganizationsAssetsCountsRetrieveMockHandler(), - getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler(), - getApiV2OrganizationsInvitesListMockHandler(), - getApiV2OrganizationsInvitesCreateMockHandler(), - getApiV2OrganizationsInvitesRetrieveMockHandler(), - getApiV2OrganizationsInvitesPartialUpdateMockHandler(), - getApiV2OrganizationsInvitesDestroyMockHandler(), - getApiV2OrganizationsMembersListMockHandler(), - getApiV2OrganizationsMembersRetrieveMockHandler(), - getApiV2OrganizationsMembersPartialUpdateMockHandler(), - getApiV2OrganizationsMembersDestroyMockHandler(), - getApiV2OrganizationsServiceUsageRetrieveMockHandler(), - getApiV2ProjectViewsListMockHandler(), - getApiV2ProjectViewsRetrieveMockHandler(), - getApiV2ProjectViewsExportRetrieveMockHandler(), - getApiV2ProjectViewsExportCreateMockHandler(), - getApiV2ProjectViewsAssetsRetrieveMockHandler(), - getApiV2ProjectViewsAssetsCountsRetrieveMockHandler(), - getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler(), - getApiV2ProjectViewsUsersRetrieveMockHandler(), - getApiV2ServiceUsageListMockHandler(), - getApiV2UsersListMockHandler(), - getApiV2UsersRetrieveMockHandler(), - getMeRetrieveMockHandler(), - getMePartialUpdateMockHandler(), - getMeDestroyMockHandler(), - getMeEmailsListMockHandler(), - getMeEmailsCreateMockHandler(), - getMeSocialAccountsListMockHandler(), - getMeSocialAccountsRetrieveMockHandler(), - getMeSocialAccountsDestroyMockHandler(), -] diff --git a/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.ts b/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.ts deleted file mode 100644 index f30710d6c3..0000000000 --- a/jsapp/js/api/react-query/user-team-organization-usage/user-team-organization-usage.ts +++ /dev/null @@ -1,3662 +0,0 @@ -/** - * Generated by orval v7.10.0 🍺 - * Do not edit manually. - * KoboToolbox Primary API - * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). - -The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. - -**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". - * OpenAPI spec version: 2.0.0 (api_v2) - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - MutationFunction, - QueryFunction, - QueryKey, - UseMutationOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import type { AssetListCount } from '../../models/assetListCount' - -import type { AssetUsageListParams } from '../../models/assetUsageListParams' - -import type { EmailAddress } from '../../models/emailAddress' - -import type { EmailRequestPayload } from '../../models/emailRequestPayload' - -import type { ErrorDetail } from '../../models/errorDetail' - -import type { ErrorObject } from '../../models/errorObject' - -import type { InviteCreatePayload } from '../../models/inviteCreatePayload' - -import type { InviteCreateResponse } from '../../models/inviteCreateResponse' - -import type { InviteResponse } from '../../models/inviteResponse' - -import type { MeEmailsListParams } from '../../models/meEmailsListParams' - -import type { MeListResponse } from '../../models/meListResponse' - -import type { MeSocialAccountsListParams } from '../../models/meSocialAccountsListParams' - -import type { MemberListResponse } from '../../models/memberListResponse' - -import type { OrganizationResponse } from '../../models/organizationResponse' - -import type { OrganizationServiceUsageResponse } from '../../models/organizationServiceUsageResponse' - -import type { OrganizationsAssetUsageListParams } from '../../models/organizationsAssetUsageListParams' - -import type { OrganizationsAssetsMinimalListRetrieveParams } from '../../models/organizationsAssetsMinimalListRetrieveParams' - -import type { OrganizationsInvitesListParams } from '../../models/organizationsInvitesListParams' - -import type { OrganizationsListParams } from '../../models/organizationsListParams' - -import type { OrganizationsMembersListParams } from '../../models/organizationsMembersListParams' - -import type { PaginatedAssetList } from '../../models/paginatedAssetList' - -import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' - -import type { PaginatedAssetUsageResponseList } from '../../models/paginatedAssetUsageResponseList' - -import type { PaginatedCustomAssetUsageList } from '../../models/paginatedCustomAssetUsageList' - -import type { PaginatedEmailAddressList } from '../../models/paginatedEmailAddressList' - -import type { PaginatedInviteResponseList } from '../../models/paginatedInviteResponseList' - -import type { PaginatedMemberListResponseList } from '../../models/paginatedMemberListResponseList' - -import type { PaginatedOrganizationResponseList } from '../../models/paginatedOrganizationResponseList' - -import type { PaginatedProjectViewAssetResponseList } from '../../models/paginatedProjectViewAssetResponseList' - -import type { PaginatedProjectViewListResponseList } from '../../models/paginatedProjectViewListResponseList' - -import type { PaginatedProjectViewUserResponseList } from '../../models/paginatedProjectViewUserResponseList' - -import type { PaginatedSocialAccountList } from '../../models/paginatedSocialAccountList' - -import type { PaginatedUserListResponseList } from '../../models/paginatedUserListResponseList' - -import type { PatchedCurrentUser } from '../../models/patchedCurrentUser' - -import type { PatchedInvitePatchPayload } from '../../models/patchedInvitePatchPayload' - -import type { PatchedMemberPatchRequest } from '../../models/patchedMemberPatchRequest' - -import type { PatchedOrganizationPatchPayload } from '../../models/patchedOrganizationPatchPayload' - -import type { ProjectViewExportCreateResponse } from '../../models/projectViewExportCreateResponse' - -import type { ProjectViewExportResponse } from '../../models/projectViewExportResponse' - -import type { ProjectViewListResponse } from '../../models/projectViewListResponse' - -import type { ProjectViewsAssetsMinimalListRetrieveParams } from '../../models/projectViewsAssetsMinimalListRetrieveParams' - -import type { ProjectViewsAssetsRetrieveParams } from '../../models/projectViewsAssetsRetrieveParams' - -import type { ProjectViewsListParams } from '../../models/projectViewsListParams' - -import type { ProjectViewsUsersRetrieveParams } from '../../models/projectViewsUsersRetrieveParams' - -import type { ServiceUsageResponse } from '../../models/serviceUsageResponse' - -import type { SocialAccount } from '../../models/socialAccount' - -import type { UserRetrieveResponse } from '../../models/userRetrieveResponse' - -import type { UsersListParams } from '../../models/usersListParams' - -import { fetchWithAuth } from '../../orval.mutator' - -// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B - -type WritableKeys = { - [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P> -}[keyof T] - -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never - -type Writable = Pick> -type NonReadonly = [T] extends [UnionToIntersection] - ? { - [P in keyof Writable]: T[P] extends object ? NonReadonly> : T[P] - } - : DistributeReadOnlyOverUnions - -type SecondParameter unknown> = Parameters[1] - -/** - * ## Get user's asset usage - - */ -export type assetUsageListResponse200 = { - data: PaginatedAssetUsageResponseList - status: 200 -} - -export type assetUsageListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type assetUsageListResponseComposite = assetUsageListResponse200 | assetUsageListResponse401 - -export type assetUsageListResponse = assetUsageListResponseComposite & { - headers: Headers -} - -export const getAssetUsageListUrl = (params?: AssetUsageListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/asset_usage/?${stringifiedParams}` : `/api/v2/asset_usage/` -} - -export const assetUsageList = async ( - params?: AssetUsageListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getAssetUsageListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getAssetUsageListQueryKey = (params?: AssetUsageListParams) => { - return ['api', 'v2', 'asset_usage', ...(params ? [params] : [])] as const -} - -export const getAssetUsageListQueryOptions = >, TError = ErrorDetail>( - params?: AssetUsageListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getAssetUsageListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - assetUsageList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type AssetUsageListQueryResult = NonNullable>> -export type AssetUsageListQueryError = ErrorDetail - -export function useAssetUsageList>, TError = ErrorDetail>( - params?: AssetUsageListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getAssetUsageListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List user's organizations - - */ -export type organizationsListResponse200 = { - data: PaginatedOrganizationResponseList - status: 200 -} - -export type organizationsListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsListResponseComposite = organizationsListResponse200 | organizationsListResponse404 - -export type organizationsListResponse = organizationsListResponseComposite & { - headers: Headers -} - -export const getOrganizationsListUrl = (params?: OrganizationsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/organizations/?${stringifiedParams}` : `/api/v2/organizations/` -} - -export const organizationsList = async ( - params?: OrganizationsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getOrganizationsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getOrganizationsListQueryKey = (params?: OrganizationsListParams) => { - return ['api', 'v2', 'organizations', ...(params ? [params] : [])] as const -} - -export const getOrganizationsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: OrganizationsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsListQueryResult = NonNullable>> -export type OrganizationsListQueryError = ErrorDetail - -export function useOrganizationsList>, TError = ErrorDetail>( - params?: OrganizationsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve organization's details - - */ -export type organizationsRetrieveResponse200 = { - data: OrganizationResponse - status: 200 -} - -export type organizationsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsRetrieveResponseComposite = organizationsRetrieveResponse200 | organizationsRetrieveResponse404 - -export type organizationsRetrieveResponse = organizationsRetrieveResponseComposite & { - headers: Headers -} - -export const getOrganizationsRetrieveUrl = (uidOrganization: string) => { - return `/api/v2/organizations/${uidOrganization}/` -} - -export const organizationsRetrieve = async ( - uidOrganization: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getOrganizationsRetrieveUrl(uidOrganization), { - ...options, - method: 'GET', - }) -} - -export const getOrganizationsRetrieveQueryKey = (uidOrganization: string) => { - return ['api', 'v2', 'organizations', uidOrganization] as const -} - -export const getOrganizationsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsRetrieveQueryKey(uidOrganization) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsRetrieve(uidOrganization, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsRetrieveQueryResult = NonNullable>> -export type OrganizationsRetrieveQueryError = ErrorDetail - -export function useOrganizationsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsRetrieveQueryOptions(uidOrganization, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update organization's details - - */ -export type organizationsPartialUpdateResponse200 = { - data: OrganizationResponse - status: 200 -} - -export type organizationsPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type organizationsPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsPartialUpdateResponseComposite = - | organizationsPartialUpdateResponse200 - | organizationsPartialUpdateResponse400 - | organizationsPartialUpdateResponse404 - -export type organizationsPartialUpdateResponse = organizationsPartialUpdateResponseComposite & { - headers: Headers -} - -export const getOrganizationsPartialUpdateUrl = (uidOrganization: string) => { - return `/api/v2/organizations/${uidOrganization}/` -} - -export const organizationsPartialUpdate = async ( - uidOrganization: string, - patchedOrganizationPatchPayload: PatchedOrganizationPatchPayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getOrganizationsPartialUpdateUrl(uidOrganization), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedOrganizationPatchPayload), - }) -} - -export const getOrganizationsPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; data: PatchedOrganizationPatchPayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; data: PatchedOrganizationPatchPayload }, - TContext -> => { - const mutationKey = ['organizationsPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidOrganization: string; data: PatchedOrganizationPatchPayload } - > = (props) => { - const { uidOrganization, data } = props ?? {} - - return organizationsPartialUpdate(uidOrganization, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type OrganizationsPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type OrganizationsPartialUpdateMutationBody = PatchedOrganizationPatchPayload -export type OrganizationsPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useOrganizationsPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; data: PatchedOrganizationPatchPayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getOrganizationsPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve organization asset usage tracker - -Tracks the total usage of each asset for the user in the given organization - - */ -export type organizationsAssetUsageListResponse200 = { - data: PaginatedCustomAssetUsageList - status: 200 -} - -export type organizationsAssetUsageListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsAssetUsageListResponseComposite = - | organizationsAssetUsageListResponse200 - | organizationsAssetUsageListResponse404 - -export type organizationsAssetUsageListResponse = organizationsAssetUsageListResponseComposite & { - headers: Headers -} - -export const getOrganizationsAssetUsageListUrl = ( - uidOrganization: string, - params?: OrganizationsAssetUsageListParams, -) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/organizations/${uidOrganization}/asset_usage/?${stringifiedParams}` - : `/api/v2/organizations/${uidOrganization}/asset_usage/` -} - -export const organizationsAssetUsageList = async ( - uidOrganization: string, - params?: OrganizationsAssetUsageListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getOrganizationsAssetUsageListUrl(uidOrganization, params), - { - ...options, - method: 'GET', - }, - ) -} - -export const getOrganizationsAssetUsageListQueryKey = ( - uidOrganization: string, - params?: OrganizationsAssetUsageListParams, -) => { - return ['api', 'v2', 'organizations', uidOrganization, 'asset_usage', ...(params ? [params] : [])] as const -} - -export const getOrganizationsAssetUsageListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - params?: OrganizationsAssetUsageListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetUsageListQueryKey(uidOrganization, params) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsAssetUsageList(uidOrganization, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsAssetUsageListQueryResult = NonNullable< - Awaited> -> -export type OrganizationsAssetUsageListQueryError = ErrorDetail - -export function useOrganizationsAssetUsageList< - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - params?: OrganizationsAssetUsageListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsAssetUsageListQueryOptions(uidOrganization, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve Organization Assets - -This endpoint returns all assets associated with a specific organization. -The assets listed here are restricted to those owned by the specified -organization. - -Only the owner or administrators of the organization can access this endpoint. - -### Additional Information -For more details, please refer to `/api/v2/assets/`. - - */ -export type organizationsAssetsRetrieveResponse200 = { - data: PaginatedAssetList - status: 200 -} - -export type organizationsAssetsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsAssetsRetrieveResponseComposite = - | organizationsAssetsRetrieveResponse200 - | organizationsAssetsRetrieveResponse404 - -export type organizationsAssetsRetrieveResponse = organizationsAssetsRetrieveResponseComposite & { - headers: Headers -} - -export const getOrganizationsAssetsRetrieveUrl = (uidOrganization: string) => { - return `/api/v2/organizations/${uidOrganization}/assets/` -} - -export const organizationsAssetsRetrieve = async ( - uidOrganization: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getOrganizationsAssetsRetrieveUrl(uidOrganization), { - ...options, - method: 'GET', - }) -} - -export const getOrganizationsAssetsRetrieveQueryKey = (uidOrganization: string) => { - return ['api', 'v2', 'organizations', uidOrganization, 'assets'] as const -} - -export const getOrganizationsAssetsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsRetrieveQueryKey(uidOrganization) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsAssetsRetrieve(uidOrganization, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsAssetsRetrieveQueryResult = NonNullable< - Awaited> -> -export type OrganizationsAssetsRetrieveQueryError = ErrorDetail - -export function useOrganizationsAssetsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsAssetsRetrieveQueryOptions(uidOrganization, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Return counts of deployed, archived, and draft assets owned by the organization - - */ -export type organizationsAssetsCountsRetrieveResponse200 = { - data: AssetListCount - status: 200 -} - -export type organizationsAssetsCountsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsAssetsCountsRetrieveResponseComposite = - | organizationsAssetsCountsRetrieveResponse200 - | organizationsAssetsCountsRetrieveResponse404 - -export type organizationsAssetsCountsRetrieveResponse = organizationsAssetsCountsRetrieveResponseComposite & { - headers: Headers -} - -export const getOrganizationsAssetsCountsRetrieveUrl = (uidOrganization: string) => { - return `/api/v2/organizations/${uidOrganization}/assets/counts/` -} - -export const organizationsAssetsCountsRetrieve = async ( - uidOrganization: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getOrganizationsAssetsCountsRetrieveUrl(uidOrganization), - { - ...options, - method: 'GET', - }, - ) -} - -export const getOrganizationsAssetsCountsRetrieveQueryKey = (uidOrganization: string) => { - return ['api', 'v2', 'organizations', uidOrganization, 'assets', 'counts'] as const -} - -export const getOrganizationsAssetsCountsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsCountsRetrieveQueryKey(uidOrganization) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsAssetsCountsRetrieve(uidOrganization, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsAssetsCountsRetrieveQueryResult = NonNullable< - Awaited> -> -export type OrganizationsAssetsCountsRetrieveQueryError = ErrorDetail - -export function useOrganizationsAssetsCountsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsAssetsCountsRetrieveQueryOptions(uidOrganization, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Return a minimal listing of assets in an organization - -Returns a paginated list of assets owned by the organization, including only `uid`, `name`, and `deployment_status` (`draft`, `deployed`, or `archived`). - -Use the `q` query parameter to filter by asset type (e.g. `?q=asset_type:survey`). - -Responses do not include a `count` field. Use the `next` and `previous` links to paginate through results. - - */ -export type organizationsAssetsMinimalListRetrieveResponse200 = { - data: PaginatedAssetMinimalListList - status: 200 -} - -export type organizationsAssetsMinimalListRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsAssetsMinimalListRetrieveResponseComposite = - | organizationsAssetsMinimalListRetrieveResponse200 - | organizationsAssetsMinimalListRetrieveResponse404 - -export type organizationsAssetsMinimalListRetrieveResponse = organizationsAssetsMinimalListRetrieveResponseComposite & { - headers: Headers -} - -export const getOrganizationsAssetsMinimalListRetrieveUrl = ( - uidOrganization: string, - params?: OrganizationsAssetsMinimalListRetrieveParams, -) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/organizations/${uidOrganization}/assets/minimal-list/?${stringifiedParams}` - : `/api/v2/organizations/${uidOrganization}/assets/minimal-list/` -} - -export const organizationsAssetsMinimalListRetrieve = async ( - uidOrganization: string, - params?: OrganizationsAssetsMinimalListRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getOrganizationsAssetsMinimalListRetrieveUrl(uidOrganization, params), - { - ...options, - method: 'GET', - }, - ) -} - -export const getOrganizationsAssetsMinimalListRetrieveQueryKey = ( - uidOrganization: string, - params?: OrganizationsAssetsMinimalListRetrieveParams, -) => { - return ['api', 'v2', 'organizations', uidOrganization, 'assets', 'minimal-list', ...(params ? [params] : [])] as const -} - -export const getOrganizationsAssetsMinimalListRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - params?: OrganizationsAssetsMinimalListRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsMinimalListRetrieveQueryKey(uidOrganization, params) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsAssetsMinimalListRetrieve(uidOrganization, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsAssetsMinimalListRetrieveQueryResult = NonNullable< - Awaited> -> -export type OrganizationsAssetsMinimalListRetrieveQueryError = ErrorDetail - -export function useOrganizationsAssetsMinimalListRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - params?: OrganizationsAssetsMinimalListRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsAssetsMinimalListRetrieveQueryOptions(uidOrganization, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List organization invites - - */ -export type organizationsInvitesListResponse200 = { - data: PaginatedInviteResponseList - status: 200 -} - -export type organizationsInvitesListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsInvitesListResponseComposite = - | organizationsInvitesListResponse200 - | organizationsInvitesListResponse404 - -export type organizationsInvitesListResponse = organizationsInvitesListResponseComposite & { - headers: Headers -} - -export const getOrganizationsInvitesListUrl = (uidOrganization: string, params?: OrganizationsInvitesListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/organizations/${uidOrganization}/invites/?${stringifiedParams}` - : `/api/v2/organizations/${uidOrganization}/invites/` -} - -export const organizationsInvitesList = async ( - uidOrganization: string, - params?: OrganizationsInvitesListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getOrganizationsInvitesListUrl(uidOrganization, params), { - ...options, - method: 'GET', - }) -} - -export const getOrganizationsInvitesListQueryKey = ( - uidOrganization: string, - params?: OrganizationsInvitesListParams, -) => { - return ['api', 'v2', 'organizations', uidOrganization, 'invites', ...(params ? [params] : [])] as const -} - -export const getOrganizationsInvitesListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - params?: OrganizationsInvitesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsInvitesListQueryKey(uidOrganization, params) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsInvitesList(uidOrganization, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsInvitesListQueryResult = NonNullable>> -export type OrganizationsInvitesListQueryError = ErrorDetail - -export function useOrganizationsInvitesList< - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - params?: OrganizationsInvitesListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsInvitesListQueryOptions(uidOrganization, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create Organization Invite - -* Create organization invites for registered and unregistered users. -* Set the role for which the user is being invited - -(Choices: `member`, `admin`). Default is `member`. - - */ -export type organizationsInvitesCreateResponse201 = { - data: InviteCreateResponse - status: 201 -} - -export type organizationsInvitesCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type organizationsInvitesCreateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsInvitesCreateResponseComposite = - | organizationsInvitesCreateResponse201 - | organizationsInvitesCreateResponse400 - | organizationsInvitesCreateResponse404 - -export type organizationsInvitesCreateResponse = organizationsInvitesCreateResponseComposite & { - headers: Headers -} - -export const getOrganizationsInvitesCreateUrl = (uidOrganization: string) => { - return `/api/v2/organizations/${uidOrganization}/invites/` -} - -export const organizationsInvitesCreate = async ( - uidOrganization: string, - inviteCreatePayload: InviteCreatePayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getOrganizationsInvitesCreateUrl(uidOrganization), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(inviteCreatePayload), - }) -} - -export const getOrganizationsInvitesCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; data: InviteCreatePayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; data: InviteCreatePayload }, - TContext -> => { - const mutationKey = ['organizationsInvitesCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidOrganization: string; data: InviteCreatePayload } - > = (props) => { - const { uidOrganization, data } = props ?? {} - - return organizationsInvitesCreate(uidOrganization, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type OrganizationsInvitesCreateMutationResult = NonNullable< - Awaited> -> -export type OrganizationsInvitesCreateMutationBody = InviteCreatePayload -export type OrganizationsInvitesCreateMutationError = ErrorObject | ErrorDetail - -export const useOrganizationsInvitesCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; data: InviteCreatePayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getOrganizationsInvitesCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve organization invite - - */ -export type organizationsInvitesRetrieveResponse200 = { - data: InviteResponse - status: 200 -} - -export type organizationsInvitesRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsInvitesRetrieveResponseComposite = - | organizationsInvitesRetrieveResponse200 - | organizationsInvitesRetrieveResponse404 - -export type organizationsInvitesRetrieveResponse = organizationsInvitesRetrieveResponseComposite & { - headers: Headers -} - -export const getOrganizationsInvitesRetrieveUrl = (uidOrganization: string, guid: string) => { - return `/api/v2/organizations/${uidOrganization}/invites/${guid}/` -} - -export const organizationsInvitesRetrieve = async ( - uidOrganization: string, - guid: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getOrganizationsInvitesRetrieveUrl(uidOrganization, guid), - { - ...options, - method: 'GET', - }, - ) -} - -export const getOrganizationsInvitesRetrieveQueryKey = (uidOrganization: string, guid: string) => { - return ['api', 'v2', 'organizations', uidOrganization, 'invites', guid] as const -} - -export const getOrganizationsInvitesRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - guid: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsInvitesRetrieveQueryKey(uidOrganization, guid) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsInvitesRetrieve(uidOrganization, guid, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidOrganization && guid), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsInvitesRetrieveQueryResult = NonNullable< - Awaited> -> -export type OrganizationsInvitesRetrieveQueryError = ErrorDetail - -export function useOrganizationsInvitesRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - guid: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsInvitesRetrieveQueryOptions(uidOrganization, guid, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update Organization Invite - -* Update an organization invite to accept, decline, cancel, expire, or resend. -* Update the role of the invitee to `admin` or `member`. Only the owner or admin can update the role. - - - */ -export type organizationsInvitesPartialUpdateResponse200 = { - data: InviteResponse - status: 200 -} - -export type organizationsInvitesPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type organizationsInvitesPartialUpdateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type organizationsInvitesPartialUpdateResponseComposite = - | organizationsInvitesPartialUpdateResponse200 - | organizationsInvitesPartialUpdateResponse400 - | organizationsInvitesPartialUpdateResponse403 - -export type organizationsInvitesPartialUpdateResponse = organizationsInvitesPartialUpdateResponseComposite & { - headers: Headers -} - -export const getOrganizationsInvitesPartialUpdateUrl = (uidOrganization: string, guid: string) => { - return `/api/v2/organizations/${uidOrganization}/invites/${guid}/` -} - -export const organizationsInvitesPartialUpdate = async ( - uidOrganization: string, - guid: string, - patchedInvitePatchPayload: PatchedInvitePatchPayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getOrganizationsInvitesPartialUpdateUrl(uidOrganization, guid), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedInvitePatchPayload), - }, - ) -} - -export const getOrganizationsInvitesPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; guid: string; data: PatchedInvitePatchPayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; guid: string; data: PatchedInvitePatchPayload }, - TContext -> => { - const mutationKey = ['organizationsInvitesPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidOrganization: string; guid: string; data: PatchedInvitePatchPayload } - > = (props) => { - const { uidOrganization, guid, data } = props ?? {} - - return organizationsInvitesPartialUpdate(uidOrganization, guid, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type OrganizationsInvitesPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type OrganizationsInvitesPartialUpdateMutationBody = PatchedInvitePatchPayload -export type OrganizationsInvitesPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useOrganizationsInvitesPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; guid: string; data: PatchedInvitePatchPayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getOrganizationsInvitesPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete Organization Invite - -* Organization owner or admin can delete an organization invite. - - */ -export type organizationsInvitesDestroyResponse204 = { - data: void - status: 204 -} - -export type organizationsInvitesDestroyResponse403 = { - data: ErrorDetail - status: 403 -} - -export type organizationsInvitesDestroyResponseComposite = - | organizationsInvitesDestroyResponse204 - | organizationsInvitesDestroyResponse403 - -export type organizationsInvitesDestroyResponse = organizationsInvitesDestroyResponseComposite & { - headers: Headers -} - -export const getOrganizationsInvitesDestroyUrl = (uidOrganization: string, guid: string) => { - return `/api/v2/organizations/${uidOrganization}/invites/${guid}/` -} - -export const organizationsInvitesDestroy = async ( - uidOrganization: string, - guid: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getOrganizationsInvitesDestroyUrl(uidOrganization, guid), { - ...options, - method: 'DELETE', - }) -} - -export const getOrganizationsInvitesDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; guid: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; guid: string }, - TContext -> => { - const mutationKey = ['organizationsInvitesDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidOrganization: string; guid: string } - > = (props) => { - const { uidOrganization, guid } = props ?? {} - - return organizationsInvitesDestroy(uidOrganization, guid, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type OrganizationsInvitesDestroyMutationResult = NonNullable< - Awaited> -> - -export type OrganizationsInvitesDestroyMutationError = ErrorDetail - -export const useOrganizationsInvitesDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; guid: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getOrganizationsInvitesDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## List Members - -Retrieves all members in the specified organization. - - */ -export type organizationsMembersListResponse200 = { - data: PaginatedMemberListResponseList - status: 200 -} - -export type organizationsMembersListResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsMembersListResponseComposite = - | organizationsMembersListResponse200 - | organizationsMembersListResponse404 - -export type organizationsMembersListResponse = organizationsMembersListResponseComposite & { - headers: Headers -} - -export const getOrganizationsMembersListUrl = (uidOrganization: string, params?: OrganizationsMembersListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/organizations/${uidOrganization}/members/?${stringifiedParams}` - : `/api/v2/organizations/${uidOrganization}/members/` -} - -export const organizationsMembersList = async ( - uidOrganization: string, - params?: OrganizationsMembersListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getOrganizationsMembersListUrl(uidOrganization, params), { - ...options, - method: 'GET', - }) -} - -export const getOrganizationsMembersListQueryKey = ( - uidOrganization: string, - params?: OrganizationsMembersListParams, -) => { - return ['api', 'v2', 'organizations', uidOrganization, 'members', ...(params ? [params] : [])] as const -} - -export const getOrganizationsMembersListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - params?: OrganizationsMembersListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsMembersListQueryKey(uidOrganization, params) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsMembersList(uidOrganization, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsMembersListQueryResult = NonNullable>> -export type OrganizationsMembersListQueryError = ErrorDetail - -export function useOrganizationsMembersList< - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - params?: OrganizationsMembersListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsMembersListQueryOptions(uidOrganization, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve Member Details - -Retrieves the details of a specific member within an organization by username. - - */ -export type organizationsMembersRetrieveResponse200 = { - data: MemberListResponse - status: 200 -} - -export type organizationsMembersRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsMembersRetrieveResponseComposite = - | organizationsMembersRetrieveResponse200 - | organizationsMembersRetrieveResponse404 - -export type organizationsMembersRetrieveResponse = organizationsMembersRetrieveResponseComposite & { - headers: Headers -} - -export const getOrganizationsMembersRetrieveUrl = (uidOrganization: string, username: string) => { - return `/api/v2/organizations/${uidOrganization}/members/${username}/` -} - -export const organizationsMembersRetrieve = async ( - uidOrganization: string, - username: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getOrganizationsMembersRetrieveUrl(uidOrganization, username), - { - ...options, - method: 'GET', - }, - ) -} - -export const getOrganizationsMembersRetrieveQueryKey = (uidOrganization: string, username: string) => { - return ['api', 'v2', 'organizations', uidOrganization, 'members', username] as const -} - -export const getOrganizationsMembersRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - username: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsMembersRetrieveQueryKey(uidOrganization, username) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsMembersRetrieve(uidOrganization, username, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidOrganization && username), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsMembersRetrieveQueryResult = NonNullable< - Awaited> -> -export type OrganizationsMembersRetrieveQueryError = ErrorDetail - -export function useOrganizationsMembersRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - username: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsMembersRetrieveQueryOptions(uidOrganization, username, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update Member Role - -Updates the role of a member within the organization to `admin` or -`member`. - -- **admin**: Grants the member admin privileges within the organization -- **member**: Revokes admin privileges, setting the member as a regular user - - */ -export type organizationsMembersPartialUpdateResponse200 = { - data: MemberListResponse - status: 200 -} - -export type organizationsMembersPartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type organizationsMembersPartialUpdateResponse403 = { - data: ErrorDetail - status: 403 -} - -export type organizationsMembersPartialUpdateResponseComposite = - | organizationsMembersPartialUpdateResponse200 - | organizationsMembersPartialUpdateResponse400 - | organizationsMembersPartialUpdateResponse403 - -export type organizationsMembersPartialUpdateResponse = organizationsMembersPartialUpdateResponseComposite & { - headers: Headers -} - -export const getOrganizationsMembersPartialUpdateUrl = (uidOrganization: string, username: string) => { - return `/api/v2/organizations/${uidOrganization}/members/${username}/` -} - -export const organizationsMembersPartialUpdate = async ( - uidOrganization: string, - username: string, - patchedMemberPatchRequest: PatchedMemberPatchRequest, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getOrganizationsMembersPartialUpdateUrl(uidOrganization, username), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedMemberPatchRequest), - }, - ) -} - -export const getOrganizationsMembersPartialUpdateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; username: string; data: PatchedMemberPatchRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; username: string; data: PatchedMemberPatchRequest }, - TContext -> => { - const mutationKey = ['organizationsMembersPartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidOrganization: string; username: string; data: PatchedMemberPatchRequest } - > = (props) => { - const { uidOrganization, username, data } = props ?? {} - - return organizationsMembersPartialUpdate(uidOrganization, username, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type OrganizationsMembersPartialUpdateMutationResult = NonNullable< - Awaited> -> -export type OrganizationsMembersPartialUpdateMutationBody = PatchedMemberPatchRequest -export type OrganizationsMembersPartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useOrganizationsMembersPartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; username: string; data: PatchedMemberPatchRequest }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getOrganizationsMembersPartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Remove Member - -Delete an organization member. - - */ -export type organizationsMembersDestroyResponse204 = { - data: void - status: 204 -} - -export type organizationsMembersDestroyResponse403 = { - data: ErrorDetail - status: 403 -} - -export type organizationsMembersDestroyResponseComposite = - | organizationsMembersDestroyResponse204 - | organizationsMembersDestroyResponse403 - -export type organizationsMembersDestroyResponse = organizationsMembersDestroyResponseComposite & { - headers: Headers -} - -export const getOrganizationsMembersDestroyUrl = (uidOrganization: string, username: string) => { - return `/api/v2/organizations/${uidOrganization}/members/${username}/` -} - -export const organizationsMembersDestroy = async ( - uidOrganization: string, - username: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getOrganizationsMembersDestroyUrl(uidOrganization, username), - { - ...options, - method: 'DELETE', - }, - ) -} - -export const getOrganizationsMembersDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; username: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; username: string }, - TContext -> => { - const mutationKey = ['organizationsMembersDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidOrganization: string; username: string } - > = (props) => { - const { uidOrganization, username } = props ?? {} - - return organizationsMembersDestroy(uidOrganization, username, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type OrganizationsMembersDestroyMutationResult = NonNullable< - Awaited> -> - -export type OrganizationsMembersDestroyMutationError = ErrorDetail - -export const useOrganizationsMembersDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidOrganization: string; username: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getOrganizationsMembersDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Organization Usage Tracker - -- Tracks the total usage of different services for each account in an organization -- Tracks the submissions and NLP seconds/characters for the current month/year/all time -- Tracks the current total storage used -- Includes a detailed list of balances relative to a user's usage limits -- If no organization is found with the provided ID, returns the usage for the logged-in user - -**This endpoint is cached for an amount of time determined by ENDPOINT_CACHE_DURATION** - - */ -export type organizationsServiceUsageRetrieveResponse200 = { - data: OrganizationServiceUsageResponse - status: 200 -} - -export type organizationsServiceUsageRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsServiceUsageRetrieveResponseComposite = - | organizationsServiceUsageRetrieveResponse200 - | organizationsServiceUsageRetrieveResponse404 - -export type organizationsServiceUsageRetrieveResponse = organizationsServiceUsageRetrieveResponseComposite & { - headers: Headers -} - -export const getOrganizationsServiceUsageRetrieveUrl = (uidOrganization: string) => { - return `/api/v2/organizations/${uidOrganization}/service_usage/` -} - -export const organizationsServiceUsageRetrieve = async ( - uidOrganization: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getOrganizationsServiceUsageRetrieveUrl(uidOrganization), - { - ...options, - method: 'GET', - }, - ) -} - -export const getOrganizationsServiceUsageRetrieveQueryKey = (uidOrganization: string) => { - return ['api', 'v2', 'organizations', uidOrganization, 'service_usage'] as const -} - -export const getOrganizationsServiceUsageRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getOrganizationsServiceUsageRetrieveQueryKey(uidOrganization) - - const queryFn: QueryFunction>> = ({ signal }) => - organizationsServiceUsageRetrieve(uidOrganization, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type OrganizationsServiceUsageRetrieveQueryResult = NonNullable< - Awaited> -> -export type OrganizationsServiceUsageRetrieveQueryError = ErrorDetail - -export function useOrganizationsServiceUsageRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidOrganization: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getOrganizationsServiceUsageRetrieveQueryOptions(uidOrganization, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List project views for current user - - */ -export type projectViewsListResponse200 = { - data: PaginatedProjectViewListResponseList - status: 200 -} - -export type projectViewsListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectViewsListResponseComposite = projectViewsListResponse200 | projectViewsListResponse403 - -export type projectViewsListResponse = projectViewsListResponseComposite & { - headers: Headers -} - -export const getProjectViewsListUrl = (params?: ProjectViewsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/project-views/?${stringifiedParams}` : `/api/v2/project-views/` -} - -export const projectViewsList = async ( - params?: ProjectViewsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectViewsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getProjectViewsListQueryKey = (params?: ProjectViewsListParams) => { - return ['api', 'v2', 'project-views', ...(params ? [params] : [])] as const -} - -export const getProjectViewsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: ProjectViewsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectViewsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - projectViewsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectViewsListQueryResult = NonNullable>> -export type ProjectViewsListQueryError = ErrorDetail - -export function useProjectViewsList>, TError = ErrorDetail>( - params?: ProjectViewsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectViewsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve project view of a shared project to current user - - */ -export type projectViewsRetrieveResponse200 = { - data: ProjectViewListResponse - status: 200 -} - -export type projectViewsRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectViewsRetrieveResponseComposite = projectViewsRetrieveResponse200 | projectViewsRetrieveResponse403 - -export type projectViewsRetrieveResponse = projectViewsRetrieveResponseComposite & { - headers: Headers -} - -export const getProjectViewsRetrieveUrl = (uidProjectView: string) => { - return `/api/v2/project-views/${uidProjectView}/` -} - -export const projectViewsRetrieve = async ( - uidProjectView: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectViewsRetrieveUrl(uidProjectView), { - ...options, - method: 'GET', - }) -} - -export const getProjectViewsRetrieveQueryKey = (uidProjectView: string) => { - return ['api', 'v2', 'project-views', uidProjectView] as const -} - -export const getProjectViewsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidProjectView: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectViewsRetrieveQueryKey(uidProjectView) - - const queryFn: QueryFunction>> = ({ signal }) => - projectViewsRetrieve(uidProjectView, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidProjectView, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectViewsRetrieveQueryResult = NonNullable>> -export type ProjectViewsRetrieveQueryError = ErrorDetail - -export function useProjectViewsRetrieve>, TError = ErrorDetail>( - uidProjectView: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectViewsRetrieveQueryOptions(uidProjectView, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve an export for the requested object - -* Note: `{obj_type}` can either be `users` or `assets` - - - */ -export type projectViewsExportRetrieveResponse200 = { - data: ProjectViewExportResponse - status: 200 -} - -export type projectViewsExportRetrieveResponse400 = { - data: ErrorObject - status: 400 -} - -export type projectViewsExportRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type projectViewsExportRetrieveResponseComposite = - | projectViewsExportRetrieveResponse200 - | projectViewsExportRetrieveResponse400 - | projectViewsExportRetrieveResponse401 - -export type projectViewsExportRetrieveResponse = projectViewsExportRetrieveResponseComposite & { - headers: Headers -} - -export const getProjectViewsExportRetrieveUrl = (uidProjectView: string, objType: string) => { - return `/api/v2/project-views/${uidProjectView}/${objType}/export/` -} - -export const projectViewsExportRetrieve = async ( - uidProjectView: string, - objType: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectViewsExportRetrieveUrl(uidProjectView, objType), { - ...options, - method: 'GET', - }) -} - -export const getProjectViewsExportRetrieveQueryKey = (uidProjectView: string, objType: string) => { - return ['api', 'v2', 'project-views', uidProjectView, objType, 'export'] as const -} - -export const getProjectViewsExportRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidProjectView: string, - objType: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectViewsExportRetrieveQueryKey(uidProjectView, objType) - - const queryFn: QueryFunction>> = ({ signal }) => - projectViewsExportRetrieve(uidProjectView, objType, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(uidProjectView && objType), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectViewsExportRetrieveQueryResult = NonNullable>> -export type ProjectViewsExportRetrieveQueryError = ErrorObject | ErrorDetail - -export function useProjectViewsExportRetrieve< - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidProjectView: string, - objType: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectViewsExportRetrieveQueryOptions(uidProjectView, objType, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Create an export for the requested object - -* Note: `{obj_type}` can either be `users` or `assets` - - */ -export type projectViewsExportCreateResponse200 = { - data: ProjectViewExportCreateResponse - status: 200 -} - -export type projectViewsExportCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type projectViewsExportCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type projectViewsExportCreateResponseComposite = - | projectViewsExportCreateResponse200 - | projectViewsExportCreateResponse400 - | projectViewsExportCreateResponse401 - -export type projectViewsExportCreateResponse = projectViewsExportCreateResponseComposite & { - headers: Headers -} - -export const getProjectViewsExportCreateUrl = (uidProjectView: string, objType: string) => { - return `/api/v2/project-views/${uidProjectView}/${objType}/export/` -} - -export const projectViewsExportCreate = async ( - uidProjectView: string, - objType: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectViewsExportCreateUrl(uidProjectView, objType), { - ...options, - method: 'POST', - }) -} - -export const getProjectViewsExportCreateMutationOptions = < - TError = ErrorObject | ErrorDetail, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidProjectView: string; objType: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { uidProjectView: string; objType: string }, - TContext -> => { - const mutationKey = ['projectViewsExportCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { uidProjectView: string; objType: string } - > = (props) => { - const { uidProjectView, objType } = props ?? {} - - return projectViewsExportCreate(uidProjectView, objType, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ProjectViewsExportCreateMutationResult = NonNullable>> - -export type ProjectViewsExportCreateMutationError = ErrorObject | ErrorDetail - -export const useProjectViewsExportCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { uidProjectView: string; objType: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getProjectViewsExportCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Retrieve assets available in project view - - */ -export type projectViewsAssetsRetrieveResponse200 = { - data: PaginatedProjectViewAssetResponseList - status: 200 -} - -export type projectViewsAssetsRetrieveResponse400 = { - data: ErrorObject - status: 400 -} - -export type projectViewsAssetsRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type projectViewsAssetsRetrieveResponseComposite = - | projectViewsAssetsRetrieveResponse200 - | projectViewsAssetsRetrieveResponse400 - | projectViewsAssetsRetrieveResponse401 - -export type projectViewsAssetsRetrieveResponse = projectViewsAssetsRetrieveResponseComposite & { - headers: Headers -} - -export const getProjectViewsAssetsRetrieveUrl = (uidProjectView: string, params?: ProjectViewsAssetsRetrieveParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/project-views/${uidProjectView}/assets/?${stringifiedParams}` - : `/api/v2/project-views/${uidProjectView}/assets/` -} - -export const projectViewsAssetsRetrieve = async ( - uidProjectView: string, - params?: ProjectViewsAssetsRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectViewsAssetsRetrieveUrl(uidProjectView, params), { - ...options, - method: 'GET', - }) -} - -export const getProjectViewsAssetsRetrieveQueryKey = ( - uidProjectView: string, - params?: ProjectViewsAssetsRetrieveParams, -) => { - return ['api', 'v2', 'project-views', uidProjectView, 'assets', ...(params ? [params] : [])] as const -} - -export const getProjectViewsAssetsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidProjectView: string, - params?: ProjectViewsAssetsRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsRetrieveQueryKey(uidProjectView, params) - - const queryFn: QueryFunction>> = ({ signal }) => - projectViewsAssetsRetrieve(uidProjectView, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidProjectView, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectViewsAssetsRetrieveQueryResult = NonNullable>> -export type ProjectViewsAssetsRetrieveQueryError = ErrorObject | ErrorDetail - -export function useProjectViewsAssetsRetrieve< - TData = Awaited>, - TError = ErrorObject | ErrorDetail, ->( - uidProjectView: string, - params?: ProjectViewsAssetsRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectViewsAssetsRetrieveQueryOptions(uidProjectView, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Return counts of deployed, archived, and draft assets in the project view - - */ -export type projectViewsAssetsCountsRetrieveResponse200 = { - data: AssetListCount - status: 200 -} - -export type projectViewsAssetsCountsRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type projectViewsAssetsCountsRetrieveResponseComposite = - | projectViewsAssetsCountsRetrieveResponse200 - | projectViewsAssetsCountsRetrieveResponse404 - -export type projectViewsAssetsCountsRetrieveResponse = projectViewsAssetsCountsRetrieveResponseComposite & { - headers: Headers -} - -export const getProjectViewsAssetsCountsRetrieveUrl = (uidProjectView: string) => { - return `/api/v2/project-views/${uidProjectView}/assets/counts/` -} - -export const projectViewsAssetsCountsRetrieve = async ( - uidProjectView: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getProjectViewsAssetsCountsRetrieveUrl(uidProjectView), - { - ...options, - method: 'GET', - }, - ) -} - -export const getProjectViewsAssetsCountsRetrieveQueryKey = (uidProjectView: string) => { - return ['api', 'v2', 'project-views', uidProjectView, 'assets', 'counts'] as const -} - -export const getProjectViewsAssetsCountsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidProjectView: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsCountsRetrieveQueryKey(uidProjectView) - - const queryFn: QueryFunction>> = ({ signal }) => - projectViewsAssetsCountsRetrieve(uidProjectView, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidProjectView, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectViewsAssetsCountsRetrieveQueryResult = NonNullable< - Awaited> -> -export type ProjectViewsAssetsCountsRetrieveQueryError = ErrorDetail - -export function useProjectViewsAssetsCountsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidProjectView: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectViewsAssetsCountsRetrieveQueryOptions(uidProjectView, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Return a minimal listing of assets in a project view - -Returns a paginated list of assets visible within the project view, including only `uid`, `name`, and `deployment_status` (`draft`, `deployed`, or `archived`). - -Use the `q` query parameter to filter by asset type (e.g. `?q=asset_type:survey`). - -Responses do not include a `count` field. Use the `next` and `previous` links to paginate through results. - - */ -export type projectViewsAssetsMinimalListRetrieveResponse200 = { - data: PaginatedAssetMinimalListList - status: 200 -} - -export type projectViewsAssetsMinimalListRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type projectViewsAssetsMinimalListRetrieveResponseComposite = - | projectViewsAssetsMinimalListRetrieveResponse200 - | projectViewsAssetsMinimalListRetrieveResponse404 - -export type projectViewsAssetsMinimalListRetrieveResponse = projectViewsAssetsMinimalListRetrieveResponseComposite & { - headers: Headers -} - -export const getProjectViewsAssetsMinimalListRetrieveUrl = ( - uidProjectView: string, - params?: ProjectViewsAssetsMinimalListRetrieveParams, -) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/project-views/${uidProjectView}/assets/minimal-list/?${stringifiedParams}` - : `/api/v2/project-views/${uidProjectView}/assets/minimal-list/` -} - -export const projectViewsAssetsMinimalListRetrieve = async ( - uidProjectView: string, - params?: ProjectViewsAssetsMinimalListRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth( - getProjectViewsAssetsMinimalListRetrieveUrl(uidProjectView, params), - { - ...options, - method: 'GET', - }, - ) -} - -export const getProjectViewsAssetsMinimalListRetrieveQueryKey = ( - uidProjectView: string, - params?: ProjectViewsAssetsMinimalListRetrieveParams, -) => { - return ['api', 'v2', 'project-views', uidProjectView, 'assets', 'minimal-list', ...(params ? [params] : [])] as const -} - -export const getProjectViewsAssetsMinimalListRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidProjectView: string, - params?: ProjectViewsAssetsMinimalListRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsMinimalListRetrieveQueryKey(uidProjectView, params) - - const queryFn: QueryFunction>> = ({ signal }) => - projectViewsAssetsMinimalListRetrieve(uidProjectView, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidProjectView, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectViewsAssetsMinimalListRetrieveQueryResult = NonNullable< - Awaited> -> -export type ProjectViewsAssetsMinimalListRetrieveQueryError = ErrorDetail - -export function useProjectViewsAssetsMinimalListRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidProjectView: string, - params?: ProjectViewsAssetsMinimalListRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectViewsAssetsMinimalListRetrieveQueryOptions(uidProjectView, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve users available in project view - - */ -export type projectViewsUsersRetrieveResponse200 = { - data: PaginatedProjectViewUserResponseList - status: 200 -} - -export type projectViewsUsersRetrieveResponse403 = { - data: ErrorDetail - status: 403 -} - -export type projectViewsUsersRetrieveResponseComposite = - | projectViewsUsersRetrieveResponse200 - | projectViewsUsersRetrieveResponse403 - -export type projectViewsUsersRetrieveResponse = projectViewsUsersRetrieveResponseComposite & { - headers: Headers -} - -export const getProjectViewsUsersRetrieveUrl = (uidProjectView: string, params?: ProjectViewsUsersRetrieveParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v2/project-views/${uidProjectView}/users/?${stringifiedParams}` - : `/api/v2/project-views/${uidProjectView}/users/` -} - -export const projectViewsUsersRetrieve = async ( - uidProjectView: string, - params?: ProjectViewsUsersRetrieveParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getProjectViewsUsersRetrieveUrl(uidProjectView, params), { - ...options, - method: 'GET', - }) -} - -export const getProjectViewsUsersRetrieveQueryKey = ( - uidProjectView: string, - params?: ProjectViewsUsersRetrieveParams, -) => { - return ['api', 'v2', 'project-views', uidProjectView, 'users', ...(params ? [params] : [])] as const -} - -export const getProjectViewsUsersRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - uidProjectView: string, - params?: ProjectViewsUsersRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getProjectViewsUsersRetrieveQueryKey(uidProjectView, params) - - const queryFn: QueryFunction>> = ({ signal }) => - projectViewsUsersRetrieve(uidProjectView, params, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!uidProjectView, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ProjectViewsUsersRetrieveQueryResult = NonNullable>> -export type ProjectViewsUsersRetrieveQueryError = ErrorDetail - -export function useProjectViewsUsersRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - uidProjectView: string, - params?: ProjectViewsUsersRetrieveParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getProjectViewsUsersRetrieveQueryOptions(uidProjectView, params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ⚠️ Deprecated -## Track Service Usage - -Tracks the total usage of different services for the logged-in user.
-Tracks the submissions and NLP seconds/characters for the current month/year/all time.
-Tracks the current total storage used.
-Note: this endpoint is not currently used by the frontend to display usage information.
-See `/api/v2/organizations/{organization_id}/service_usage/` for the endpoint we use on the Usage page.
- - */ -export type serviceUsageListResponse200 = { - data: ServiceUsageResponse[] - status: 200 -} - -export type serviceUsageListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type serviceUsageListResponseComposite = serviceUsageListResponse200 | serviceUsageListResponse401 - -export type serviceUsageListResponse = serviceUsageListResponseComposite & { - headers: Headers -} - -export const getServiceUsageListUrl = () => { - return `/api/v2/service_usage/` -} - -export const serviceUsageList = async (options?: RequestInit): Promise => { - return fetchWithAuth(getServiceUsageListUrl(), { - ...options, - method: 'GET', - }) -} - -export const getServiceUsageListQueryKey = () => { - return ['api', 'v2', 'service_usage'] as const -} - -export const getServiceUsageListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getServiceUsageListQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - serviceUsageList({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type ServiceUsageListQueryResult = NonNullable>> -export type ServiceUsageListQueryError = ErrorDetail - -export function useServiceUsageList< - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getServiceUsageListQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## List users - -⚠️ _Only available to superusers_ - -Search can be made with `q` parameter. - -Allowed fields are: - -- `username` -- `is_active` -- `email` -- `date_joined` -- `last_login` -- `extra_details__data__` - - */ -export type usersListResponse200 = { - data: PaginatedUserListResponseList - status: 200 -} - -export type usersListResponse403 = { - data: ErrorDetail - status: 403 -} - -export type usersListResponseComposite = usersListResponse200 | usersListResponse403 - -export type usersListResponse = usersListResponseComposite & { - headers: Headers -} - -export const getUsersListUrl = (params?: UsersListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/api/v2/users/?${stringifiedParams}` : `/api/v2/users/` -} - -export const usersList = async (params?: UsersListParams, options?: RequestInit): Promise => { - return fetchWithAuth(getUsersListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getUsersListQueryKey = (params?: UsersListParams) => { - return ['api', 'v2', 'users', ...(params ? [params] : [])] as const -} - -export const getUsersListQueryOptions = >, TError = ErrorDetail>( - params?: UsersListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getUsersListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - usersList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type UsersListQueryResult = NonNullable>> -export type UsersListQueryError = ErrorDetail - -export function useUsersList>, TError = ErrorDetail>( - params?: UsersListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getUsersListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve a user - -⚠️ _Regular users have access to active users only_ - - */ -export type usersRetrieveResponse200 = { - data: UserRetrieveResponse - status: 200 -} - -export type usersRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type usersRetrieveResponseComposite = usersRetrieveResponse200 | usersRetrieveResponse404 - -export type usersRetrieveResponse = usersRetrieveResponseComposite & { - headers: Headers -} - -export const getUsersRetrieveUrl = (username: string) => { - return `/api/v2/users/${username}/` -} - -export const usersRetrieve = async (username: string, options?: RequestInit): Promise => { - return fetchWithAuth(getUsersRetrieveUrl(username), { - ...options, - method: 'GET', - }) -} - -export const getUsersRetrieveQueryKey = (username: string) => { - return ['api', 'v2', 'users', username] as const -} - -export const getUsersRetrieveQueryOptions = >, TError = ErrorDetail>( - username: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getUsersRetrieveQueryKey(username) - - const queryFn: QueryFunction>> = ({ signal }) => - usersRetrieve(username, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!username, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type UsersRetrieveQueryResult = NonNullable>> -export type UsersRetrieveQueryError = ErrorDetail - -export function useUsersRetrieve>, TError = ErrorDetail>( - username: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getUsersRetrieveQueryOptions(username, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve current user profile - - */ -export type meRetrieveResponse200 = { - data: MeListResponse - status: 200 -} - -export type meRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type meRetrieveResponseComposite = meRetrieveResponse200 | meRetrieveResponse401 - -export type meRetrieveResponse = meRetrieveResponseComposite & { - headers: Headers -} - -export const getMeRetrieveUrl = () => { - return `/me/` -} - -export const meRetrieve = async (options?: RequestInit): Promise => { - return fetchWithAuth(getMeRetrieveUrl(), { - ...options, - method: 'GET', - }) -} - -export const getMeRetrieveQueryKey = () => { - return ['me'] as const -} - -export const getMeRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getMeRetrieveQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - meRetrieve({ signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type MeRetrieveQueryResult = NonNullable>> -export type MeRetrieveQueryError = ErrorDetail - -export function useMeRetrieve>, TError = ErrorDetail>(options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter -}): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getMeRetrieveQueryOptions(options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Update current user infos - - */ -export type mePartialUpdateResponse200 = { - data: MeListResponse - status: 200 -} - -export type mePartialUpdateResponse400 = { - data: ErrorObject - status: 400 -} - -export type mePartialUpdateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type mePartialUpdateResponseComposite = - | mePartialUpdateResponse200 - | mePartialUpdateResponse400 - | mePartialUpdateResponse401 - -export type mePartialUpdateResponse = mePartialUpdateResponseComposite & { - headers: Headers -} - -export const getMePartialUpdateUrl = () => { - return `/me/` -} - -export const mePartialUpdate = async ( - patchedCurrentUser: NonReadonly, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getMePartialUpdateUrl(), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(patchedCurrentUser), - }) -} - -export const getMePartialUpdateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext -> => { - const mutationKey = ['mePartialUpdate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: NonReadonly } - > = (props) => { - const { data } = props ?? {} - - return mePartialUpdate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type MePartialUpdateMutationResult = NonNullable>> -export type MePartialUpdateMutationBody = NonReadonly -export type MePartialUpdateMutationError = ErrorObject | ErrorDetail - -export const useMePartialUpdate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: NonReadonly }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getMePartialUpdateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## Delete current user - -> Payload Example: -> -> { -> "confirm": "user__extra_details__uid", -> } - - -### !! Due to current DRF-Spectacular limitations with AOS 3.1, DELETE operations do not display request or response bodies in this documentation (as payloads are not typically recommended for DELETE). This means direct testing is unavailable. However, example payloads and responses are provided for reference, and HTTP codes/error messages are accurate. !! - - */ -export type meDestroyResponse204 = { - data: void - status: 204 -} - -export type meDestroyResponse400 = { - data: ErrorObject - status: 400 -} - -export type meDestroyResponse401 = { - data: ErrorDetail - status: 401 -} - -export type meDestroyResponseComposite = meDestroyResponse204 | meDestroyResponse400 | meDestroyResponse401 - -export type meDestroyResponse = meDestroyResponseComposite & { - headers: Headers -} - -export const getMeDestroyUrl = () => { - return `/me/` -} - -export const meDestroy = async (options?: RequestInit): Promise => { - return fetchWithAuth(getMeDestroyUrl(), { - ...options, - method: 'DELETE', - }) -} - -export const getMeDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['meDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return meDestroy(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type MeDestroyMutationResult = NonNullable>> - -export type MeDestroyMutationError = ErrorObject | ErrorDetail - -export const useMeDestroy = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}) => { - const mutationOptions = getMeDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## View current user's email - - */ -export type meEmailsListResponse200 = { - data: PaginatedEmailAddressList - status: 200 -} - -export type meEmailsListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type meEmailsListResponseComposite = meEmailsListResponse200 | meEmailsListResponse401 - -export type meEmailsListResponse = meEmailsListResponseComposite & { - headers: Headers -} - -export const getMeEmailsListUrl = (params?: MeEmailsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/me/emails/?${stringifiedParams}` : `/me/emails/` -} - -export const meEmailsList = async ( - params?: MeEmailsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getMeEmailsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getMeEmailsListQueryKey = (params?: MeEmailsListParams) => { - return ['me', 'emails', ...(params ? [params] : [])] as const -} - -export const getMeEmailsListQueryOptions = >, TError = ErrorDetail>( - params?: MeEmailsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getMeEmailsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - meEmailsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type MeEmailsListQueryResult = NonNullable>> -export type MeEmailsListQueryError = ErrorDetail - -export function useMeEmailsList>, TError = ErrorDetail>( - params?: MeEmailsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getMeEmailsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Set a new email - -The new email will be unverified and replace existing unverified, non-primary emails. -New email is not usable until verified. - - */ -export type meEmailsCreateResponse201 = { - data: EmailAddress - status: 201 -} - -export type meEmailsCreateResponse400 = { - data: ErrorObject - status: 400 -} - -export type meEmailsCreateResponse401 = { - data: ErrorDetail - status: 401 -} - -export type meEmailsCreateResponseComposite = - | meEmailsCreateResponse201 - | meEmailsCreateResponse400 - | meEmailsCreateResponse401 - -export type meEmailsCreateResponse = meEmailsCreateResponseComposite & { - headers: Headers -} - -export const getMeEmailsCreateUrl = () => { - return `/me/emails/` -} - -export const meEmailsCreate = async ( - emailRequestPayload: EmailRequestPayload, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getMeEmailsCreateUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(emailRequestPayload), - }) -} - -export const getMeEmailsCreateMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailRequestPayload }, - TContext - > - request?: SecondParameter -}): UseMutationOptions>, TError, { data: EmailRequestPayload }, TContext> => { - const mutationKey = ['meEmailsCreate'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { data: EmailRequestPayload }> = ( - props, - ) => { - const { data } = props ?? {} - - return meEmailsCreate(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type MeEmailsCreateMutationResult = NonNullable>> -export type MeEmailsCreateMutationBody = EmailRequestPayload -export type MeEmailsCreateMutationError = ErrorObject | ErrorDetail - -export const useMeEmailsCreate = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: EmailRequestPayload }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getMeEmailsCreateMutationOptions(options) - - return useMutation(mutationOptions) -} -/** - * ## List user's social accounts - - */ -export type meSocialAccountsListResponse200 = { - data: PaginatedSocialAccountList - status: 200 -} - -export type meSocialAccountsListResponse401 = { - data: ErrorDetail - status: 401 -} - -export type meSocialAccountsListResponseComposite = meSocialAccountsListResponse200 | meSocialAccountsListResponse401 - -export type meSocialAccountsListResponse = meSocialAccountsListResponseComposite & { - headers: Headers -} - -export const getMeSocialAccountsListUrl = (params?: MeSocialAccountsListParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 ? `/me/social-accounts/?${stringifiedParams}` : `/me/social-accounts/` -} - -export const meSocialAccountsList = async ( - params?: MeSocialAccountsListParams, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getMeSocialAccountsListUrl(params), { - ...options, - method: 'GET', - }) -} - -export const getMeSocialAccountsListQueryKey = (params?: MeSocialAccountsListParams) => { - return ['me', 'social-accounts', ...(params ? [params] : [])] as const -} - -export const getMeSocialAccountsListQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - params?: MeSocialAccountsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getMeSocialAccountsListQueryKey(params) - - const queryFn: QueryFunction>> = ({ signal }) => - meSocialAccountsList(params, { signal, ...requestOptions }) - - return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type MeSocialAccountsListQueryResult = NonNullable>> -export type MeSocialAccountsListQueryError = ErrorDetail - -export function useMeSocialAccountsList>, TError = ErrorDetail>( - params?: MeSocialAccountsListParams, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getMeSocialAccountsListQueryOptions(params, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Retrieve a social account provider - - */ -export type meSocialAccountsRetrieveResponse200 = { - data: SocialAccount - status: 200 -} - -export type meSocialAccountsRetrieveResponse401 = { - data: ErrorDetail - status: 401 -} - -export type meSocialAccountsRetrieveResponseComposite = - | meSocialAccountsRetrieveResponse200 - | meSocialAccountsRetrieveResponse401 - -export type meSocialAccountsRetrieveResponse = meSocialAccountsRetrieveResponseComposite & { - headers: Headers -} - -export const getMeSocialAccountsRetrieveUrl = (provider: string, uidSocialAccount: string) => { - return `/me/social-accounts/${provider}/${uidSocialAccount}/` -} - -export const meSocialAccountsRetrieve = async ( - provider: string, - uidSocialAccount: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getMeSocialAccountsRetrieveUrl(provider, uidSocialAccount), { - ...options, - method: 'GET', - }) -} - -export const getMeSocialAccountsRetrieveQueryKey = (provider: string, uidSocialAccount: string) => { - return ['me', 'social-accounts', provider, uidSocialAccount] as const -} - -export const getMeSocialAccountsRetrieveQueryOptions = < - TData = Awaited>, - TError = ErrorDetail, ->( - provider: string, - uidSocialAccount: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getMeSocialAccountsRetrieveQueryKey(provider, uidSocialAccount) - - const queryFn: QueryFunction>> = ({ signal }) => - meSocialAccountsRetrieve(provider, uidSocialAccount, { signal, ...requestOptions }) - - return { queryKey, queryFn, enabled: !!(provider && uidSocialAccount), ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: QueryKey } -} - -export type MeSocialAccountsRetrieveQueryResult = NonNullable>> -export type MeSocialAccountsRetrieveQueryError = ErrorDetail - -export function useMeSocialAccountsRetrieve< - TData = Awaited>, - TError = ErrorDetail, ->( - provider: string, - uidSocialAccount: string, - options?: { - query?: UseQueryOptions>, TError, TData> - request?: SecondParameter - }, -): UseQueryResult & { queryKey: QueryKey } { - const queryOptions = getMeSocialAccountsRetrieveQueryOptions(provider, uidSocialAccount, options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - - query.queryKey = queryOptions.queryKey - - return query -} - -/** - * ## Delete a social account provider - - */ -export type meSocialAccountsDestroyResponse204 = { - data: void - status: 204 -} - -export type meSocialAccountsDestroyResponse401 = { - data: ErrorDetail - status: 401 -} - -export type meSocialAccountsDestroyResponseComposite = - | meSocialAccountsDestroyResponse204 - | meSocialAccountsDestroyResponse401 - -export type meSocialAccountsDestroyResponse = meSocialAccountsDestroyResponseComposite & { - headers: Headers -} - -export const getMeSocialAccountsDestroyUrl = (provider: string, uidSocialAccount: string) => { - return `/me/social-accounts/${provider}/${uidSocialAccount}/` -} - -export const meSocialAccountsDestroy = async ( - provider: string, - uidSocialAccount: string, - options?: RequestInit, -): Promise => { - return fetchWithAuth(getMeSocialAccountsDestroyUrl(provider, uidSocialAccount), { - ...options, - method: 'DELETE', - }) -} - -export const getMeSocialAccountsDestroyMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { provider: string; uidSocialAccount: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { provider: string; uidSocialAccount: string }, - TContext -> => { - const mutationKey = ['meSocialAccountsDestroy'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { provider: string; uidSocialAccount: string } - > = (props) => { - const { provider, uidSocialAccount } = props ?? {} - - return meSocialAccountsDestroy(provider, uidSocialAccount, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type MeSocialAccountsDestroyMutationResult = NonNullable>> - -export type MeSocialAccountsDestroyMutationError = ErrorDetail - -export const useMeSocialAccountsDestroy = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { provider: string; uidSocialAccount: string }, - TContext - > - request?: SecondParameter -}) => { - const mutationOptions = getMeSocialAccountsDestroyMutationOptions(options) - - return useMutation(mutationOptions) -} diff --git a/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts b/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts index 96433f1f0f..c731b202e6 100644 --- a/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts +++ b/jsapp/js/attachments/AttachmentActionsDropdown.mocks.ts @@ -1,4 +1,4 @@ -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import { ANY_ROW_TYPE_NAMES, AssetTypeName } from '#/constants' import type { AssetResponse, SubmissionResponse } from '#/dataInterface' diff --git a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx index 6534d8d552..37f1f3a3f1 100644 --- a/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx +++ b/jsapp/js/components/AssetTagsModal/AssetTagsModal.stories.tsx @@ -1,7 +1,7 @@ import { ModalsProvider } from '@mantine/modals' import type { Meta, StoryObj } from '@storybook/react-webpack5' import { expect, fn, userEvent, waitFor, within } from 'storybook/test' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import ButtonNew from '#/components/common/ButtonNew' import type { AssetResponse } from '#/dataInterface' import { assetPatchMock } from '#/endpoints/asset.mocks' diff --git a/jsapp/js/components/activity/FormActivity.stories.tsx b/jsapp/js/components/activity/FormActivity.stories.tsx index b290bf61eb..65d5865514 100644 --- a/jsapp/js/components/activity/FormActivity.stories.tsx +++ b/jsapp/js/components/activity/FormActivity.stories.tsx @@ -1,7 +1,7 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { reactRouterParameters, withRouter } from 'storybook-addon-remix-react-router' import { expect, userEvent, waitFor, within } from 'storybook/test' -import { getApiV2AssetsHistoryActionsRetrieveMockHandler } from '#/api/react-query/logging.msw' +import { getApiV2AssetsHistoryActionsRetrieveMockHandler } from '#/api/react-query/logging/msw' import assetHistoryMock, { assetHistoryMockWithOngoingBulkProcessing, mockAssetUid, diff --git a/jsapp/js/components/locking/lockingUtils.mocks.ts b/jsapp/js/components/locking/lockingUtils.mocks.ts index 33904d85a1..a8de005968 100644 --- a/jsapp/js/components/locking/lockingUtils.mocks.ts +++ b/jsapp/js/components/locking/lockingUtils.mocks.ts @@ -1,6 +1,6 @@ import cloneDeep from 'lodash.clonedeep' import merge from 'lodash.merge' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import { AssetTypeName, GroupTypeBeginName, diff --git a/jsapp/js/components/map/FormMapWrapper.stories.tsx b/jsapp/js/components/map/FormMapWrapper.stories.tsx index 8ad5eadc8c..dddd07677d 100644 --- a/jsapp/js/components/map/FormMapWrapper.stories.tsx +++ b/jsapp/js/components/map/FormMapWrapper.stories.tsx @@ -3,7 +3,7 @@ import { http, HttpResponse } from 'msw' import { reactRouterParameters, withRouter } from 'storybook-addon-remix-react-router' import { expect, waitFor, within } from 'storybook/test' import { endpoints } from '#/api.endpoints' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import { MetaQuestionTypeName, QuestionTypeName } from '#/constants' import type { AssetResponse, PaginatedResponse, SubmissionResponse } from '#/dataInterface' import assetDataFactory from '#/endpoints/assetData.factory' diff --git a/jsapp/js/components/reports/reports.utils.tests.ts b/jsapp/js/components/reports/reports.utils.tests.ts index e5fe04df7b..3033bb4f4a 100644 --- a/jsapp/js/components/reports/reports.utils.tests.ts +++ b/jsapp/js/components/reports/reports.utils.tests.ts @@ -1,5 +1,5 @@ import chai from 'chai' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import { QuestionTypeName } from '#/constants' import type { AssetResponse } from '#/dataInterface' import { reportStyleFactory, reportsResponseDataFactory } from './reports.factory' diff --git a/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx b/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx index b37321d9fa..bf40300d96 100644 --- a/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx +++ b/jsapp/js/components/submissions/BulkProcessingBanner.stories.tsx @@ -1,6 +1,6 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { withRouter } from 'storybook-addon-remix-react-router' -import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data.msw' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data/msw' import BulkProcessingBanner from './BulkProcessingBanner' import { withBulkProcessingBannerSessionReset } from './BulkProcessingBannerStoriesUtils' diff --git a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx index fa35d8aef5..2370eb4dab 100644 --- a/jsapp/js/components/submissions/DataTableWrapper.stories.tsx +++ b/jsapp/js/components/submissions/DataTableWrapper.stories.tsx @@ -17,8 +17,8 @@ import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseSta import { getApiV2AssetsRetrieveMockHandler, getApiV2AssetsRetrieveResponseMock, -} from '#/api/react-query/manage-projects-and-library-content.msw' -import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data.msw' +} from '#/api/react-query/manage-projects-and-library-content/msw' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data/msw' import { QuestionTypeName } from '#/constants' import assetDataFactory from '#/endpoints/assetData.factory' import assetDataMock from '#/endpoints/assetData.mocks' diff --git a/jsapp/js/components/submissions/submissionUtils.mocks.ts b/jsapp/js/components/submissions/submissionUtils.mocks.ts index d1241af5b0..a3c1527d99 100644 --- a/jsapp/js/components/submissions/submissionUtils.mocks.ts +++ b/jsapp/js/components/submissions/submissionUtils.mocks.ts @@ -1,4 +1,4 @@ -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import { AssetTypeName, GroupTypeBeginName, diff --git a/jsapp/js/components/submissions/tableUtils.mocks.ts b/jsapp/js/components/submissions/tableUtils.mocks.ts index b9e1a91b91..eb66aba556 100644 --- a/jsapp/js/components/submissions/tableUtils.mocks.ts +++ b/jsapp/js/components/submissions/tableUtils.mocks.ts @@ -1,4 +1,4 @@ -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import { ANY_ROW_TYPE_NAMES, AssetTypeName } from '#/constants' import type { AssetResponse } from '#/dataInterface' diff --git a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts index cf091bc941..af67bd9a5b 100644 --- a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts +++ b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts @@ -6,7 +6,7 @@ import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock, getAssetsAdvancedFeaturesBulkActionsListQueryKey, useAssetsAdvancedFeaturesBulkActionsList, -} from '#/api/react-query/survey-data.msw' +} from '#/api/react-query/survey-data/msw' import { useFeatureFlag } from '#/featureFlags' import { useSession } from '#/stores/useSession' import { getBulkActionsPollingIntervalMs, useDataTableBulkActions } from './useDataTableBulkActions' diff --git a/jsapp/js/endpoints/assetHistory.mocks.ts b/jsapp/js/endpoints/assetHistory.mocks.ts index 68094191a4..fc91df44b3 100644 --- a/jsapp/js/endpoints/assetHistory.mocks.ts +++ b/jsapp/js/endpoints/assetHistory.mocks.ts @@ -1,7 +1,7 @@ import { http, HttpResponse, type PathParams } from 'msw' import { endpoints } from '#/api.endpoints' import type { ProjectHistoryLogResponse } from '#/api/models/projectHistoryLogResponse' -import { getApiV2ProjectHistoryLogsListResponseMock } from '#/api/react-query/server-logs-superusers.msw' +import { getApiV2ProjectHistoryLogsListResponseMock } from '#/api/react-query/server-logs-superusers/msw' import { type ActivityLogsItem, AuditActions, diff --git a/jsapp/js/endpoints/assets.mocks.ts b/jsapp/js/endpoints/assets.mocks.ts index 43486118f2..9028cc3407 100644 --- a/jsapp/js/endpoints/assets.mocks.ts +++ b/jsapp/js/endpoints/assets.mocks.ts @@ -1,7 +1,7 @@ import { getApiV2AssetsListMockHandler, getApiV2AssetsRetrieveResponseMock, -} from '#/api/react-query/manage-projects-and-library-content.msw' +} from '#/api/react-query/manage-projects-and-library-content/msw' import { AssetTypeName, QuestionTypeName } from '#/constants' import type { AssetResponse, PaginatedResponse } from '#/dataInterface' import { mockTemplates } from './assets.templates' diff --git a/jsapp/js/endpoints/assets.templates.ts b/jsapp/js/endpoints/assets.templates.ts index 134d12701b..b93e3f9b2b 100644 --- a/jsapp/js/endpoints/assets.templates.ts +++ b/jsapp/js/endpoints/assets.templates.ts @@ -1,4 +1,4 @@ -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import { AssetTypeName, QuestionTypeName } from '#/constants' /** diff --git a/jsapp/js/endpoints/bulkActions.mocks.ts b/jsapp/js/endpoints/bulkActions.mocks.ts index ec2827cc14..3a65c3e2fe 100644 --- a/jsapp/js/endpoints/bulkActions.mocks.ts +++ b/jsapp/js/endpoints/bulkActions.mocks.ts @@ -5,7 +5,7 @@ import type { BulkActionListResponse } from '#/api/models/bulkActionListResponse import type { BulkActionResponse } from '#/api/models/bulkActionResponse' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' import { BulkActionSubmissionStatusResponseStatusEnum } from '#/api/models/bulkActionSubmissionStatusResponseStatusEnum' -import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data.msw' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data/msw' /** * Mock API for bulk actions list. Use it in Storybook tests in `parameters.msw.handlers.bulkActions`. diff --git a/jsapp/js/endpoints/environment.mocks.ts b/jsapp/js/endpoints/environment.mocks.ts index ad7673b540..ee59f55b47 100644 --- a/jsapp/js/endpoints/environment.mocks.ts +++ b/jsapp/js/endpoints/environment.mocks.ts @@ -1,4 +1,4 @@ -import { getApiV2EnvironmentRetrieveMockHandler } from '#/api/react-query/configuration.msw' +import { getApiV2EnvironmentRetrieveMockHandler } from '#/api/react-query/configuration/msw' /** * Production-like environment configuration for testing. diff --git a/jsapp/js/endpoints/formMedia.mocks.ts b/jsapp/js/endpoints/formMedia.mocks.ts index 371eb0d0dd..e567b3dddf 100644 --- a/jsapp/js/endpoints/formMedia.mocks.ts +++ b/jsapp/js/endpoints/formMedia.mocks.ts @@ -4,7 +4,7 @@ import { getApiV2AssetsFilesCreateResponseMock, getApiV2AssetsFilesDestroyMockHandler, getApiV2AssetsFilesListMockHandler, -} from '#/api/react-query/survey-data.msw' +} from '#/api/react-query/survey-data/msw' /** * Extended FilesResponse type with redirect_url in metadata. diff --git a/jsapp/js/endpoints/languageDetail.mocks.ts b/jsapp/js/endpoints/languageDetail.mocks.ts index 6b215bd3cd..e4484bb5be 100644 --- a/jsapp/js/endpoints/languageDetail.mocks.ts +++ b/jsapp/js/endpoints/languageDetail.mocks.ts @@ -1,4 +1,4 @@ -import { getApiV2LanguagesRetrieveMockHandler } from '#/api/react-query/other.msw' +import { getApiV2LanguagesRetrieveMockHandler } from '#/api/react-query/other/msw' /** * Mock API for language detail endpoint using Orval-generated handler. diff --git a/jsapp/js/endpoints/me.mocks.ts b/jsapp/js/endpoints/me.mocks.ts index 0db619a373..1ade1873d5 100644 --- a/jsapp/js/endpoints/me.mocks.ts +++ b/jsapp/js/endpoints/me.mocks.ts @@ -1,5 +1,5 @@ import type { MeListResponse } from '#/api/models/meListResponse' -import { getMeRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage.msw' +import { getMeRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage/msw' /** * Mock response data for /me/ endpoint. diff --git a/jsapp/js/endpoints/organization.mocks.ts b/jsapp/js/endpoints/organization.mocks.ts index ab10f14795..81792fba40 100644 --- a/jsapp/js/endpoints/organization.mocks.ts +++ b/jsapp/js/endpoints/organization.mocks.ts @@ -1,5 +1,5 @@ import type { OrganizationResponse } from '#/api/models/organizationResponse' -import { getApiV2OrganizationsRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage.msw' +import { getApiV2OrganizationsRetrieveMockHandler } from '#/api/react-query/user-team-organization-usage/msw' import { meMockResponse } from './me.mocks' /** diff --git a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx index 855b9384b4..a587274dd6 100644 --- a/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx +++ b/jsapp/js/project/FormLanguagesManager/FormLanguagesManager.stories.tsx @@ -3,7 +3,7 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { expect, fn, userEvent, waitFor, within } from 'storybook/test' import type { AssetContentSurveyItem } from '#/api/models/assetContentSurveyItem' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import ButtonNew from '#/components/common/ButtonNew' import { QuestionTypeName } from '#/constants' import type { AssetResponse } from '#/dataInterface' diff --git a/jsapp/js/project/FormMedia/FormMedia.stories.tsx b/jsapp/js/project/FormMedia/FormMedia.stories.tsx index dbbbeb541f..7f1a5787fb 100644 --- a/jsapp/js/project/FormMedia/FormMedia.stories.tsx +++ b/jsapp/js/project/FormMedia/FormMedia.stories.tsx @@ -1,6 +1,6 @@ import type { Meta, StoryObj } from '@storybook/react-webpack5' import { expect, userEvent, waitFor, within } from 'storybook/test' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content.msw' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import { createFormMediaItem, formMediaHandlers } from '#/endpoints/formMedia.mocks' import { queryClientDecorator } from '#/query/queryClient.mocks' import FormMedia from './index' From e6b1562d749eff334e922b4fb4a270aa50394c5c Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 18:26:29 +0200 Subject: [PATCH 75/86] fix filenames --- orval.config.js | 2 ++ scripts/orval-rename-to-index.js | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 scripts/orval-rename-to-index.js diff --git a/orval.config.js b/orval.config.js index 8a73a48d99..1ad616db73 100644 --- a/orval.config.js +++ b/orval.config.js @@ -49,7 +49,9 @@ module.exports = { // See https://github.com/orval-labs/orval/issues/1077. // Also fix TypeScript errors in MSW mock factories for types with index signatures. // Make trailing slashes optional in MSW handlers to match both /path and /path/ + // Rename files to index.ts/msw.ts pattern for clean imports afterAllFilesWrite: [ + 'node scripts/orval-rename-to-index.js', 'node scripts/orval-fix-referenced-additional-properties.js', 'node scripts/orval-fix-mock-factory-type-assertions.js', 'node scripts/orval-make-trailing-slash-optional.js', diff --git a/scripts/orval-rename-to-index.js b/scripts/orval-rename-to-index.js new file mode 100755 index 0000000000..5fdac46a62 --- /dev/null +++ b/scripts/orval-rename-to-index.js @@ -0,0 +1,55 @@ +#!/usr/bin/env node + +/** + * Renames Orval-generated files to index.ts/msw.ts pattern for cleaner imports. + * + * With mode: 'tags-split', Orval creates: + * react-query/manage-projects-and-library-content/manage-projects-and-library-content.ts + * react-query/manage-projects-and-library-content/manage-projects-and-library-content.msw.ts + * + * This script renames to: + * react-query/manage-projects-and-library-content/index.ts + * react-query/manage-projects-and-library-content/msw.ts + * + * So imports can be: + * from '#/api/react-query/manage-projects-and-library-content' (runtime) + * from '#/api/react-query/manage-projects-and-library-content/msw' (mocks) + */ + +const fs = require('fs') +const path = require('path') + +const REACT_QUERY_DIR = path.join(__dirname, '../jsapp/js/api/react-query') + +function renameInDirectory(dirPath) { + const entries = fs.readdirSync(dirPath, { withFileTypes: true }) + + for (const entry of entries) { + if (entry.isDirectory()) { + const subDirPath = path.join(dirPath, entry.name) + const baseFileName = `${entry.name}.ts` + const baseMswFileName = `${entry.name}.msw.ts` + + const oldMainPath = path.join(subDirPath, baseFileName) + const oldMswPath = path.join(subDirPath, baseMswFileName) + const newMainPath = path.join(subDirPath, 'index.ts') + const newMswPath = path.join(subDirPath, 'msw.ts') + + // Rename main file if it exists + if (fs.existsSync(oldMainPath)) { + fs.renameSync(oldMainPath, newMainPath) + console.log(`✓ Renamed: ${entry.name}/${entry.name}.ts → ${entry.name}/index.ts`) + } + + // Rename .msw file if it exists + if (fs.existsSync(oldMswPath)) { + fs.renameSync(oldMswPath, newMswPath) + console.log(`✓ Renamed: ${entry.name}/${entry.name}.msw.ts → ${entry.name}/msw.ts`) + } + } + } +} + +console.log('Renaming Orval-generated files to index.ts/msw.ts pattern...') +renameInDirectory(REACT_QUERY_DIR) +console.log('Done!') From 967134956f447c16bd1fa036afd6f66fbdf87c29 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 18:32:30 +0200 Subject: [PATCH 76/86] run biome on generated orval files --- .../authentication-allauth-headless/index.ts | 9325 +++++++++-------- .../authentication-allauth-headless/msw.ts | 4591 ++++++-- .../js/api/react-query/configuration/index.ts | 113 +- jsapp/js/api/react-query/configuration/msw.ts | 150 +- .../js/api/react-query/form-content/index.ts | 1195 ++- jsapp/js/api/react-query/form-content/msw.ts | 584 +- .../react-query/library-collections/index.ts | 470 +- .../react-query/library-collections/msw.ts | 140 +- jsapp/js/api/react-query/logging/index.ts | 646 +- jsapp/js/api/react-query/logging/msw.ts | 432 +- .../react-query/manage-permissions/index.ts | 917 +- .../api/react-query/manage-permissions/msw.ts | 228 +- .../index.ts | 3071 +++--- .../msw.ts | 5379 +++++++++- jsapp/js/api/react-query/other/index.ts | 1895 ++-- jsapp/js/api/react-query/other/msw.ts | 1240 ++- jsapp/js/api/react-query/scim/index.ts | 1785 ++-- jsapp/js/api/react-query/scim/msw.ts | 607 +- .../server-logs-superusers/index.ts | 834 +- .../react-query/server-logs-superusers/msw.ts | 1097 +- .../survey-data-rest-services/index.ts | 1156 +- .../survey-data-rest-services/msw.ts | 470 +- jsapp/js/api/react-query/survey-data/index.ts | 7012 +++++++------ jsapp/js/api/react-query/survey-data/msw.ts | 3483 ++++-- .../user-team-organization-usage/index.ts | 4352 ++++---- .../user-team-organization-usage/msw.ts | 2545 ++++- orval.config.js | 6 +- 27 files changed, 34398 insertions(+), 19325 deletions(-) diff --git a/jsapp/js/api/react-query/authentication-allauth-headless/index.ts b/jsapp/js/api/react-query/authentication-allauth-headless/index.ts index f291ac9f14..042476b18e 100644 --- a/jsapp/js/api/react-query/authentication-allauth-headless/index.ts +++ b/jsapp/js/api/react-query/authentication-allauth-headless/index.ts @@ -9,225 +9,119 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - AddAuthenticatorConflictResponse -} from '../../models/addAuthenticatorConflictResponse'; - -import type { - AuthenticatedByCodeResponse -} from '../../models/authenticatedByCodeResponse'; - -import type { - AuthenticatedByPasswordAnd2FAResponse -} from '../../models/authenticatedByPasswordAnd2FAResponse'; - -import type { - AuthenticatedByPasswordResponse -} from '../../models/authenticatedByPasswordResponse'; +import type { AddAuthenticatorConflictResponse } from '../../models/addAuthenticatorConflictResponse' -import type { - AuthenticatedResponse -} from '../../models/authenticatedResponse'; +import type { AuthenticatedByCodeResponse } from '../../models/authenticatedByCodeResponse' -import type { - AuthenticationOrReauthenticationResponse -} from '../../models/authenticationOrReauthenticationResponse'; +import type { AuthenticatedByPasswordAnd2FAResponse } from '../../models/authenticatedByPasswordAnd2FAResponse' -import type { - AuthenticationResponse -} from '../../models/authenticationResponse'; +import type { AuthenticatedByPasswordResponse } from '../../models/authenticatedByPasswordResponse' -import type { - AuthenticatorsResponse -} from '../../models/authenticatorsResponse'; +import type { AuthenticatedResponse } from '../../models/authenticatedResponse' -import type { - ChangePasswordBody -} from '../../models/changePasswordBody'; +import type { AuthenticationOrReauthenticationResponse } from '../../models/authenticationOrReauthenticationResponse' -import type { - ConfigurationResponse -} from '../../models/configurationResponse'; +import type { AuthenticationResponse } from '../../models/authenticationResponse' -import type { - ConfirmLoginCodeBody -} from '../../models/confirmLoginCodeBody'; +import type { AuthenticatorsResponse } from '../../models/authenticatorsResponse' -import type { - ConflictResponse -} from '../../models/conflictResponse'; +import type { ChangePasswordBody } from '../../models/changePasswordBody' -import type { - EmailAddressesResponse -} from '../../models/emailAddressesResponse'; +import type { ConfigurationResponse } from '../../models/configurationResponse' -import type { - EmailBody -} from '../../models/emailBody'; +import type { ConfirmLoginCodeBody } from '../../models/confirmLoginCodeBody' -import type { - EmailVerificationInfoResponse -} from '../../models/emailVerificationInfoResponse'; +import type { ConflictResponse } from '../../models/conflictResponse' -import type { - EndSessionsBody -} from '../../models/endSessionsBody'; +import type { EmailAddressesResponse } from '../../models/emailAddressesResponse' -import type { - ErrorResponse -} from '../../models/errorResponse'; +import type { EmailBody } from '../../models/emailBody' -import type { - ForbiddenResponse -} from '../../models/forbiddenResponse'; +import type { EmailVerificationInfoResponse } from '../../models/emailVerificationInfoResponse' -import type { - LoginBody -} from '../../models/loginBody'; +import type { EndSessionsBody } from '../../models/endSessionsBody' -import type { - MFAAuthenticateBody -} from '../../models/mFAAuthenticateBody'; +import type { ErrorResponse } from '../../models/errorResponse' -import type { - MarkPrimaryEmailBody -} from '../../models/markPrimaryEmailBody'; +import type { ForbiddenResponse } from '../../models/forbiddenResponse' -import type { - NotFoundResponse -} from '../../models/notFoundResponse'; +import type { LoginBody } from '../../models/loginBody' -import type { - PasswordResetInfoResponse -} from '../../models/passwordResetInfoResponse'; +import type { MFAAuthenticateBody } from '../../models/mFAAuthenticateBody' -import type { - PhoneBody -} from '../../models/phoneBody'; +import type { MarkPrimaryEmailBody } from '../../models/markPrimaryEmailBody' -import type { - PhoneNumberChangeResponse -} from '../../models/phoneNumberChangeResponse'; +import type { NotFoundResponse } from '../../models/notFoundResponse' -import type { - PhoneNumbersResponse -} from '../../models/phoneNumbersResponse'; +import type { PasswordResetInfoResponse } from '../../models/passwordResetInfoResponse' -import type { - ProviderAccountBody -} from '../../models/providerAccountBody'; +import type { PhoneBody } from '../../models/phoneBody' -import type { - ProviderAccountsResponse -} from '../../models/providerAccountsResponse'; +import type { PhoneNumberChangeResponse } from '../../models/phoneNumberChangeResponse' -import type { - ProviderRedirectBody -} from '../../models/providerRedirectBody'; +import type { PhoneNumbersResponse } from '../../models/phoneNumbersResponse' -import type { - ProviderSignupBody -} from '../../models/providerSignupBody'; +import type { ProviderAccountBody } from '../../models/providerAccountBody' -import type { - ProviderSignupResponse -} from '../../models/providerSignupResponse'; +import type { ProviderAccountsResponse } from '../../models/providerAccountsResponse' -import type { - ProviderTokenBody -} from '../../models/providerTokenBody'; +import type { ProviderRedirectBody } from '../../models/providerRedirectBody' -import type { - ReauthenticateBody -} from '../../models/reauthenticateBody'; +import type { ProviderSignupBody } from '../../models/providerSignupBody' -import type { - ReauthenticationRequiredResponse -} from '../../models/reauthenticationRequiredResponse'; +import type { ProviderSignupResponse } from '../../models/providerSignupResponse' -import type { - RecoveryCodesResponse -} from '../../models/recoveryCodesResponse'; +import type { ProviderTokenBody } from '../../models/providerTokenBody' -import type { - RefreshTokenBody -} from '../../models/refreshTokenBody'; +import type { ReauthenticateBody } from '../../models/reauthenticateBody' -import type { - RefreshTokenResponse -} from '../../models/refreshTokenResponse'; +import type { ReauthenticationRequiredResponse } from '../../models/reauthenticationRequiredResponse' -import type { - RequestPasswordBody -} from '../../models/requestPasswordBody'; +import type { RecoveryCodesResponse } from '../../models/recoveryCodesResponse' -import type { - ResetPasswordBody -} from '../../models/resetPasswordBody'; +import type { RefreshTokenBody } from '../../models/refreshTokenBody' -import type { - SessionGoneResponse -} from '../../models/sessionGoneResponse'; +import type { RefreshTokenResponse } from '../../models/refreshTokenResponse' -import type { - SessionsResponse -} from '../../models/sessionsResponse'; +import type { RequestPasswordBody } from '../../models/requestPasswordBody' -import type { - SetupTOTPBody -} from '../../models/setupTOTPBody'; +import type { ResetPasswordBody } from '../../models/resetPasswordBody' -import type { - SignupBody -} from '../../models/signupBody'; +import type { SessionGoneResponse } from '../../models/sessionGoneResponse' -import type { - StatusOKResponse -} from '../../models/statusOKResponse'; +import type { SessionsResponse } from '../../models/sessionsResponse' -import type { - TOTPAuthenticatorNotFoundResponse -} from '../../models/tOTPAuthenticatorNotFoundResponse'; +import type { SetupTOTPBody } from '../../models/setupTOTPBody' -import type { - TOTPAuthenticatorResponse -} from '../../models/tOTPAuthenticatorResponse'; +import type { SignupBody } from '../../models/signupBody' -import type { - TooManyRequestsResponse -} from '../../models/tooManyRequestsResponse'; +import type { StatusOKResponse } from '../../models/statusOKResponse' -import type { - UnauthenticatedResponse -} from '../../models/unauthenticatedResponse'; +import type { TOTPAuthenticatorNotFoundResponse } from '../../models/tOTPAuthenticatorNotFoundResponse' -import type { - VerifyEmailBody -} from '../../models/verifyEmailBody'; +import type { TOTPAuthenticatorResponse } from '../../models/tOTPAuthenticatorResponse' -import type { - VerifyPhoneBody -} from '../../models/verifyPhoneBody'; +import type { TooManyRequestsResponse } from '../../models/tooManyRequestsResponse' -import { fetchWithAuth } from '../../orval.mutator'; +import type { UnauthenticatedResponse } from '../../models/unauthenticatedResponse' +import type { VerifyEmailBody } from '../../models/verifyEmailBody' -type SecondParameter unknown> = Parameters[1]; +import type { VerifyPhoneBody } from '../../models/verifyPhoneBody' +import { fetchWithAuth } from '../../orval.mutator' +type SecondParameter unknown> = Parameters[1] /** * There are many configuration options that alter the functionality @@ -243,81 +137,72 @@ export type allauthBrowserV1ConfigGetResponse200 = { data: ConfigurationResponse status: 200 } - -export type allauthBrowserV1ConfigGetResponseComposite = allauthBrowserV1ConfigGetResponse200; - + +export type allauthBrowserV1ConfigGetResponseComposite = allauthBrowserV1ConfigGetResponse200 + export type allauthBrowserV1ConfigGetResponse = allauthBrowserV1ConfigGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1ConfigGetUrl = () => { - - - - return `/api/v2/allauth/browser/v1/config` } -export const allauthBrowserV1ConfigGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1ConfigGetUrl(), - { +export const allauthBrowserV1ConfigGet = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAllauthBrowserV1ConfigGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthBrowserV1ConfigGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','config'] as const; - } - - -export const getAllauthBrowserV1ConfigGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1ConfigGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'config'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1ConfigGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1ConfigGetQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1ConfigGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthBrowserV1ConfigGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AllauthBrowserV1ConfigGetQueryResult = NonNullable>> export type AllauthBrowserV1ConfigGetQueryError = unknown - /** * @summary Get configuration */ -export function useAllauthBrowserV1ConfigGet>, TError = unknown>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1ConfigGet< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1ConfigGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * There are many configuration options that alter the functionality and behavior of django-allauth, some of which can also impact the @@ -332,81 +217,72 @@ export type allauthAppV1ConfigGetResponse200 = { data: ConfigurationResponse status: 200 } - -export type allauthAppV1ConfigGetResponseComposite = allauthAppV1ConfigGetResponse200; - + +export type allauthAppV1ConfigGetResponseComposite = allauthAppV1ConfigGetResponse200 + export type allauthAppV1ConfigGetResponse = allauthAppV1ConfigGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1ConfigGetUrl = () => { - - - - return `/api/v2/allauth/app/v1/config` } -export const allauthAppV1ConfigGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1ConfigGetUrl(), - { +export const allauthAppV1ConfigGet = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAllauthAppV1ConfigGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthAppV1ConfigGetQueryKey = () => { - return ['api','v2','allauth','app','v1','config'] as const; - } - - -export const getAllauthAppV1ConfigGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1ConfigGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'config'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1ConfigGet({ signal, ...requestOptions }); +export const getAllauthAppV1ConfigGetQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1ConfigGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1ConfigGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AllauthAppV1ConfigGetQueryResult = NonNullable>> export type AllauthAppV1ConfigGetQueryError = unknown - /** * @summary Get configuration */ -export function useAllauthAppV1ConfigGet>, TError = unknown>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1ConfigGet< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1ConfigGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Login using a username-password or email-password combination. @@ -431,77 +307,94 @@ export type allauthBrowserV1AuthLoginPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AuthLoginPostResponseComposite = allauthBrowserV1AuthLoginPostResponse200 | allauthBrowserV1AuthLoginPostResponse400 | allauthBrowserV1AuthLoginPostResponse401 | allauthBrowserV1AuthLoginPostResponse409; - + +export type allauthBrowserV1AuthLoginPostResponseComposite = + | allauthBrowserV1AuthLoginPostResponse200 + | allauthBrowserV1AuthLoginPostResponse400 + | allauthBrowserV1AuthLoginPostResponse401 + | allauthBrowserV1AuthLoginPostResponse409 + export type allauthBrowserV1AuthLoginPostResponse = allauthBrowserV1AuthLoginPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthLoginPostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/login` } -export const allauthBrowserV1AuthLoginPost = async (loginBody: LoginBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthLoginPostUrl(), - { +export const allauthBrowserV1AuthLoginPost = async ( + loginBody: LoginBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthLoginPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - loginBody,) + body: JSON.stringify(loginBody), + }) +} + +export const getAllauthBrowserV1AuthLoginPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: LoginBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: LoginBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthLoginPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: LoginBody }> = ( + props, + ) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthLoginPost(data, requestOptions) } -);} - - + return { mutationFn, ...mutationOptions } +} -export const getAllauthBrowserV1AuthLoginPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: LoginBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: LoginBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthLoginPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: LoginBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AuthLoginPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthBrowserV1AuthLoginPostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthLoginPostMutationBody = LoginBody - export type AllauthBrowserV1AuthLoginPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse +export type AllauthBrowserV1AuthLoginPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthLoginPostMutationBody = LoginBody +export type AllauthBrowserV1AuthLoginPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - /** +/** * @summary Login */ -export const useAllauthBrowserV1AuthLoginPost = (options?: { mutation?:UseMutationOptions>, TError,{data: LoginBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthLoginPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthLoginPost = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: LoginBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthLoginPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Login using a username-password or email-password combination. * @summary Login @@ -525,77 +418,92 @@ export type allauthAppV1AuthLoginPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AuthLoginPostResponseComposite = allauthAppV1AuthLoginPostResponse200 | allauthAppV1AuthLoginPostResponse400 | allauthAppV1AuthLoginPostResponse401 | allauthAppV1AuthLoginPostResponse409; - + +export type allauthAppV1AuthLoginPostResponseComposite = + | allauthAppV1AuthLoginPostResponse200 + | allauthAppV1AuthLoginPostResponse400 + | allauthAppV1AuthLoginPostResponse401 + | allauthAppV1AuthLoginPostResponse409 + export type allauthAppV1AuthLoginPostResponse = allauthAppV1AuthLoginPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthLoginPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/login` } -export const allauthAppV1AuthLoginPost = async (loginBody: LoginBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthLoginPostUrl(), - { +export const allauthAppV1AuthLoginPost = async ( + loginBody: LoginBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthLoginPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - loginBody,) + body: JSON.stringify(loginBody), + }) +} + +export const getAllauthAppV1AuthLoginPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: LoginBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: LoginBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthLoginPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: LoginBody }> = ( + props, + ) => { + const { data } = props ?? {} + + return allauthAppV1AuthLoginPost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1AuthLoginPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: LoginBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: LoginBody}, TContext> => { -const mutationKey = ['allauthAppV1AuthLoginPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: LoginBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthLoginPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthAppV1AuthLoginPostMutationResult = NonNullable>> - export type AllauthAppV1AuthLoginPostMutationBody = LoginBody - export type AllauthAppV1AuthLoginPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse +export type AllauthAppV1AuthLoginPostMutationResult = NonNullable>> +export type AllauthAppV1AuthLoginPostMutationBody = LoginBody +export type AllauthAppV1AuthLoginPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - /** +/** * @summary Login */ -export const useAllauthAppV1AuthLoginPost = (options?: { mutation?:UseMutationOptions>, TError,{data: LoginBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthLoginPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AuthLoginPost = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: LoginBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthLoginPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Whether or not `username`, `email`, `phone` or combination of those are required depends on the configuration of django-allauth. Additionally, if a custom signup form is used there may be other custom properties @@ -627,77 +535,100 @@ export type allauthBrowserV1AuthSignupPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AuthSignupPostResponseComposite = allauthBrowserV1AuthSignupPostResponse200 | allauthBrowserV1AuthSignupPostResponse400 | allauthBrowserV1AuthSignupPostResponse401 | allauthBrowserV1AuthSignupPostResponse403 | allauthBrowserV1AuthSignupPostResponse409; - + +export type allauthBrowserV1AuthSignupPostResponseComposite = + | allauthBrowserV1AuthSignupPostResponse200 + | allauthBrowserV1AuthSignupPostResponse400 + | allauthBrowserV1AuthSignupPostResponse401 + | allauthBrowserV1AuthSignupPostResponse403 + | allauthBrowserV1AuthSignupPostResponse409 + export type allauthBrowserV1AuthSignupPostResponse = allauthBrowserV1AuthSignupPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthSignupPostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/signup` } -export const allauthBrowserV1AuthSignupPost = async (signupBody: SignupBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthSignupPostUrl(), - { +export const allauthBrowserV1AuthSignupPost = async ( + signupBody: SignupBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthSignupPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - signupBody,) + body: JSON.stringify(signupBody), + }) +} + +export const getAllauthBrowserV1AuthSignupPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: SignupBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: SignupBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthSignupPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: SignupBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthSignupPost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthSignupPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: SignupBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: SignupBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthSignupPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {data: SignupBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AuthSignupPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthBrowserV1AuthSignupPostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthSignupPostMutationBody = SignupBody - export type AllauthBrowserV1AuthSignupPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse +export type AllauthBrowserV1AuthSignupPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthSignupPostMutationBody = SignupBody +export type AllauthBrowserV1AuthSignupPostMutationError = + | ErrorResponse + | AuthenticationResponse + | ForbiddenResponse + | ConflictResponse - /** +/** * @summary Signup */ -export const useAllauthBrowserV1AuthSignupPost = (options?: { mutation?:UseMutationOptions>, TError,{data: SignupBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthSignupPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthSignupPost = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: SignupBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthSignupPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Whether or not `username`, `email`, `phone` or combination of those are required depends on the configuration of django-allauth. Additionally, if a custom signup form is used there may be other custom properties @@ -729,77 +660,99 @@ export type allauthAppV1AuthSignupPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AuthSignupPostResponseComposite = allauthAppV1AuthSignupPostResponse200 | allauthAppV1AuthSignupPostResponse400 | allauthAppV1AuthSignupPostResponse401 | allauthAppV1AuthSignupPostResponse403 | allauthAppV1AuthSignupPostResponse409; - + +export type allauthAppV1AuthSignupPostResponseComposite = + | allauthAppV1AuthSignupPostResponse200 + | allauthAppV1AuthSignupPostResponse400 + | allauthAppV1AuthSignupPostResponse401 + | allauthAppV1AuthSignupPostResponse403 + | allauthAppV1AuthSignupPostResponse409 + export type allauthAppV1AuthSignupPostResponse = allauthAppV1AuthSignupPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthSignupPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/signup` } -export const allauthAppV1AuthSignupPost = async (signupBody: SignupBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthSignupPostUrl(), - { +export const allauthAppV1AuthSignupPost = async ( + signupBody: SignupBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthSignupPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - signupBody,) + body: JSON.stringify(signupBody), + }) +} + +export const getAllauthAppV1AuthSignupPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: SignupBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: SignupBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthSignupPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: SignupBody }> = ( + props, + ) => { + const { data } = props ?? {} + + return allauthAppV1AuthSignupPost(data, requestOptions) } -);} + return { mutationFn, ...mutationOptions } +} +export type AllauthAppV1AuthSignupPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AuthSignupPostMutationBody = SignupBody +export type AllauthAppV1AuthSignupPostMutationError = + | ErrorResponse + | AuthenticationResponse + | ForbiddenResponse + | ConflictResponse - -export const getAllauthAppV1AuthSignupPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: SignupBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: SignupBody}, TContext> => { - -const mutationKey = ['allauthAppV1AuthSignupPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: SignupBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthSignupPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AuthSignupPostMutationResult = NonNullable>> - export type AllauthAppV1AuthSignupPostMutationBody = SignupBody - export type AllauthAppV1AuthSignupPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse - - /** +/** * @summary Signup */ -export const useAllauthAppV1AuthSignupPost = (options?: { mutation?:UseMutationOptions>, TError,{data: SignupBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthSignupPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AuthSignupPost = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: SignupBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthSignupPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Obtain email verification information, given the token that was sent to the user by email. @@ -819,81 +772,79 @@ export type allauthBrowserV1AuthEmailVerifyGetResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AuthEmailVerifyGetResponseComposite = allauthBrowserV1AuthEmailVerifyGetResponse200 | allauthBrowserV1AuthEmailVerifyGetResponse400 | allauthBrowserV1AuthEmailVerifyGetResponse409; - + +export type allauthBrowserV1AuthEmailVerifyGetResponseComposite = + | allauthBrowserV1AuthEmailVerifyGetResponse200 + | allauthBrowserV1AuthEmailVerifyGetResponse400 + | allauthBrowserV1AuthEmailVerifyGetResponse409 + export type allauthBrowserV1AuthEmailVerifyGetResponse = allauthBrowserV1AuthEmailVerifyGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthEmailVerifyGetUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/email/verify` } -export const allauthBrowserV1AuthEmailVerifyGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthEmailVerifyGetUrl(), - { +export const allauthBrowserV1AuthEmailVerifyGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthEmailVerifyGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthBrowserV1AuthEmailVerifyGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','auth','email','verify'] as const; - } - - -export const getAllauthBrowserV1AuthEmailVerifyGetQueryOptions = >, TError = ErrorResponse | ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthEmailVerifyGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'auth', 'email', 'verify'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AuthEmailVerifyGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1AuthEmailVerifyGetQueryOptions = < + TData = Awaited>, + TError = ErrorResponse | ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthEmailVerifyGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthBrowserV1AuthEmailVerifyGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthBrowserV1AuthEmailVerifyGetQueryResult = NonNullable>> +export type AllauthBrowserV1AuthEmailVerifyGetQueryResult = NonNullable< + Awaited> +> export type AllauthBrowserV1AuthEmailVerifyGetQueryError = ErrorResponse | ConflictResponse - /** * @summary Get email verification information */ -export function useAllauthBrowserV1AuthEmailVerifyGet>, TError = ErrorResponse | ConflictResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AuthEmailVerifyGet< + TData = Awaited>, + TError = ErrorResponse | ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AuthEmailVerifyGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Complete the email verification process. Depending on the configuration, email addresses are either verified by opening a link that is sent to @@ -927,77 +878,98 @@ export type allauthBrowserV1AuthEmailVerifyPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AuthEmailVerifyPostResponseComposite = allauthBrowserV1AuthEmailVerifyPostResponse200 | allauthBrowserV1AuthEmailVerifyPostResponse400 | allauthBrowserV1AuthEmailVerifyPostResponse401 | allauthBrowserV1AuthEmailVerifyPostResponse409; - + +export type allauthBrowserV1AuthEmailVerifyPostResponseComposite = + | allauthBrowserV1AuthEmailVerifyPostResponse200 + | allauthBrowserV1AuthEmailVerifyPostResponse400 + | allauthBrowserV1AuthEmailVerifyPostResponse401 + | allauthBrowserV1AuthEmailVerifyPostResponse409 + export type allauthBrowserV1AuthEmailVerifyPostResponse = allauthBrowserV1AuthEmailVerifyPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthEmailVerifyPostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/email/verify` } -export const allauthBrowserV1AuthEmailVerifyPost = async (verifyEmailBody: VerifyEmailBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthEmailVerifyPostUrl(), - { +export const allauthBrowserV1AuthEmailVerifyPost = async ( + verifyEmailBody: VerifyEmailBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthEmailVerifyPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - verifyEmailBody,) + body: JSON.stringify(verifyEmailBody), + }) +} + +export const getAllauthBrowserV1AuthEmailVerifyPostMutationOptions = < + TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: VerifyEmailBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: VerifyEmailBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthEmailVerifyPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: VerifyEmailBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthEmailVerifyPost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthEmailVerifyPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthEmailVerifyPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: VerifyEmailBody}> = (props) => { - const {data} = props ?? {}; - return allauthBrowserV1AuthEmailVerifyPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AuthEmailVerifyPostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthEmailVerifyPostMutationBody = VerifyEmailBody - export type AllauthBrowserV1AuthEmailVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse +export type AllauthBrowserV1AuthEmailVerifyPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthEmailVerifyPostMutationBody = VerifyEmailBody +export type AllauthBrowserV1AuthEmailVerifyPostMutationError = + | ErrorResponse + | UnauthenticatedResponse + | ConflictResponse - /** +/** * @summary Verify an email */ -export const useAllauthBrowserV1AuthEmailVerifyPost = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthEmailVerifyPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthEmailVerifyPost = < + TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: VerifyEmailBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthEmailVerifyPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Obtain email verification information, given the token that was sent to the user by email. @@ -1017,81 +989,79 @@ export type allauthAppV1AuthEmailVerifyGetResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AuthEmailVerifyGetResponseComposite = allauthAppV1AuthEmailVerifyGetResponse200 | allauthAppV1AuthEmailVerifyGetResponse400 | allauthAppV1AuthEmailVerifyGetResponse409; - + +export type allauthAppV1AuthEmailVerifyGetResponseComposite = + | allauthAppV1AuthEmailVerifyGetResponse200 + | allauthAppV1AuthEmailVerifyGetResponse400 + | allauthAppV1AuthEmailVerifyGetResponse409 + export type allauthAppV1AuthEmailVerifyGetResponse = allauthAppV1AuthEmailVerifyGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthEmailVerifyGetUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/email/verify` } -export const allauthAppV1AuthEmailVerifyGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthEmailVerifyGetUrl(), - { +export const allauthAppV1AuthEmailVerifyGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthEmailVerifyGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthAppV1AuthEmailVerifyGetQueryKey = () => { - return ['api','v2','allauth','app','v1','auth','email','verify'] as const; - } - - -export const getAllauthAppV1AuthEmailVerifyGetQueryOptions = >, TError = ErrorResponse | ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthEmailVerifyGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'auth', 'email', 'verify'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AuthEmailVerifyGet({ signal, ...requestOptions }); +export const getAllauthAppV1AuthEmailVerifyGetQueryOptions = < + TData = Awaited>, + TError = ErrorResponse | ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthEmailVerifyGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1AuthEmailVerifyGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthAppV1AuthEmailVerifyGetQueryResult = NonNullable>> +export type AllauthAppV1AuthEmailVerifyGetQueryResult = NonNullable< + Awaited> +> export type AllauthAppV1AuthEmailVerifyGetQueryError = ErrorResponse | ConflictResponse - /** * @summary Get email verification information */ -export function useAllauthAppV1AuthEmailVerifyGet>, TError = ErrorResponse | ConflictResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AuthEmailVerifyGet< + TData = Awaited>, + TError = ErrorResponse | ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AuthEmailVerifyGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Complete the email verification process. Depending on the configuration, email addresses are either verified by opening a link that is sent to @@ -1125,78 +1095,96 @@ export type allauthAppV1AuthEmailVerifyPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AuthEmailVerifyPostResponseComposite = allauthAppV1AuthEmailVerifyPostResponse200 | allauthAppV1AuthEmailVerifyPostResponse400 | allauthAppV1AuthEmailVerifyPostResponse401 | allauthAppV1AuthEmailVerifyPostResponse409; - + +export type allauthAppV1AuthEmailVerifyPostResponseComposite = + | allauthAppV1AuthEmailVerifyPostResponse200 + | allauthAppV1AuthEmailVerifyPostResponse400 + | allauthAppV1AuthEmailVerifyPostResponse401 + | allauthAppV1AuthEmailVerifyPostResponse409 + export type allauthAppV1AuthEmailVerifyPostResponse = allauthAppV1AuthEmailVerifyPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthEmailVerifyPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/email/verify` } -export const allauthAppV1AuthEmailVerifyPost = async (verifyEmailBody: VerifyEmailBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthEmailVerifyPostUrl(), - { +export const allauthAppV1AuthEmailVerifyPost = async ( + verifyEmailBody: VerifyEmailBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthEmailVerifyPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - verifyEmailBody,) + body: JSON.stringify(verifyEmailBody), + }) +} + +export const getAllauthAppV1AuthEmailVerifyPostMutationOptions = < + TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: VerifyEmailBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: VerifyEmailBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthEmailVerifyPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: VerifyEmailBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AuthEmailVerifyPost(data, requestOptions) } -);} + return { mutationFn, ...mutationOptions } +} +export type AllauthAppV1AuthEmailVerifyPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AuthEmailVerifyPostMutationBody = VerifyEmailBody +export type AllauthAppV1AuthEmailVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse - -export const getAllauthAppV1AuthEmailVerifyPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext> => { - -const mutationKey = ['allauthAppV1AuthEmailVerifyPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: VerifyEmailBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthEmailVerifyPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AuthEmailVerifyPostMutationResult = NonNullable>> - export type AllauthAppV1AuthEmailVerifyPostMutationBody = VerifyEmailBody - export type AllauthAppV1AuthEmailVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse - - /** +/** * @summary Verify an email */ -export const useAllauthAppV1AuthEmailVerifyPost = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyEmailBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthEmailVerifyPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** - * Requests a new email verification code. +export const useAllauthAppV1AuthEmailVerifyPost = < + TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: VerifyEmailBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthEmailVerifyPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * Requests a new email verification code. Requires `ACCOUNT_EMAIL_VERIFICATION_SUPPORTS_RESEND = True`. * @summary Resend email verification code @@ -1215,76 +1203,93 @@ export type allauthBrowserV1AuthEmailVerifyResendPostResponse429 = { data: TooManyRequestsResponse status: 429 } - -export type allauthBrowserV1AuthEmailVerifyResendPostResponseComposite = allauthBrowserV1AuthEmailVerifyResendPostResponse200 | allauthBrowserV1AuthEmailVerifyResendPostResponse409 | allauthBrowserV1AuthEmailVerifyResendPostResponse429; - -export type allauthBrowserV1AuthEmailVerifyResendPostResponse = allauthBrowserV1AuthEmailVerifyResendPostResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1AuthEmailVerifyResendPostUrl = () => { +export type allauthBrowserV1AuthEmailVerifyResendPostResponseComposite = + | allauthBrowserV1AuthEmailVerifyResendPostResponse200 + | allauthBrowserV1AuthEmailVerifyResendPostResponse409 + | allauthBrowserV1AuthEmailVerifyResendPostResponse429 - +export type allauthBrowserV1AuthEmailVerifyResendPostResponse = + allauthBrowserV1AuthEmailVerifyResendPostResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1AuthEmailVerifyResendPostUrl = () => { return `/api/v2/allauth/browser/v1/auth/email/verify/resend` } -export const allauthBrowserV1AuthEmailVerifyResendPost = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthEmailVerifyResendPostUrl(), - { - ...options, - method: 'POST' - - +export const allauthBrowserV1AuthEmailVerifyResendPost = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1AuthEmailVerifyResendPostUrl(), + { + ...options, + method: 'POST', + }, + ) +} + +export const getAllauthBrowserV1AuthEmailVerifyResendPostMutationOptions = < + TError = ConflictResponse | TooManyRequestsResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthEmailVerifyResendPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + void + > = () => { + return allauthBrowserV1AuthEmailVerifyResendPost(requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthEmailVerifyResendPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthEmailVerifyResendPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return allauthBrowserV1AuthEmailVerifyResendPost(requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} +export type AllauthBrowserV1AuthEmailVerifyResendPostMutationResult = NonNullable< + Awaited> +> - export type AllauthBrowserV1AuthEmailVerifyResendPostMutationResult = NonNullable>> - - export type AllauthBrowserV1AuthEmailVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse +export type AllauthBrowserV1AuthEmailVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse - /** +/** * @summary Resend email verification code */ -export const useAllauthBrowserV1AuthEmailVerifyResendPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthEmailVerifyResendPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthEmailVerifyResendPost = < + TError = ConflictResponse | TooManyRequestsResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthEmailVerifyResendPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Requests a new email verification code. Requires `ACCOUNT_EMAIL_VERIFICATION_SUPPORTS_RESEND = True`. @@ -1304,76 +1309,81 @@ export type allauthAppV1AuthEmailVerifyResendPostResponse429 = { data: TooManyRequestsResponse status: 429 } - -export type allauthAppV1AuthEmailVerifyResendPostResponseComposite = allauthAppV1AuthEmailVerifyResendPostResponse200 | allauthAppV1AuthEmailVerifyResendPostResponse409 | allauthAppV1AuthEmailVerifyResendPostResponse429; - + +export type allauthAppV1AuthEmailVerifyResendPostResponseComposite = + | allauthAppV1AuthEmailVerifyResendPostResponse200 + | allauthAppV1AuthEmailVerifyResendPostResponse409 + | allauthAppV1AuthEmailVerifyResendPostResponse429 + export type allauthAppV1AuthEmailVerifyResendPostResponse = allauthAppV1AuthEmailVerifyResendPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthEmailVerifyResendPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/email/verify/resend` } -export const allauthAppV1AuthEmailVerifyResendPost = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthEmailVerifyResendPostUrl(), - { +export const allauthAppV1AuthEmailVerifyResendPost = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthEmailVerifyResendPostUrl(), { ...options, - method: 'POST' - - + method: 'POST', + }) +} + +export const getAllauthAppV1AuthEmailVerifyResendPostMutationOptions = < + TError = ConflictResponse | TooManyRequestsResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['allauthAppV1AuthEmailVerifyResendPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return allauthAppV1AuthEmailVerifyResendPost(requestOptions) } -);} - - - - -export const getAllauthAppV1AuthEmailVerifyResendPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['allauthAppV1AuthEmailVerifyResendPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return allauthAppV1AuthEmailVerifyResendPost(requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} +export type AllauthAppV1AuthEmailVerifyResendPostMutationResult = NonNullable< + Awaited> +> - export type AllauthAppV1AuthEmailVerifyResendPostMutationResult = NonNullable>> - - export type AllauthAppV1AuthEmailVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse +export type AllauthAppV1AuthEmailVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse - /** +/** * @summary Resend email verification code */ -export const useAllauthAppV1AuthEmailVerifyResendPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthEmailVerifyResendPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AuthEmailVerifyResendPost = < + TError = ConflictResponse | TooManyRequestsResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthEmailVerifyResendPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Complete the phone number verification process. Note that a status code of 401 does not imply failure. It merely indicates that the phone number verification was successful, yet, the user is still not signed in. @@ -1399,77 +1409,98 @@ export type allauthBrowserV1AuthPhoneVerifyPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AuthPhoneVerifyPostResponseComposite = allauthBrowserV1AuthPhoneVerifyPostResponse200 | allauthBrowserV1AuthPhoneVerifyPostResponse400 | allauthBrowserV1AuthPhoneVerifyPostResponse401 | allauthBrowserV1AuthPhoneVerifyPostResponse409; - + +export type allauthBrowserV1AuthPhoneVerifyPostResponseComposite = + | allauthBrowserV1AuthPhoneVerifyPostResponse200 + | allauthBrowserV1AuthPhoneVerifyPostResponse400 + | allauthBrowserV1AuthPhoneVerifyPostResponse401 + | allauthBrowserV1AuthPhoneVerifyPostResponse409 + export type allauthBrowserV1AuthPhoneVerifyPostResponse = allauthBrowserV1AuthPhoneVerifyPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthPhoneVerifyPostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/phone/verify` } -export const allauthBrowserV1AuthPhoneVerifyPost = async (verifyPhoneBody: VerifyPhoneBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthPhoneVerifyPostUrl(), - { +export const allauthBrowserV1AuthPhoneVerifyPost = async ( + verifyPhoneBody: VerifyPhoneBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthPhoneVerifyPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - verifyPhoneBody,) + body: JSON.stringify(verifyPhoneBody), + }) +} + +export const getAllauthBrowserV1AuthPhoneVerifyPostMutationOptions = < + TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: VerifyPhoneBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: VerifyPhoneBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthPhoneVerifyPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: VerifyPhoneBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthPhoneVerifyPost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthPhoneVerifyPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext> => { -const mutationKey = ['allauthBrowserV1AuthPhoneVerifyPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: VerifyPhoneBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AuthPhoneVerifyPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AuthPhoneVerifyPostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthPhoneVerifyPostMutationBody = VerifyPhoneBody - export type AllauthBrowserV1AuthPhoneVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse +export type AllauthBrowserV1AuthPhoneVerifyPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthPhoneVerifyPostMutationBody = VerifyPhoneBody +export type AllauthBrowserV1AuthPhoneVerifyPostMutationError = + | ErrorResponse + | UnauthenticatedResponse + | ConflictResponse - /** +/** * @summary Verify a phone number */ -export const useAllauthBrowserV1AuthPhoneVerifyPost = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthPhoneVerifyPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthPhoneVerifyPost = < + TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: VerifyPhoneBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthPhoneVerifyPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Complete the phone number verification process. Note that a status code of 401 does not imply failure. It merely indicates that the phone number verification was successful, yet, the user is still not signed in. @@ -1495,77 +1526,95 @@ export type allauthAppV1AuthPhoneVerifyPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AuthPhoneVerifyPostResponseComposite = allauthAppV1AuthPhoneVerifyPostResponse200 | allauthAppV1AuthPhoneVerifyPostResponse400 | allauthAppV1AuthPhoneVerifyPostResponse401 | allauthAppV1AuthPhoneVerifyPostResponse409; - + +export type allauthAppV1AuthPhoneVerifyPostResponseComposite = + | allauthAppV1AuthPhoneVerifyPostResponse200 + | allauthAppV1AuthPhoneVerifyPostResponse400 + | allauthAppV1AuthPhoneVerifyPostResponse401 + | allauthAppV1AuthPhoneVerifyPostResponse409 + export type allauthAppV1AuthPhoneVerifyPostResponse = allauthAppV1AuthPhoneVerifyPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthPhoneVerifyPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/phone/verify` } -export const allauthAppV1AuthPhoneVerifyPost = async (verifyPhoneBody: VerifyPhoneBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthPhoneVerifyPostUrl(), - { +export const allauthAppV1AuthPhoneVerifyPost = async ( + verifyPhoneBody: VerifyPhoneBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthPhoneVerifyPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - verifyPhoneBody,) + body: JSON.stringify(verifyPhoneBody), + }) +} + +export const getAllauthAppV1AuthPhoneVerifyPostMutationOptions = < + TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: VerifyPhoneBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: VerifyPhoneBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthPhoneVerifyPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: VerifyPhoneBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AuthPhoneVerifyPost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1AuthPhoneVerifyPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext> => { - -const mutationKey = ['allauthAppV1AuthPhoneVerifyPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {data: VerifyPhoneBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthPhoneVerifyPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AuthPhoneVerifyPostMutationResult = NonNullable>> - export type AllauthAppV1AuthPhoneVerifyPostMutationBody = VerifyPhoneBody - export type AllauthAppV1AuthPhoneVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse +export type AllauthAppV1AuthPhoneVerifyPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AuthPhoneVerifyPostMutationBody = VerifyPhoneBody +export type AllauthAppV1AuthPhoneVerifyPostMutationError = ErrorResponse | UnauthenticatedResponse | ConflictResponse - /** +/** * @summary Verify a phone number */ -export const useAllauthAppV1AuthPhoneVerifyPost = (options?: { mutation?:UseMutationOptions>, TError,{data: VerifyPhoneBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthPhoneVerifyPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AuthPhoneVerifyPost = < + TError = ErrorResponse | UnauthenticatedResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: VerifyPhoneBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthPhoneVerifyPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Requests a new phone number verification code. Requires `ACCOUNT_PHONE_VERIFICATION_SUPPORTS_RESEND = True`. @@ -1585,76 +1634,93 @@ export type allauthBrowserV1AuthPhoneVerifyResendPostResponse429 = { data: TooManyRequestsResponse status: 429 } - -export type allauthBrowserV1AuthPhoneVerifyResendPostResponseComposite = allauthBrowserV1AuthPhoneVerifyResendPostResponse200 | allauthBrowserV1AuthPhoneVerifyResendPostResponse409 | allauthBrowserV1AuthPhoneVerifyResendPostResponse429; - -export type allauthBrowserV1AuthPhoneVerifyResendPostResponse = allauthBrowserV1AuthPhoneVerifyResendPostResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1AuthPhoneVerifyResendPostUrl = () => { +export type allauthBrowserV1AuthPhoneVerifyResendPostResponseComposite = + | allauthBrowserV1AuthPhoneVerifyResendPostResponse200 + | allauthBrowserV1AuthPhoneVerifyResendPostResponse409 + | allauthBrowserV1AuthPhoneVerifyResendPostResponse429 - +export type allauthBrowserV1AuthPhoneVerifyResendPostResponse = + allauthBrowserV1AuthPhoneVerifyResendPostResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1AuthPhoneVerifyResendPostUrl = () => { return `/api/v2/allauth/browser/v1/auth/phone/verify/resend` } -export const allauthBrowserV1AuthPhoneVerifyResendPost = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthPhoneVerifyResendPostUrl(), - { - ...options, - method: 'POST' - - +export const allauthBrowserV1AuthPhoneVerifyResendPost = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1AuthPhoneVerifyResendPostUrl(), + { + ...options, + method: 'POST', + }, + ) +} + +export const getAllauthBrowserV1AuthPhoneVerifyResendPostMutationOptions = < + TError = ConflictResponse | TooManyRequestsResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthPhoneVerifyResendPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + void + > = () => { + return allauthBrowserV1AuthPhoneVerifyResendPost(requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthPhoneVerifyResendPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthPhoneVerifyResendPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return allauthBrowserV1AuthPhoneVerifyResendPost(requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} +export type AllauthBrowserV1AuthPhoneVerifyResendPostMutationResult = NonNullable< + Awaited> +> - export type AllauthBrowserV1AuthPhoneVerifyResendPostMutationResult = NonNullable>> - - export type AllauthBrowserV1AuthPhoneVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse +export type AllauthBrowserV1AuthPhoneVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse - /** +/** * @summary Resend phone number verification code */ -export const useAllauthBrowserV1AuthPhoneVerifyResendPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthPhoneVerifyResendPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthPhoneVerifyResendPost = < + TError = ConflictResponse | TooManyRequestsResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthPhoneVerifyResendPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Requests a new phone number verification code. Requires `ACCOUNT_PHONE_VERIFICATION_SUPPORTS_RESEND = True`. @@ -1674,76 +1740,81 @@ export type allauthAppV1AuthPhoneVerifyResendPostResponse429 = { data: TooManyRequestsResponse status: 429 } - -export type allauthAppV1AuthPhoneVerifyResendPostResponseComposite = allauthAppV1AuthPhoneVerifyResendPostResponse200 | allauthAppV1AuthPhoneVerifyResendPostResponse409 | allauthAppV1AuthPhoneVerifyResendPostResponse429; - + +export type allauthAppV1AuthPhoneVerifyResendPostResponseComposite = + | allauthAppV1AuthPhoneVerifyResendPostResponse200 + | allauthAppV1AuthPhoneVerifyResendPostResponse409 + | allauthAppV1AuthPhoneVerifyResendPostResponse429 + export type allauthAppV1AuthPhoneVerifyResendPostResponse = allauthAppV1AuthPhoneVerifyResendPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthPhoneVerifyResendPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/phone/verify/resend` } -export const allauthAppV1AuthPhoneVerifyResendPost = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthPhoneVerifyResendPostUrl(), - { +export const allauthAppV1AuthPhoneVerifyResendPost = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthPhoneVerifyResendPostUrl(), { ...options, - method: 'POST' - - + method: 'POST', + }) +} + +export const getAllauthAppV1AuthPhoneVerifyResendPostMutationOptions = < + TError = ConflictResponse | TooManyRequestsResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['allauthAppV1AuthPhoneVerifyResendPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return allauthAppV1AuthPhoneVerifyResendPost(requestOptions) } -);} - - - - -export const getAllauthAppV1AuthPhoneVerifyResendPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['allauthAppV1AuthPhoneVerifyResendPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return allauthAppV1AuthPhoneVerifyResendPost(requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} +export type AllauthAppV1AuthPhoneVerifyResendPostMutationResult = NonNullable< + Awaited> +> - export type AllauthAppV1AuthPhoneVerifyResendPostMutationResult = NonNullable>> - - export type AllauthAppV1AuthPhoneVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse +export type AllauthAppV1AuthPhoneVerifyResendPostMutationError = ConflictResponse | TooManyRequestsResponse - /** +/** * @summary Resend phone number verification code */ -export const useAllauthAppV1AuthPhoneVerifyResendPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthPhoneVerifyResendPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AuthPhoneVerifyResendPost = < + TError = ConflictResponse | TooManyRequestsResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthPhoneVerifyResendPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * In order to safeguard the account, some actions require the user to be recently authenticated. If you try to perform such an action without having been recently authenticated, a `401` status is returned, listing @@ -1762,77 +1833,90 @@ export type allauthBrowserV1AuthReauthenticatePostResponse400 = { data: ErrorResponse status: 400 } - -export type allauthBrowserV1AuthReauthenticatePostResponseComposite = allauthBrowserV1AuthReauthenticatePostResponse200 | allauthBrowserV1AuthReauthenticatePostResponse400; - + +export type allauthBrowserV1AuthReauthenticatePostResponseComposite = + | allauthBrowserV1AuthReauthenticatePostResponse200 + | allauthBrowserV1AuthReauthenticatePostResponse400 + export type allauthBrowserV1AuthReauthenticatePostResponse = allauthBrowserV1AuthReauthenticatePostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthReauthenticatePostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/reauthenticate` } -export const allauthBrowserV1AuthReauthenticatePost = async (reauthenticateBody: ReauthenticateBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthReauthenticatePostUrl(), - { +export const allauthBrowserV1AuthReauthenticatePost = async ( + reauthenticateBody: ReauthenticateBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthReauthenticatePostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - reauthenticateBody,) + body: JSON.stringify(reauthenticateBody), + }) +} + +export const getAllauthBrowserV1AuthReauthenticatePostMutationOptions = < + TError = ErrorResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ReauthenticateBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ReauthenticateBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthReauthenticatePost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ReauthenticateBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthReauthenticatePost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthReauthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext> => { -const mutationKey = ['allauthBrowserV1AuthReauthenticatePost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ReauthenticateBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AuthReauthenticatePost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AuthReauthenticatePostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthReauthenticatePostMutationBody = ReauthenticateBody - export type AllauthBrowserV1AuthReauthenticatePostMutationError = ErrorResponse +export type AllauthBrowserV1AuthReauthenticatePostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthReauthenticatePostMutationBody = ReauthenticateBody +export type AllauthBrowserV1AuthReauthenticatePostMutationError = ErrorResponse - /** +/** * @summary Reauthenticate */ -export const useAllauthBrowserV1AuthReauthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthReauthenticatePostMutationOptions(options); +export const useAllauthBrowserV1AuthReauthenticatePost = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ReauthenticateBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthReauthenticatePostMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * In order to safeguard the account, some actions require the user to be recently authenticated. If you try to perform such an action without having been recently authenticated, a `401` status is returned, listing @@ -1851,77 +1935,90 @@ export type allauthAppV1AuthReauthenticatePostResponse400 = { data: ErrorResponse status: 400 } - -export type allauthAppV1AuthReauthenticatePostResponseComposite = allauthAppV1AuthReauthenticatePostResponse200 | allauthAppV1AuthReauthenticatePostResponse400; - + +export type allauthAppV1AuthReauthenticatePostResponseComposite = + | allauthAppV1AuthReauthenticatePostResponse200 + | allauthAppV1AuthReauthenticatePostResponse400 + export type allauthAppV1AuthReauthenticatePostResponse = allauthAppV1AuthReauthenticatePostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthReauthenticatePostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/reauthenticate` } -export const allauthAppV1AuthReauthenticatePost = async (reauthenticateBody: ReauthenticateBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthReauthenticatePostUrl(), - { +export const allauthAppV1AuthReauthenticatePost = async ( + reauthenticateBody: ReauthenticateBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthReauthenticatePostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - reauthenticateBody,) + body: JSON.stringify(reauthenticateBody), + }) +} + +export const getAllauthAppV1AuthReauthenticatePostMutationOptions = < + TError = ErrorResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ReauthenticateBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ReauthenticateBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthReauthenticatePost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ReauthenticateBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AuthReauthenticatePost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1AuthReauthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext> => { - -const mutationKey = ['allauthAppV1AuthReauthenticatePost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {data: ReauthenticateBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthReauthenticatePost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthAppV1AuthReauthenticatePostMutationResult = NonNullable>> - export type AllauthAppV1AuthReauthenticatePostMutationBody = ReauthenticateBody - export type AllauthAppV1AuthReauthenticatePostMutationError = ErrorResponse +export type AllauthAppV1AuthReauthenticatePostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AuthReauthenticatePostMutationBody = ReauthenticateBody +export type AllauthAppV1AuthReauthenticatePostMutationError = ErrorResponse - /** +/** * @summary Reauthenticate */ -export const useAllauthAppV1AuthReauthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: ReauthenticateBody}, TContext>, request?: SecondParameter} - ) => { +export const useAllauthAppV1AuthReauthenticatePost = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ReauthenticateBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthReauthenticatePostMutationOptions(options) - const mutationOptions = getAllauthAppV1AuthReauthenticatePostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Initiates the password reset procedure. Depending on whether or not `ACCOUNT_PASSWORD_RESET_BY_CODE_ENABLED` is `True`, the procedure is either stateless or stateful. @@ -1950,77 +2047,98 @@ export type allauthBrowserV1AuthPasswordRequestPostResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthBrowserV1AuthPasswordRequestPostResponseComposite = allauthBrowserV1AuthPasswordRequestPostResponse200 | allauthBrowserV1AuthPasswordRequestPostResponse400 | allauthBrowserV1AuthPasswordRequestPostResponse401; - -export type allauthBrowserV1AuthPasswordRequestPostResponse = allauthBrowserV1AuthPasswordRequestPostResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1AuthPasswordRequestPostUrl = () => { +export type allauthBrowserV1AuthPasswordRequestPostResponseComposite = + | allauthBrowserV1AuthPasswordRequestPostResponse200 + | allauthBrowserV1AuthPasswordRequestPostResponse400 + | allauthBrowserV1AuthPasswordRequestPostResponse401 - +export type allauthBrowserV1AuthPasswordRequestPostResponse = + allauthBrowserV1AuthPasswordRequestPostResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1AuthPasswordRequestPostUrl = () => { return `/api/v2/allauth/browser/v1/auth/password/request` } -export const allauthBrowserV1AuthPasswordRequestPost = async (requestPasswordBody: RequestPasswordBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthPasswordRequestPostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - requestPasswordBody,) +export const allauthBrowserV1AuthPasswordRequestPost = async ( + requestPasswordBody: RequestPasswordBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1AuthPasswordRequestPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(requestPasswordBody), + }, + ) +} + +export const getAllauthBrowserV1AuthPasswordRequestPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: RequestPasswordBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: RequestPasswordBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthPasswordRequestPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: RequestPasswordBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthPasswordRequestPost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthPasswordRequestPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthPasswordRequestPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {data: RequestPasswordBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AuthPasswordRequestPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AuthPasswordRequestPostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthPasswordRequestPostMutationBody = RequestPasswordBody - export type AllauthBrowserV1AuthPasswordRequestPostMutationError = ErrorResponse | AuthenticationResponse +export type AllauthBrowserV1AuthPasswordRequestPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthPasswordRequestPostMutationBody = RequestPasswordBody +export type AllauthBrowserV1AuthPasswordRequestPostMutationError = ErrorResponse | AuthenticationResponse - /** +/** * @summary Request password */ -export const useAllauthBrowserV1AuthPasswordRequestPost = (options?: { mutation?:UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthPasswordRequestPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthPasswordRequestPost = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: RequestPasswordBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthPasswordRequestPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Initiates the password reset procedure. Depending on whether or not `ACCOUNT_PASSWORD_RESET_BY_CODE_ENABLED` is `True`, the procedure is either stateless or stateful. @@ -2049,77 +2167,94 @@ export type allauthAppV1AuthPasswordRequestPostResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthAppV1AuthPasswordRequestPostResponseComposite = allauthAppV1AuthPasswordRequestPostResponse200 | allauthAppV1AuthPasswordRequestPostResponse400 | allauthAppV1AuthPasswordRequestPostResponse401; - + +export type allauthAppV1AuthPasswordRequestPostResponseComposite = + | allauthAppV1AuthPasswordRequestPostResponse200 + | allauthAppV1AuthPasswordRequestPostResponse400 + | allauthAppV1AuthPasswordRequestPostResponse401 + export type allauthAppV1AuthPasswordRequestPostResponse = allauthAppV1AuthPasswordRequestPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthPasswordRequestPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/password/request` } -export const allauthAppV1AuthPasswordRequestPost = async (requestPasswordBody: RequestPasswordBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthPasswordRequestPostUrl(), - { +export const allauthAppV1AuthPasswordRequestPost = async ( + requestPasswordBody: RequestPasswordBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthPasswordRequestPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - requestPasswordBody,) + body: JSON.stringify(requestPasswordBody), + }) +} + +export const getAllauthAppV1AuthPasswordRequestPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: RequestPasswordBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: RequestPasswordBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthPasswordRequestPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: RequestPasswordBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AuthPasswordRequestPost(data, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} +export type AllauthAppV1AuthPasswordRequestPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AuthPasswordRequestPostMutationBody = RequestPasswordBody +export type AllauthAppV1AuthPasswordRequestPostMutationError = ErrorResponse | AuthenticationResponse -export const getAllauthAppV1AuthPasswordRequestPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext> => { - -const mutationKey = ['allauthAppV1AuthPasswordRequestPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: RequestPasswordBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthPasswordRequestPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AuthPasswordRequestPostMutationResult = NonNullable>> - export type AllauthAppV1AuthPasswordRequestPostMutationBody = RequestPasswordBody - export type AllauthAppV1AuthPasswordRequestPostMutationError = ErrorResponse | AuthenticationResponse - - /** +/** * @summary Request password */ -export const useAllauthAppV1AuthPasswordRequestPost = (options?: { mutation?:UseMutationOptions>, TError,{data: RequestPasswordBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthPasswordRequestPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AuthPasswordRequestPost = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: RequestPasswordBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthPasswordRequestPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Used to obtain information on and validate a password reset key. The key passed is either the key encoded in the password reset URL that the user has received per email, or, the password reset code in case of @@ -2143,81 +2278,79 @@ export type allauthBrowserV1AuthPasswordResetGetResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AuthPasswordResetGetResponseComposite = allauthBrowserV1AuthPasswordResetGetResponse200 | allauthBrowserV1AuthPasswordResetGetResponse400 | allauthBrowserV1AuthPasswordResetGetResponse409; - + +export type allauthBrowserV1AuthPasswordResetGetResponseComposite = + | allauthBrowserV1AuthPasswordResetGetResponse200 + | allauthBrowserV1AuthPasswordResetGetResponse400 + | allauthBrowserV1AuthPasswordResetGetResponse409 + export type allauthBrowserV1AuthPasswordResetGetResponse = allauthBrowserV1AuthPasswordResetGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthPasswordResetGetUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/password/reset` } -export const allauthBrowserV1AuthPasswordResetGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthPasswordResetGetUrl(), - { +export const allauthBrowserV1AuthPasswordResetGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthPasswordResetGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthBrowserV1AuthPasswordResetGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','auth','password','reset'] as const; - } - - -export const getAllauthBrowserV1AuthPasswordResetGetQueryOptions = >, TError = ErrorResponse | ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthPasswordResetGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'auth', 'password', 'reset'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AuthPasswordResetGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1AuthPasswordResetGetQueryOptions = < + TData = Awaited>, + TError = ErrorResponse | ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthPasswordResetGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthBrowserV1AuthPasswordResetGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthBrowserV1AuthPasswordResetGetQueryResult = NonNullable>> +export type AllauthBrowserV1AuthPasswordResetGetQueryResult = NonNullable< + Awaited> +> export type AllauthBrowserV1AuthPasswordResetGetQueryError = ErrorResponse | ConflictResponse - /** * @summary Get password reset information */ -export function useAllauthBrowserV1AuthPasswordResetGet>, TError = ErrorResponse | ConflictResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AuthPasswordResetGet< + TData = Awaited>, + TError = ErrorResponse | ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AuthPasswordResetGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Perform the password reset, by handing over the password reset key and the new password. After successfully completing the password reset, the @@ -2247,77 +2380,98 @@ export type allauthBrowserV1AuthPasswordResetPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AuthPasswordResetPostResponseComposite = allauthBrowserV1AuthPasswordResetPostResponse200 | allauthBrowserV1AuthPasswordResetPostResponse400 | allauthBrowserV1AuthPasswordResetPostResponse401 | allauthBrowserV1AuthPasswordResetPostResponse409; - + +export type allauthBrowserV1AuthPasswordResetPostResponseComposite = + | allauthBrowserV1AuthPasswordResetPostResponse200 + | allauthBrowserV1AuthPasswordResetPostResponse400 + | allauthBrowserV1AuthPasswordResetPostResponse401 + | allauthBrowserV1AuthPasswordResetPostResponse409 + export type allauthBrowserV1AuthPasswordResetPostResponse = allauthBrowserV1AuthPasswordResetPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthPasswordResetPostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/password/reset` } -export const allauthBrowserV1AuthPasswordResetPost = async (resetPasswordBody: ResetPasswordBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthPasswordResetPostUrl(), - { +export const allauthBrowserV1AuthPasswordResetPost = async ( + resetPasswordBody: ResetPasswordBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthPasswordResetPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - resetPasswordBody,) + body: JSON.stringify(resetPasswordBody), + }) +} + +export const getAllauthBrowserV1AuthPasswordResetPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ResetPasswordBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ResetPasswordBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthPasswordResetPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ResetPasswordBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthPasswordResetPost(data, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} +export type AllauthBrowserV1AuthPasswordResetPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthPasswordResetPostMutationBody = ResetPasswordBody +export type AllauthBrowserV1AuthPasswordResetPostMutationError = + | ErrorResponse + | AuthenticationResponse + | ConflictResponse -export const getAllauthBrowserV1AuthPasswordResetPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthPasswordResetPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ResetPasswordBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AuthPasswordResetPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthBrowserV1AuthPasswordResetPostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthPasswordResetPostMutationBody = ResetPasswordBody - export type AllauthBrowserV1AuthPasswordResetPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - - /** +/** * @summary Reset password */ -export const useAllauthBrowserV1AuthPasswordResetPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthPasswordResetPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthPasswordResetPost = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ResetPasswordBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthPasswordResetPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Used to obtain information on and validate a password reset key. The key passed is either the key encoded in the password reset URL that the user has received per email, or, the password reset code in case of @@ -2341,81 +2495,79 @@ export type allauthAppV1AuthPasswordResetGetResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AuthPasswordResetGetResponseComposite = allauthAppV1AuthPasswordResetGetResponse200 | allauthAppV1AuthPasswordResetGetResponse400 | allauthAppV1AuthPasswordResetGetResponse409; - + +export type allauthAppV1AuthPasswordResetGetResponseComposite = + | allauthAppV1AuthPasswordResetGetResponse200 + | allauthAppV1AuthPasswordResetGetResponse400 + | allauthAppV1AuthPasswordResetGetResponse409 + export type allauthAppV1AuthPasswordResetGetResponse = allauthAppV1AuthPasswordResetGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthPasswordResetGetUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/password/reset` } -export const allauthAppV1AuthPasswordResetGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthPasswordResetGetUrl(), - { +export const allauthAppV1AuthPasswordResetGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthPasswordResetGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthAppV1AuthPasswordResetGetQueryKey = () => { - return ['api','v2','allauth','app','v1','auth','password','reset'] as const; - } - - -export const getAllauthAppV1AuthPasswordResetGetQueryOptions = >, TError = ErrorResponse | ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthPasswordResetGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'auth', 'password', 'reset'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AuthPasswordResetGet({ signal, ...requestOptions }); +export const getAllauthAppV1AuthPasswordResetGetQueryOptions = < + TData = Awaited>, + TError = ErrorResponse | ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthPasswordResetGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1AuthPasswordResetGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthAppV1AuthPasswordResetGetQueryResult = NonNullable>> +export type AllauthAppV1AuthPasswordResetGetQueryResult = NonNullable< + Awaited> +> export type AllauthAppV1AuthPasswordResetGetQueryError = ErrorResponse | ConflictResponse - /** * @summary Get password reset information */ -export function useAllauthAppV1AuthPasswordResetGet>, TError = ErrorResponse | ConflictResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AuthPasswordResetGet< + TData = Awaited>, + TError = ErrorResponse | ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AuthPasswordResetGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Perform the password reset, by handing over the password reset key and the new password. After successfully completing the password reset, the @@ -2445,77 +2597,95 @@ export type allauthAppV1AuthPasswordResetPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AuthPasswordResetPostResponseComposite = allauthAppV1AuthPasswordResetPostResponse200 | allauthAppV1AuthPasswordResetPostResponse400 | allauthAppV1AuthPasswordResetPostResponse401 | allauthAppV1AuthPasswordResetPostResponse409; - + +export type allauthAppV1AuthPasswordResetPostResponseComposite = + | allauthAppV1AuthPasswordResetPostResponse200 + | allauthAppV1AuthPasswordResetPostResponse400 + | allauthAppV1AuthPasswordResetPostResponse401 + | allauthAppV1AuthPasswordResetPostResponse409 + export type allauthAppV1AuthPasswordResetPostResponse = allauthAppV1AuthPasswordResetPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthPasswordResetPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/password/reset` } -export const allauthAppV1AuthPasswordResetPost = async (resetPasswordBody: ResetPasswordBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthPasswordResetPostUrl(), - { +export const allauthAppV1AuthPasswordResetPost = async ( + resetPasswordBody: ResetPasswordBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthPasswordResetPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - resetPasswordBody,) + body: JSON.stringify(resetPasswordBody), + }) +} + +export const getAllauthAppV1AuthPasswordResetPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ResetPasswordBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ResetPasswordBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthPasswordResetPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ResetPasswordBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AuthPasswordResetPost(data, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} +export type AllauthAppV1AuthPasswordResetPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AuthPasswordResetPostMutationBody = ResetPasswordBody +export type AllauthAppV1AuthPasswordResetPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse -export const getAllauthAppV1AuthPasswordResetPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext> => { - -const mutationKey = ['allauthAppV1AuthPasswordResetPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ResetPasswordBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthPasswordResetPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AuthPasswordResetPostMutationResult = NonNullable>> - export type AllauthAppV1AuthPasswordResetPostMutationBody = ResetPasswordBody - export type AllauthAppV1AuthPasswordResetPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - - /** +/** * @summary Reset password */ -export const useAllauthAppV1AuthPasswordResetPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ResetPasswordBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthPasswordResetPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AuthPasswordResetPost = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ResetPasswordBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthPasswordResetPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Initiates the third-party provider authentication redirect flow. As calling this endpoint results in a user facing redirect (302), this call is only available in a browser, and must be called in a synchronous (non-XHR) @@ -2527,81 +2697,98 @@ export type allauthBrowserV1AuthProviderRedirectPostResponse302 = { data: void status: 302 } - -export type allauthBrowserV1AuthProviderRedirectPostResponseComposite = allauthBrowserV1AuthProviderRedirectPostResponse302; - -export type allauthBrowserV1AuthProviderRedirectPostResponse = allauthBrowserV1AuthProviderRedirectPostResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1AuthProviderRedirectPostUrl = () => { +export type allauthBrowserV1AuthProviderRedirectPostResponseComposite = + allauthBrowserV1AuthProviderRedirectPostResponse302 - +export type allauthBrowserV1AuthProviderRedirectPostResponse = + allauthBrowserV1AuthProviderRedirectPostResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1AuthProviderRedirectPostUrl = () => { return `/api/v2/allauth/browser/v1/auth/provider/redirect` } -export const allauthBrowserV1AuthProviderRedirectPost = async (providerRedirectBody: ProviderRedirectBody, options?: RequestInit): Promise => { - const formUrlEncoded = new URLSearchParams(); -formUrlEncoded.append(`provider`, providerRedirectBody.provider) -formUrlEncoded.append(`callback_url`, providerRedirectBody.callback_url) -formUrlEncoded.append(`process`, providerRedirectBody.process) - - return fetchWithAuth(getAllauthBrowserV1AuthProviderRedirectPostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/x-www-form-urlencoded', ...options?.headers }, - body: - formUrlEncoded, +export const allauthBrowserV1AuthProviderRedirectPost = async ( + providerRedirectBody: ProviderRedirectBody, + options?: RequestInit, +): Promise => { + const formUrlEncoded = new URLSearchParams() + formUrlEncoded.append(`provider`, providerRedirectBody.provider) + formUrlEncoded.append(`callback_url`, providerRedirectBody.callback_url) + formUrlEncoded.append(`process`, providerRedirectBody.process) + + return fetchWithAuth( + getAllauthBrowserV1AuthProviderRedirectPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded', ...options?.headers }, + body: formUrlEncoded, + }, + ) +} + +export const getAllauthBrowserV1AuthProviderRedirectPostMutationOptions = < + TError = void, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderRedirectBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ProviderRedirectBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthProviderRedirectPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ProviderRedirectBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthProviderRedirectPost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthProviderRedirectPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderRedirectBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ProviderRedirectBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthProviderRedirectPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ProviderRedirectBody}> = (props) => { - const {data} = props ?? {}; - return allauthBrowserV1AuthProviderRedirectPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AuthProviderRedirectPostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthProviderRedirectPostMutationBody = ProviderRedirectBody - export type AllauthBrowserV1AuthProviderRedirectPostMutationError = void +export type AllauthBrowserV1AuthProviderRedirectPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthProviderRedirectPostMutationBody = ProviderRedirectBody +export type AllauthBrowserV1AuthProviderRedirectPostMutationError = void - /** +/** * @summary Provider redirect */ -export const useAllauthBrowserV1AuthProviderRedirectPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderRedirectBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthProviderRedirectPostMutationOptions(options); +export const useAllauthBrowserV1AuthProviderRedirectPost = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderRedirectBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthProviderRedirectPostMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Authenticates with a third-party provider using provider tokens received by other means. For example, in case of a mobile app, the authentication flow runs completely on the device itself, without any interaction with @@ -2630,77 +2817,98 @@ export type allauthBrowserV1AuthProviderTokenPostResponse403 = { data: ForbiddenResponse status: 403 } - -export type allauthBrowserV1AuthProviderTokenPostResponseComposite = allauthBrowserV1AuthProviderTokenPostResponse200 | allauthBrowserV1AuthProviderTokenPostResponse400 | allauthBrowserV1AuthProviderTokenPostResponse401 | allauthBrowserV1AuthProviderTokenPostResponse403; - + +export type allauthBrowserV1AuthProviderTokenPostResponseComposite = + | allauthBrowserV1AuthProviderTokenPostResponse200 + | allauthBrowserV1AuthProviderTokenPostResponse400 + | allauthBrowserV1AuthProviderTokenPostResponse401 + | allauthBrowserV1AuthProviderTokenPostResponse403 + export type allauthBrowserV1AuthProviderTokenPostResponse = allauthBrowserV1AuthProviderTokenPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthProviderTokenPostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/provider/token` } -export const allauthBrowserV1AuthProviderTokenPost = async (providerTokenBody: ProviderTokenBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthProviderTokenPostUrl(), - { +export const allauthBrowserV1AuthProviderTokenPost = async ( + providerTokenBody: ProviderTokenBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthProviderTokenPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - providerTokenBody,) + body: JSON.stringify(providerTokenBody), + }) +} + +export const getAllauthBrowserV1AuthProviderTokenPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderTokenBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ProviderTokenBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthProviderTokenPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ProviderTokenBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthProviderTokenPost(data, requestOptions) } -);} - - - -export const getAllauthBrowserV1AuthProviderTokenPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthProviderTokenPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ProviderTokenBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AuthProviderTokenPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AuthProviderTokenPostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthProviderTokenPostMutationBody = ProviderTokenBody - export type AllauthBrowserV1AuthProviderTokenPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse +export type AllauthBrowserV1AuthProviderTokenPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthProviderTokenPostMutationBody = ProviderTokenBody +export type AllauthBrowserV1AuthProviderTokenPostMutationError = + | ErrorResponse + | AuthenticationResponse + | ForbiddenResponse - /** +/** * @summary Provider token */ -export const useAllauthBrowserV1AuthProviderTokenPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthProviderTokenPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthProviderTokenPost = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderTokenBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthProviderTokenPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Authenticates with a third-party provider using provider tokens received by other means. For example, in case of a mobile app, the authentication flow runs completely on the device itself, without any interaction with @@ -2729,77 +2937,95 @@ export type allauthAppV1AuthProviderTokenPostResponse403 = { data: ForbiddenResponse status: 403 } - -export type allauthAppV1AuthProviderTokenPostResponseComposite = allauthAppV1AuthProviderTokenPostResponse200 | allauthAppV1AuthProviderTokenPostResponse400 | allauthAppV1AuthProviderTokenPostResponse401 | allauthAppV1AuthProviderTokenPostResponse403; - + +export type allauthAppV1AuthProviderTokenPostResponseComposite = + | allauthAppV1AuthProviderTokenPostResponse200 + | allauthAppV1AuthProviderTokenPostResponse400 + | allauthAppV1AuthProviderTokenPostResponse401 + | allauthAppV1AuthProviderTokenPostResponse403 + export type allauthAppV1AuthProviderTokenPostResponse = allauthAppV1AuthProviderTokenPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthProviderTokenPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/provider/token` } -export const allauthAppV1AuthProviderTokenPost = async (providerTokenBody: ProviderTokenBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthProviderTokenPostUrl(), - { +export const allauthAppV1AuthProviderTokenPost = async ( + providerTokenBody: ProviderTokenBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthProviderTokenPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - providerTokenBody,) + body: JSON.stringify(providerTokenBody), + }) +} + +export const getAllauthAppV1AuthProviderTokenPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderTokenBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ProviderTokenBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthProviderTokenPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ProviderTokenBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AuthProviderTokenPost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1AuthProviderTokenPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext> => { - -const mutationKey = ['allauthAppV1AuthProviderTokenPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {data: ProviderTokenBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthProviderTokenPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthAppV1AuthProviderTokenPostMutationResult = NonNullable>> - export type AllauthAppV1AuthProviderTokenPostMutationBody = ProviderTokenBody - export type AllauthAppV1AuthProviderTokenPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse +export type AllauthAppV1AuthProviderTokenPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AuthProviderTokenPostMutationBody = ProviderTokenBody +export type AllauthAppV1AuthProviderTokenPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse - /** +/** * @summary Provider token */ -export const useAllauthAppV1AuthProviderTokenPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderTokenBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthProviderTokenPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AuthProviderTokenPost = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderTokenBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthProviderTokenPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * If, while signing up using a third-party provider account, there is insufficient information received from the provider to automatically complete the signup process, an additional step is needed to complete @@ -2818,81 +3044,78 @@ export type allauthBrowserV1AuthProviderSignupGetResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AuthProviderSignupGetResponseComposite = allauthBrowserV1AuthProviderSignupGetResponse200 | allauthBrowserV1AuthProviderSignupGetResponse409; - + +export type allauthBrowserV1AuthProviderSignupGetResponseComposite = + | allauthBrowserV1AuthProviderSignupGetResponse200 + | allauthBrowserV1AuthProviderSignupGetResponse409 + export type allauthBrowserV1AuthProviderSignupGetResponse = allauthBrowserV1AuthProviderSignupGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthProviderSignupGetUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/provider/signup` } -export const allauthBrowserV1AuthProviderSignupGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthProviderSignupGetUrl(), - { +export const allauthBrowserV1AuthProviderSignupGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthProviderSignupGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthBrowserV1AuthProviderSignupGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','auth','provider','signup'] as const; - } - - -export const getAllauthBrowserV1AuthProviderSignupGetQueryOptions = >, TError = ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthProviderSignupGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'auth', 'provider', 'signup'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AuthProviderSignupGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1AuthProviderSignupGetQueryOptions = < + TData = Awaited>, + TError = ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthProviderSignupGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthBrowserV1AuthProviderSignupGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthBrowserV1AuthProviderSignupGetQueryResult = NonNullable>> +export type AllauthBrowserV1AuthProviderSignupGetQueryResult = NonNullable< + Awaited> +> export type AllauthBrowserV1AuthProviderSignupGetQueryError = ConflictResponse - /** * @summary Provider signup information */ -export function useAllauthBrowserV1AuthProviderSignupGet>, TError = ConflictResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AuthProviderSignupGet< + TData = Awaited>, + TError = ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AuthProviderSignupGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * If, while signing up using a third-party provider account, there is insufficient information received from the provider to automatically @@ -2925,77 +3148,100 @@ export type allauthBrowserV1AuthProviderSignupPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AuthProviderSignupPostResponseComposite = allauthBrowserV1AuthProviderSignupPostResponse200 | allauthBrowserV1AuthProviderSignupPostResponse400 | allauthBrowserV1AuthProviderSignupPostResponse401 | allauthBrowserV1AuthProviderSignupPostResponse403 | allauthBrowserV1AuthProviderSignupPostResponse409; - + +export type allauthBrowserV1AuthProviderSignupPostResponseComposite = + | allauthBrowserV1AuthProviderSignupPostResponse200 + | allauthBrowserV1AuthProviderSignupPostResponse400 + | allauthBrowserV1AuthProviderSignupPostResponse401 + | allauthBrowserV1AuthProviderSignupPostResponse403 + | allauthBrowserV1AuthProviderSignupPostResponse409 + export type allauthBrowserV1AuthProviderSignupPostResponse = allauthBrowserV1AuthProviderSignupPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthProviderSignupPostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/provider/signup` } -export const allauthBrowserV1AuthProviderSignupPost = async (providerSignupBody: ProviderSignupBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthProviderSignupPostUrl(), - { +export const allauthBrowserV1AuthProviderSignupPost = async ( + providerSignupBody: ProviderSignupBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthProviderSignupPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - providerSignupBody,) + body: JSON.stringify(providerSignupBody), + }) +} + +export const getAllauthBrowserV1AuthProviderSignupPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderSignupBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ProviderSignupBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthProviderSignupPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ProviderSignupBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthProviderSignupPost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthProviderSignupPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthProviderSignupPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {data: ProviderSignupBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AuthProviderSignupPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AuthProviderSignupPostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthProviderSignupPostMutationBody = ProviderSignupBody - export type AllauthBrowserV1AuthProviderSignupPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse +export type AllauthBrowserV1AuthProviderSignupPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthProviderSignupPostMutationBody = ProviderSignupBody +export type AllauthBrowserV1AuthProviderSignupPostMutationError = + | ErrorResponse + | AuthenticationResponse + | ForbiddenResponse + | ConflictResponse - /** +/** * @summary Provider signup */ -export const useAllauthBrowserV1AuthProviderSignupPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthProviderSignupPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthProviderSignupPost = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderSignupBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthProviderSignupPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * If, while signing up using a third-party provider account, there is insufficient information received from the provider to automatically complete the signup process, an additional step is needed to complete @@ -3014,81 +3260,78 @@ export type allauthAppV1AuthProviderSignupGetResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AuthProviderSignupGetResponseComposite = allauthAppV1AuthProviderSignupGetResponse200 | allauthAppV1AuthProviderSignupGetResponse409; - + +export type allauthAppV1AuthProviderSignupGetResponseComposite = + | allauthAppV1AuthProviderSignupGetResponse200 + | allauthAppV1AuthProviderSignupGetResponse409 + export type allauthAppV1AuthProviderSignupGetResponse = allauthAppV1AuthProviderSignupGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthProviderSignupGetUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/provider/signup` } -export const allauthAppV1AuthProviderSignupGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthProviderSignupGetUrl(), - { +export const allauthAppV1AuthProviderSignupGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthProviderSignupGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthAppV1AuthProviderSignupGetQueryKey = () => { - return ['api','v2','allauth','app','v1','auth','provider','signup'] as const; - } - - -export const getAllauthAppV1AuthProviderSignupGetQueryOptions = >, TError = ConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthProviderSignupGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'auth', 'provider', 'signup'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AuthProviderSignupGet({ signal, ...requestOptions }); +export const getAllauthAppV1AuthProviderSignupGetQueryOptions = < + TData = Awaited>, + TError = ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthProviderSignupGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1AuthProviderSignupGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthAppV1AuthProviderSignupGetQueryResult = NonNullable>> +export type AllauthAppV1AuthProviderSignupGetQueryResult = NonNullable< + Awaited> +> export type AllauthAppV1AuthProviderSignupGetQueryError = ConflictResponse - /** * @summary Provider signup information */ -export function useAllauthAppV1AuthProviderSignupGet>, TError = ConflictResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AuthProviderSignupGet< + TData = Awaited>, + TError = ConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AuthProviderSignupGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * If, while signing up using a third-party provider account, there is insufficient information received from the provider to automatically @@ -3121,77 +3364,100 @@ export type allauthAppV1AuthProviderSignupPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AuthProviderSignupPostResponseComposite = allauthAppV1AuthProviderSignupPostResponse200 | allauthAppV1AuthProviderSignupPostResponse400 | allauthAppV1AuthProviderSignupPostResponse401 | allauthAppV1AuthProviderSignupPostResponse403 | allauthAppV1AuthProviderSignupPostResponse409; - + +export type allauthAppV1AuthProviderSignupPostResponseComposite = + | allauthAppV1AuthProviderSignupPostResponse200 + | allauthAppV1AuthProviderSignupPostResponse400 + | allauthAppV1AuthProviderSignupPostResponse401 + | allauthAppV1AuthProviderSignupPostResponse403 + | allauthAppV1AuthProviderSignupPostResponse409 + export type allauthAppV1AuthProviderSignupPostResponse = allauthAppV1AuthProviderSignupPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthProviderSignupPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/provider/signup` } -export const allauthAppV1AuthProviderSignupPost = async (providerSignupBody: ProviderSignupBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthProviderSignupPostUrl(), - { +export const allauthAppV1AuthProviderSignupPost = async ( + providerSignupBody: ProviderSignupBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthProviderSignupPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - providerSignupBody,) + body: JSON.stringify(providerSignupBody), + }) +} + +export const getAllauthAppV1AuthProviderSignupPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderSignupBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ProviderSignupBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthProviderSignupPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ProviderSignupBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AuthProviderSignupPost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1AuthProviderSignupPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext> => { - -const mutationKey = ['allauthAppV1AuthProviderSignupPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {data: ProviderSignupBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthProviderSignupPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthAppV1AuthProviderSignupPostMutationResult = NonNullable>> - export type AllauthAppV1AuthProviderSignupPostMutationBody = ProviderSignupBody - export type AllauthAppV1AuthProviderSignupPostMutationError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse +export type AllauthAppV1AuthProviderSignupPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AuthProviderSignupPostMutationBody = ProviderSignupBody +export type AllauthAppV1AuthProviderSignupPostMutationError = + | ErrorResponse + | AuthenticationResponse + | ForbiddenResponse + | ConflictResponse - /** +/** * @summary Provider signup */ -export const useAllauthAppV1AuthProviderSignupPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderSignupBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthProviderSignupPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AuthProviderSignupPost = < + TError = ErrorResponse | AuthenticationResponse | ForbiddenResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderSignupBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthProviderSignupPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * If, during authentication, a response with status 401 is encountered where one of the pending flows has ID `mfa_authenticate`, that indicates that the Two-Factor Authentication stage needs to be completed. @@ -3212,77 +3478,98 @@ export type allauthBrowserV1Auth2faAuthenticatePostResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthBrowserV1Auth2faAuthenticatePostResponseComposite = allauthBrowserV1Auth2faAuthenticatePostResponse200 | allauthBrowserV1Auth2faAuthenticatePostResponse400 | allauthBrowserV1Auth2faAuthenticatePostResponse401; - -export type allauthBrowserV1Auth2faAuthenticatePostResponse = allauthBrowserV1Auth2faAuthenticatePostResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1Auth2faAuthenticatePostUrl = () => { +export type allauthBrowserV1Auth2faAuthenticatePostResponseComposite = + | allauthBrowserV1Auth2faAuthenticatePostResponse200 + | allauthBrowserV1Auth2faAuthenticatePostResponse400 + | allauthBrowserV1Auth2faAuthenticatePostResponse401 - +export type allauthBrowserV1Auth2faAuthenticatePostResponse = + allauthBrowserV1Auth2faAuthenticatePostResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1Auth2faAuthenticatePostUrl = () => { return `/api/v2/allauth/browser/v1/auth/2fa/authenticate` } -export const allauthBrowserV1Auth2faAuthenticatePost = async (mFAAuthenticateBody: MFAAuthenticateBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1Auth2faAuthenticatePostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - mFAAuthenticateBody,) +export const allauthBrowserV1Auth2faAuthenticatePost = async ( + mFAAuthenticateBody: MFAAuthenticateBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1Auth2faAuthenticatePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(mFAAuthenticateBody), + }, + ) +} + +export const getAllauthBrowserV1Auth2faAuthenticatePostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1Auth2faAuthenticatePost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: MFAAuthenticateBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1Auth2faAuthenticatePost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1Auth2faAuthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext> => { -const mutationKey = ['allauthBrowserV1Auth2faAuthenticatePost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: MFAAuthenticateBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1Auth2faAuthenticatePost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1Auth2faAuthenticatePostMutationResult = NonNullable>> - export type AllauthBrowserV1Auth2faAuthenticatePostMutationBody = MFAAuthenticateBody - export type AllauthBrowserV1Auth2faAuthenticatePostMutationError = ErrorResponse | AuthenticationResponse +export type AllauthBrowserV1Auth2faAuthenticatePostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1Auth2faAuthenticatePostMutationBody = MFAAuthenticateBody +export type AllauthBrowserV1Auth2faAuthenticatePostMutationError = ErrorResponse | AuthenticationResponse - /** +/** * @summary Two-factor authentication */ -export const useAllauthBrowserV1Auth2faAuthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1Auth2faAuthenticatePostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1Auth2faAuthenticatePost = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1Auth2faAuthenticatePostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * If, during authentication, a response with status 401 is encountered where one of the pending flows has ID `mfa_authenticate`, that indicates that the Two-Factor Authentication stage needs to be completed. @@ -3303,77 +3590,94 @@ export type allauthAppV1Auth2faAuthenticatePostResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthAppV1Auth2faAuthenticatePostResponseComposite = allauthAppV1Auth2faAuthenticatePostResponse200 | allauthAppV1Auth2faAuthenticatePostResponse400 | allauthAppV1Auth2faAuthenticatePostResponse401; - + +export type allauthAppV1Auth2faAuthenticatePostResponseComposite = + | allauthAppV1Auth2faAuthenticatePostResponse200 + | allauthAppV1Auth2faAuthenticatePostResponse400 + | allauthAppV1Auth2faAuthenticatePostResponse401 + export type allauthAppV1Auth2faAuthenticatePostResponse = allauthAppV1Auth2faAuthenticatePostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1Auth2faAuthenticatePostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/2fa/authenticate` } -export const allauthAppV1Auth2faAuthenticatePost = async (mFAAuthenticateBody: MFAAuthenticateBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1Auth2faAuthenticatePostUrl(), - { +export const allauthAppV1Auth2faAuthenticatePost = async ( + mFAAuthenticateBody: MFAAuthenticateBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1Auth2faAuthenticatePostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - mFAAuthenticateBody,) + body: JSON.stringify(mFAAuthenticateBody), + }) +} + +export const getAllauthAppV1Auth2faAuthenticatePostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext +> => { + const mutationKey = ['allauthAppV1Auth2faAuthenticatePost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: MFAAuthenticateBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1Auth2faAuthenticatePost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1Auth2faAuthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext> => { - -const mutationKey = ['allauthAppV1Auth2faAuthenticatePost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {data: MFAAuthenticateBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1Auth2faAuthenticatePost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1Auth2faAuthenticatePostMutationResult = NonNullable>> - export type AllauthAppV1Auth2faAuthenticatePostMutationBody = MFAAuthenticateBody - export type AllauthAppV1Auth2faAuthenticatePostMutationError = ErrorResponse | AuthenticationResponse +export type AllauthAppV1Auth2faAuthenticatePostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1Auth2faAuthenticatePostMutationBody = MFAAuthenticateBody +export type AllauthAppV1Auth2faAuthenticatePostMutationError = ErrorResponse | AuthenticationResponse - /** +/** * @summary Two-factor authentication */ -export const useAllauthAppV1Auth2faAuthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1Auth2faAuthenticatePostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1Auth2faAuthenticatePost = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1Auth2faAuthenticatePostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * In order to safeguard the account, some actions require the user to be recently authenticated. If you try to perform such an action without having been recently authenticated, a `401` status is returned, listing @@ -3393,77 +3697,94 @@ export type allauthBrowserV1Auth2faReauthenticatePostResponse400 = { data: ErrorResponse status: 400 } - -export type allauthBrowserV1Auth2faReauthenticatePostResponseComposite = allauthBrowserV1Auth2faReauthenticatePostResponse200 | allauthBrowserV1Auth2faReauthenticatePostResponse400; - -export type allauthBrowserV1Auth2faReauthenticatePostResponse = allauthBrowserV1Auth2faReauthenticatePostResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1Auth2faReauthenticatePostUrl = () => { +export type allauthBrowserV1Auth2faReauthenticatePostResponseComposite = + | allauthBrowserV1Auth2faReauthenticatePostResponse200 + | allauthBrowserV1Auth2faReauthenticatePostResponse400 - +export type allauthBrowserV1Auth2faReauthenticatePostResponse = + allauthBrowserV1Auth2faReauthenticatePostResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1Auth2faReauthenticatePostUrl = () => { return `/api/v2/allauth/browser/v1/auth/2fa/reauthenticate` } -export const allauthBrowserV1Auth2faReauthenticatePost = async (mFAAuthenticateBody: MFAAuthenticateBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1Auth2faReauthenticatePostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - mFAAuthenticateBody,) +export const allauthBrowserV1Auth2faReauthenticatePost = async ( + mFAAuthenticateBody: MFAAuthenticateBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1Auth2faReauthenticatePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(mFAAuthenticateBody), + }, + ) +} + +export const getAllauthBrowserV1Auth2faReauthenticatePostMutationOptions = < + TError = ErrorResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1Auth2faReauthenticatePost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: MFAAuthenticateBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1Auth2faReauthenticatePost(data, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} +export type AllauthBrowserV1Auth2faReauthenticatePostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1Auth2faReauthenticatePostMutationBody = MFAAuthenticateBody +export type AllauthBrowserV1Auth2faReauthenticatePostMutationError = ErrorResponse -export const getAllauthBrowserV1Auth2faReauthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext> => { +/** + * @summary Reauthenticate using 2FA + */ +export const useAllauthBrowserV1Auth2faReauthenticatePost = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1Auth2faReauthenticatePostMutationOptions(options) -const mutationKey = ['allauthBrowserV1Auth2faReauthenticatePost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: MFAAuthenticateBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1Auth2faReauthenticatePost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthBrowserV1Auth2faReauthenticatePostMutationResult = NonNullable>> - export type AllauthBrowserV1Auth2faReauthenticatePostMutationBody = MFAAuthenticateBody - export type AllauthBrowserV1Auth2faReauthenticatePostMutationError = ErrorResponse - - /** - * @summary Reauthenticate using 2FA - */ -export const useAllauthBrowserV1Auth2faReauthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1Auth2faReauthenticatePostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * In order to safeguard the account, some actions require the user to be recently authenticated. If you try to perform such an action without having been recently authenticated, a `401` status is returned, listing @@ -3483,77 +3804,90 @@ export type allauthAppV1Auth2faReauthenticatePostResponse400 = { data: ErrorResponse status: 400 } - -export type allauthAppV1Auth2faReauthenticatePostResponseComposite = allauthAppV1Auth2faReauthenticatePostResponse200 | allauthAppV1Auth2faReauthenticatePostResponse400; - + +export type allauthAppV1Auth2faReauthenticatePostResponseComposite = + | allauthAppV1Auth2faReauthenticatePostResponse200 + | allauthAppV1Auth2faReauthenticatePostResponse400 + export type allauthAppV1Auth2faReauthenticatePostResponse = allauthAppV1Auth2faReauthenticatePostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1Auth2faReauthenticatePostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/2fa/reauthenticate` } -export const allauthAppV1Auth2faReauthenticatePost = async (mFAAuthenticateBody: MFAAuthenticateBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1Auth2faReauthenticatePostUrl(), - { +export const allauthAppV1Auth2faReauthenticatePost = async ( + mFAAuthenticateBody: MFAAuthenticateBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1Auth2faReauthenticatePostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - mFAAuthenticateBody,) + body: JSON.stringify(mFAAuthenticateBody), + }) +} + +export const getAllauthAppV1Auth2faReauthenticatePostMutationOptions = < + TError = ErrorResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext +> => { + const mutationKey = ['allauthAppV1Auth2faReauthenticatePost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: MFAAuthenticateBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1Auth2faReauthenticatePost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1Auth2faReauthenticatePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext> => { -const mutationKey = ['allauthAppV1Auth2faReauthenticatePost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: MFAAuthenticateBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1Auth2faReauthenticatePost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthAppV1Auth2faReauthenticatePostMutationResult = NonNullable>> - export type AllauthAppV1Auth2faReauthenticatePostMutationBody = MFAAuthenticateBody - export type AllauthAppV1Auth2faReauthenticatePostMutationError = ErrorResponse +export type AllauthAppV1Auth2faReauthenticatePostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1Auth2faReauthenticatePostMutationBody = MFAAuthenticateBody +export type AllauthAppV1Auth2faReauthenticatePostMutationError = ErrorResponse - /** +/** * @summary Reauthenticate using 2FA */ -export const useAllauthAppV1Auth2faReauthenticatePost = (options?: { mutation?:UseMutationOptions>, TError,{data: MFAAuthenticateBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1Auth2faReauthenticatePostMutationOptions(options); +export const useAllauthAppV1Auth2faReauthenticatePost = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MFAAuthenticateBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1Auth2faReauthenticatePostMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Use this endpoint to pass along the received "special" login code. * @summary Confirm login code @@ -3577,77 +3911,95 @@ export type allauthBrowserV1AuthCodeConfirmPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AuthCodeConfirmPostResponseComposite = allauthBrowserV1AuthCodeConfirmPostResponse200 | allauthBrowserV1AuthCodeConfirmPostResponse400 | allauthBrowserV1AuthCodeConfirmPostResponse401 | allauthBrowserV1AuthCodeConfirmPostResponse409; - + +export type allauthBrowserV1AuthCodeConfirmPostResponseComposite = + | allauthBrowserV1AuthCodeConfirmPostResponse200 + | allauthBrowserV1AuthCodeConfirmPostResponse400 + | allauthBrowserV1AuthCodeConfirmPostResponse401 + | allauthBrowserV1AuthCodeConfirmPostResponse409 + export type allauthBrowserV1AuthCodeConfirmPostResponse = allauthBrowserV1AuthCodeConfirmPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthCodeConfirmPostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/code/confirm` } -export const allauthBrowserV1AuthCodeConfirmPost = async (confirmLoginCodeBody: ConfirmLoginCodeBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthCodeConfirmPostUrl(), - { +export const allauthBrowserV1AuthCodeConfirmPost = async ( + confirmLoginCodeBody: ConfirmLoginCodeBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthCodeConfirmPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - confirmLoginCodeBody,) + body: JSON.stringify(confirmLoginCodeBody), + }) +} + +export const getAllauthBrowserV1AuthCodeConfirmPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ConfirmLoginCodeBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ConfirmLoginCodeBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthCodeConfirmPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ConfirmLoginCodeBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthCodeConfirmPost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthCodeConfirmPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthCodeConfirmPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {data: ConfirmLoginCodeBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AuthCodeConfirmPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AuthCodeConfirmPostMutationResult = NonNullable>> - export type AllauthBrowserV1AuthCodeConfirmPostMutationBody = ConfirmLoginCodeBody - export type AllauthBrowserV1AuthCodeConfirmPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse +export type AllauthBrowserV1AuthCodeConfirmPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthCodeConfirmPostMutationBody = ConfirmLoginCodeBody +export type AllauthBrowserV1AuthCodeConfirmPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - /** +/** * @summary Confirm login code */ -export const useAllauthBrowserV1AuthCodeConfirmPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AuthCodeConfirmPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AuthCodeConfirmPost = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ConfirmLoginCodeBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthCodeConfirmPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Use this endpoint to pass along the received "special" login code. * @summary Confirm login code @@ -3671,158 +4023,171 @@ export type allauthAppV1AuthCodeConfirmPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AuthCodeConfirmPostResponseComposite = allauthAppV1AuthCodeConfirmPostResponse200 | allauthAppV1AuthCodeConfirmPostResponse400 | allauthAppV1AuthCodeConfirmPostResponse401 | allauthAppV1AuthCodeConfirmPostResponse409; - + +export type allauthAppV1AuthCodeConfirmPostResponseComposite = + | allauthAppV1AuthCodeConfirmPostResponse200 + | allauthAppV1AuthCodeConfirmPostResponse400 + | allauthAppV1AuthCodeConfirmPostResponse401 + | allauthAppV1AuthCodeConfirmPostResponse409 + export type allauthAppV1AuthCodeConfirmPostResponse = allauthAppV1AuthCodeConfirmPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthCodeConfirmPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/code/confirm` } -export const allauthAppV1AuthCodeConfirmPost = async (confirmLoginCodeBody: ConfirmLoginCodeBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthCodeConfirmPostUrl(), - { +export const allauthAppV1AuthCodeConfirmPost = async ( + confirmLoginCodeBody: ConfirmLoginCodeBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthCodeConfirmPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - confirmLoginCodeBody,) + body: JSON.stringify(confirmLoginCodeBody), + }) +} + +export const getAllauthAppV1AuthCodeConfirmPostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ConfirmLoginCodeBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ConfirmLoginCodeBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthCodeConfirmPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ConfirmLoginCodeBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AuthCodeConfirmPost(data, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} +export type AllauthAppV1AuthCodeConfirmPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AuthCodeConfirmPostMutationBody = ConfirmLoginCodeBody +export type AllauthAppV1AuthCodeConfirmPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse -export const getAllauthAppV1AuthCodeConfirmPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext> => { - -const mutationKey = ['allauthAppV1AuthCodeConfirmPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ConfirmLoginCodeBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthCodeConfirmPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AuthCodeConfirmPostMutationResult = NonNullable>> - export type AllauthAppV1AuthCodeConfirmPostMutationBody = ConfirmLoginCodeBody - export type AllauthAppV1AuthCodeConfirmPostMutationError = ErrorResponse | AuthenticationResponse | ConflictResponse - - /** +/** * @summary Confirm login code */ -export const useAllauthAppV1AuthCodeConfirmPost = (options?: { mutation?:UseMutationOptions>, TError,{data: ConfirmLoginCodeBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthCodeConfirmPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AuthCodeConfirmPost = < + TError = ErrorResponse | AuthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ConfirmLoginCodeBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthCodeConfirmPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * @summary List the connected third-party provider accounts */ export type allauthBrowserV1AccountProvidersGetResponse200 = { data: ProviderAccountsResponse status: 200 } - -export type allauthBrowserV1AccountProvidersGetResponseComposite = allauthBrowserV1AccountProvidersGetResponse200; - + +export type allauthBrowserV1AccountProvidersGetResponseComposite = allauthBrowserV1AccountProvidersGetResponse200 + export type allauthBrowserV1AccountProvidersGetResponse = allauthBrowserV1AccountProvidersGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AccountProvidersGetUrl = () => { - - - - return `/api/v2/allauth/browser/v1/account/providers` } -export const allauthBrowserV1AccountProvidersGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountProvidersGetUrl(), - { +export const allauthBrowserV1AccountProvidersGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AccountProvidersGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthBrowserV1AccountProvidersGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','account','providers'] as const; - } - - -export const getAllauthBrowserV1AccountProvidersGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountProvidersGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'providers'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountProvidersGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1AccountProvidersGetQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountProvidersGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthBrowserV1AccountProvidersGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthBrowserV1AccountProvidersGetQueryResult = NonNullable>> +export type AllauthBrowserV1AccountProvidersGetQueryResult = NonNullable< + Awaited> +> export type AllauthBrowserV1AccountProvidersGetQueryError = unknown - /** * @summary List the connected third-party provider accounts */ -export function useAllauthBrowserV1AccountProvidersGet>, TError = unknown>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AccountProvidersGet< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AccountProvidersGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Disconnect a third-party provider account, returning the remaining accounts that are still connected. The disconnect is not allowed if it @@ -3841,159 +4206,167 @@ export type allauthBrowserV1AccountProvidersDeleteResponse400 = { data: ErrorResponse status: 400 } - -export type allauthBrowserV1AccountProvidersDeleteResponseComposite = allauthBrowserV1AccountProvidersDeleteResponse200 | allauthBrowserV1AccountProvidersDeleteResponse400; - + +export type allauthBrowserV1AccountProvidersDeleteResponseComposite = + | allauthBrowserV1AccountProvidersDeleteResponse200 + | allauthBrowserV1AccountProvidersDeleteResponse400 + export type allauthBrowserV1AccountProvidersDeleteResponse = allauthBrowserV1AccountProvidersDeleteResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AccountProvidersDeleteUrl = () => { - - - - return `/api/v2/allauth/browser/v1/account/providers` } -export const allauthBrowserV1AccountProvidersDelete = async (providerAccountBody: ProviderAccountBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountProvidersDeleteUrl(), - { +export const allauthBrowserV1AccountProvidersDelete = async ( + providerAccountBody: ProviderAccountBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AccountProvidersDeleteUrl(), { ...options, method: 'DELETE', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - providerAccountBody,) + body: JSON.stringify(providerAccountBody), + }) +} + +export const getAllauthBrowserV1AccountProvidersDeleteMutationOptions = < + TError = ErrorResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderAccountBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ProviderAccountBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AccountProvidersDelete'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ProviderAccountBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AccountProvidersDelete(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AccountProvidersDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AccountProvidersDelete']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ProviderAccountBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AccountProvidersDelete(data,requestOptions) - } - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AccountProvidersDeleteMutationResult = NonNullable>> - export type AllauthBrowserV1AccountProvidersDeleteMutationBody = ProviderAccountBody - export type AllauthBrowserV1AccountProvidersDeleteMutationError = ErrorResponse +export type AllauthBrowserV1AccountProvidersDeleteMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AccountProvidersDeleteMutationBody = ProviderAccountBody +export type AllauthBrowserV1AccountProvidersDeleteMutationError = ErrorResponse - /** +/** * @summary Disconnect a third-party provider account */ -export const useAllauthBrowserV1AccountProvidersDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext>, request?: SecondParameter} - ) => { +export const useAllauthBrowserV1AccountProvidersDelete = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderAccountBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AccountProvidersDeleteMutationOptions(options) - const mutationOptions = getAllauthBrowserV1AccountProvidersDeleteMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * @summary List the connected third-party provider accounts */ export type allauthAppV1AccountProvidersGetResponse200 = { data: ProviderAccountsResponse status: 200 } - -export type allauthAppV1AccountProvidersGetResponseComposite = allauthAppV1AccountProvidersGetResponse200; - + +export type allauthAppV1AccountProvidersGetResponseComposite = allauthAppV1AccountProvidersGetResponse200 + export type allauthAppV1AccountProvidersGetResponse = allauthAppV1AccountProvidersGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountProvidersGetUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/providers` } -export const allauthAppV1AccountProvidersGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountProvidersGetUrl(), - { +export const allauthAppV1AccountProvidersGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountProvidersGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthAppV1AccountProvidersGetQueryKey = () => { - return ['api','v2','allauth','app','v1','account','providers'] as const; - } - - -export const getAllauthAppV1AccountProvidersGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountProvidersGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'providers'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountProvidersGet({ signal, ...requestOptions }); +export const getAllauthAppV1AccountProvidersGetQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountProvidersGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1AccountProvidersGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthAppV1AccountProvidersGetQueryResult = NonNullable>> +export type AllauthAppV1AccountProvidersGetQueryResult = NonNullable< + Awaited> +> export type AllauthAppV1AccountProvidersGetQueryError = unknown - /** * @summary List the connected third-party provider accounts */ -export function useAllauthAppV1AccountProvidersGet>, TError = unknown>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AccountProvidersGet< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AccountProvidersGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Disconnect a third-party provider account, returning the remaining accounts that are still connected. The disconnect is not allowed if it @@ -4012,78 +4385,91 @@ export type allauthAppV1AccountProvidersDeleteResponse400 = { data: ErrorResponse status: 400 } - -export type allauthAppV1AccountProvidersDeleteResponseComposite = allauthAppV1AccountProvidersDeleteResponse200 | allauthAppV1AccountProvidersDeleteResponse400; - + +export type allauthAppV1AccountProvidersDeleteResponseComposite = + | allauthAppV1AccountProvidersDeleteResponse200 + | allauthAppV1AccountProvidersDeleteResponse400 + export type allauthAppV1AccountProvidersDeleteResponse = allauthAppV1AccountProvidersDeleteResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountProvidersDeleteUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/providers` } -export const allauthAppV1AccountProvidersDelete = async (providerAccountBody: ProviderAccountBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountProvidersDeleteUrl(), - { +export const allauthAppV1AccountProvidersDelete = async ( + providerAccountBody: ProviderAccountBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountProvidersDeleteUrl(), { ...options, method: 'DELETE', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - providerAccountBody,) + body: JSON.stringify(providerAccountBody), + }) +} + +export const getAllauthAppV1AccountProvidersDeleteMutationOptions = < + TError = ErrorResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderAccountBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ProviderAccountBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AccountProvidersDelete'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ProviderAccountBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AccountProvidersDelete(data, requestOptions) } -);} - - + return { mutationFn, ...mutationOptions } +} -export const getAllauthAppV1AccountProvidersDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext> => { - -const mutationKey = ['allauthAppV1AccountProvidersDelete']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ProviderAccountBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AccountProvidersDelete(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AccountProvidersDeleteMutationResult = NonNullable>> - export type AllauthAppV1AccountProvidersDeleteMutationBody = ProviderAccountBody - export type AllauthAppV1AccountProvidersDeleteMutationError = ErrorResponse +export type AllauthAppV1AccountProvidersDeleteMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AccountProvidersDeleteMutationBody = ProviderAccountBody +export type AllauthAppV1AccountProvidersDeleteMutationError = ErrorResponse - /** +/** * @summary Disconnect a third-party provider account */ -export const useAllauthAppV1AccountProvidersDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: ProviderAccountBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AccountProvidersDeleteMutationOptions(options); +export const useAllauthAppV1AccountProvidersDelete = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProviderAccountBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AccountProvidersDeleteMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Retrieves the list of email addresses of the account. * @summary List email addresses @@ -4097,81 +4483,78 @@ export type allauthBrowserV1AccountEmailGetResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthBrowserV1AccountEmailGetResponseComposite = allauthBrowserV1AccountEmailGetResponse200 | allauthBrowserV1AccountEmailGetResponse401; - + +export type allauthBrowserV1AccountEmailGetResponseComposite = + | allauthBrowserV1AccountEmailGetResponse200 + | allauthBrowserV1AccountEmailGetResponse401 + export type allauthBrowserV1AccountEmailGetResponse = allauthBrowserV1AccountEmailGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AccountEmailGetUrl = () => { - - - - return `/api/v2/allauth/browser/v1/account/email` } -export const allauthBrowserV1AccountEmailGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountEmailGetUrl(), - { +export const allauthBrowserV1AccountEmailGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AccountEmailGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthBrowserV1AccountEmailGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','account','email'] as const; - } - - -export const getAllauthBrowserV1AccountEmailGetQueryOptions = >, TError = AuthenticationResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountEmailGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'email'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountEmailGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1AccountEmailGetQueryOptions = < + TData = Awaited>, + TError = AuthenticationResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountEmailGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthBrowserV1AccountEmailGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthBrowserV1AccountEmailGetQueryResult = NonNullable>> +export type AllauthBrowserV1AccountEmailGetQueryResult = NonNullable< + Awaited> +> export type AllauthBrowserV1AccountEmailGetQueryError = AuthenticationResponse - /** * @summary List email addresses */ -export function useAllauthBrowserV1AccountEmailGet>, TError = AuthenticationResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AccountEmailGet< + TData = Awaited>, + TError = AuthenticationResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AccountEmailGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * The following functionality is available: @@ -4203,78 +4586,99 @@ export type allauthBrowserV1AccountEmailPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AccountEmailPostResponseComposite = allauthBrowserV1AccountEmailPostResponse200 | allauthBrowserV1AccountEmailPostResponse400 | allauthBrowserV1AccountEmailPostResponse401 | allauthBrowserV1AccountEmailPostResponse409; - + +export type allauthBrowserV1AccountEmailPostResponseComposite = + | allauthBrowserV1AccountEmailPostResponse200 + | allauthBrowserV1AccountEmailPostResponse400 + | allauthBrowserV1AccountEmailPostResponse401 + | allauthBrowserV1AccountEmailPostResponse409 + export type allauthBrowserV1AccountEmailPostResponse = allauthBrowserV1AccountEmailPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AccountEmailPostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/account/email` } -export const allauthBrowserV1AccountEmailPost = async (emailBody: EmailBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountEmailPostUrl(), - { +export const allauthBrowserV1AccountEmailPost = async ( + emailBody: EmailBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AccountEmailPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - emailBody,) + body: JSON.stringify(emailBody), + }) +} + +export const getAllauthBrowserV1AccountEmailPostMutationOptions = < + TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AccountEmailPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: EmailBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AccountEmailPost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AccountEmailPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AccountEmailPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AccountEmailPost(data,requestOptions) - } - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AccountEmailPostMutationResult = NonNullable>> - export type AllauthBrowserV1AccountEmailPostMutationBody = EmailBody - export type AllauthBrowserV1AccountEmailPostMutationError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse +export type AllauthBrowserV1AccountEmailPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AccountEmailPostMutationBody = EmailBody +export type AllauthBrowserV1AccountEmailPostMutationError = + | ErrorResponse + | AuthenticationOrReauthenticationResponse + | ConflictResponse - /** +/** * @summary Add/Change email address */ -export const useAllauthBrowserV1AccountEmailPost = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} - ) => { +export const useAllauthBrowserV1AccountEmailPost = < + TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AccountEmailPostMutationOptions(options) - const mutationOptions = getAllauthBrowserV1AccountEmailPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Requests for (another) email verification email to be sent. Note that sending emails is rate limited, so when you send too many requests the email will not be sent. @@ -4295,77 +4699,94 @@ export type allauthBrowserV1AccountEmailPutResponse403 = { data: ForbiddenResponse status: 403 } - -export type allauthBrowserV1AccountEmailPutResponseComposite = allauthBrowserV1AccountEmailPutResponse200 | allauthBrowserV1AccountEmailPutResponse400 | allauthBrowserV1AccountEmailPutResponse403; - + +export type allauthBrowserV1AccountEmailPutResponseComposite = + | allauthBrowserV1AccountEmailPutResponse200 + | allauthBrowserV1AccountEmailPutResponse400 + | allauthBrowserV1AccountEmailPutResponse403 + export type allauthBrowserV1AccountEmailPutResponse = allauthBrowserV1AccountEmailPutResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AccountEmailPutUrl = () => { - - - - return `/api/v2/allauth/browser/v1/account/email` } -export const allauthBrowserV1AccountEmailPut = async (emailBody: EmailBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountEmailPutUrl(), - { +export const allauthBrowserV1AccountEmailPut = async ( + emailBody: EmailBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AccountEmailPutUrl(), { ...options, method: 'PUT', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - emailBody,) + body: JSON.stringify(emailBody), + }) +} + +export const getAllauthBrowserV1AccountEmailPutMutationOptions = < + TError = ErrorResponse | ForbiddenResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AccountEmailPut'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: EmailBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AccountEmailPut(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AccountEmailPutMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AccountEmailPut']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AccountEmailPut(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthBrowserV1AccountEmailPutMutationResult = NonNullable>> - export type AllauthBrowserV1AccountEmailPutMutationBody = EmailBody - export type AllauthBrowserV1AccountEmailPutMutationError = ErrorResponse | ForbiddenResponse +export type AllauthBrowserV1AccountEmailPutMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AccountEmailPutMutationBody = EmailBody +export type AllauthBrowserV1AccountEmailPutMutationError = ErrorResponse | ForbiddenResponse - /** +/** * @summary Request email verification */ -export const useAllauthBrowserV1AccountEmailPut = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AccountEmailPutMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AccountEmailPut = < + TError = ErrorResponse | ForbiddenResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AccountEmailPutMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Used to change primary email address to a different one. Note that only verified email addresses can be marked as primary. @@ -4380,77 +4801,90 @@ export type allauthBrowserV1AccountEmailPatchResponse400 = { data: ErrorResponse status: 400 } - -export type allauthBrowserV1AccountEmailPatchResponseComposite = allauthBrowserV1AccountEmailPatchResponse200 | allauthBrowserV1AccountEmailPatchResponse400; - + +export type allauthBrowserV1AccountEmailPatchResponseComposite = + | allauthBrowserV1AccountEmailPatchResponse200 + | allauthBrowserV1AccountEmailPatchResponse400 + export type allauthBrowserV1AccountEmailPatchResponse = allauthBrowserV1AccountEmailPatchResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AccountEmailPatchUrl = () => { - - - - return `/api/v2/allauth/browser/v1/account/email` } -export const allauthBrowserV1AccountEmailPatch = async (markPrimaryEmailBody: MarkPrimaryEmailBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountEmailPatchUrl(), - { +export const allauthBrowserV1AccountEmailPatch = async ( + markPrimaryEmailBody: MarkPrimaryEmailBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AccountEmailPatchUrl(), { ...options, method: 'PATCH', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - markPrimaryEmailBody,) + body: JSON.stringify(markPrimaryEmailBody), + }) +} + +export const getAllauthBrowserV1AccountEmailPatchMutationOptions = < + TError = ErrorResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MarkPrimaryEmailBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: MarkPrimaryEmailBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AccountEmailPatch'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: MarkPrimaryEmailBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AccountEmailPatch(data, requestOptions) } -);} + return { mutationFn, ...mutationOptions } +} +export type AllauthBrowserV1AccountEmailPatchMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AccountEmailPatchMutationBody = MarkPrimaryEmailBody +export type AllauthBrowserV1AccountEmailPatchMutationError = ErrorResponse - -export const getAllauthBrowserV1AccountEmailPatchMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AccountEmailPatch']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: MarkPrimaryEmailBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AccountEmailPatch(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthBrowserV1AccountEmailPatchMutationResult = NonNullable>> - export type AllauthBrowserV1AccountEmailPatchMutationBody = MarkPrimaryEmailBody - export type AllauthBrowserV1AccountEmailPatchMutationError = ErrorResponse - - /** +/** * @summary Change primary email address */ -export const useAllauthBrowserV1AccountEmailPatch = (options?: { mutation?:UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AccountEmailPatchMutationOptions(options); +export const useAllauthBrowserV1AccountEmailPatch = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MarkPrimaryEmailBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AccountEmailPatchMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Used to remove an email address. * @summary Remove an email address @@ -4464,78 +4898,91 @@ export type allauthBrowserV1AccountEmailDeleteResponse400 = { data: ErrorResponse status: 400 } - -export type allauthBrowserV1AccountEmailDeleteResponseComposite = allauthBrowserV1AccountEmailDeleteResponse200 | allauthBrowserV1AccountEmailDeleteResponse400; - + +export type allauthBrowserV1AccountEmailDeleteResponseComposite = + | allauthBrowserV1AccountEmailDeleteResponse200 + | allauthBrowserV1AccountEmailDeleteResponse400 + export type allauthBrowserV1AccountEmailDeleteResponse = allauthBrowserV1AccountEmailDeleteResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AccountEmailDeleteUrl = () => { - - - - return `/api/v2/allauth/browser/v1/account/email` } -export const allauthBrowserV1AccountEmailDelete = async (emailBody: EmailBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountEmailDeleteUrl(), - { +export const allauthBrowserV1AccountEmailDelete = async ( + emailBody: EmailBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AccountEmailDeleteUrl(), { ...options, method: 'DELETE', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - emailBody,) + body: JSON.stringify(emailBody), + }) +} + +export const getAllauthBrowserV1AccountEmailDeleteMutationOptions = < + TError = ErrorResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AccountEmailDelete'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: EmailBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AccountEmailDelete(data, requestOptions) } -);} - - - -export const getAllauthBrowserV1AccountEmailDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AccountEmailDelete']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; + return { mutationFn, ...mutationOptions } +} - +export type AllauthBrowserV1AccountEmailDeleteMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AccountEmailDeleteMutationBody = EmailBody +export type AllauthBrowserV1AccountEmailDeleteMutationError = ErrorResponse +/** + * @summary Remove an email address + */ +export const useAllauthBrowserV1AccountEmailDelete = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AccountEmailDeleteMutationOptions(options) - const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AccountEmailDelete(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthBrowserV1AccountEmailDeleteMutationResult = NonNullable>> - export type AllauthBrowserV1AccountEmailDeleteMutationBody = EmailBody - export type AllauthBrowserV1AccountEmailDeleteMutationError = ErrorResponse - - /** - * @summary Remove an email address - */ -export const useAllauthBrowserV1AccountEmailDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AccountEmailDeleteMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** - * Retrieves the list of email addresses of the account. + return useMutation(mutationOptions) +} +/** + * Retrieves the list of email addresses of the account. * @summary List email addresses */ @@ -4548,81 +4995,78 @@ export type allauthAppV1AccountEmailGetResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthAppV1AccountEmailGetResponseComposite = allauthAppV1AccountEmailGetResponse200 | allauthAppV1AccountEmailGetResponse401; - + +export type allauthAppV1AccountEmailGetResponseComposite = + | allauthAppV1AccountEmailGetResponse200 + | allauthAppV1AccountEmailGetResponse401 + export type allauthAppV1AccountEmailGetResponse = allauthAppV1AccountEmailGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountEmailGetUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/email` } -export const allauthAppV1AccountEmailGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountEmailGetUrl(), - { +export const allauthAppV1AccountEmailGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountEmailGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthAppV1AccountEmailGetQueryKey = () => { - return ['api','v2','allauth','app','v1','account','email'] as const; - } - - -export const getAllauthAppV1AccountEmailGetQueryOptions = >, TError = AuthenticationResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountEmailGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'email'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountEmailGet({ signal, ...requestOptions }); +export const getAllauthAppV1AccountEmailGetQueryOptions = < + TData = Awaited>, + TError = AuthenticationResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountEmailGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1AccountEmailGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthAppV1AccountEmailGetQueryResult = NonNullable>> +export type AllauthAppV1AccountEmailGetQueryResult = NonNullable< + Awaited> +> export type AllauthAppV1AccountEmailGetQueryError = AuthenticationResponse - /** * @summary List email addresses */ -export function useAllauthAppV1AccountEmailGet>, TError = AuthenticationResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AccountEmailGet< + TData = Awaited>, + TError = AuthenticationResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AccountEmailGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * The following functionality is available: @@ -4654,78 +5098,98 @@ export type allauthAppV1AccountEmailPostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AccountEmailPostResponseComposite = allauthAppV1AccountEmailPostResponse200 | allauthAppV1AccountEmailPostResponse400 | allauthAppV1AccountEmailPostResponse401 | allauthAppV1AccountEmailPostResponse409; - + +export type allauthAppV1AccountEmailPostResponseComposite = + | allauthAppV1AccountEmailPostResponse200 + | allauthAppV1AccountEmailPostResponse400 + | allauthAppV1AccountEmailPostResponse401 + | allauthAppV1AccountEmailPostResponse409 + export type allauthAppV1AccountEmailPostResponse = allauthAppV1AccountEmailPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountEmailPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/email` } -export const allauthAppV1AccountEmailPost = async (emailBody: EmailBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountEmailPostUrl(), - { +export const allauthAppV1AccountEmailPost = async ( + emailBody: EmailBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountEmailPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - emailBody,) + body: JSON.stringify(emailBody), + }) +} + +export const getAllauthAppV1AccountEmailPostMutationOptions = < + TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AccountEmailPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: EmailBody }> = ( + props, + ) => { + const { data } = props ?? {} + + return allauthAppV1AccountEmailPost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1AccountEmailPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { - -const mutationKey = ['allauthAppV1AccountEmailPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AccountEmailPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AccountEmailPostMutationResult = NonNullable>> - export type AllauthAppV1AccountEmailPostMutationBody = EmailBody - export type AllauthAppV1AccountEmailPostMutationError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse +export type AllauthAppV1AccountEmailPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AccountEmailPostMutationBody = EmailBody +export type AllauthAppV1AccountEmailPostMutationError = + | ErrorResponse + | AuthenticationOrReauthenticationResponse + | ConflictResponse - /** +/** * @summary Add/Change email address */ -export const useAllauthAppV1AccountEmailPost = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AccountEmailPostMutationOptions(options); +export const useAllauthAppV1AccountEmailPost = < + TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AccountEmailPostMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Requests for (another) email verification email to be sent. Note that sending emails is rate limited, so when you send too many requests the email will not be sent. @@ -4746,77 +5210,93 @@ export type allauthAppV1AccountEmailPutResponse403 = { data: ForbiddenResponse status: 403 } - -export type allauthAppV1AccountEmailPutResponseComposite = allauthAppV1AccountEmailPutResponse200 | allauthAppV1AccountEmailPutResponse400 | allauthAppV1AccountEmailPutResponse403; - + +export type allauthAppV1AccountEmailPutResponseComposite = + | allauthAppV1AccountEmailPutResponse200 + | allauthAppV1AccountEmailPutResponse400 + | allauthAppV1AccountEmailPutResponse403 + export type allauthAppV1AccountEmailPutResponse = allauthAppV1AccountEmailPutResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountEmailPutUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/email` } -export const allauthAppV1AccountEmailPut = async (emailBody: EmailBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountEmailPutUrl(), - { +export const allauthAppV1AccountEmailPut = async ( + emailBody: EmailBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountEmailPutUrl(), { ...options, method: 'PUT', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - emailBody,) + body: JSON.stringify(emailBody), + }) +} + +export const getAllauthAppV1AccountEmailPutMutationOptions = < + TError = ErrorResponse | ForbiddenResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AccountEmailPut'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: EmailBody }> = ( + props, + ) => { + const { data } = props ?? {} + + return allauthAppV1AccountEmailPut(data, requestOptions) } -);} - - - - -export const getAllauthAppV1AccountEmailPutMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { - -const mutationKey = ['allauthAppV1AccountEmailPut']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AccountEmailPut(data,requestOptions) - } - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthAppV1AccountEmailPutMutationResult = NonNullable>> - export type AllauthAppV1AccountEmailPutMutationBody = EmailBody - export type AllauthAppV1AccountEmailPutMutationError = ErrorResponse | ForbiddenResponse +export type AllauthAppV1AccountEmailPutMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AccountEmailPutMutationBody = EmailBody +export type AllauthAppV1AccountEmailPutMutationError = ErrorResponse | ForbiddenResponse - /** +/** * @summary Request email verification */ -export const useAllauthAppV1AccountEmailPut = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AccountEmailPutMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AccountEmailPut = < + TError = ErrorResponse | ForbiddenResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AccountEmailPutMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Used to change primary email address to a different one. Note that only verified email addresses can be marked as primary. @@ -4831,77 +5311,87 @@ export type allauthAppV1AccountEmailPatchResponse400 = { data: ErrorResponse status: 400 } - -export type allauthAppV1AccountEmailPatchResponseComposite = allauthAppV1AccountEmailPatchResponse200 | allauthAppV1AccountEmailPatchResponse400; - + +export type allauthAppV1AccountEmailPatchResponseComposite = + | allauthAppV1AccountEmailPatchResponse200 + | allauthAppV1AccountEmailPatchResponse400 + export type allauthAppV1AccountEmailPatchResponse = allauthAppV1AccountEmailPatchResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountEmailPatchUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/email` } -export const allauthAppV1AccountEmailPatch = async (markPrimaryEmailBody: MarkPrimaryEmailBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountEmailPatchUrl(), - { +export const allauthAppV1AccountEmailPatch = async ( + markPrimaryEmailBody: MarkPrimaryEmailBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountEmailPatchUrl(), { ...options, method: 'PATCH', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - markPrimaryEmailBody,) + body: JSON.stringify(markPrimaryEmailBody), + }) +} + +export const getAllauthAppV1AccountEmailPatchMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MarkPrimaryEmailBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: MarkPrimaryEmailBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AccountEmailPatch'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: MarkPrimaryEmailBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AccountEmailPatch(data, requestOptions) } -);} - - - -export const getAllauthAppV1AccountEmailPatchMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext> => { - -const mutationKey = ['allauthAppV1AccountEmailPatch']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: MarkPrimaryEmailBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AccountEmailPatch(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthAppV1AccountEmailPatchMutationResult = NonNullable>> - export type AllauthAppV1AccountEmailPatchMutationBody = MarkPrimaryEmailBody - export type AllauthAppV1AccountEmailPatchMutationError = ErrorResponse +export type AllauthAppV1AccountEmailPatchMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AccountEmailPatchMutationBody = MarkPrimaryEmailBody +export type AllauthAppV1AccountEmailPatchMutationError = ErrorResponse - /** +/** * @summary Change primary email address */ -export const useAllauthAppV1AccountEmailPatch = (options?: { mutation?:UseMutationOptions>, TError,{data: MarkPrimaryEmailBody}, TContext>, request?: SecondParameter} - ) => { +export const useAllauthAppV1AccountEmailPatch = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: MarkPrimaryEmailBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AccountEmailPatchMutationOptions(options) - const mutationOptions = getAllauthAppV1AccountEmailPatchMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Used to remove an email address. * @summary Remove an email address @@ -4915,77 +5405,87 @@ export type allauthAppV1AccountEmailDeleteResponse400 = { data: ErrorResponse status: 400 } - -export type allauthAppV1AccountEmailDeleteResponseComposite = allauthAppV1AccountEmailDeleteResponse200 | allauthAppV1AccountEmailDeleteResponse400; - + +export type allauthAppV1AccountEmailDeleteResponseComposite = + | allauthAppV1AccountEmailDeleteResponse200 + | allauthAppV1AccountEmailDeleteResponse400 + export type allauthAppV1AccountEmailDeleteResponse = allauthAppV1AccountEmailDeleteResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountEmailDeleteUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/email` } -export const allauthAppV1AccountEmailDelete = async (emailBody: EmailBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountEmailDeleteUrl(), - { +export const allauthAppV1AccountEmailDelete = async ( + emailBody: EmailBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountEmailDeleteUrl(), { ...options, method: 'DELETE', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - emailBody,) + body: JSON.stringify(emailBody), + }) +} + +export const getAllauthAppV1AccountEmailDeleteMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AccountEmailDelete'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: EmailBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AccountEmailDelete(data, requestOptions) } -);} - - - - -export const getAllauthAppV1AccountEmailDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: EmailBody}, TContext> => { - -const mutationKey = ['allauthAppV1AccountEmailDelete']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {data: EmailBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AccountEmailDelete(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AccountEmailDeleteMutationResult = NonNullable>> - export type AllauthAppV1AccountEmailDeleteMutationBody = EmailBody - export type AllauthAppV1AccountEmailDeleteMutationError = ErrorResponse +export type AllauthAppV1AccountEmailDeleteMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AccountEmailDeleteMutationBody = EmailBody +export type AllauthAppV1AccountEmailDeleteMutationError = ErrorResponse - /** +/** * @summary Remove an email address */ -export const useAllauthAppV1AccountEmailDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AccountEmailDeleteMutationOptions(options); +export const useAllauthAppV1AccountEmailDelete = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AccountEmailDeleteMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Retrieves the phone number of the account, if any. Note that while the endpoint returns a list of phone numbers, at most one entry is returned. @@ -5000,81 +5500,78 @@ export type allauthBrowserV1AccountPhoneGetResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthBrowserV1AccountPhoneGetResponseComposite = allauthBrowserV1AccountPhoneGetResponse200 | allauthBrowserV1AccountPhoneGetResponse401; - + +export type allauthBrowserV1AccountPhoneGetResponseComposite = + | allauthBrowserV1AccountPhoneGetResponse200 + | allauthBrowserV1AccountPhoneGetResponse401 + export type allauthBrowserV1AccountPhoneGetResponse = allauthBrowserV1AccountPhoneGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AccountPhoneGetUrl = () => { - - - - return `/api/v2/allauth/browser/v1/account/phone` } -export const allauthBrowserV1AccountPhoneGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountPhoneGetUrl(), - { +export const allauthBrowserV1AccountPhoneGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AccountPhoneGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthBrowserV1AccountPhoneGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','account','phone'] as const; - } - - -export const getAllauthBrowserV1AccountPhoneGetQueryOptions = >, TError = AuthenticationResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountPhoneGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'phone'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountPhoneGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1AccountPhoneGetQueryOptions = < + TData = Awaited>, + TError = AuthenticationResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountPhoneGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthBrowserV1AccountPhoneGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthBrowserV1AccountPhoneGetQueryResult = NonNullable>> +export type AllauthBrowserV1AccountPhoneGetQueryResult = NonNullable< + Awaited> +> export type AllauthBrowserV1AccountPhoneGetQueryError = AuthenticationResponse - /** * @summary Get the phone number */ -export function useAllauthBrowserV1AccountPhoneGet>, TError = AuthenticationResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AccountPhoneGet< + TData = Awaited>, + TError = AuthenticationResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AccountPhoneGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * The following functionality is available: @@ -5109,78 +5606,99 @@ export type allauthBrowserV1AccountPhonePostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthBrowserV1AccountPhonePostResponseComposite = allauthBrowserV1AccountPhonePostResponse202 | allauthBrowserV1AccountPhonePostResponse400 | allauthBrowserV1AccountPhonePostResponse401 | allauthBrowserV1AccountPhonePostResponse409; - + +export type allauthBrowserV1AccountPhonePostResponseComposite = + | allauthBrowserV1AccountPhonePostResponse202 + | allauthBrowserV1AccountPhonePostResponse400 + | allauthBrowserV1AccountPhonePostResponse401 + | allauthBrowserV1AccountPhonePostResponse409 + export type allauthBrowserV1AccountPhonePostResponse = allauthBrowserV1AccountPhonePostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AccountPhonePostUrl = () => { - - - - return `/api/v2/allauth/browser/v1/account/phone` } -export const allauthBrowserV1AccountPhonePost = async (phoneBody: PhoneBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountPhonePostUrl(), - { +export const allauthBrowserV1AccountPhonePost = async ( + phoneBody: PhoneBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AccountPhonePostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - phoneBody,) + body: JSON.stringify(phoneBody), + }) +} + +export const getAllauthBrowserV1AccountPhonePostMutationOptions = < + TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: PhoneBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: PhoneBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AccountPhonePost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: PhoneBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AccountPhonePost(data, requestOptions) } -);} - - - - -export const getAllauthBrowserV1AccountPhonePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: PhoneBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: PhoneBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AccountPhonePost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {data: PhoneBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AccountPhonePost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AccountPhonePostMutationResult = NonNullable>> - export type AllauthBrowserV1AccountPhonePostMutationBody = PhoneBody - export type AllauthBrowserV1AccountPhonePostMutationError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse +export type AllauthBrowserV1AccountPhonePostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AccountPhonePostMutationBody = PhoneBody +export type AllauthBrowserV1AccountPhonePostMutationError = + | ErrorResponse + | AuthenticationOrReauthenticationResponse + | ConflictResponse - /** +/** * @summary Change the phone number */ -export const useAllauthBrowserV1AccountPhonePost = (options?: { mutation?:UseMutationOptions>, TError,{data: PhoneBody}, TContext>, request?: SecondParameter} - ) => { +export const useAllauthBrowserV1AccountPhonePost = < + TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: PhoneBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AccountPhonePostMutationOptions(options) - const mutationOptions = getAllauthBrowserV1AccountPhonePostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Retrieves the phone number of the account, if any. Note that while the endpoint returns a list of phone numbers, at most one entry is returned. @@ -5195,81 +5713,78 @@ export type allauthAppV1AccountPhoneGetResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthAppV1AccountPhoneGetResponseComposite = allauthAppV1AccountPhoneGetResponse200 | allauthAppV1AccountPhoneGetResponse401; - + +export type allauthAppV1AccountPhoneGetResponseComposite = + | allauthAppV1AccountPhoneGetResponse200 + | allauthAppV1AccountPhoneGetResponse401 + export type allauthAppV1AccountPhoneGetResponse = allauthAppV1AccountPhoneGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountPhoneGetUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/phone` } -export const allauthAppV1AccountPhoneGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountPhoneGetUrl(), - { +export const allauthAppV1AccountPhoneGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountPhoneGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthAppV1AccountPhoneGetQueryKey = () => { - return ['api','v2','allauth','app','v1','account','phone'] as const; - } - - -export const getAllauthAppV1AccountPhoneGetQueryOptions = >, TError = AuthenticationResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountPhoneGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'phone'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountPhoneGet({ signal, ...requestOptions }); +export const getAllauthAppV1AccountPhoneGetQueryOptions = < + TData = Awaited>, + TError = AuthenticationResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountPhoneGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1AccountPhoneGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthAppV1AccountPhoneGetQueryResult = NonNullable>> +export type AllauthAppV1AccountPhoneGetQueryResult = NonNullable< + Awaited> +> export type AllauthAppV1AccountPhoneGetQueryError = AuthenticationResponse - /** * @summary Get the phone number */ -export function useAllauthAppV1AccountPhoneGet>, TError = AuthenticationResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AccountPhoneGet< + TData = Awaited>, + TError = AuthenticationResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AccountPhoneGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * The following functionality is available: @@ -5304,78 +5819,98 @@ export type allauthAppV1AccountPhonePostResponse409 = { data: ConflictResponse status: 409 } - -export type allauthAppV1AccountPhonePostResponseComposite = allauthAppV1AccountPhonePostResponse202 | allauthAppV1AccountPhonePostResponse400 | allauthAppV1AccountPhonePostResponse401 | allauthAppV1AccountPhonePostResponse409; - + +export type allauthAppV1AccountPhonePostResponseComposite = + | allauthAppV1AccountPhonePostResponse202 + | allauthAppV1AccountPhonePostResponse400 + | allauthAppV1AccountPhonePostResponse401 + | allauthAppV1AccountPhonePostResponse409 + export type allauthAppV1AccountPhonePostResponse = allauthAppV1AccountPhonePostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountPhonePostUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/phone` } -export const allauthAppV1AccountPhonePost = async (phoneBody: PhoneBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountPhonePostUrl(), - { +export const allauthAppV1AccountPhonePost = async ( + phoneBody: PhoneBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountPhonePostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - phoneBody,) + body: JSON.stringify(phoneBody), + }) +} + +export const getAllauthAppV1AccountPhonePostMutationOptions = < + TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: PhoneBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: PhoneBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AccountPhonePost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: PhoneBody }> = ( + props, + ) => { + const { data } = props ?? {} + + return allauthAppV1AccountPhonePost(data, requestOptions) } -);} + return { mutationFn, ...mutationOptions } +} +export type AllauthAppV1AccountPhonePostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AccountPhonePostMutationBody = PhoneBody +export type AllauthAppV1AccountPhonePostMutationError = + | ErrorResponse + | AuthenticationOrReauthenticationResponse + | ConflictResponse - -export const getAllauthAppV1AccountPhonePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: PhoneBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: PhoneBody}, TContext> => { - -const mutationKey = ['allauthAppV1AccountPhonePost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: PhoneBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AccountPhonePost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AccountPhonePostMutationResult = NonNullable>> - export type AllauthAppV1AccountPhonePostMutationBody = PhoneBody - export type AllauthAppV1AccountPhonePostMutationError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse - - /** +/** * @summary Change the phone number */ -export const useAllauthAppV1AccountPhonePost = (options?: { mutation?:UseMutationOptions>, TError,{data: PhoneBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AccountPhonePostMutationOptions(options); +export const useAllauthAppV1AccountPhonePost = < + TError = ErrorResponse | AuthenticationOrReauthenticationResponse | ConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: PhoneBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AccountPhonePostMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * @summary List authenticators */ export type allauthBrowserV1AccountAuthenticatorsGetResponse200 = { @@ -5392,81 +5927,83 @@ export type allauthBrowserV1AccountAuthenticatorsGetResponse410 = { data: SessionGoneResponse status: 410 } - -export type allauthBrowserV1AccountAuthenticatorsGetResponseComposite = allauthBrowserV1AccountAuthenticatorsGetResponse200 | allauthBrowserV1AccountAuthenticatorsGetResponse401 | allauthBrowserV1AccountAuthenticatorsGetResponse410; - -export type allauthBrowserV1AccountAuthenticatorsGetResponse = allauthBrowserV1AccountAuthenticatorsGetResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1AccountAuthenticatorsGetUrl = () => { +export type allauthBrowserV1AccountAuthenticatorsGetResponseComposite = + | allauthBrowserV1AccountAuthenticatorsGetResponse200 + | allauthBrowserV1AccountAuthenticatorsGetResponse401 + | allauthBrowserV1AccountAuthenticatorsGetResponse410 - +export type allauthBrowserV1AccountAuthenticatorsGetResponse = + allauthBrowserV1AccountAuthenticatorsGetResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1AccountAuthenticatorsGetUrl = () => { return `/api/v2/allauth/browser/v1/account/authenticators` } -export const allauthBrowserV1AccountAuthenticatorsGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsGetUrl(), - { - ...options, - method: 'GET' - - - } -);} - - +export const allauthBrowserV1AccountAuthenticatorsGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1AccountAuthenticatorsGetUrl(), + { + ...options, + method: 'GET', + }, + ) +} export const getAllauthBrowserV1AccountAuthenticatorsGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','account','authenticators'] as const; - } - - -export const getAllauthBrowserV1AccountAuthenticatorsGetQueryOptions = >, TError = AuthenticationResponse | SessionGoneResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'authenticators'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountAuthenticatorsGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1AccountAuthenticatorsGetQueryOptions = < + TData = Awaited>, + TError = AuthenticationResponse | SessionGoneResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthBrowserV1AccountAuthenticatorsGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthBrowserV1AccountAuthenticatorsGetQueryResult = NonNullable>> +export type AllauthBrowserV1AccountAuthenticatorsGetQueryResult = NonNullable< + Awaited> +> export type AllauthBrowserV1AccountAuthenticatorsGetQueryError = AuthenticationResponse | SessionGoneResponse - /** * @summary List authenticators */ -export function useAllauthBrowserV1AccountAuthenticatorsGet>, TError = AuthenticationResponse | SessionGoneResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AccountAuthenticatorsGet< + TData = Awaited>, + TError = AuthenticationResponse | SessionGoneResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AccountAuthenticatorsGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * @summary List authenticators */ @@ -5484,81 +6021,79 @@ export type allauthAppV1AccountAuthenticatorsGetResponse410 = { data: SessionGoneResponse status: 410 } - -export type allauthAppV1AccountAuthenticatorsGetResponseComposite = allauthAppV1AccountAuthenticatorsGetResponse200 | allauthAppV1AccountAuthenticatorsGetResponse401 | allauthAppV1AccountAuthenticatorsGetResponse410; - + +export type allauthAppV1AccountAuthenticatorsGetResponseComposite = + | allauthAppV1AccountAuthenticatorsGetResponse200 + | allauthAppV1AccountAuthenticatorsGetResponse401 + | allauthAppV1AccountAuthenticatorsGetResponse410 + export type allauthAppV1AccountAuthenticatorsGetResponse = allauthAppV1AccountAuthenticatorsGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountAuthenticatorsGetUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/authenticators` } -export const allauthAppV1AccountAuthenticatorsGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsGetUrl(), - { +export const allauthAppV1AccountAuthenticatorsGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthAppV1AccountAuthenticatorsGetQueryKey = () => { - return ['api','v2','allauth','app','v1','account','authenticators'] as const; - } - - -export const getAllauthAppV1AccountAuthenticatorsGetQueryOptions = >, TError = AuthenticationResponse | SessionGoneResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'authenticators'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountAuthenticatorsGet({ signal, ...requestOptions }); +export const getAllauthAppV1AccountAuthenticatorsGetQueryOptions = < + TData = Awaited>, + TError = AuthenticationResponse | SessionGoneResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1AccountAuthenticatorsGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthAppV1AccountAuthenticatorsGetQueryResult = NonNullable>> +export type AllauthAppV1AccountAuthenticatorsGetQueryResult = NonNullable< + Awaited> +> export type AllauthAppV1AccountAuthenticatorsGetQueryError = AuthenticationResponse | SessionGoneResponse - /** * @summary List authenticators */ -export function useAllauthAppV1AccountAuthenticatorsGet>, TError = AuthenticationResponse | SessionGoneResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AccountAuthenticatorsGet< + TData = Awaited>, + TError = AuthenticationResponse | SessionGoneResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AccountAuthenticatorsGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Retrieve the information about the current TOTP authenticator, if any. @@ -5578,81 +6113,86 @@ export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse409 = { data: AddAuthenticatorConflictResponse status: 409 } - -export type allauthBrowserV1AccountAuthenticatorsTotpGetResponseComposite = allauthBrowserV1AccountAuthenticatorsTotpGetResponse200 | allauthBrowserV1AccountAuthenticatorsTotpGetResponse404 | allauthBrowserV1AccountAuthenticatorsTotpGetResponse409; - -export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse = allauthBrowserV1AccountAuthenticatorsTotpGetResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1AccountAuthenticatorsTotpGetUrl = () => { +export type allauthBrowserV1AccountAuthenticatorsTotpGetResponseComposite = + | allauthBrowserV1AccountAuthenticatorsTotpGetResponse200 + | allauthBrowserV1AccountAuthenticatorsTotpGetResponse404 + | allauthBrowserV1AccountAuthenticatorsTotpGetResponse409 - +export type allauthBrowserV1AccountAuthenticatorsTotpGetResponse = + allauthBrowserV1AccountAuthenticatorsTotpGetResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1AccountAuthenticatorsTotpGetUrl = () => { return `/api/v2/allauth/browser/v1/account/authenticators/totp` } -export const allauthBrowserV1AccountAuthenticatorsTotpGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsTotpGetUrl(), - { - ...options, - method: 'GET' - - - } -);} - - +export const allauthBrowserV1AccountAuthenticatorsTotpGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1AccountAuthenticatorsTotpGetUrl(), + { + ...options, + method: 'GET', + }, + ) +} export const getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','account','authenticators','totp'] as const; - } - - -export const getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryOptions = >, TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'authenticators', 'totp'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountAuthenticatorsTotpGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryOptions = < + TData = Awaited>, + TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryKey() - + const queryFn: QueryFunction>> = ({ + signal, + }) => allauthBrowserV1AccountAuthenticatorsTotpGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthBrowserV1AccountAuthenticatorsTotpGetQueryResult = NonNullable>> -export type AllauthBrowserV1AccountAuthenticatorsTotpGetQueryError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse - +export type AllauthBrowserV1AccountAuthenticatorsTotpGetQueryResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AccountAuthenticatorsTotpGetQueryError = + | TOTPAuthenticatorNotFoundResponse + | AddAuthenticatorConflictResponse /** * @summary TOTP authenticator status */ -export function useAllauthBrowserV1AccountAuthenticatorsTotpGet>, TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AccountAuthenticatorsTotpGet< + TData = Awaited>, + TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AccountAuthenticatorsTotpGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * The code should be provided from the consuming TOTP authenticator application which was generated using the TOTP authenticator secret @@ -5679,77 +6219,102 @@ export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse409 = { data: AddAuthenticatorConflictResponse status: 409 } - -export type allauthBrowserV1AccountAuthenticatorsTotpPostResponseComposite = allauthBrowserV1AccountAuthenticatorsTotpPostResponse200 | allauthBrowserV1AccountAuthenticatorsTotpPostResponse400 | allauthBrowserV1AccountAuthenticatorsTotpPostResponse401 | allauthBrowserV1AccountAuthenticatorsTotpPostResponse409; - -export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse = allauthBrowserV1AccountAuthenticatorsTotpPostResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1AccountAuthenticatorsTotpPostUrl = () => { +export type allauthBrowserV1AccountAuthenticatorsTotpPostResponseComposite = + | allauthBrowserV1AccountAuthenticatorsTotpPostResponse200 + | allauthBrowserV1AccountAuthenticatorsTotpPostResponse400 + | allauthBrowserV1AccountAuthenticatorsTotpPostResponse401 + | allauthBrowserV1AccountAuthenticatorsTotpPostResponse409 - +export type allauthBrowserV1AccountAuthenticatorsTotpPostResponse = + allauthBrowserV1AccountAuthenticatorsTotpPostResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1AccountAuthenticatorsTotpPostUrl = () => { return `/api/v2/allauth/browser/v1/account/authenticators/totp` } -export const allauthBrowserV1AccountAuthenticatorsTotpPost = async (setupTOTPBody: SetupTOTPBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsTotpPostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - setupTOTPBody,) +export const allauthBrowserV1AccountAuthenticatorsTotpPost = async ( + setupTOTPBody: SetupTOTPBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1AccountAuthenticatorsTotpPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(setupTOTPBody), + }, + ) +} + +export const getAllauthBrowserV1AccountAuthenticatorsTotpPostMutationOptions = < + TError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: SetupTOTPBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: SetupTOTPBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AccountAuthenticatorsTotpPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: SetupTOTPBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AccountAuthenticatorsTotpPost(data, requestOptions) } -);} + return { mutationFn, ...mutationOptions } +} +export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationBody = SetupTOTPBody +export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationError = + | ErrorResponse + | ReauthenticationRequiredResponse + | AddAuthenticatorConflictResponse - -export const getAllauthBrowserV1AccountAuthenticatorsTotpPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AccountAuthenticatorsTotpPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: SetupTOTPBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AccountAuthenticatorsTotpPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationResult = NonNullable>> - export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationBody = SetupTOTPBody - export type AllauthBrowserV1AccountAuthenticatorsTotpPostMutationError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse - - /** +/** * @summary Activate TOTP */ -export const useAllauthBrowserV1AccountAuthenticatorsTotpPost = (options?: { mutation?:UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsTotpPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AccountAuthenticatorsTotpPost = < + TError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: SetupTOTPBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsTotpPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Deactivates TOTP authentication. If the user authentication is not sufficiently recent, a reauthentication flow (`401`) will is presented. @@ -5764,76 +6329,92 @@ export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse401 = { data: ReauthenticationRequiredResponse status: 401 } - -export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponseComposite = allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse200 | allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse401; - -export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse = allauthBrowserV1AccountAuthenticatorsTotpDeleteResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1AccountAuthenticatorsTotpDeleteUrl = () => { +export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponseComposite = + | allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse200 + | allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse401 - +export type allauthBrowserV1AccountAuthenticatorsTotpDeleteResponse = + allauthBrowserV1AccountAuthenticatorsTotpDeleteResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1AccountAuthenticatorsTotpDeleteUrl = () => { return `/api/v2/allauth/browser/v1/account/authenticators/totp` } -export const allauthBrowserV1AccountAuthenticatorsTotpDelete = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsTotpDeleteUrl(), - { - ...options, - method: 'DELETE' - - +export const allauthBrowserV1AccountAuthenticatorsTotpDelete = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1AccountAuthenticatorsTotpDeleteUrl(), + { + ...options, + method: 'DELETE', + }, + ) +} + +export const getAllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationOptions = < + TError = ReauthenticationRequiredResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ['allauthBrowserV1AccountAuthenticatorsTotpDelete'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + void + > = () => { + return allauthBrowserV1AccountAuthenticatorsTotpDelete(requestOptions) } -);} - - - - -export const getAllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['allauthBrowserV1AccountAuthenticatorsTotpDelete']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return allauthBrowserV1AccountAuthenticatorsTotpDelete(requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} +export type AllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationResult = NonNullable< + Awaited> +> - export type AllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationResult = NonNullable>> - - export type AllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationError = ReauthenticationRequiredResponse +export type AllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationError = ReauthenticationRequiredResponse - /** +/** * @summary Deactivate TOTP */ -export const useAllauthBrowserV1AccountAuthenticatorsTotpDelete = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AccountAuthenticatorsTotpDelete = < + TError = ReauthenticationRequiredResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsTotpDeleteMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Retrieve the information about the current TOTP authenticator, if any. * @summary TOTP authenticator status @@ -5852,81 +6433,85 @@ export type allauthAppV1AccountAuthenticatorsTotpGetResponse409 = { data: AddAuthenticatorConflictResponse status: 409 } - -export type allauthAppV1AccountAuthenticatorsTotpGetResponseComposite = allauthAppV1AccountAuthenticatorsTotpGetResponse200 | allauthAppV1AccountAuthenticatorsTotpGetResponse404 | allauthAppV1AccountAuthenticatorsTotpGetResponse409; - -export type allauthAppV1AccountAuthenticatorsTotpGetResponse = allauthAppV1AccountAuthenticatorsTotpGetResponseComposite & { - headers: Headers; -} - -export const getAllauthAppV1AccountAuthenticatorsTotpGetUrl = () => { +export type allauthAppV1AccountAuthenticatorsTotpGetResponseComposite = + | allauthAppV1AccountAuthenticatorsTotpGetResponse200 + | allauthAppV1AccountAuthenticatorsTotpGetResponse404 + | allauthAppV1AccountAuthenticatorsTotpGetResponse409 - +export type allauthAppV1AccountAuthenticatorsTotpGetResponse = + allauthAppV1AccountAuthenticatorsTotpGetResponseComposite & { + headers: Headers + } +export const getAllauthAppV1AccountAuthenticatorsTotpGetUrl = () => { return `/api/v2/allauth/app/v1/account/authenticators/totp` } -export const allauthAppV1AccountAuthenticatorsTotpGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsTotpGetUrl(), - { - ...options, - method: 'GET' - - - } -);} - - +export const allauthAppV1AccountAuthenticatorsTotpGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthAppV1AccountAuthenticatorsTotpGetUrl(), + { + ...options, + method: 'GET', + }, + ) +} export const getAllauthAppV1AccountAuthenticatorsTotpGetQueryKey = () => { - return ['api','v2','allauth','app','v1','account','authenticators','totp'] as const; - } - - -export const getAllauthAppV1AccountAuthenticatorsTotpGetQueryOptions = >, TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsTotpGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'authenticators', 'totp'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountAuthenticatorsTotpGet({ signal, ...requestOptions }); +export const getAllauthAppV1AccountAuthenticatorsTotpGetQueryOptions = < + TData = Awaited>, + TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsTotpGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1AccountAuthenticatorsTotpGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthAppV1AccountAuthenticatorsTotpGetQueryResult = NonNullable>> -export type AllauthAppV1AccountAuthenticatorsTotpGetQueryError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse - +export type AllauthAppV1AccountAuthenticatorsTotpGetQueryResult = NonNullable< + Awaited> +> +export type AllauthAppV1AccountAuthenticatorsTotpGetQueryError = + | TOTPAuthenticatorNotFoundResponse + | AddAuthenticatorConflictResponse /** * @summary TOTP authenticator status */ -export function useAllauthAppV1AccountAuthenticatorsTotpGet>, TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AccountAuthenticatorsTotpGet< + TData = Awaited>, + TError = TOTPAuthenticatorNotFoundResponse | AddAuthenticatorConflictResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AccountAuthenticatorsTotpGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * The code should be provided from the consuming TOTP authenticator application which was generated using the TOTP authenticator secret @@ -5953,77 +6538,102 @@ export type allauthAppV1AccountAuthenticatorsTotpPostResponse409 = { data: AddAuthenticatorConflictResponse status: 409 } - -export type allauthAppV1AccountAuthenticatorsTotpPostResponseComposite = allauthAppV1AccountAuthenticatorsTotpPostResponse200 | allauthAppV1AccountAuthenticatorsTotpPostResponse400 | allauthAppV1AccountAuthenticatorsTotpPostResponse401 | allauthAppV1AccountAuthenticatorsTotpPostResponse409; - -export type allauthAppV1AccountAuthenticatorsTotpPostResponse = allauthAppV1AccountAuthenticatorsTotpPostResponseComposite & { - headers: Headers; -} - -export const getAllauthAppV1AccountAuthenticatorsTotpPostUrl = () => { +export type allauthAppV1AccountAuthenticatorsTotpPostResponseComposite = + | allauthAppV1AccountAuthenticatorsTotpPostResponse200 + | allauthAppV1AccountAuthenticatorsTotpPostResponse400 + | allauthAppV1AccountAuthenticatorsTotpPostResponse401 + | allauthAppV1AccountAuthenticatorsTotpPostResponse409 - +export type allauthAppV1AccountAuthenticatorsTotpPostResponse = + allauthAppV1AccountAuthenticatorsTotpPostResponseComposite & { + headers: Headers + } +export const getAllauthAppV1AccountAuthenticatorsTotpPostUrl = () => { return `/api/v2/allauth/app/v1/account/authenticators/totp` } -export const allauthAppV1AccountAuthenticatorsTotpPost = async (setupTOTPBody: SetupTOTPBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsTotpPostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - setupTOTPBody,) +export const allauthAppV1AccountAuthenticatorsTotpPost = async ( + setupTOTPBody: SetupTOTPBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthAppV1AccountAuthenticatorsTotpPostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(setupTOTPBody), + }, + ) +} + +export const getAllauthAppV1AccountAuthenticatorsTotpPostMutationOptions = < + TError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: SetupTOTPBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: SetupTOTPBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AccountAuthenticatorsTotpPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: SetupTOTPBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AccountAuthenticatorsTotpPost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1AccountAuthenticatorsTotpPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext> => { - -const mutationKey = ['allauthAppV1AccountAuthenticatorsTotpPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {data: SetupTOTPBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AccountAuthenticatorsTotpPost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthAppV1AccountAuthenticatorsTotpPostMutationResult = NonNullable>> - export type AllauthAppV1AccountAuthenticatorsTotpPostMutationBody = SetupTOTPBody - export type AllauthAppV1AccountAuthenticatorsTotpPostMutationError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse +export type AllauthAppV1AccountAuthenticatorsTotpPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AccountAuthenticatorsTotpPostMutationBody = SetupTOTPBody +export type AllauthAppV1AccountAuthenticatorsTotpPostMutationError = + | ErrorResponse + | ReauthenticationRequiredResponse + | AddAuthenticatorConflictResponse - /** +/** * @summary Activate TOTP */ -export const useAllauthAppV1AccountAuthenticatorsTotpPost = (options?: { mutation?:UseMutationOptions>, TError,{data: SetupTOTPBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AccountAuthenticatorsTotpPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AccountAuthenticatorsTotpPost = < + TError = ErrorResponse | ReauthenticationRequiredResponse | AddAuthenticatorConflictResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: SetupTOTPBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AccountAuthenticatorsTotpPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Deactivates TOTP authentication. If the user authentication is not sufficiently recent, a reauthentication flow (`401`) will is presented. @@ -6038,76 +6648,92 @@ export type allauthAppV1AccountAuthenticatorsTotpDeleteResponse401 = { data: ReauthenticationRequiredResponse status: 401 } - -export type allauthAppV1AccountAuthenticatorsTotpDeleteResponseComposite = allauthAppV1AccountAuthenticatorsTotpDeleteResponse200 | allauthAppV1AccountAuthenticatorsTotpDeleteResponse401; - -export type allauthAppV1AccountAuthenticatorsTotpDeleteResponse = allauthAppV1AccountAuthenticatorsTotpDeleteResponseComposite & { - headers: Headers; -} -export const getAllauthAppV1AccountAuthenticatorsTotpDeleteUrl = () => { +export type allauthAppV1AccountAuthenticatorsTotpDeleteResponseComposite = + | allauthAppV1AccountAuthenticatorsTotpDeleteResponse200 + | allauthAppV1AccountAuthenticatorsTotpDeleteResponse401 +export type allauthAppV1AccountAuthenticatorsTotpDeleteResponse = + allauthAppV1AccountAuthenticatorsTotpDeleteResponseComposite & { + headers: Headers + } - - +export const getAllauthAppV1AccountAuthenticatorsTotpDeleteUrl = () => { return `/api/v2/allauth/app/v1/account/authenticators/totp` } -export const allauthAppV1AccountAuthenticatorsTotpDelete = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsTotpDeleteUrl(), - { - ...options, - method: 'DELETE' - - +export const allauthAppV1AccountAuthenticatorsTotpDelete = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthAppV1AccountAuthenticatorsTotpDeleteUrl(), + { + ...options, + method: 'DELETE', + }, + ) +} + +export const getAllauthAppV1AccountAuthenticatorsTotpDeleteMutationOptions = < + TError = ReauthenticationRequiredResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ['allauthAppV1AccountAuthenticatorsTotpDelete'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + void + > = () => { + return allauthAppV1AccountAuthenticatorsTotpDelete(requestOptions) } -);} - - - - -export const getAllauthAppV1AccountAuthenticatorsTotpDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['allauthAppV1AccountAuthenticatorsTotpDelete']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return allauthAppV1AccountAuthenticatorsTotpDelete(requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} +export type AllauthAppV1AccountAuthenticatorsTotpDeleteMutationResult = NonNullable< + Awaited> +> - export type AllauthAppV1AccountAuthenticatorsTotpDeleteMutationResult = NonNullable>> - - export type AllauthAppV1AccountAuthenticatorsTotpDeleteMutationError = ReauthenticationRequiredResponse +export type AllauthAppV1AccountAuthenticatorsTotpDeleteMutationError = ReauthenticationRequiredResponse - /** +/** * @summary Deactivate TOTP */ -export const useAllauthAppV1AccountAuthenticatorsTotpDelete = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AccountAuthenticatorsTotpDeleteMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AccountAuthenticatorsTotpDelete = < + TError = ReauthenticationRequiredResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AccountAuthenticatorsTotpDeleteMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * List recovery codes. * @summary List recovery codes @@ -6126,81 +6752,94 @@ export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse404 = { data: NotFoundResponse status: 404 } - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseComposite = allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse200 | allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse401 | allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse404; - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse = allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetUrl = () => { +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseComposite = + | allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse200 + | allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse401 + | allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse404 - +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponse = + allauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetUrl = () => { return `/api/v2/allauth/browser/v1/account/authenticators/recovery-codes` } -export const allauthBrowserV1AccountAuthenticatorsRecoveryCodesGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetUrl(), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','account','authenticators','recovery-codes'] as const; - } - - -export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryOptions = >, TError = ReauthenticationRequiredResponse | NotFoundResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryKey(); - - - - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AccountAuthenticatorsRecoveryCodesGet({ signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +export const allauthBrowserV1AccountAuthenticatorsRecoveryCodesGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetUrl(), + { + ...options, + method: 'GET', + }, + ) } -export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryResult = NonNullable>> -export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryError = ReauthenticationRequiredResponse | NotFoundResponse - +export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryKey = () => { + return ['api', 'v2', 'allauth', 'browser', 'v1', 'account', 'authenticators', 'recovery-codes'] as const +} + +export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryOptions = < + TData = Awaited>, + TError = ReauthenticationRequiredResponse | NotFoundResponse, +>(options?: { + query?: UseQueryOptions< + Awaited>, + TError, + TData + > + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryKey() + + const queryFn: QueryFunction>> = ({ + signal, + }) => allauthBrowserV1AccountAuthenticatorsRecoveryCodesGet({ signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryError = + | ReauthenticationRequiredResponse + | NotFoundResponse /** * @summary List recovery codes */ -export function useAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGet>, TError = ReauthenticationRequiredResponse | NotFoundResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGet< + TData = Awaited>, + TError = ReauthenticationRequiredResponse | NotFoundResponse, +>(options?: { + query?: UseQueryOptions< + Awaited>, + TError, + TData + > + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * @summary Regenerate recovery codes */ @@ -6213,76 +6852,94 @@ export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse401 = data: ReauthenticationRequiredResponse status: 401 } - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponseComposite = allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse400 | allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse401; - -export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse = allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponseComposite & { - headers: Headers; -} - -export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostUrl = () => { +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponseComposite = + | allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse400 + | allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse401 - +export type allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponse = + allauthBrowserV1AccountAuthenticatorsRecoveryCodesPostResponseComposite & { + headers: Headers + } +export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostUrl = () => { return `/api/v2/allauth/browser/v1/account/authenticators/recovery-codes` } -export const allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostUrl(), - { - ...options, - method: 'POST' - - +export const allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostUrl(), + { + ...options, + method: 'POST', + }, + ) +} + +export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationOptions = < + TError = ErrorResponse | ReauthenticationRequiredResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ['allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + void + > = () => { + return allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost(requestOptions) } -);} - - - - -export const getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return allauthBrowserV1AccountAuthenticatorsRecoveryCodesPost(requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} +export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationResult = NonNullable< + Awaited> +> - export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationResult = NonNullable>> - - export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationError = ErrorResponse | ReauthenticationRequiredResponse +export type AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationError = + | ErrorResponse + | ReauthenticationRequiredResponse - /** +/** * @summary Regenerate recovery codes */ -export const useAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPost = < + TError = ErrorResponse | ReauthenticationRequiredResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * List recovery codes. * @summary List recovery codes @@ -6301,81 +6958,86 @@ export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse404 = { data: NotFoundResponse status: 404 } - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseComposite = allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse200 | allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse401 | allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse404; - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse = allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseComposite & { - headers: Headers; -} - -export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetUrl = () => { +export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseComposite = + | allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse200 + | allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse401 + | allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse404 - +export type allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponse = + allauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseComposite & { + headers: Headers + } +export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetUrl = () => { return `/api/v2/allauth/app/v1/account/authenticators/recovery-codes` } -export const allauthAppV1AccountAuthenticatorsRecoveryCodesGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetUrl(), - { - ...options, - method: 'GET' - - - } -);} - - +export const allauthAppV1AccountAuthenticatorsRecoveryCodesGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetUrl(), + { + ...options, + method: 'GET', + }, + ) +} export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryKey = () => { - return ['api','v2','allauth','app','v1','account','authenticators','recovery-codes'] as const; - } - - -export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryOptions = >, TError = ReauthenticationRequiredResponse | NotFoundResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'account', 'authenticators', 'recovery-codes'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AccountAuthenticatorsRecoveryCodesGet({ signal, ...requestOptions }); +export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryOptions = < + TData = Awaited>, + TError = ReauthenticationRequiredResponse | NotFoundResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryKey() - + const queryFn: QueryFunction>> = ({ + signal, + }) => allauthAppV1AccountAuthenticatorsRecoveryCodesGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryResult = NonNullable>> -export type AllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryError = ReauthenticationRequiredResponse | NotFoundResponse - +export type AllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryResult = NonNullable< + Awaited> +> +export type AllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryError = + | ReauthenticationRequiredResponse + | NotFoundResponse /** * @summary List recovery codes */ -export function useAllauthAppV1AccountAuthenticatorsRecoveryCodesGet>, TError = ReauthenticationRequiredResponse | NotFoundResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AccountAuthenticatorsRecoveryCodesGet< + TData = Awaited>, + TError = ReauthenticationRequiredResponse | NotFoundResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AccountAuthenticatorsRecoveryCodesGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * @summary Regenerate recovery codes */ @@ -6388,76 +7050,94 @@ export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse401 = { data: ReauthenticationRequiredResponse status: 401 } - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponseComposite = allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse400 | allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse401; - -export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse = allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponseComposite & { - headers: Headers; -} - -export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostUrl = () => { +export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponseComposite = + | allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse400 + | allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse401 - +export type allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponse = + allauthAppV1AccountAuthenticatorsRecoveryCodesPostResponseComposite & { + headers: Headers + } +export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostUrl = () => { return `/api/v2/allauth/app/v1/account/authenticators/recovery-codes` } -export const allauthAppV1AccountAuthenticatorsRecoveryCodesPost = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostUrl(), - { - ...options, - method: 'POST' - - +export const allauthAppV1AccountAuthenticatorsRecoveryCodesPost = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostUrl(), + { + ...options, + method: 'POST', + }, + ) +} + +export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationOptions = < + TError = ErrorResponse | ReauthenticationRequiredResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ['allauthAppV1AccountAuthenticatorsRecoveryCodesPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + void + > = () => { + return allauthAppV1AccountAuthenticatorsRecoveryCodesPost(requestOptions) } -);} - - - - -export const getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['allauthAppV1AccountAuthenticatorsRecoveryCodesPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return allauthAppV1AccountAuthenticatorsRecoveryCodesPost(requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} +export type AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationResult = NonNullable< + Awaited> +> - export type AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationResult = NonNullable>> - - export type AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationError = ErrorResponse | ReauthenticationRequiredResponse +export type AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationError = + | ErrorResponse + | ReauthenticationRequiredResponse - /** +/** * @summary Regenerate recovery codes */ -export const useAllauthAppV1AccountAuthenticatorsRecoveryCodesPost = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AccountAuthenticatorsRecoveryCodesPost = < + TError = ErrorResponse | ReauthenticationRequiredResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AccountAuthenticatorsRecoveryCodesPostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Retrieve information about the authentication status for the current session. @@ -6478,82 +7158,80 @@ export type allauthBrowserV1AuthSessionGetResponse410 = { data: SessionGoneResponse status: 410 } - -export type allauthBrowserV1AuthSessionGetResponseComposite = allauthBrowserV1AuthSessionGetResponse200 | allauthBrowserV1AuthSessionGetResponse401 | allauthBrowserV1AuthSessionGetResponse410; - + +export type allauthBrowserV1AuthSessionGetResponseComposite = + | allauthBrowserV1AuthSessionGetResponse200 + | allauthBrowserV1AuthSessionGetResponse401 + | allauthBrowserV1AuthSessionGetResponse410 + export type allauthBrowserV1AuthSessionGetResponse = allauthBrowserV1AuthSessionGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthSessionGetUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/session` } -export const allauthBrowserV1AuthSessionGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthSessionGetUrl(), - { +export const allauthBrowserV1AuthSessionGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthSessionGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthBrowserV1AuthSessionGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','auth','session'] as const; - } - - -export const getAllauthBrowserV1AuthSessionGetQueryOptions = >, TError = AuthenticationResponse | SessionGoneResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthSessionGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'auth', 'session'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AuthSessionGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1AuthSessionGetQueryOptions = < + TData = Awaited>, + TError = AuthenticationResponse | SessionGoneResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthSessionGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthBrowserV1AuthSessionGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthBrowserV1AuthSessionGetQueryResult = NonNullable>> +export type AllauthBrowserV1AuthSessionGetQueryResult = NonNullable< + Awaited> +> export type AllauthBrowserV1AuthSessionGetQueryError = AuthenticationResponse | SessionGoneResponse - /** * @summary Get authentication status */ -export function useAllauthBrowserV1AuthSessionGet>, TError = AuthenticationResponse | SessionGoneResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AuthSessionGet< + TData = Awaited>, + TError = AuthenticationResponse | SessionGoneResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AuthSessionGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Logs out the user from the current session. @@ -6563,76 +7241,65 @@ export type allauthBrowserV1AuthSessionDeleteResponse401 = { data: UnauthenticatedResponse status: 401 } - -export type allauthBrowserV1AuthSessionDeleteResponseComposite = allauthBrowserV1AuthSessionDeleteResponse401; - + +export type allauthBrowserV1AuthSessionDeleteResponseComposite = allauthBrowserV1AuthSessionDeleteResponse401 + export type allauthBrowserV1AuthSessionDeleteResponse = allauthBrowserV1AuthSessionDeleteResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthSessionDeleteUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/session` } -export const allauthBrowserV1AuthSessionDelete = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthSessionDeleteUrl(), - { +export const allauthBrowserV1AuthSessionDelete = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthSessionDeleteUrl(), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getAllauthBrowserV1AuthSessionDeleteMutationOptions = < + TError = UnauthenticatedResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['allauthBrowserV1AuthSessionDelete'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return allauthBrowserV1AuthSessionDelete(requestOptions) } -);} - - - - -export const getAllauthBrowserV1AuthSessionDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthSessionDelete']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return allauthBrowserV1AuthSessionDelete(requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} +export type AllauthBrowserV1AuthSessionDeleteMutationResult = NonNullable< + Awaited> +> - export type AllauthBrowserV1AuthSessionDeleteMutationResult = NonNullable>> - - export type AllauthBrowserV1AuthSessionDeleteMutationError = UnauthenticatedResponse +export type AllauthBrowserV1AuthSessionDeleteMutationError = UnauthenticatedResponse - /** +/** * @summary Logout */ -export const useAllauthBrowserV1AuthSessionDelete = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { +export const useAllauthBrowserV1AuthSessionDelete = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthSessionDeleteMutationOptions(options) - const mutationOptions = getAllauthBrowserV1AuthSessionDeleteMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Retrieve information about the authentication status for the current session. @@ -6653,82 +7320,78 @@ export type allauthAppV1AuthSessionGetResponse410 = { data: SessionGoneResponse status: 410 } - -export type allauthAppV1AuthSessionGetResponseComposite = allauthAppV1AuthSessionGetResponse200 | allauthAppV1AuthSessionGetResponse401 | allauthAppV1AuthSessionGetResponse410; - + +export type allauthAppV1AuthSessionGetResponseComposite = + | allauthAppV1AuthSessionGetResponse200 + | allauthAppV1AuthSessionGetResponse401 + | allauthAppV1AuthSessionGetResponse410 + export type allauthAppV1AuthSessionGetResponse = allauthAppV1AuthSessionGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthSessionGetUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/session` } -export const allauthAppV1AuthSessionGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthSessionGetUrl(), - { +export const allauthAppV1AuthSessionGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthSessionGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthAppV1AuthSessionGetQueryKey = () => { - return ['api','v2','allauth','app','v1','auth','session'] as const; - } - - -export const getAllauthAppV1AuthSessionGetQueryOptions = >, TError = AuthenticationResponse | SessionGoneResponse>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthSessionGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'auth', 'session'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AuthSessionGet({ signal, ...requestOptions }); +export const getAllauthAppV1AuthSessionGetQueryOptions = < + TData = Awaited>, + TError = AuthenticationResponse | SessionGoneResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthSessionGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1AuthSessionGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AllauthAppV1AuthSessionGetQueryResult = NonNullable>> export type AllauthAppV1AuthSessionGetQueryError = AuthenticationResponse | SessionGoneResponse - /** * @summary Get authentication status */ -export function useAllauthAppV1AuthSessionGet>, TError = AuthenticationResponse | SessionGoneResponse>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AuthSessionGet< + TData = Awaited>, + TError = AuthenticationResponse | SessionGoneResponse, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AuthSessionGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Logs out the user from the current session. @@ -6738,76 +7401,65 @@ export type allauthAppV1AuthSessionDeleteResponse401 = { data: UnauthenticatedResponse status: 401 } - -export type allauthAppV1AuthSessionDeleteResponseComposite = allauthAppV1AuthSessionDeleteResponse401; - + +export type allauthAppV1AuthSessionDeleteResponseComposite = allauthAppV1AuthSessionDeleteResponse401 + export type allauthAppV1AuthSessionDeleteResponse = allauthAppV1AuthSessionDeleteResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthSessionDeleteUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/session` } -export const allauthAppV1AuthSessionDelete = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthSessionDeleteUrl(), - { +export const allauthAppV1AuthSessionDelete = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthSessionDeleteUrl(), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getAllauthAppV1AuthSessionDeleteMutationOptions = < + TError = UnauthenticatedResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['allauthAppV1AuthSessionDelete'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return allauthAppV1AuthSessionDelete(requestOptions) } -);} - - - - -export const getAllauthAppV1AuthSessionDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['allauthAppV1AuthSessionDelete']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return allauthAppV1AuthSessionDelete(requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} +export type AllauthAppV1AuthSessionDeleteMutationResult = NonNullable< + Awaited> +> - export type AllauthAppV1AuthSessionDeleteMutationResult = NonNullable>> - - export type AllauthAppV1AuthSessionDeleteMutationError = UnauthenticatedResponse +export type AllauthAppV1AuthSessionDeleteMutationError = UnauthenticatedResponse - /** +/** * @summary Logout */ -export const useAllauthAppV1AuthSessionDelete = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { +export const useAllauthAppV1AuthSessionDelete = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthSessionDeleteMutationOptions(options) - const mutationOptions = getAllauthAppV1AuthSessionDeleteMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Used to retrieve a new access token. Depending on `settings.HEADLESS_JWT_ROTATE_REFRESH_TOKEN`, a new refresh token is returned as well. @@ -6823,78 +7475,88 @@ export type allauthAppV1TokensRefreshPostResponse400 = { data: ErrorResponse status: 400 } - -export type allauthAppV1TokensRefreshPostResponseComposite = allauthAppV1TokensRefreshPostResponse200 | allauthAppV1TokensRefreshPostResponse400; - + +export type allauthAppV1TokensRefreshPostResponseComposite = + | allauthAppV1TokensRefreshPostResponse200 + | allauthAppV1TokensRefreshPostResponse400 + export type allauthAppV1TokensRefreshPostResponse = allauthAppV1TokensRefreshPostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1TokensRefreshPostUrl = () => { - - - - return `/api/v2/allauth/app/v1/tokens/refresh` } -export const allauthAppV1TokensRefreshPost = async (refreshTokenBody: RefreshTokenBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1TokensRefreshPostUrl(), - { +export const allauthAppV1TokensRefreshPost = async ( + refreshTokenBody: RefreshTokenBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1TokensRefreshPostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - refreshTokenBody,) + body: JSON.stringify(refreshTokenBody), + }) +} + +export const getAllauthAppV1TokensRefreshPostMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: RefreshTokenBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: RefreshTokenBody }, + TContext +> => { + const mutationKey = ['allauthAppV1TokensRefreshPost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: RefreshTokenBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1TokensRefreshPost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1TokensRefreshPostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: RefreshTokenBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: RefreshTokenBody}, TContext> => { - -const mutationKey = ['allauthAppV1TokensRefreshPost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: RefreshTokenBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1TokensRefreshPost(data,requestOptions) - } - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthAppV1TokensRefreshPostMutationResult = NonNullable>> - export type AllauthAppV1TokensRefreshPostMutationBody = RefreshTokenBody - export type AllauthAppV1TokensRefreshPostMutationError = ErrorResponse +export type AllauthAppV1TokensRefreshPostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1TokensRefreshPostMutationBody = RefreshTokenBody +export type AllauthAppV1TokensRefreshPostMutationError = ErrorResponse - /** +/** * @summary Refresh the access token */ -export const useAllauthAppV1TokensRefreshPost = (options?: { mutation?:UseMutationOptions>, TError,{data: RefreshTokenBody}, TContext>, request?: SecondParameter} - ) => { +export const useAllauthAppV1TokensRefreshPost = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: RefreshTokenBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1TokensRefreshPostMutationOptions(options) - const mutationOptions = getAllauthAppV1TokensRefreshPostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * In order to change the password of an account, the current and new password must be provider. However, accounts that were created by signing up using a third-party provider do not have a password set. In @@ -6911,77 +7573,97 @@ export type allauthBrowserV1AccountPasswordChangePostResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthBrowserV1AccountPasswordChangePostResponseComposite = allauthBrowserV1AccountPasswordChangePostResponse400 | allauthBrowserV1AccountPasswordChangePostResponse401; - -export type allauthBrowserV1AccountPasswordChangePostResponse = allauthBrowserV1AccountPasswordChangePostResponseComposite & { - headers: Headers; -} -export const getAllauthBrowserV1AccountPasswordChangePostUrl = () => { +export type allauthBrowserV1AccountPasswordChangePostResponseComposite = + | allauthBrowserV1AccountPasswordChangePostResponse400 + | allauthBrowserV1AccountPasswordChangePostResponse401 +export type allauthBrowserV1AccountPasswordChangePostResponse = + allauthBrowserV1AccountPasswordChangePostResponseComposite & { + headers: Headers + } - - +export const getAllauthBrowserV1AccountPasswordChangePostUrl = () => { return `/api/v2/allauth/browser/v1/account/password/change` } -export const allauthBrowserV1AccountPasswordChangePost = async (changePasswordBody: ChangePasswordBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AccountPasswordChangePostUrl(), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - changePasswordBody,) +export const allauthBrowserV1AccountPasswordChangePost = async ( + changePasswordBody: ChangePasswordBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAllauthBrowserV1AccountPasswordChangePostUrl(), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(changePasswordBody), + }, + ) +} + +export const getAllauthBrowserV1AccountPasswordChangePostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ChangePasswordBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ChangePasswordBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AccountPasswordChangePost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ChangePasswordBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AccountPasswordChangePost(data, requestOptions) } -);} + return { mutationFn, ...mutationOptions } +} +export type AllauthBrowserV1AccountPasswordChangePostMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AccountPasswordChangePostMutationBody = ChangePasswordBody +export type AllauthBrowserV1AccountPasswordChangePostMutationError = ErrorResponse | AuthenticationResponse - -export const getAllauthBrowserV1AccountPasswordChangePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AccountPasswordChangePost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ChangePasswordBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AccountPasswordChangePost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AllauthBrowserV1AccountPasswordChangePostMutationResult = NonNullable>> - export type AllauthBrowserV1AccountPasswordChangePostMutationBody = ChangePasswordBody - export type AllauthBrowserV1AccountPasswordChangePostMutationError = ErrorResponse | AuthenticationResponse - - /** +/** * @summary Change password */ -export const useAllauthBrowserV1AccountPasswordChangePost = (options?: { mutation?:UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthBrowserV1AccountPasswordChangePostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthBrowserV1AccountPasswordChangePost = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ChangePasswordBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AccountPasswordChangePostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * In order to change the password of an account, the current and new password must be provider. However, accounts that were created by signing up using a third-party provider do not have a password set. In @@ -6998,158 +7680,169 @@ export type allauthAppV1AccountPasswordChangePostResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthAppV1AccountPasswordChangePostResponseComposite = allauthAppV1AccountPasswordChangePostResponse400 | allauthAppV1AccountPasswordChangePostResponse401; - + +export type allauthAppV1AccountPasswordChangePostResponseComposite = + | allauthAppV1AccountPasswordChangePostResponse400 + | allauthAppV1AccountPasswordChangePostResponse401 + export type allauthAppV1AccountPasswordChangePostResponse = allauthAppV1AccountPasswordChangePostResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AccountPasswordChangePostUrl = () => { - - - - return `/api/v2/allauth/app/v1/account/password/change` } -export const allauthAppV1AccountPasswordChangePost = async (changePasswordBody: ChangePasswordBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AccountPasswordChangePostUrl(), - { +export const allauthAppV1AccountPasswordChangePost = async ( + changePasswordBody: ChangePasswordBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AccountPasswordChangePostUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - changePasswordBody,) + body: JSON.stringify(changePasswordBody), + }) +} + +export const getAllauthAppV1AccountPasswordChangePostMutationOptions = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ChangePasswordBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ChangePasswordBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AccountPasswordChangePost'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ChangePasswordBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AccountPasswordChangePost(data, requestOptions) } -);} - - - - -export const getAllauthAppV1AccountPasswordChangePostMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext> => { -const mutationKey = ['allauthAppV1AccountPasswordChangePost']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ChangePasswordBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AccountPasswordChangePost(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthAppV1AccountPasswordChangePostMutationResult = NonNullable>> - export type AllauthAppV1AccountPasswordChangePostMutationBody = ChangePasswordBody - export type AllauthAppV1AccountPasswordChangePostMutationError = ErrorResponse | AuthenticationResponse +export type AllauthAppV1AccountPasswordChangePostMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AccountPasswordChangePostMutationBody = ChangePasswordBody +export type AllauthAppV1AccountPasswordChangePostMutationError = ErrorResponse | AuthenticationResponse - /** +/** * @summary Change password */ -export const useAllauthAppV1AccountPasswordChangePost = (options?: { mutation?:UseMutationOptions>, TError,{data: ChangePasswordBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AccountPasswordChangePostMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export const useAllauthAppV1AccountPasswordChangePost = < + TError = ErrorResponse | AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ChangePasswordBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AccountPasswordChangePostMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * @summary List sessions */ export type allauthBrowserV1AuthSessionsGetResponse200 = { data: SessionsResponse status: 200 } - -export type allauthBrowserV1AuthSessionsGetResponseComposite = allauthBrowserV1AuthSessionsGetResponse200; - + +export type allauthBrowserV1AuthSessionsGetResponseComposite = allauthBrowserV1AuthSessionsGetResponse200 + export type allauthBrowserV1AuthSessionsGetResponse = allauthBrowserV1AuthSessionsGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthSessionsGetUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/sessions` } -export const allauthBrowserV1AuthSessionsGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthSessionsGetUrl(), - { +export const allauthBrowserV1AuthSessionsGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthSessionsGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthBrowserV1AuthSessionsGetQueryKey = () => { - return ['api','v2','allauth','browser','v1','auth','sessions'] as const; - } - - -export const getAllauthBrowserV1AuthSessionsGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthSessionsGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'browser', 'v1', 'auth', 'sessions'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthBrowserV1AuthSessionsGet({ signal, ...requestOptions }); +export const getAllauthBrowserV1AuthSessionsGetQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthBrowserV1AuthSessionsGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthBrowserV1AuthSessionsGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthBrowserV1AuthSessionsGetQueryResult = NonNullable>> +export type AllauthBrowserV1AuthSessionsGetQueryResult = NonNullable< + Awaited> +> export type AllauthBrowserV1AuthSessionsGetQueryError = unknown - /** * @summary List sessions */ -export function useAllauthBrowserV1AuthSessionsGet>, TError = unknown>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthBrowserV1AuthSessionsGet< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthBrowserV1AuthSessionsGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * @summary End one or more sessions */ @@ -7162,158 +7855,166 @@ export type allauthBrowserV1AuthSessionsDeleteResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthBrowserV1AuthSessionsDeleteResponseComposite = allauthBrowserV1AuthSessionsDeleteResponse200 | allauthBrowserV1AuthSessionsDeleteResponse401; - + +export type allauthBrowserV1AuthSessionsDeleteResponseComposite = + | allauthBrowserV1AuthSessionsDeleteResponse200 + | allauthBrowserV1AuthSessionsDeleteResponse401 + export type allauthBrowserV1AuthSessionsDeleteResponse = allauthBrowserV1AuthSessionsDeleteResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthBrowserV1AuthSessionsDeleteUrl = () => { - - - - return `/api/v2/allauth/browser/v1/auth/sessions` } -export const allauthBrowserV1AuthSessionsDelete = async (endSessionsBody: EndSessionsBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthBrowserV1AuthSessionsDeleteUrl(), - { +export const allauthBrowserV1AuthSessionsDelete = async ( + endSessionsBody: EndSessionsBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthBrowserV1AuthSessionsDeleteUrl(), { ...options, method: 'DELETE', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - endSessionsBody,) + body: JSON.stringify(endSessionsBody), + }) +} + +export const getAllauthBrowserV1AuthSessionsDeleteMutationOptions = < + TError = AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EndSessionsBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: EndSessionsBody }, + TContext +> => { + const mutationKey = ['allauthBrowserV1AuthSessionsDelete'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: EndSessionsBody } + > = (props) => { + const { data } = props ?? {} + + return allauthBrowserV1AuthSessionsDelete(data, requestOptions) } -);} - - - -export const getAllauthBrowserV1AuthSessionsDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EndSessionsBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: EndSessionsBody}, TContext> => { - -const mutationKey = ['allauthBrowserV1AuthSessionsDelete']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: EndSessionsBody}> = (props) => { - const {data} = props ?? {}; - - return allauthBrowserV1AuthSessionsDelete(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthBrowserV1AuthSessionsDeleteMutationResult = NonNullable>> - export type AllauthBrowserV1AuthSessionsDeleteMutationBody = EndSessionsBody - export type AllauthBrowserV1AuthSessionsDeleteMutationError = AuthenticationResponse +export type AllauthBrowserV1AuthSessionsDeleteMutationResult = NonNullable< + Awaited> +> +export type AllauthBrowserV1AuthSessionsDeleteMutationBody = EndSessionsBody +export type AllauthBrowserV1AuthSessionsDeleteMutationError = AuthenticationResponse - /** +/** * @summary End one or more sessions */ -export const useAllauthBrowserV1AuthSessionsDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: EndSessionsBody}, TContext>, request?: SecondParameter} - ) => { +export const useAllauthBrowserV1AuthSessionsDelete = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EndSessionsBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthBrowserV1AuthSessionsDeleteMutationOptions(options) - const mutationOptions = getAllauthBrowserV1AuthSessionsDeleteMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * @summary List sessions */ export type allauthAppV1AuthSessionsGetResponse200 = { data: SessionsResponse status: 200 } - -export type allauthAppV1AuthSessionsGetResponseComposite = allauthAppV1AuthSessionsGetResponse200; - + +export type allauthAppV1AuthSessionsGetResponseComposite = allauthAppV1AuthSessionsGetResponse200 + export type allauthAppV1AuthSessionsGetResponse = allauthAppV1AuthSessionsGetResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthSessionsGetUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/sessions` } -export const allauthAppV1AuthSessionsGet = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthSessionsGetUrl(), - { +export const allauthAppV1AuthSessionsGet = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthSessionsGetUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAllauthAppV1AuthSessionsGetQueryKey = () => { - return ['api','v2','allauth','app','v1','auth','sessions'] as const; - } - - -export const getAllauthAppV1AuthSessionsGetQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthSessionsGetQueryKey(); - - + return ['api', 'v2', 'allauth', 'app', 'v1', 'auth', 'sessions'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => allauthAppV1AuthSessionsGet({ signal, ...requestOptions }); +export const getAllauthAppV1AuthSessionsGetQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAllauthAppV1AuthSessionsGetQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + allauthAppV1AuthSessionsGet({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AllauthAppV1AuthSessionsGetQueryResult = NonNullable>> +export type AllauthAppV1AuthSessionsGetQueryResult = NonNullable< + Awaited> +> export type AllauthAppV1AuthSessionsGetQueryError = unknown - /** * @summary List sessions */ -export function useAllauthAppV1AuthSessionsGet>, TError = unknown>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAllauthAppV1AuthSessionsGet< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAllauthAppV1AuthSessionsGetQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * @summary End one or more sessions */ @@ -7326,74 +8027,86 @@ export type allauthAppV1AuthSessionsDeleteResponse401 = { data: AuthenticationResponse status: 401 } - -export type allauthAppV1AuthSessionsDeleteResponseComposite = allauthAppV1AuthSessionsDeleteResponse200 | allauthAppV1AuthSessionsDeleteResponse401; - + +export type allauthAppV1AuthSessionsDeleteResponseComposite = + | allauthAppV1AuthSessionsDeleteResponse200 + | allauthAppV1AuthSessionsDeleteResponse401 + export type allauthAppV1AuthSessionsDeleteResponse = allauthAppV1AuthSessionsDeleteResponseComposite & { - headers: Headers; + headers: Headers } export const getAllauthAppV1AuthSessionsDeleteUrl = () => { - - - - return `/api/v2/allauth/app/v1/auth/sessions` } -export const allauthAppV1AuthSessionsDelete = async (endSessionsBody: EndSessionsBody, options?: RequestInit): Promise => { - - return fetchWithAuth(getAllauthAppV1AuthSessionsDeleteUrl(), - { +export const allauthAppV1AuthSessionsDelete = async ( + endSessionsBody: EndSessionsBody, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAllauthAppV1AuthSessionsDeleteUrl(), { ...options, method: 'DELETE', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - endSessionsBody,) + body: JSON.stringify(endSessionsBody), + }) +} + +export const getAllauthAppV1AuthSessionsDeleteMutationOptions = < + TError = AuthenticationResponse, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EndSessionsBody }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: EndSessionsBody }, + TContext +> => { + const mutationKey = ['allauthAppV1AuthSessionsDelete'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: EndSessionsBody } + > = (props) => { + const { data } = props ?? {} + + return allauthAppV1AuthSessionsDelete(data, requestOptions) } -);} - - - -export const getAllauthAppV1AuthSessionsDeleteMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EndSessionsBody}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: EndSessionsBody}, TContext> => { - -const mutationKey = ['allauthAppV1AuthSessionsDelete']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: EndSessionsBody}> = (props) => { - const {data} = props ?? {}; - - return allauthAppV1AuthSessionsDelete(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AllauthAppV1AuthSessionsDeleteMutationResult = NonNullable>> - export type AllauthAppV1AuthSessionsDeleteMutationBody = EndSessionsBody - export type AllauthAppV1AuthSessionsDeleteMutationError = AuthenticationResponse +export type AllauthAppV1AuthSessionsDeleteMutationResult = NonNullable< + Awaited> +> +export type AllauthAppV1AuthSessionsDeleteMutationBody = EndSessionsBody +export type AllauthAppV1AuthSessionsDeleteMutationError = AuthenticationResponse - /** +/** * @summary End one or more sessions */ -export const useAllauthAppV1AuthSessionsDelete = (options?: { mutation?:UseMutationOptions>, TError,{data: EndSessionsBody}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAllauthAppV1AuthSessionsDeleteMutationOptions(options); +export const useAllauthAppV1AuthSessionsDelete = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EndSessionsBody }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAllauthAppV1AuthSessionsDeleteMutationOptions(options) - return useMutation(mutationOptions ); - } - \ No newline at end of file + return useMutation(mutationOptions) +} diff --git a/jsapp/js/api/react-query/authentication-allauth-headless/msw.ts b/jsapp/js/api/react-query/authentication-allauth-headless/msw.ts index aa7dc99c11..1360bd115d 100644 --- a/jsapp/js/api/react-query/authentication-allauth-headless/msw.ts +++ b/jsapp/js/api/react-query/authentication-allauth-headless/msw.ts @@ -9,1027 +9,4038 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; - -import type { - AuthenticatedByCodeResponse -} from '../../models/authenticatedByCodeResponse'; - -import type { - AuthenticatedByPasswordAnd2FAResponse -} from '../../models/authenticatedByPasswordAnd2FAResponse'; - -import type { - AuthenticatedByPasswordResponse -} from '../../models/authenticatedByPasswordResponse'; - -import type { - AuthenticatedResponse -} from '../../models/authenticatedResponse'; - -import { - AuthenticatorType -} from '../../models/authenticatorType'; - -import type { - AuthenticatorsResponse -} from '../../models/authenticatorsResponse'; - -import type { - ConfigurationResponse -} from '../../models/configurationResponse'; - -import type { - EmailAddressesResponse -} from '../../models/emailAddressesResponse'; - -import type { - EmailVerificationInfoResponse -} from '../../models/emailVerificationInfoResponse'; - -import type { - PasswordResetInfoResponse -} from '../../models/passwordResetInfoResponse'; - -import type { - PhoneNumberChangeResponse -} from '../../models/phoneNumberChangeResponse'; - -import type { - PhoneNumbersResponse -} from '../../models/phoneNumbersResponse'; - -import type { - ProviderAccountsResponse -} from '../../models/providerAccountsResponse'; - -import type { - ProviderSignupResponse -} from '../../models/providerSignupResponse'; - -import type { - RecoveryCodesAuthenticator -} from '../../models/recoveryCodesAuthenticator'; - -import type { - RecoveryCodesResponse -} from '../../models/recoveryCodesResponse'; - -import type { - RefreshTokenResponse -} from '../../models/refreshTokenResponse'; - -import type { - SessionsResponse -} from '../../models/sessionsResponse'; - -import type { - StatusOKResponse -} from '../../models/statusOKResponse'; - -import type { - TOTPAuthenticator -} from '../../models/tOTPAuthenticator'; - -import type { - TOTPAuthenticatorResponse -} from '../../models/tOTPAuthenticatorResponse'; - -import type { - WebAuthnAuthenticator -} from '../../models/webAuthnAuthenticator'; - - -export const getApiV2AllauthBrowserV1ConfigGetResponseMock = (overrideResponse: Partial< ConfigurationResponse > = {}): ConfigurationResponse => ({data: {account: {login_methods: faker.helpers.arrayElement([faker.helpers.arrayElements(['email','username'] as const), undefined]), is_open_for_signup: faker.datatype.boolean(), email_verification_by_code_enabled: faker.datatype.boolean(), login_by_code_enabled: faker.datatype.boolean(), password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, socialaccount: faker.helpers.arrayElement([{providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}))}, undefined]), mfa: faker.helpers.arrayElement([{supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType))}, undefined]), usersessions: faker.helpers.arrayElement([{track_activity: faker.datatype.boolean()}, undefined])}, status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthAppV1ConfigGetResponseMock = (overrideResponse: Partial< ConfigurationResponse > = {}): ConfigurationResponse => ({data: {account: {login_methods: faker.helpers.arrayElement([faker.helpers.arrayElements(['email','username'] as const), undefined]), is_open_for_signup: faker.datatype.boolean(), email_verification_by_code_enabled: faker.datatype.boolean(), login_by_code_enabled: faker.datatype.boolean(), password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, socialaccount: faker.helpers.arrayElement([{providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}))}, undefined]), mfa: faker.helpers.arrayElement([{supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType))}, undefined]), usersessions: faker.helpers.arrayElement([{track_activity: faker.datatype.boolean()}, undefined])}, status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthLoginPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthLoginPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthSignupPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthSignupPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock = (overrideResponse: Partial< EmailVerificationInfoResponse > = {}): EmailVerificationInfoResponse => ({status: faker.helpers.arrayElement([200] as const), data: {email: faker.string.alpha({length: {min: 10, max: 20}}), user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}}, meta: {is_authenticating: faker.datatype.boolean()}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock = (overrideResponse: Partial< EmailVerificationInfoResponse > = {}): EmailVerificationInfoResponse => ({status: faker.helpers.arrayElement([200] as const), data: {email: faker.string.alpha({length: {min: 10, max: 20}}), user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}}, meta: {is_authenticating: faker.datatype.boolean()}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthReauthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock = (overrideResponse: Partial< PasswordResetInfoResponse > = {}): PasswordResetInfoResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: faker.helpers.arrayElement([{id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, undefined])}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthPasswordResetGetResponseMock = (overrideResponse: Partial< PasswordResetInfoResponse > = {}): PasswordResetInfoResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: faker.helpers.arrayElement([{id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, undefined])}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthPasswordResetPostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordResponse > = {}): AuthenticatedByPasswordResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthProviderTokenPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock = (overrideResponse: Partial< ProviderSignupResponse > = {}): ProviderSignupResponse => ({status: faker.helpers.arrayElement([200] as const), data: {email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), account: {uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}}, user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthProviderSignupGetResponseMock = (overrideResponse: Partial< ProviderSignupResponse > = {}): ProviderSignupResponse => ({status: faker.helpers.arrayElement([200] as const), data: {email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), account: {uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}}, user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthProviderSignupPostResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordAnd2FAResponse > = {}): AuthenticatedByPasswordAnd2FAResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordAnd2FAResponse > = {}): AuthenticatedByPasswordAnd2FAResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordAnd2FAResponse > = {}): AuthenticatedByPasswordAnd2FAResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock = (overrideResponse: Partial< AuthenticatedByPasswordAnd2FAResponse > = {}): AuthenticatedByPasswordAnd2FAResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock = (overrideResponse: Partial< AuthenticatedByCodeResponse > = {}): AuthenticatedByCodeResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock = (overrideResponse: Partial< AuthenticatedByCodeResponse > = {}): AuthenticatedByCodeResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountProvidersGetResponseMock = (overrideResponse: Partial< ProviderAccountsResponse > = {}): ProviderAccountsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}})), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock = (overrideResponse: Partial< ProviderAccountsResponse > = {}): ProviderAccountsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}})), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountProvidersGetResponseMock = (overrideResponse: Partial< ProviderAccountsResponse > = {}): ProviderAccountsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}})), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountProvidersDeleteResponseMock = (overrideResponse: Partial< ProviderAccountsResponse > = {}): ProviderAccountsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), display: faker.string.alpha({length: {min: 10, max: 20}}), provider: {id: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), openid_configuration_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), flows: faker.helpers.arrayElements(['provider_redirect','provider_token'] as const)}})), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountEmailGetResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountEmailPostResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountEmailPutResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountEmailPatchResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountEmailGetResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountEmailPostResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountEmailPutResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountEmailPatchResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountEmailDeleteResponseMock = (overrideResponse: Partial< EmailAddressesResponse > = {}): EmailAddressesResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountPhoneGetResponseMock = (overrideResponse: Partial< PhoneNumbersResponse > = {}): PhoneNumbersResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({phone: faker.string.alpha({length: {min: 10, max: 20}}), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountPhonePostResponseMock = (overrideResponse: Partial< PhoneNumberChangeResponse > = {}): PhoneNumberChangeResponse => ({status: faker.helpers.arrayElement([202] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({phone: faker.string.alpha({length: {min: 10, max: 20}}), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountPhoneGetResponseMock = (overrideResponse: Partial< PhoneNumbersResponse > = {}): PhoneNumbersResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({phone: faker.string.alpha({length: {min: 10, max: 20}}), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountPhonePostResponseMock = (overrideResponse: Partial< PhoneNumberChangeResponse > = {}): PhoneNumberChangeResponse => ({status: faker.helpers.arrayElement([202] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({phone: faker.string.alpha({length: {min: 10, max: 20}}), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = (overrideResponse: Partial = {}): TOTPAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}); - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = (overrideResponse: Partial = {}): RecoveryCodesAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['recovery_codes'] as const), total_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), unused_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},}, ...overrideResponse}); - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = (overrideResponse: Partial = {}): WebAuthnAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['webauthn'] as const), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), name: faker.string.alpha({length: {min: 10, max: 20}}), is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},}, ...overrideResponse}); - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock = (overrideResponse: Partial< AuthenticatorsResponse > = {}): AuthenticatorsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock()},{...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock()},{...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock()},]))), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = (overrideResponse: Partial = {}): TOTPAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}); - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = (overrideResponse: Partial = {}): RecoveryCodesAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['recovery_codes'] as const), total_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), unused_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},}, ...overrideResponse}); - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = (overrideResponse: Partial = {}): WebAuthnAuthenticator => ({...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['webauthn'] as const), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), name: faker.string.alpha({length: {min: 10, max: 20}}), is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},}, ...overrideResponse}); - -export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock = (overrideResponse: Partial< AuthenticatorsResponse > = {}): AuthenticatorsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock()},{...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock()},{...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock()},]))), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock = (overrideResponse: Partial< TOTPAuthenticatorResponse > = {}): TOTPAuthenticatorResponse => ({status: faker.helpers.arrayElement([200] as const), meta: faker.helpers.arrayElement([{recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), data: {...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock = (overrideResponse: Partial< TOTPAuthenticatorResponse > = {}): TOTPAuthenticatorResponse => ({status: faker.helpers.arrayElement([200] as const), meta: faker.helpers.arrayElement([{recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), data: {...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock = (overrideResponse: Partial< TOTPAuthenticatorResponse > = {}): TOTPAuthenticatorResponse => ({status: faker.helpers.arrayElement([200] as const), meta: faker.helpers.arrayElement([{recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), data: {...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock = (overrideResponse: Partial< TOTPAuthenticatorResponse > = {}): TOTPAuthenticatorResponse => ({status: faker.helpers.arrayElement([200] as const), meta: faker.helpers.arrayElement([{recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), data: {...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['totp'] as const)},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock = (overrideResponse: Partial< StatusOKResponse > = {}): StatusOKResponse => ({status: faker.helpers.arrayElement([200] as const), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock = (overrideResponse: Partial< RecoveryCodesResponse > = {}): RecoveryCodesResponse => ({status: faker.helpers.arrayElement([200] as const), data: {...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['recovery_codes'] as const), total_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), unused_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},},...{unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}})))},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock = (overrideResponse: Partial< RecoveryCodesResponse > = {}): RecoveryCodesResponse => ({status: faker.helpers.arrayElement([200] as const), data: {...{...{last_used_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2})},...{type: faker.helpers.arrayElement(['recovery_codes'] as const), total_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), unused_code_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},},...{unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}})))},}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthSessionGetResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthSessionGetResponseMock = (overrideResponse: Partial< AuthenticatedResponse > = {}): AuthenticatedResponse => ({status: faker.helpers.arrayElement([200] as const), data: {user: {id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), display: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), has_usable_password: faker.datatype.boolean(), username: faker.string.alpha({length: {min: 10, max: 20}})}, methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},{method: faker.helpers.arrayElement(['password_reset'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), email: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['code'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), phone: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['password'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), reauthenticated: faker.datatype.boolean()},{method: faker.helpers.arrayElement(['socialaccount'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), provider: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}})},{method: faker.helpers.arrayElement(['mfa'] as const), at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])},])))}, meta: {...{session_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), access_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},...{is_authenticated: faker.datatype.boolean()},}, ...overrideResponse}) - -export const getApiV2AllauthAppV1TokensRefreshPostResponseMock = (overrideResponse: Partial< RefreshTokenResponse > = {}): RefreshTokenResponse => ({status: faker.helpers.arrayElement([200] as const), data: {access_token: faker.string.alpha({length: {min: 10, max: 20}}), refresh_token: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthSessionsGetResponseMock = (overrideResponse: Partial< SessionsResponse > = {}): SessionsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user_agent: faker.string.alpha({length: {min: 10, max: 20}}), ip: faker.string.alpha({length: {min: 10, max: 20}}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), is_current: faker.datatype.boolean(), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), last_seen_at: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined])})), ...overrideResponse}) - -export const getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock = (overrideResponse: Partial< SessionsResponse > = {}): SessionsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user_agent: faker.string.alpha({length: {min: 10, max: 20}}), ip: faker.string.alpha({length: {min: 10, max: 20}}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), is_current: faker.datatype.boolean(), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), last_seen_at: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined])})), ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthSessionsGetResponseMock = (overrideResponse: Partial< SessionsResponse > = {}): SessionsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user_agent: faker.string.alpha({length: {min: 10, max: 20}}), ip: faker.string.alpha({length: {min: 10, max: 20}}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), is_current: faker.datatype.boolean(), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), last_seen_at: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined])})), ...overrideResponse}) - -export const getApiV2AllauthAppV1AuthSessionsDeleteResponseMock = (overrideResponse: Partial< SessionsResponse > = {}): SessionsResponse => ({status: faker.helpers.arrayElement([200] as const), data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user_agent: faker.string.alpha({length: {min: 10, max: 20}}), ip: faker.string.alpha({length: {min: 10, max: 20}}), created_at: faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), is_current: faker.datatype.boolean(), id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), last_seen_at: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined])})), ...overrideResponse}) - - -export const getApiV2AllauthBrowserV1ConfigGetMockHandler = (overrideResponse?: ConfigurationResponse | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/config', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1ConfigGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +import { http, HttpResponse } from 'msw' + +import type { AuthenticatedByCodeResponse } from '../../models/authenticatedByCodeResponse' + +import type { AuthenticatedByPasswordAnd2FAResponse } from '../../models/authenticatedByPasswordAnd2FAResponse' + +import type { AuthenticatedByPasswordResponse } from '../../models/authenticatedByPasswordResponse' + +import type { AuthenticatedResponse } from '../../models/authenticatedResponse' + +import { AuthenticatorType } from '../../models/authenticatorType' + +import type { AuthenticatorsResponse } from '../../models/authenticatorsResponse' + +import type { ConfigurationResponse } from '../../models/configurationResponse' + +import type { EmailAddressesResponse } from '../../models/emailAddressesResponse' + +import type { EmailVerificationInfoResponse } from '../../models/emailVerificationInfoResponse' + +import type { PasswordResetInfoResponse } from '../../models/passwordResetInfoResponse' + +import type { PhoneNumberChangeResponse } from '../../models/phoneNumberChangeResponse' + +import type { PhoneNumbersResponse } from '../../models/phoneNumbersResponse' + +import type { ProviderAccountsResponse } from '../../models/providerAccountsResponse' + +import type { ProviderSignupResponse } from '../../models/providerSignupResponse' + +import type { RecoveryCodesAuthenticator } from '../../models/recoveryCodesAuthenticator' + +import type { RecoveryCodesResponse } from '../../models/recoveryCodesResponse' + +import type { RefreshTokenResponse } from '../../models/refreshTokenResponse' + +import type { SessionsResponse } from '../../models/sessionsResponse' + +import type { StatusOKResponse } from '../../models/statusOKResponse' + +import type { TOTPAuthenticator } from '../../models/tOTPAuthenticator' + +import type { TOTPAuthenticatorResponse } from '../../models/tOTPAuthenticatorResponse' + +import type { WebAuthnAuthenticator } from '../../models/webAuthnAuthenticator' + +export const getApiV2AllauthBrowserV1ConfigGetResponseMock = ( + overrideResponse: Partial = {}, +): ConfigurationResponse => ({ + data: { + account: { + login_methods: faker.helpers.arrayElement([ + faker.helpers.arrayElements(['email', 'username'] as const), + undefined, + ]), + is_open_for_signup: faker.datatype.boolean(), + email_verification_by_code_enabled: faker.datatype.boolean(), + login_by_code_enabled: faker.datatype.boolean(), + password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + socialaccount: faker.helpers.arrayElement([ + { + providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + })), + }, + undefined, + ]), + mfa: faker.helpers.arrayElement([ + { supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType)) }, + undefined, + ]), + usersessions: faker.helpers.arrayElement([{ track_activity: faker.datatype.boolean() }, undefined]), + }, + status: faker.helpers.arrayElement([200] as const), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1ConfigGetResponseMock = ( + overrideResponse: Partial = {}, +): ConfigurationResponse => ({ + data: { + account: { + login_methods: faker.helpers.arrayElement([ + faker.helpers.arrayElements(['email', 'username'] as const), + undefined, + ]), + is_open_for_signup: faker.datatype.boolean(), + email_verification_by_code_enabled: faker.datatype.boolean(), + login_by_code_enabled: faker.datatype.boolean(), + password_reset_by_code_enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + socialaccount: faker.helpers.arrayElement([ + { + providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + })), + }, + undefined, + ]), + mfa: faker.helpers.arrayElement([ + { supported_types: faker.helpers.arrayElements(Object.values(AuthenticatorType)) }, + undefined, + ]), + usersessions: faker.helpers.arrayElement([{ track_activity: faker.datatype.boolean() }, undefined]), + }, + status: faker.helpers.arrayElement([200] as const), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthLoginPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthLoginPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailVerificationInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + meta: { is_authenticating: faker.datatype.boolean() }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailVerificationInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + meta: { is_authenticating: faker.datatype.boolean() }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock = ( + overrideResponse: Partial = {}, +): PasswordResetInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: faker.helpers.arrayElement([ + { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthPasswordResetGetResponseMock = ( + overrideResponse: Partial = {}, +): PasswordResetInfoResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: faker.helpers.arrayElement([ + { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthPasswordResetPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthProviderTokenPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderSignupResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + account: { + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + }, + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthProviderSignupGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderSignupResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + email: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + account: { + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + }, + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthProviderSignupPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByPasswordAnd2FAResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByCodeResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedByCodeResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountProvidersGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountProvidersGetResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountProvidersDeleteResponseMock = ( + overrideResponse: Partial = {}, +): ProviderAccountsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider: { + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + openid_configuration_url: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + flows: faker.helpers.arrayElements(['provider_redirect', 'provider_token'] as const), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailPostResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailPutResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AccountEmailPatchResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailGetResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailPostResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailPutResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AccountEmailPatchResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountEmailDeleteResponseMock = ( + overrideResponse: Partial = {}, +): EmailAddressesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountPhoneGetResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumbersResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountPhonePostResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumberChangeResponse => ({ + status: faker.helpers.arrayElement([202] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountPhoneGetResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumbersResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountPhonePostResponseMock = ( + overrideResponse: Partial = {}, +): PhoneNumberChangeResponse => ({ + status: faker.helpers.arrayElement([202] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = ( + overrideResponse: Partial = {}, +): WebAuthnAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['webauthn'] as const), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatorsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock() }, + { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock() }, + { ...getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock() }, + ]), + ), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock = ( + overrideResponse: Partial = {}, +): WebAuthnAuthenticator => ({ + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['webauthn'] as const), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_passwordless: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatorsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseTOTPAuthenticatorMock() }, + { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseRecoveryCodesAuthenticatorMock() }, + { ...getApiV2AllauthAppV1AccountAuthenticatorsGetResponseWebAuthnAuthenticatorMock() }, + ]), + ), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock = ( + overrideResponse: Partial = {}, +): TOTPAuthenticatorResponse => ({ + status: faker.helpers.arrayElement([200] as const), + meta: faker.helpers.arrayElement([ + { recovery_codes_generated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + data: { + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ type: faker.helpers.arrayElement(['totp'] as const) }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock = ( + overrideResponse: Partial = {}, +): StatusOKResponse => ({ status: faker.helpers.arrayElement([200] as const), ...overrideResponse }) + +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...{ + unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock = ( + overrideResponse: Partial = {}, +): RecoveryCodesResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + ...{ + ...{ + last_used_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + }, + ...{ + type: faker.helpers.arrayElement(['recovery_codes'] as const), + total_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + unused_code_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + ...{ + unused_codes: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSessionGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSessionGetResponseMock = ( + overrideResponse: Partial = {}, +): AuthenticatedResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + user: { + id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + display: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + has_usable_password: faker.datatype.boolean(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + methods: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + { + method: faker.helpers.arrayElement(['password_reset'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['code'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + phone: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['password'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + reauthenticated: faker.datatype.boolean(), + }, + { + method: faker.helpers.arrayElement(['socialaccount'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + method: faker.helpers.arrayElement(['mfa'] as const), + at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + type: faker.helpers.arrayElement(Object.values(AuthenticatorType)), + reauthenticated: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ]), + ), + }, + meta: { + ...{ + session_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + access_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...{ is_authenticated: faker.datatype.boolean() }, + }, + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1TokensRefreshPostResponseMock = ( + overrideResponse: Partial = {}, +): RefreshTokenResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: { + access_token: faker.string.alpha({ length: { min: 10, max: 20 } }), + refresh_token: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSessionsGetResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSessionsGetResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthAppV1AuthSessionsDeleteResponseMock = ( + overrideResponse: Partial = {}, +): SessionsResponse => ({ + status: faker.helpers.arrayElement([200] as const), + data: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_agent: faker.string.alpha({ length: { min: 10, max: 20 } }), + ip: faker.string.alpha({ length: { min: 10, max: 20 } }), + created_at: faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + is_current: faker.datatype.boolean(), + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_seen_at: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AllauthBrowserV1ConfigGetMockHandler = ( + overrideResponse?: + | ConfigurationResponse + | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/config', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1ConfigGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1ConfigGetMockHandler = (overrideResponse?: ConfigurationResponse | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse)) => { - return http.get('*/api/v2/allauth/app/v1/config', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1ConfigGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1ConfigGetMockHandler = ( + overrideResponse?: + | ConfigurationResponse + | ((info: Parameters[1]>[0]) => Promise | ConfigurationResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/config', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1ConfigGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthLoginPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/login', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthLoginPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthLoginPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/login', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthLoginPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthLoginPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/login', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthLoginPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthLoginPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/login', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthLoginPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthSignupPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthSignupPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthSignupPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthSignupPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler = (overrideResponse?: EmailVerificationInfoResponse | ((info: Parameters[1]>[0]) => Promise | EmailVerificationInfoResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthEmailVerifyGetMockHandler = ( + overrideResponse?: + | EmailVerificationInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailVerificationInfoResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthEmailVerifyGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthEmailVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/email/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthEmailVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler = (overrideResponse?: EmailVerificationInfoResponse | ((info: Parameters[1]>[0]) => Promise | EmailVerificationInfoResponse)) => { - return http.get('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthEmailVerifyGetMockHandler = ( + overrideResponse?: + | EmailVerificationInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailVerificationInfoResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthEmailVerifyGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthEmailVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/email/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthEmailVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/email/verify/resend', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthEmailVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/email/verify/resend', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthEmailVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/email/verify/resend', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthEmailVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/email/verify/resend', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthEmailVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthPhoneVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPhoneVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/phone/verify', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthPhoneVerifyPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/phone/verify', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPhoneVerifyPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify/resend', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/phone/verify/resend', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPhoneVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/phone/verify/resend', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthPhoneVerifyResendPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/phone/verify/resend', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPhoneVerifyResendPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/reauthenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/reauthenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthReauthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/reauthenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthReauthenticatePostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/reauthenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/password/request', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthPasswordRequestPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/password/request', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPasswordRequestPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/password/request', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthPasswordRequestPostMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/password/request', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPasswordRequestPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler = (overrideResponse?: PasswordResetInfoResponse | ((info: Parameters[1]>[0]) => Promise | PasswordResetInfoResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthPasswordResetGetMockHandler = ( + overrideResponse?: + | PasswordResetInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PasswordResetInfoResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPasswordResetGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthPasswordResetPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/password/reset', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthPasswordResetPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthPasswordResetGetMockHandler = (overrideResponse?: PasswordResetInfoResponse | ((info: Parameters[1]>[0]) => Promise | PasswordResetInfoResponse)) => { - return http.get('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthPasswordResetGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthPasswordResetGetMockHandler = ( + overrideResponse?: + | PasswordResetInfoResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PasswordResetInfoResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPasswordResetGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthPasswordResetPostMockHandler = (overrideResponse?: AuthenticatedByPasswordResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthPasswordResetPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthPasswordResetPostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/password/reset', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthPasswordResetPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/provider/redirect', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AllauthBrowserV1AuthProviderRedirectPostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/redirect', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/provider/token', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthProviderTokenPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/token', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthProviderTokenPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthProviderTokenPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/provider/token', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthProviderTokenPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthProviderTokenPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/provider/token', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthProviderTokenPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler = (overrideResponse?: ProviderSignupResponse | ((info: Parameters[1]>[0]) => Promise | ProviderSignupResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthProviderSignupGetMockHandler = ( + overrideResponse?: + | ProviderSignupResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderSignupResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthProviderSignupGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthProviderSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/provider/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthProviderSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthProviderSignupGetMockHandler = (overrideResponse?: ProviderSignupResponse | ((info: Parameters[1]>[0]) => Promise | ProviderSignupResponse)) => { - return http.get('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthProviderSignupGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthProviderSignupGetMockHandler = ( + overrideResponse?: + | ProviderSignupResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderSignupResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthProviderSignupGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthProviderSignupPostMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthProviderSignupPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthProviderSignupPostMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/provider/signup', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthProviderSignupPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordAnd2FAResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordAnd2FAResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/2fa/authenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1Auth2faAuthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/2fa/authenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1Auth2faAuthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordAnd2FAResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordAnd2FAResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/2fa/authenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1Auth2faAuthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/2fa/authenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1Auth2faAuthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordAnd2FAResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordAnd2FAResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/2fa/reauthenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1Auth2faReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/2fa/reauthenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1Auth2faReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler = (overrideResponse?: AuthenticatedByPasswordAnd2FAResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByPasswordAnd2FAResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/2fa/reauthenticate', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1Auth2faReauthenticatePostMockHandler = ( + overrideResponse?: + | AuthenticatedByPasswordAnd2FAResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByPasswordAnd2FAResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/2fa/reauthenticate', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1Auth2faReauthenticatePostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler = (overrideResponse?: AuthenticatedByCodeResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByCodeResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/auth/code/confirm', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthCodeConfirmPostMockHandler = ( + overrideResponse?: + | AuthenticatedByCodeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByCodeResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/auth/code/confirm', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthCodeConfirmPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler = (overrideResponse?: AuthenticatedByCodeResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedByCodeResponse)) => { - return http.post('*/api/v2/allauth/app/v1/auth/code/confirm', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthCodeConfirmPostMockHandler = ( + overrideResponse?: + | AuthenticatedByCodeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatedByCodeResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/auth/code/confirm', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthCodeConfirmPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountProvidersGetMockHandler = (overrideResponse?: ProviderAccountsResponse | ((info: Parameters[1]>[0]) => Promise | ProviderAccountsResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/account/providers', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountProvidersGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountProvidersGetMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/providers', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountProvidersGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler = (overrideResponse?: ProviderAccountsResponse | ((info: Parameters[1]>[0]) => Promise | ProviderAccountsResponse)) => { - return http.delete('*/api/v2/allauth/browser/v1/account/providers', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountProvidersDeleteMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/account/providers', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountProvidersDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountProvidersGetMockHandler = (overrideResponse?: ProviderAccountsResponse | ((info: Parameters[1]>[0]) => Promise | ProviderAccountsResponse)) => { - return http.get('*/api/v2/allauth/app/v1/account/providers', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountProvidersGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountProvidersGetMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/providers', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountProvidersGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountProvidersDeleteMockHandler = (overrideResponse?: ProviderAccountsResponse | ((info: Parameters[1]>[0]) => Promise | ProviderAccountsResponse)) => { - return http.delete('*/api/v2/allauth/app/v1/account/providers', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountProvidersDeleteResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountProvidersDeleteMockHandler = ( + overrideResponse?: + | ProviderAccountsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProviderAccountsResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/account/providers', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountProvidersDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountEmailGetMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountEmailGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountEmailGetMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountEmailPostMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountEmailPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountEmailPostMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountEmailPutMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { - return http.put('*/api/v2/allauth/browser/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountEmailPutResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountEmailPutMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.put('*/api/v2/allauth/browser/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailPutResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountEmailPatchMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { - return http.patch('*/api/v2/allauth/browser/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountEmailPatchResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountEmailPatchMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.patch('*/api/v2/allauth/browser/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailPatchResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { - return http.delete('*/api/v2/allauth/browser/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountEmailDeleteMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountEmailDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountEmailGetMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { - return http.get('*/api/v2/allauth/app/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountEmailGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountEmailGetMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountEmailPostMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { - return http.post('*/api/v2/allauth/app/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountEmailPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountEmailPostMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountEmailPutMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { - return http.put('*/api/v2/allauth/app/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountEmailPutResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountEmailPutMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.put('*/api/v2/allauth/app/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailPutResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountEmailPatchMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { - return http.patch('*/api/v2/allauth/app/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountEmailPatchResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountEmailPatchMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.patch('*/api/v2/allauth/app/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailPatchResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountEmailDeleteMockHandler = (overrideResponse?: EmailAddressesResponse | ((info: Parameters[1]>[0]) => Promise | EmailAddressesResponse)) => { - return http.delete('*/api/v2/allauth/app/v1/account/email', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountEmailDeleteResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountEmailDeleteMockHandler = ( + overrideResponse?: + | EmailAddressesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | EmailAddressesResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/account/email', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountEmailDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountPhoneGetMockHandler = (overrideResponse?: PhoneNumbersResponse | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/account/phone', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountPhoneGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountPhoneGetMockHandler = ( + overrideResponse?: + | PhoneNumbersResponse + | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/phone', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountPhoneGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountPhonePostMockHandler = (overrideResponse?: PhoneNumberChangeResponse | ((info: Parameters[1]>[0]) => Promise | PhoneNumberChangeResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/account/phone', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountPhonePostResponseMock()), - { status: 202, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountPhonePostMockHandler = ( + overrideResponse?: + | PhoneNumberChangeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PhoneNumberChangeResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/phone', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountPhonePostResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountPhoneGetMockHandler = (overrideResponse?: PhoneNumbersResponse | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse)) => { - return http.get('*/api/v2/allauth/app/v1/account/phone', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountPhoneGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountPhoneGetMockHandler = ( + overrideResponse?: + | PhoneNumbersResponse + | ((info: Parameters[1]>[0]) => Promise | PhoneNumbersResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/phone', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountPhoneGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountPhonePostMockHandler = (overrideResponse?: PhoneNumberChangeResponse | ((info: Parameters[1]>[0]) => Promise | PhoneNumberChangeResponse)) => { - return http.post('*/api/v2/allauth/app/v1/account/phone', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountPhonePostResponseMock()), - { status: 202, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountPhonePostMockHandler = ( + overrideResponse?: + | PhoneNumberChangeResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PhoneNumberChangeResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/account/phone', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountPhonePostResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler = (overrideResponse?: AuthenticatorsResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatorsResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/account/authenticators', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountAuthenticatorsGetMockHandler = ( + overrideResponse?: + | AuthenticatorsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatorsResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler = (overrideResponse?: AuthenticatorsResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatorsResponse)) => { - return http.get('*/api/v2/allauth/app/v1/account/authenticators', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountAuthenticatorsGetMockHandler = ( + overrideResponse?: + | AuthenticatorsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AuthenticatorsResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler = (overrideResponse?: TOTPAuthenticatorResponse | ((info: Parameters[1]>[0]) => Promise | TOTPAuthenticatorResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler = (overrideResponse?: TOTPAuthenticatorResponse | ((info: Parameters[1]>[0]) => Promise | TOTPAuthenticatorResponse)) => { - return http.post('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { - return http.delete('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsTotpDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler = (overrideResponse?: TOTPAuthenticatorResponse | ((info: Parameters[1]>[0]) => Promise | TOTPAuthenticatorResponse)) => { - return http.get('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpGetMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsTotpGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler = (overrideResponse?: TOTPAuthenticatorResponse | ((info: Parameters[1]>[0]) => Promise | TOTPAuthenticatorResponse)) => { - return http.post('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpPostMockHandler = ( + overrideResponse?: + | TOTPAuthenticatorResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TOTPAuthenticatorResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsTotpPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler = (overrideResponse?: StatusOKResponse | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse)) => { - return http.delete('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteMockHandler = ( + overrideResponse?: + | StatusOKResponse + | ((info: Parameters[1]>[0]) => Promise | StatusOKResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/account/authenticators/totp', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsTotpDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler = (overrideResponse?: RecoveryCodesResponse | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetMockHandler = ( + overrideResponse?: + | RecoveryCodesResponse + | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { - return http.post('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AllauthBrowserV1AccountAuthenticatorsRecoveryCodesPostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/authenticators/recovery-codes', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler = (overrideResponse?: RecoveryCodesResponse | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse)) => { - return http.get('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetMockHandler = ( + overrideResponse?: + | RecoveryCodesResponse + | ((info: Parameters[1]>[0]) => Promise | RecoveryCodesResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { - return http.post('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AllauthAppV1AccountAuthenticatorsRecoveryCodesPostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/app/v1/account/authenticators/recovery-codes', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AllauthBrowserV1AuthSessionGetMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/auth/session', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthSessionGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthSessionGetMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/session', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSessionGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { - return http.delete('*/api/v2/allauth/browser/v1/auth/session', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AllauthBrowserV1AuthSessionDeleteMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.delete('*/api/v2/allauth/browser/v1/auth/session', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AllauthAppV1AuthSessionGetMockHandler = (overrideResponse?: AuthenticatedResponse | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse)) => { - return http.get('*/api/v2/allauth/app/v1/auth/session', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthSessionGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthSessionGetMockHandler = ( + overrideResponse?: + | AuthenticatedResponse + | ((info: Parameters[1]>[0]) => Promise | AuthenticatedResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/session', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSessionGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthSessionDeleteMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { - return http.delete('*/api/v2/allauth/app/v1/auth/session', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AllauthAppV1AuthSessionDeleteMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.delete('*/api/v2/allauth/app/v1/auth/session', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AllauthAppV1TokensRefreshPostMockHandler = (overrideResponse?: RefreshTokenResponse | ((info: Parameters[1]>[0]) => Promise | RefreshTokenResponse)) => { - return http.post('*/api/v2/allauth/app/v1/tokens/refresh', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1TokensRefreshPostResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1TokensRefreshPostMockHandler = ( + overrideResponse?: + | RefreshTokenResponse + | ((info: Parameters[1]>[0]) => Promise | RefreshTokenResponse), +) => { + return http.post('*/api/v2/allauth/app/v1/tokens/refresh', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1TokensRefreshPostResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { - return http.post('*/api/v2/allauth/browser/v1/account/password/change', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AllauthBrowserV1AccountPasswordChangePostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/browser/v1/account/password/change', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AllauthAppV1AccountPasswordChangePostMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { - return http.post('*/api/v2/allauth/app/v1/account/password/change', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AllauthAppV1AccountPasswordChangePostMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.post('*/api/v2/allauth/app/v1/account/password/change', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AllauthBrowserV1AuthSessionsGetMockHandler = (overrideResponse?: SessionsResponse | ((info: Parameters[1]>[0]) => Promise | SessionsResponse)) => { - return http.get('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthSessionsGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthSessionsGetMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.get('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSessionsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler = (overrideResponse?: SessionsResponse | ((info: Parameters[1]>[0]) => Promise | SessionsResponse)) => { - return http.delete('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.delete('*/api/v2/allauth/browser/v1/auth/sessions', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthBrowserV1AuthSessionsDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthSessionsGetMockHandler = (overrideResponse?: SessionsResponse | ((info: Parameters[1]>[0]) => Promise | SessionsResponse)) => { - return http.get('*/api/v2/allauth/app/v1/auth/sessions', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthSessionsGetResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthSessionsGetMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.get('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSessionsGetResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AllauthAppV1AuthSessionsDeleteMockHandler = (overrideResponse?: SessionsResponse | ((info: Parameters[1]>[0]) => Promise | SessionsResponse)) => { - return http.delete('*/api/v2/allauth/app/v1/auth/sessions', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AllauthAppV1AuthSessionsDeleteResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AllauthAppV1AuthSessionsDeleteMockHandler = ( + overrideResponse?: + | SessionsResponse + | ((info: Parameters[1]>[0]) => Promise | SessionsResponse), +) => { + return http.delete('*/api/v2/allauth/app/v1/auth/sessions', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AllauthAppV1AuthSessionsDeleteResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } export const getAuthenticationAllauthHeadlessMock = () => [ @@ -1110,5 +4121,5 @@ export const getAuthenticationAllauthHeadlessMock = () => [ getApiV2AllauthBrowserV1AuthSessionsGetMockHandler(), getApiV2AllauthBrowserV1AuthSessionsDeleteMockHandler(), getApiV2AllauthAppV1AuthSessionsGetMockHandler(), - getApiV2AllauthAppV1AuthSessionsDeleteMockHandler() + getApiV2AllauthAppV1AuthSessionsDeleteMockHandler(), ] diff --git a/jsapp/js/api/react-query/configuration/index.ts b/jsapp/js/api/react-query/configuration/index.ts index 10005099a0..c6fac2287d 100644 --- a/jsapp/js/api/react-query/configuration/index.ts +++ b/jsapp/js/api/react-query/configuration/index.ts @@ -9,26 +9,14 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useQuery -} from '@tanstack/react-query'; -import type { - QueryFunction, - QueryKey, - UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query' +import type { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query' -import type { - EnvironmentResponse -} from '../../models/environmentResponse'; - -import { fetchWithAuth } from '../../orval.mutator'; - - -type SecondParameter unknown> = Parameters[1]; +import type { EnvironmentResponse } from '../../models/environmentResponse' +import { fetchWithAuth } from '../../orval.mutator' +type SecondParameter unknown> = Parameters[1] /** * Retrieve Kobo server environment configurations. @@ -46,75 +34,64 @@ export type environmentRetrieveResponse200 = { data: EnvironmentResponse status: 200 } - -export type environmentRetrieveResponseComposite = environmentRetrieveResponse200; - + +export type environmentRetrieveResponseComposite = environmentRetrieveResponse200 + export type environmentRetrieveResponse = environmentRetrieveResponseComposite & { - headers: Headers; + headers: Headers } export const getEnvironmentRetrieveUrl = () => { - - - - return `/api/v2/environment/` } -export const environmentRetrieve = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getEnvironmentRetrieveUrl(), - { +export const environmentRetrieve = async (options?: RequestInit): Promise => { + return fetchWithAuth(getEnvironmentRetrieveUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getEnvironmentRetrieveQueryKey = () => { - return ['api','v2','environment'] as const; - } - - -export const getEnvironmentRetrieveQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getEnvironmentRetrieveQueryKey(); - - - - const queryFn: QueryFunction>> = ({ signal }) => environmentRetrieve({ signal, ...requestOptions }); - - - - + return ['api', 'v2', 'environment'] as const +} - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +export const getEnvironmentRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getEnvironmentRetrieveQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + environmentRetrieve({ signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type EnvironmentRetrieveQueryResult = NonNullable>> export type EnvironmentRetrieveQueryError = unknown - - -export function useEnvironmentRetrieve>, TError = unknown>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useEnvironmentRetrieve< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getEnvironmentRetrieveQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - - diff --git a/jsapp/js/api/react-query/configuration/msw.ts b/jsapp/js/api/react-query/configuration/msw.ts index cc0086b1d8..7e57ce7fd7 100644 --- a/jsapp/js/api/react-query/configuration/msw.ts +++ b/jsapp/js/api/react-query/configuration/msw.ts @@ -9,36 +9,132 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; +import { http, HttpResponse } from 'msw' -import type { - EnvironmentResponse -} from '../../models/environmentResponse'; +import type { EnvironmentResponse } from '../../models/environmentResponse' +export const getApiV2EnvironmentRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnvironmentResponse => ({ + terms_of_service_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + privacy_policy_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + source_code_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + support_email: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + support_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + academy_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + community_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + frontend_min_retry_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + frontend_max_retry_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + use_team_label: faker.datatype.boolean(), + usage_limit_enforcement: faker.datatype.boolean(), + allow_self_account_deletion: faker.datatype.boolean(), + project_history_log_lifespan: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + sector_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + operational_purpose_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + country_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + interface_languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + mfa_localized_help_text: faker.string.alpha({ length: { min: 10, max: 20 } }), + mfa_enabled: faker.datatype.boolean(), + mfa_code_length: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + superuser_auth_enforcement: faker.datatype.boolean(), + enable_password_entropy_meter: faker.datatype.boolean(), + enable_custom_password_guidance_text: faker.datatype.boolean(), + custom_password_localized_help_text: faker.string.alpha({ length: { min: 10, max: 20 } }), + project_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + options: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + })), + undefined, + ]), + })), + extra_project_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + options: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + })), + undefined, + ]), + }), + ), + user_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + options: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + })), + undefined, + ]), + })), + social_apps: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + client_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + provider_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + asr_mt_features_enabled: faker.datatype.boolean(), + submission_placeholder: faker.string.alpha({ length: { min: 10, max: 20 } }), + stripe_public_key: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + terms_of_service__sitewidemessage__exists: faker.datatype.boolean(), + open_rosa_server: faker.internet.url(), + ...overrideResponse, +}) -export const getApiV2EnvironmentRetrieveResponseMock = (overrideResponse: Partial< EnvironmentResponse > = {}): EnvironmentResponse => ({terms_of_service_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), privacy_policy_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), source_code_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), support_email: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), support_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), academy_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), community_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), frontend_min_retry_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), frontend_max_retry_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), use_team_label: faker.datatype.boolean(), usage_limit_enforcement: faker.datatype.boolean(), allow_self_account_deletion: faker.datatype.boolean(), project_history_log_lifespan: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), sector_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), operational_purpose_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), country_choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), interface_languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), mfa_localized_help_text: faker.string.alpha({length: {min: 10, max: 20}}), mfa_enabled: faker.datatype.boolean(), mfa_code_length: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), superuser_auth_enforcement: faker.datatype.boolean(), enable_password_entropy_meter: faker.datatype.boolean(), enable_custom_password_guidance_text: faker.datatype.boolean(), custom_password_localized_help_text: faker.string.alpha({length: {min: 10, max: 20}}), project_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), options: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: { - [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) - }})), undefined])})), extra_project_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), options: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: { - [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) - }})), undefined])})), user_metadata_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), options: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), label: { - [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) - }})), undefined])})), social_apps: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({provider: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), client_id: faker.string.alpha({length: {min: 10, max: 20}}), provider_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), asr_mt_features_enabled: faker.datatype.boolean(), submission_placeholder: faker.string.alpha({length: {min: 10, max: 20}}), stripe_public_key: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), terms_of_service__sitewidemessage__exists: faker.datatype.boolean(), open_rosa_server: faker.internet.url(), ...overrideResponse}) - - -export const getApiV2EnvironmentRetrieveMockHandler = (overrideResponse?: EnvironmentResponse | ((info: Parameters[1]>[0]) => Promise | EnvironmentResponse)) => { - return http.get('*/api/v2/environment/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2EnvironmentRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2EnvironmentRetrieveMockHandler = ( + overrideResponse?: + | EnvironmentResponse + | ((info: Parameters[1]>[0]) => Promise | EnvironmentResponse), +) => { + return http.get('*/api/v2/environment/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2EnvironmentRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getConfigurationMock = () => [ - getApiV2EnvironmentRetrieveMockHandler() -] +export const getConfigurationMock = () => [getApiV2EnvironmentRetrieveMockHandler()] diff --git a/jsapp/js/api/react-query/form-content/index.ts b/jsapp/js/api/react-query/form-content/index.ts index a0a4d89921..57ce837713 100644 --- a/jsapp/js/api/react-query/form-content/index.ts +++ b/jsapp/js/api/react-query/form-content/index.ts @@ -9,65 +9,39 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - AssetSnapshotCreateRequest -} from '../../models/assetSnapshotCreateRequest'; +import type { AssetSnapshotCreateRequest } from '../../models/assetSnapshotCreateRequest' -import type { - AssetSnapshotResponse -} from '../../models/assetSnapshotResponse'; +import type { AssetSnapshotResponse } from '../../models/assetSnapshotResponse' -import type { - AssetSnapshotsListParams -} from '../../models/assetSnapshotsListParams'; +import type { AssetSnapshotsListParams } from '../../models/assetSnapshotsListParams' -import type { - AssetSnapshotsRetrieveParams -} from '../../models/assetSnapshotsRetrieveParams'; +import type { AssetSnapshotsRetrieveParams } from '../../models/assetSnapshotsRetrieveParams' -import type { - AssetValidContentResponse -} from '../../models/assetValidContentResponse'; +import type { AssetValidContentResponse } from '../../models/assetValidContentResponse' -import type { - ContentResponse -} from '../../models/contentResponse'; +import type { ContentResponse } from '../../models/contentResponse' -import type { - ErrorDetail -} from '../../models/errorDetail'; +import type { ErrorDetail } from '../../models/errorDetail' -import type { - ErrorObject -} from '../../models/errorObject'; +import type { ErrorObject } from '../../models/errorObject' -import type { - OpenRosaXFormResponse -} from '../../models/openRosaXFormResponse'; - -import type { - PaginatedAssetSnapshotResponseList -} from '../../models/paginatedAssetSnapshotResponseList'; - -import { fetchWithAuth } from '../../orval.mutator'; +import type { OpenRosaXFormResponse } from '../../models/openRosaXFormResponse' +import type { PaginatedAssetSnapshotResponseList } from '../../models/paginatedAssetSnapshotResponseList' -type SecondParameter unknown> = Parameters[1]; - +import { fetchWithAuth } from '../../orval.mutator' +type SecondParameter unknown> = Parameters[1] /** * ## List all snapshots for every asset of a user @@ -82,85 +56,84 @@ export type assetSnapshotsListResponse401 = { data: ErrorDetail status: 401 } - -export type assetSnapshotsListResponseComposite = assetSnapshotsListResponse200 | assetSnapshotsListResponse401; - + +export type assetSnapshotsListResponseComposite = assetSnapshotsListResponse200 | assetSnapshotsListResponse401 + export type assetSnapshotsListResponse = assetSnapshotsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetSnapshotsListUrl = (params?: AssetSnapshotsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetSnapshotsListUrl = (params?: AssetSnapshotsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/asset_snapshots/?${stringifiedParams}` : `/api/v2/asset_snapshots/` } -export const assetSnapshotsList = async (params?: AssetSnapshotsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSnapshotsListUrl(params), - { +export const assetSnapshotsList = async ( + params?: AssetSnapshotsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetSnapshotsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetSnapshotsListQueryKey = (params?: AssetSnapshotsListParams,) => { - return ['api','v2','asset_snapshots', ...(params ? [params]: [])] as const; - } +export const getAssetSnapshotsListQueryKey = (params?: AssetSnapshotsListParams) => { + return ['api', 'v2', 'asset_snapshots', ...(params ? [params] : [])] as const +} - -export const getAssetSnapshotsListQueryOptions = >, TError = ErrorDetail>(params?: AssetSnapshotsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetSnapshotsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: AssetSnapshotsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsListQueryKey(params); - - + const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsListQueryKey(params) - const queryFn: QueryFunction>> = ({ signal }) => assetSnapshotsList(params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetSnapshotsList(params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetSnapshotsListQueryResult = NonNullable>> export type AssetSnapshotsListQueryError = ErrorDetail - - export function useAssetSnapshotsList>, TError = ErrorDetail>( - params?: AssetSnapshotsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + params?: AssetSnapshotsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetSnapshotsListQueryOptions(params, options) - const queryOptions = getAssetSnapshotsListQueryOptions(params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Create an asset snapshot @@ -186,74 +159,86 @@ export type assetSnapshotsCreateResponse401 = { data: ErrorDetail status: 401 } - -export type assetSnapshotsCreateResponseComposite = assetSnapshotsCreateResponse201 | assetSnapshotsCreateResponse400 | assetSnapshotsCreateResponse401; - + +export type assetSnapshotsCreateResponseComposite = + | assetSnapshotsCreateResponse201 + | assetSnapshotsCreateResponse400 + | assetSnapshotsCreateResponse401 + export type assetSnapshotsCreateResponse = assetSnapshotsCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getAssetSnapshotsCreateUrl = () => { - - - - return `/api/v2/asset_snapshots/` } -export const assetSnapshotsCreate = async (assetSnapshotCreateRequest: AssetSnapshotCreateRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSnapshotsCreateUrl(), - { +export const assetSnapshotsCreate = async ( + assetSnapshotCreateRequest: AssetSnapshotCreateRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetSnapshotsCreateUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - assetSnapshotCreateRequest,) - } -);} - - - - -export const getAssetSnapshotsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetSnapshotCreateRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: AssetSnapshotCreateRequest}, TContext> => { - -const mutationKey = ['assetSnapshotsCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: AssetSnapshotCreateRequest}> = (props) => { - const {data} = props ?? {}; - - return assetSnapshotsCreate(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetSnapshotsCreateMutationResult = NonNullable>> - export type AssetSnapshotsCreateMutationBody = AssetSnapshotCreateRequest - export type AssetSnapshotsCreateMutationError = ErrorObject | ErrorDetail + body: JSON.stringify(assetSnapshotCreateRequest), + }) +} - export const useAssetSnapshotsCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetSnapshotCreateRequest}, TContext>, request?: SecondParameter} - ) => { +export const getAssetSnapshotsCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetSnapshotCreateRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: AssetSnapshotCreateRequest }, + TContext +> => { + const mutationKey = ['assetSnapshotsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: AssetSnapshotCreateRequest } + > = (props) => { + const { data } = props ?? {} + + return assetSnapshotsCreate(data, requestOptions) + } - const mutationOptions = getAssetSnapshotsCreateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetSnapshotsCreateMutationResult = NonNullable>> +export type AssetSnapshotsCreateMutationBody = AssetSnapshotCreateRequest +export type AssetSnapshotsCreateMutationError = ErrorObject | ErrorDetail + +export const useAssetSnapshotsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetSnapshotCreateRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetSnapshotsCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Retrieve an asset snapshot Note: If the `Content-Type` of the request is set to `application/xml`, the response will @@ -270,90 +255,94 @@ export type assetSnapshotsRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type assetSnapshotsRetrieveResponseComposite = assetSnapshotsRetrieveResponse200 | assetSnapshotsRetrieveResponse401; - + +export type assetSnapshotsRetrieveResponseComposite = + | assetSnapshotsRetrieveResponse200 + | assetSnapshotsRetrieveResponse401 + export type assetSnapshotsRetrieveResponse = assetSnapshotsRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetSnapshotsRetrieveUrl = (uidAssetSnapshot: string, - params?: AssetSnapshotsRetrieveParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetSnapshotsRetrieveUrl = (uidAssetSnapshot: string, params?: AssetSnapshotsRetrieveParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/asset_snapshots/${uidAssetSnapshot}/?${stringifiedParams}` : `/api/v2/asset_snapshots/${uidAssetSnapshot}/` + return stringifiedParams.length > 0 + ? `/api/v2/asset_snapshots/${uidAssetSnapshot}/?${stringifiedParams}` + : `/api/v2/asset_snapshots/${uidAssetSnapshot}/` } -export const assetSnapshotsRetrieve = async (uidAssetSnapshot: string, - params?: AssetSnapshotsRetrieveParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSnapshotsRetrieveUrl(uidAssetSnapshot,params), - { +export const assetSnapshotsRetrieve = async ( + uidAssetSnapshot: string, + params?: AssetSnapshotsRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetSnapshotsRetrieveUrl(uidAssetSnapshot, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetSnapshotsRetrieveQueryKey = (uidAssetSnapshot: string, - params?: AssetSnapshotsRetrieveParams,) => { - return ['api','v2','asset_snapshots',uidAssetSnapshot, ...(params ? [params]: [])] as const; - } +export const getAssetSnapshotsRetrieveQueryKey = (uidAssetSnapshot: string, params?: AssetSnapshotsRetrieveParams) => { + return ['api', 'v2', 'asset_snapshots', uidAssetSnapshot, ...(params ? [params] : [])] as const +} - -export const getAssetSnapshotsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAssetSnapshot: string, - params?: AssetSnapshotsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetSnapshotsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAssetSnapshot: string, + params?: AssetSnapshotsRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsRetrieveQueryKey(uidAssetSnapshot,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetSnapshotsRetrieve(uidAssetSnapshot,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsRetrieveQueryKey(uidAssetSnapshot, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetSnapshotsRetrieve(uidAssetSnapshot, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidAssetSnapshot), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAssetSnapshot, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetSnapshotsRetrieveQueryResult = NonNullable>> export type AssetSnapshotsRetrieveQueryError = ErrorDetail +export function useAssetSnapshotsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAssetSnapshot: string, + params?: AssetSnapshotsRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetSnapshotsRetrieveQueryOptions(uidAssetSnapshot, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetSnapshotsRetrieve>, TError = ErrorDetail>( - uidAssetSnapshot: string, - params?: AssetSnapshotsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getAssetSnapshotsRetrieveQueryOptions(uidAssetSnapshot,params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Delete an asset snapshot @@ -367,73 +356,78 @@ export type assetSnapshotsDestroyResponse401 = { data: ErrorDetail status: 401 } - -export type assetSnapshotsDestroyResponseComposite = assetSnapshotsDestroyResponse204 | assetSnapshotsDestroyResponse401; - -export type assetSnapshotsDestroyResponse = assetSnapshotsDestroyResponseComposite & { - headers: Headers; -} -export const getAssetSnapshotsDestroyUrl = (uidAssetSnapshot: string,) => { +export type assetSnapshotsDestroyResponseComposite = assetSnapshotsDestroyResponse204 | assetSnapshotsDestroyResponse401 +export type assetSnapshotsDestroyResponse = assetSnapshotsDestroyResponseComposite & { + headers: Headers +} - - +export const getAssetSnapshotsDestroyUrl = (uidAssetSnapshot: string) => { return `/api/v2/asset_snapshots/${uidAssetSnapshot}/` } -export const assetSnapshotsDestroy = async (uidAssetSnapshot: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSnapshotsDestroyUrl(uidAssetSnapshot), - { +export const assetSnapshotsDestroy = async ( + uidAssetSnapshot: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetSnapshotsDestroyUrl(uidAssetSnapshot), { ...options, - method: 'DELETE' - - - } -);} - - - - -export const getAssetSnapshotsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAssetSnapshot: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAssetSnapshot: string}, TContext> => { - -const mutationKey = ['assetSnapshotsDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAssetSnapshot: string}> = (props) => { - const {uidAssetSnapshot} = props ?? {}; - - return assetSnapshotsDestroy(uidAssetSnapshot,requestOptions) - } - - + method: 'DELETE', + }) +} +export const getAssetSnapshotsDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAssetSnapshot: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAssetSnapshot: string }, + TContext +> => { + const mutationKey = ['assetSnapshotsDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAssetSnapshot: string } + > = (props) => { + const { uidAssetSnapshot } = props ?? {} + + return assetSnapshotsDestroy(uidAssetSnapshot, requestOptions) + } - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetSnapshotsDestroyMutationResult = NonNullable>> - - export type AssetSnapshotsDestroyMutationError = ErrorDetail +export type AssetSnapshotsDestroyMutationResult = NonNullable>> - export const useAssetSnapshotsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAssetSnapshot: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetSnapshotsDestroyMutationError = ErrorDetail - const mutationOptions = getAssetSnapshotsDestroyMutationOptions(options); +export const useAssetSnapshotsDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAssetSnapshot: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetSnapshotsDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Asset snapshot preview Returns a `302 Found` redirect to the Enketo preview page associated with the asset. @@ -448,78 +442,81 @@ export type assetSnapshotsPreviewRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetSnapshotsPreviewRetrieveResponseComposite = assetSnapshotsPreviewRetrieveResponse302 | assetSnapshotsPreviewRetrieveResponse404; - -export type assetSnapshotsPreviewRetrieveResponse = assetSnapshotsPreviewRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetSnapshotsPreviewRetrieveUrl = (uidAssetSnapshot: string,) => { +export type assetSnapshotsPreviewRetrieveResponseComposite = + | assetSnapshotsPreviewRetrieveResponse302 + | assetSnapshotsPreviewRetrieveResponse404 +export type assetSnapshotsPreviewRetrieveResponse = assetSnapshotsPreviewRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetSnapshotsPreviewRetrieveUrl = (uidAssetSnapshot: string) => { return `/api/v2/asset_snapshots/${uidAssetSnapshot}/preview/` } -export const assetSnapshotsPreviewRetrieve = async (uidAssetSnapshot: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSnapshotsPreviewRetrieveUrl(uidAssetSnapshot), - { +export const assetSnapshotsPreviewRetrieve = async ( + uidAssetSnapshot: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetSnapshotsPreviewRetrieveUrl(uidAssetSnapshot), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetSnapshotsPreviewRetrieveQueryKey = (uidAssetSnapshot: string,) => { - return ['api','v2','asset_snapshots',uidAssetSnapshot,'preview'] as const; - } +export const getAssetSnapshotsPreviewRetrieveQueryKey = (uidAssetSnapshot: string) => { + return ['api', 'v2', 'asset_snapshots', uidAssetSnapshot, 'preview'] as const +} - -export const getAssetSnapshotsPreviewRetrieveQueryOptions = >, TError = void | ErrorDetail>(uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetSnapshotsPreviewRetrieveQueryOptions = < + TData = Awaited>, + TError = void | ErrorDetail, +>( + uidAssetSnapshot: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsPreviewRetrieveQueryKey(uidAssetSnapshot); - - + const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsPreviewRetrieveQueryKey(uidAssetSnapshot) - const queryFn: QueryFunction>> = ({ signal }) => assetSnapshotsPreviewRetrieve(uidAssetSnapshot, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetSnapshotsPreviewRetrieve(uidAssetSnapshot, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAssetSnapshot), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAssetSnapshot, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetSnapshotsPreviewRetrieveQueryResult = NonNullable>> +export type AssetSnapshotsPreviewRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetSnapshotsPreviewRetrieveQueryError = void | ErrorDetail +export function useAssetSnapshotsPreviewRetrieve< + TData = Awaited>, + TError = void | ErrorDetail, +>( + uidAssetSnapshot: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetSnapshotsPreviewRetrieveQueryOptions(uidAssetSnapshot, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetSnapshotsPreviewRetrieve>, TError = void | ErrorDetail>( - uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetSnapshotsPreviewRetrieveQueryOptions(uidAssetSnapshot,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## This route will render the XForm into syntax-highlighted HTML. @@ -535,78 +532,81 @@ export type assetSnapshotsXformRetrieveResponse404 = { data: void status: 404 } - -export type assetSnapshotsXformRetrieveResponseComposite = assetSnapshotsXformRetrieveResponse200 | assetSnapshotsXformRetrieveResponse404; - -export type assetSnapshotsXformRetrieveResponse = assetSnapshotsXformRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetSnapshotsXformRetrieveUrl = (uidAssetSnapshot: string,) => { +export type assetSnapshotsXformRetrieveResponseComposite = + | assetSnapshotsXformRetrieveResponse200 + | assetSnapshotsXformRetrieveResponse404 - +export type assetSnapshotsXformRetrieveResponse = assetSnapshotsXformRetrieveResponseComposite & { + headers: Headers +} +export const getAssetSnapshotsXformRetrieveUrl = (uidAssetSnapshot: string) => { return `/api/v2/asset_snapshots/${uidAssetSnapshot}/xform/` } -export const assetSnapshotsXformRetrieve = async (uidAssetSnapshot: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSnapshotsXformRetrieveUrl(uidAssetSnapshot), - { +export const assetSnapshotsXformRetrieve = async ( + uidAssetSnapshot: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetSnapshotsXformRetrieveUrl(uidAssetSnapshot), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetSnapshotsXformRetrieveQueryKey = (uidAssetSnapshot: string,) => { - return ['api','v2','asset_snapshots',uidAssetSnapshot,'xform'] as const; - } +export const getAssetSnapshotsXformRetrieveQueryKey = (uidAssetSnapshot: string) => { + return ['api', 'v2', 'asset_snapshots', uidAssetSnapshot, 'xform'] as const +} - -export const getAssetSnapshotsXformRetrieveQueryOptions = >, TError = void>(uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetSnapshotsXformRetrieveQueryOptions = < + TData = Awaited>, + TError = void, +>( + uidAssetSnapshot: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsXformRetrieveQueryKey(uidAssetSnapshot) - const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsXformRetrieveQueryKey(uidAssetSnapshot); + const queryFn: QueryFunction>> = ({ signal }) => + assetSnapshotsXformRetrieve(uidAssetSnapshot, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => assetSnapshotsXformRetrieve(uidAssetSnapshot, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAssetSnapshot), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAssetSnapshot, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetSnapshotsXformRetrieveQueryResult = NonNullable>> +export type AssetSnapshotsXformRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetSnapshotsXformRetrieveQueryError = void +export function useAssetSnapshotsXformRetrieve< + TData = Awaited>, + TError = void, +>( + uidAssetSnapshot: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetSnapshotsXformRetrieveQueryOptions(uidAssetSnapshot, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetSnapshotsXformRetrieve>, TError = void>( - uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetSnapshotsXformRetrieveQueryOptions(uidAssetSnapshot,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Implement part of the OpenRosa Form List API @@ -624,78 +624,85 @@ export type assetSnapshotsXmlWithDisclaimerRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetSnapshotsXmlWithDisclaimerRetrieveResponseComposite = assetSnapshotsXmlWithDisclaimerRetrieveResponse200 | assetSnapshotsXmlWithDisclaimerRetrieveResponse404; - -export type assetSnapshotsXmlWithDisclaimerRetrieveResponse = assetSnapshotsXmlWithDisclaimerRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetSnapshotsXmlWithDisclaimerRetrieveUrl = (uidAssetSnapshot: string,) => { +export type assetSnapshotsXmlWithDisclaimerRetrieveResponseComposite = + | assetSnapshotsXmlWithDisclaimerRetrieveResponse200 + | assetSnapshotsXmlWithDisclaimerRetrieveResponse404 - +export type assetSnapshotsXmlWithDisclaimerRetrieveResponse = + assetSnapshotsXmlWithDisclaimerRetrieveResponseComposite & { + headers: Headers + } +export const getAssetSnapshotsXmlWithDisclaimerRetrieveUrl = (uidAssetSnapshot: string) => { return `/api/v2/asset_snapshots/${uidAssetSnapshot}/xml_with_disclaimer/` } -export const assetSnapshotsXmlWithDisclaimerRetrieve = async (uidAssetSnapshot: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSnapshotsXmlWithDisclaimerRetrieveUrl(uidAssetSnapshot), - { - ...options, - method: 'GET' - - - } -);} - - +export const assetSnapshotsXmlWithDisclaimerRetrieve = async ( + uidAssetSnapshot: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetSnapshotsXmlWithDisclaimerRetrieveUrl(uidAssetSnapshot), + { + ...options, + method: 'GET', + }, + ) +} -export const getAssetSnapshotsXmlWithDisclaimerRetrieveQueryKey = (uidAssetSnapshot: string,) => { - return ['api','v2','asset_snapshots',uidAssetSnapshot,'xml_with_disclaimer'] as const; - } +export const getAssetSnapshotsXmlWithDisclaimerRetrieveQueryKey = (uidAssetSnapshot: string) => { + return ['api', 'v2', 'asset_snapshots', uidAssetSnapshot, 'xml_with_disclaimer'] as const +} - -export const getAssetSnapshotsXmlWithDisclaimerRetrieveQueryOptions = >, TError = ErrorDetail>(uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetSnapshotsXmlWithDisclaimerRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAssetSnapshot: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsXmlWithDisclaimerRetrieveQueryKey(uidAssetSnapshot); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetSnapshotsXmlWithDisclaimerRetrieve(uidAssetSnapshot, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetSnapshotsXmlWithDisclaimerRetrieveQueryKey(uidAssetSnapshot) - + const queryFn: QueryFunction>> = ({ signal }) => + assetSnapshotsXmlWithDisclaimerRetrieve(uidAssetSnapshot, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAssetSnapshot), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAssetSnapshot, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetSnapshotsXmlWithDisclaimerRetrieveQueryResult = NonNullable>> +export type AssetSnapshotsXmlWithDisclaimerRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetSnapshotsXmlWithDisclaimerRetrieveQueryError = ErrorDetail +export function useAssetSnapshotsXmlWithDisclaimerRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAssetSnapshot: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetSnapshotsXmlWithDisclaimerRetrieveQueryOptions(uidAssetSnapshot, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetSnapshotsXmlWithDisclaimerRetrieve>, TError = ErrorDetail>( - uidAssetSnapshot: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetSnapshotsXmlWithDisclaimerRetrieveQueryOptions(uidAssetSnapshot,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Return the content of a user's asset. @@ -709,78 +716,77 @@ export type assetsContentRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsContentRetrieveResponseComposite = assetsContentRetrieveResponse200 | assetsContentRetrieveResponse404; - -export type assetsContentRetrieveResponse = assetsContentRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsContentRetrieveUrl = (uidAsset: string,) => { +export type assetsContentRetrieveResponseComposite = assetsContentRetrieveResponse200 | assetsContentRetrieveResponse404 +export type assetsContentRetrieveResponse = assetsContentRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsContentRetrieveUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/content/` } -export const assetsContentRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsContentRetrieveUrl(uidAsset), - { +export const assetsContentRetrieve = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsContentRetrieveUrl(uidAsset), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsContentRetrieveQueryKey = (uidAsset: string,) => { - return ['api','v2','assets',uidAsset,'content'] as const; - } +export const getAssetsContentRetrieveQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'content'] as const +} - -export const getAssetsContentRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsContentRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsContentRetrieveQueryKey(uidAsset); - - + const queryKey = queryOptions?.queryKey ?? getAssetsContentRetrieveQueryKey(uidAsset) - const queryFn: QueryFunction>> = ({ signal }) => assetsContentRetrieve(uidAsset, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetsContentRetrieve(uidAsset, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsContentRetrieveQueryResult = NonNullable>> export type AssetsContentRetrieveQueryError = ErrorDetail +export function useAssetsContentRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsContentRetrieveQueryOptions(uidAsset, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsContentRetrieve>, TError = ErrorDetail>( - uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsContentRetrieveQueryOptions(uidAsset,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Return plain HTML of survey in tabular format @@ -794,78 +800,76 @@ export type assetsTableViewRetrieveResponse404 = { data: void status: 404 } - -export type assetsTableViewRetrieveResponseComposite = assetsTableViewRetrieveResponse200 | assetsTableViewRetrieveResponse404; - -export type assetsTableViewRetrieveResponse = assetsTableViewRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsTableViewRetrieveUrl = (uidAsset: string,) => { +export type assetsTableViewRetrieveResponseComposite = + | assetsTableViewRetrieveResponse200 + | assetsTableViewRetrieveResponse404 - +export type assetsTableViewRetrieveResponse = assetsTableViewRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsTableViewRetrieveUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/table_view/` } -export const assetsTableViewRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsTableViewRetrieveUrl(uidAsset), - { +export const assetsTableViewRetrieve = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsTableViewRetrieveUrl(uidAsset), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsTableViewRetrieveQueryKey = (uidAsset: string,) => { - return ['api','v2','assets',uidAsset,'table_view'] as const; - } +export const getAssetsTableViewRetrieveQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'table_view'] as const +} - -export const getAssetsTableViewRetrieveQueryOptions = >, TError = void>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsTableViewRetrieveQueryOptions = < + TData = Awaited>, + TError = void, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getAssetsTableViewRetrieveQueryKey(uidAsset) - const queryKey = queryOptions?.queryKey ?? getAssetsTableViewRetrieveQueryKey(uidAsset); + const queryFn: QueryFunction>> = ({ signal }) => + assetsTableViewRetrieve(uidAsset, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => assetsTableViewRetrieve(uidAsset, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsTableViewRetrieveQueryResult = NonNullable>> export type AssetsTableViewRetrieveQueryError = void - - export function useAssetsTableViewRetrieve>, TError = void>( - uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsTableViewRetrieveQueryOptions(uidAsset,options) + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsTableViewRetrieveQueryOptions(uidAsset, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Return valid content for user's asset @@ -879,78 +883,79 @@ export type assetsValidContentRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsValidContentRetrieveResponseComposite = assetsValidContentRetrieveResponse200 | assetsValidContentRetrieveResponse404; - -export type assetsValidContentRetrieveResponse = assetsValidContentRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsValidContentRetrieveUrl = (uidAsset: string,) => { +export type assetsValidContentRetrieveResponseComposite = + | assetsValidContentRetrieveResponse200 + | assetsValidContentRetrieveResponse404 +export type assetsValidContentRetrieveResponse = assetsValidContentRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsValidContentRetrieveUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/valid_content/` } -export const assetsValidContentRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsValidContentRetrieveUrl(uidAsset), - { +export const assetsValidContentRetrieve = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsValidContentRetrieveUrl(uidAsset), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsValidContentRetrieveQueryKey = (uidAsset: string,) => { - return ['api','v2','assets',uidAsset,'valid_content'] as const; - } +export const getAssetsValidContentRetrieveQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'valid_content'] as const +} - -export const getAssetsValidContentRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsValidContentRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsValidContentRetrieveQueryKey(uidAsset); + const queryKey = queryOptions?.queryKey ?? getAssetsValidContentRetrieveQueryKey(uidAsset) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsValidContentRetrieve(uidAsset, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsValidContentRetrieve(uidAsset, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsValidContentRetrieveQueryResult = NonNullable>> export type AssetsValidContentRetrieveQueryError = ErrorDetail +export function useAssetsValidContentRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsValidContentRetrieveQueryOptions(uidAsset, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsValidContentRetrieve>, TError = ErrorDetail>( - uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsValidContentRetrieveQueryOptions(uidAsset,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Return plain HTML of survey in tabular format @@ -964,75 +969,67 @@ export type assetsXlsRetrieveResponse404 = { data: void status: 404 } - -export type assetsXlsRetrieveResponseComposite = assetsXlsRetrieveResponse200 | assetsXlsRetrieveResponse404; - -export type assetsXlsRetrieveResponse = assetsXlsRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsXlsRetrieveUrl = (uidAsset: string,) => { +export type assetsXlsRetrieveResponseComposite = assetsXlsRetrieveResponse200 | assetsXlsRetrieveResponse404 +export type assetsXlsRetrieveResponse = assetsXlsRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsXlsRetrieveUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/xls/` } -export const assetsXlsRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsXlsRetrieveUrl(uidAsset), - { +export const assetsXlsRetrieve = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsXlsRetrieveUrl(uidAsset), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsXlsRetrieveQueryKey = (uidAsset: string,) => { - return ['api','v2','assets',uidAsset,'xls'] as const; - } +export const getAssetsXlsRetrieveQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'xls'] as const +} - -export const getAssetsXlsRetrieveQueryOptions = >, TError = void>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsXlsRetrieveQueryOptions = >, TError = void>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsXlsRetrieveQueryKey(uidAsset); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsXlsRetrieve(uidAsset, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetsXlsRetrieveQueryKey(uidAsset) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsXlsRetrieve(uidAsset, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsXlsRetrieveQueryResult = NonNullable>> export type AssetsXlsRetrieveQueryError = void - - export function useAssetsXlsRetrieve>, TError = void>( - uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsXlsRetrieveQueryOptions(uidAsset,options) + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsXlsRetrieveQueryOptions(uidAsset, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - - diff --git a/jsapp/js/api/react-query/form-content/msw.ts b/jsapp/js/api/react-query/form-content/msw.ts index 2e6f11929d..63aa1d2bd5 100644 --- a/jsapp/js/api/react-query/form-content/msw.ts +++ b/jsapp/js/api/react-query/form-content/msw.ts @@ -9,158 +9,528 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; +import { http, HttpResponse } from 'msw' -import type { - AssetSnapshotResponse -} from '../../models/assetSnapshotResponse'; +import type { AssetSnapshotResponse } from '../../models/assetSnapshotResponse' -import type { - AssetValidContentResponse -} from '../../models/assetValidContentResponse'; +import type { AssetValidContentResponse } from '../../models/assetValidContentResponse' -import type { - ContentResponse -} from '../../models/contentResponse'; +import type { ContentResponse } from '../../models/contentResponse' -import type { - OpenRosaXFormResponse -} from '../../models/openRosaXFormResponse'; +import type { OpenRosaXFormResponse } from '../../models/openRosaXFormResponse' -import type { - PaginatedAssetSnapshotResponseList -} from '../../models/paginatedAssetSnapshotResponseList'; +import type { PaginatedAssetSnapshotResponseList } from '../../models/paginatedAssetSnapshotResponseList' +export const getApiV2AssetSnapshotsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetSnapshotResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + xml: faker.internet.url(), + enketopreviewlink: faker.internet.url(), + asset: faker.internet.url(), + asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + details: { + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + warnings: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + source: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + })), + ...overrideResponse, +}) -export const getApiV2AssetSnapshotsListResponseMock = (overrideResponse: Partial< PaginatedAssetSnapshotResponseList > = {}): PaginatedAssetSnapshotResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), owner: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, xml: faker.internet.url(), enketopreviewlink: faker.internet.url(), asset: faker.internet.url(), asset_version_id: faker.string.alpha({length: {min: 10, max: 20}}), details: {status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), warnings: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), message: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined])}, source: {schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{form_title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translation: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}})), ...overrideResponse}) +export const getApiV2AssetSnapshotsCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetSnapshotResponse => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + xml: faker.internet.url(), + enketopreviewlink: faker.internet.url(), + asset: faker.internet.url(), + asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + details: { + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + warnings: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + source: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) -export const getApiV2AssetSnapshotsCreateResponseMock = (overrideResponse: Partial< AssetSnapshotResponse > = {}): AssetSnapshotResponse => ({url: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), owner: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, xml: faker.internet.url(), enketopreviewlink: faker.internet.url(), asset: faker.internet.url(), asset_version_id: faker.string.alpha({length: {min: 10, max: 20}}), details: {status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), warnings: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), message: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined])}, source: {schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{form_title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translation: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, ...overrideResponse}) +export const getApiV2AssetSnapshotsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetSnapshotResponse => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + xml: faker.internet.url(), + enketopreviewlink: faker.internet.url(), + asset: faker.internet.url(), + asset_version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + details: { + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + warnings: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + source: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { form_title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) -export const getApiV2AssetSnapshotsRetrieveResponseMock = (overrideResponse: Partial< AssetSnapshotResponse > = {}): AssetSnapshotResponse => ({url: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), owner: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, xml: faker.internet.url(), enketopreviewlink: faker.internet.url(), asset: faker.internet.url(), asset_version_id: faker.string.alpha({length: {min: 10, max: 20}}), details: {status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), warnings: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), message: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined])}, source: {schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{form_title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translation: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, ...overrideResponse}) +export const getApiV2AssetSnapshotsXformRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OpenRosaXFormResponse => ({ + html: { + head: faker.helpers.arrayElement([ + { + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + model: faker.helpers.arrayElement([ + { + instance: faker.helpers.arrayElement([ + { + instanceUuid: faker.helpers.arrayElement([ + { + fieldName: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + meta: faker.helpers.arrayElement([ + { + instanceID: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + body: faker.helpers.arrayElement([ + { + input: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + hint: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + ...overrideResponse, +}) -export const getApiV2AssetSnapshotsXformRetrieveResponseMock = (overrideResponse: Partial< OpenRosaXFormResponse > = {}): OpenRosaXFormResponse => ({html: {head: faker.helpers.arrayElement([{title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), model: faker.helpers.arrayElement([{instance: faker.helpers.arrayElement([{instanceUuid: faker.helpers.arrayElement([{fieldName: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), meta: faker.helpers.arrayElement([{instanceID: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined])}, undefined])}, undefined])}, undefined]), body: faker.helpers.arrayElement([{input: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), hint: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined])}, ...overrideResponse}) +export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OpenRosaXFormResponse => ({ + html: { + head: faker.helpers.arrayElement([ + { + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + model: faker.helpers.arrayElement([ + { + instance: faker.helpers.arrayElement([ + { + instanceUuid: faker.helpers.arrayElement([ + { + fieldName: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + meta: faker.helpers.arrayElement([ + { + instanceID: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + body: faker.helpers.arrayElement([ + { + input: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + hint: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + ...overrideResponse, +}) -export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock = (overrideResponse: Partial< OpenRosaXFormResponse > = {}): OpenRosaXFormResponse => ({html: {head: faker.helpers.arrayElement([{title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), model: faker.helpers.arrayElement([{instance: faker.helpers.arrayElement([{instanceUuid: faker.helpers.arrayElement([{fieldName: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), meta: faker.helpers.arrayElement([{instanceID: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined])}, undefined])}, undefined])}, undefined]), body: faker.helpers.arrayElement([{input: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), hint: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined])}, ...overrideResponse}) +export const getApiV2AssetsContentRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ContentResponse => ({ + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + data: { + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + }, + ...overrideResponse, +}) -export const getApiV2AssetsContentRetrieveResponseMock = (overrideResponse: Partial< ContentResponse > = {}): ContentResponse => ({kind: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), data: {survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined]), settings: faker.helpers.arrayElement([{}, undefined])}, ...overrideResponse}) +export const getApiV2AssetsTableViewRetrieveResponseMock = (): string => faker.word.sample() -export const getApiV2AssetsTableViewRetrieveResponseMock = (): string => (faker.word.sample()) +export const getApiV2AssetsValidContentRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetValidContentResponse => ({ + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + data: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([{}, undefined]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) -export const getApiV2AssetsValidContentRetrieveResponseMock = (overrideResponse: Partial< AssetValidContentResponse > = {}): AssetValidContentResponse => ({kind: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), data: {schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $kuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, ...overrideResponse}) +export const getApiV2AssetsXlsRetrieveResponseMock = (): string => faker.word.sample() -export const getApiV2AssetsXlsRetrieveResponseMock = (): string => (faker.word.sample()) - - -export const getApiV2AssetSnapshotsListMockHandler = (overrideResponse?: PaginatedAssetSnapshotResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetSnapshotResponseList)) => { - return http.get('*/api/v2/asset_snapshots/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetSnapshotsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetSnapshotsListMockHandler = ( + overrideResponse?: + | PaginatedAssetSnapshotResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetSnapshotResponseList), +) => { + return http.get('*/api/v2/asset_snapshots/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetSnapshotsCreateMockHandler = (overrideResponse?: AssetSnapshotResponse | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse)) => { - return http.post('*/api/v2/asset_snapshots/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetSnapshotsCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetSnapshotsCreateMockHandler = ( + overrideResponse?: + | AssetSnapshotResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetSnapshotResponse), +) => { + return http.post('*/api/v2/asset_snapshots/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetSnapshotsRetrieveMockHandler = (overrideResponse?: AssetSnapshotResponse | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse)) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetSnapshotsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetSnapshotsRetrieveMockHandler = ( + overrideResponse?: + | AssetSnapshotResponse + | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetSnapshotsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetSnapshotsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetSnapshotsPreviewRetrieveMockHandler = (overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown)) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AssetSnapshotsPreviewRetrieveMockHandler = ( + overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AssetSnapshotsXformRetrieveMockHandler = (overrideResponse?: OpenRosaXFormResponse | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse)) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetSnapshotsXformRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetSnapshotsXformRetrieveMockHandler = ( + overrideResponse?: + | OpenRosaXFormResponse + | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsXformRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler = (overrideResponse?: OpenRosaXFormResponse | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse)) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler = ( + overrideResponse?: + | OpenRosaXFormResponse + | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), +) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsContentRetrieveMockHandler = (overrideResponse?: ContentResponse | ((info: Parameters[1]>[0]) => Promise | ContentResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/content/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsContentRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsContentRetrieveMockHandler = ( + overrideResponse?: + | ContentResponse + | ((info: Parameters[1]>[0]) => Promise | ContentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/content/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsContentRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsTableViewRetrieveMockHandler = (overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string)) => { - return http.get('*/api/v2/assets/:uidAsset/table_view/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsTableViewRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsTableViewRetrieveMockHandler = ( + overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), +) => { + return http.get('*/api/v2/assets/:uidAsset/table_view/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsTableViewRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsValidContentRetrieveMockHandler = (overrideResponse?: AssetValidContentResponse | ((info: Parameters[1]>[0]) => Promise | AssetValidContentResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/valid_content/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsValidContentRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsValidContentRetrieveMockHandler = ( + overrideResponse?: + | AssetValidContentResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetValidContentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/valid_content/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsValidContentRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsXlsRetrieveMockHandler = (overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string)) => { - return http.get('*/api/v2/assets/:uidAsset/xls/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsXlsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsXlsRetrieveMockHandler = ( + overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), +) => { + return http.get('*/api/v2/assets/:uidAsset/xls/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsXlsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } export const getFormContentMock = () => [ @@ -174,5 +544,5 @@ export const getFormContentMock = () => [ getApiV2AssetsContentRetrieveMockHandler(), getApiV2AssetsTableViewRetrieveMockHandler(), getApiV2AssetsValidContentRetrieveMockHandler(), - getApiV2AssetsXlsRetrieveMockHandler() + getApiV2AssetsXlsRetrieveMockHandler(), ] diff --git a/jsapp/js/api/react-query/library-collections/index.ts b/jsapp/js/api/react-query/library-collections/index.ts index 1d306b0b1b..67ac4d8d2f 100644 --- a/jsapp/js/api/react-query/library-collections/index.ts +++ b/jsapp/js/api/react-query/library-collections/index.ts @@ -9,49 +9,31 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - AssetSubscriptionRequest -} from '../../models/assetSubscriptionRequest'; - -import type { - AssetSubscriptionResponse -} from '../../models/assetSubscriptionResponse'; - -import type { - AssetSubscriptionsListParams -} from '../../models/assetSubscriptionsListParams'; - -import type { - ErrorDetail -} from '../../models/errorDetail'; +import type { AssetSubscriptionRequest } from '../../models/assetSubscriptionRequest' -import type { - ErrorObject -} from '../../models/errorObject'; +import type { AssetSubscriptionResponse } from '../../models/assetSubscriptionResponse' -import type { - PaginatedAssetSubscriptionResponseList -} from '../../models/paginatedAssetSubscriptionResponseList'; +import type { AssetSubscriptionsListParams } from '../../models/assetSubscriptionsListParams' -import { fetchWithAuth } from '../../orval.mutator'; +import type { ErrorDetail } from '../../models/errorDetail' +import type { ErrorObject } from '../../models/errorObject' -type SecondParameter unknown> = Parameters[1]; +import type { PaginatedAssetSubscriptionResponseList } from '../../models/paginatedAssetSubscriptionResponseList' +import { fetchWithAuth } from '../../orval.mutator' +type SecondParameter unknown> = Parameters[1] /** * ## List all asset subscriptions of a user @@ -61,85 +43,86 @@ export type assetSubscriptionsListResponse200 = { data: PaginatedAssetSubscriptionResponseList status: 200 } - -export type assetSubscriptionsListResponseComposite = assetSubscriptionsListResponse200; - + +export type assetSubscriptionsListResponseComposite = assetSubscriptionsListResponse200 + export type assetSubscriptionsListResponse = assetSubscriptionsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetSubscriptionsListUrl = (params?: AssetSubscriptionsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetSubscriptionsListUrl = (params?: AssetSubscriptionsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/asset_subscriptions/?${stringifiedParams}` : `/api/v2/asset_subscriptions/` + return stringifiedParams.length > 0 + ? `/api/v2/asset_subscriptions/?${stringifiedParams}` + : `/api/v2/asset_subscriptions/` } -export const assetSubscriptionsList = async (params?: AssetSubscriptionsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSubscriptionsListUrl(params), - { +export const assetSubscriptionsList = async ( + params?: AssetSubscriptionsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetSubscriptionsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetSubscriptionsListQueryKey = (params?: AssetSubscriptionsListParams,) => { - return ['api','v2','asset_subscriptions', ...(params ? [params]: [])] as const; - } +export const getAssetSubscriptionsListQueryKey = (params?: AssetSubscriptionsListParams) => { + return ['api', 'v2', 'asset_subscriptions', ...(params ? [params] : [])] as const +} - -export const getAssetSubscriptionsListQueryOptions = >, TError = unknown>(params?: AssetSubscriptionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetSubscriptionsListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: AssetSubscriptionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetSubscriptionsListQueryKey(params); + const queryKey = queryOptions?.queryKey ?? getAssetSubscriptionsListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetSubscriptionsList(params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetSubscriptionsList(params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetSubscriptionsListQueryResult = NonNullable>> export type AssetSubscriptionsListQueryError = unknown - - export function useAssetSubscriptionsList>, TError = unknown>( - params?: AssetSubscriptionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + params?: AssetSubscriptionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetSubscriptionsListQueryOptions(params, options) - const queryOptions = getAssetSubscriptionsListQueryOptions(params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Create an asset subscription @@ -155,74 +138,82 @@ export type assetSubscriptionsCreateResponse400 = { data: ErrorObject status: 400 } - -export type assetSubscriptionsCreateResponseComposite = assetSubscriptionsCreateResponse201 | assetSubscriptionsCreateResponse400; - + +export type assetSubscriptionsCreateResponseComposite = + | assetSubscriptionsCreateResponse201 + | assetSubscriptionsCreateResponse400 + export type assetSubscriptionsCreateResponse = assetSubscriptionsCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getAssetSubscriptionsCreateUrl = () => { - - - - return `/api/v2/asset_subscriptions/` } -export const assetSubscriptionsCreate = async (assetSubscriptionRequest: AssetSubscriptionRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSubscriptionsCreateUrl(), - { +export const assetSubscriptionsCreate = async ( + assetSubscriptionRequest: AssetSubscriptionRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetSubscriptionsCreateUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - assetSubscriptionRequest,) - } -);} - - - - -export const getAssetSubscriptionsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetSubscriptionRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: AssetSubscriptionRequest}, TContext> => { - -const mutationKey = ['assetSubscriptionsCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: AssetSubscriptionRequest}> = (props) => { - const {data} = props ?? {}; - - return assetSubscriptionsCreate(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetSubscriptionsCreateMutationResult = NonNullable>> - export type AssetSubscriptionsCreateMutationBody = AssetSubscriptionRequest - export type AssetSubscriptionsCreateMutationError = ErrorObject + body: JSON.stringify(assetSubscriptionRequest), + }) +} - export const useAssetSubscriptionsCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetSubscriptionRequest}, TContext>, request?: SecondParameter} - ) => { +export const getAssetSubscriptionsCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetSubscriptionRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: AssetSubscriptionRequest }, + TContext +> => { + const mutationKey = ['assetSubscriptionsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: AssetSubscriptionRequest } + > = (props) => { + const { data } = props ?? {} + + return assetSubscriptionsCreate(data, requestOptions) + } - const mutationOptions = getAssetSubscriptionsCreateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetSubscriptionsCreateMutationResult = NonNullable>> +export type AssetSubscriptionsCreateMutationBody = AssetSubscriptionRequest +export type AssetSubscriptionsCreateMutationError = ErrorObject + +export const useAssetSubscriptionsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetSubscriptionRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetSubscriptionsCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Retrieve an asset subscription */ @@ -235,78 +226,79 @@ export type assetSubscriptionsRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetSubscriptionsRetrieveResponseComposite = assetSubscriptionsRetrieveResponse200 | assetSubscriptionsRetrieveResponse404; - -export type assetSubscriptionsRetrieveResponse = assetSubscriptionsRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetSubscriptionsRetrieveUrl = (uidAssetSubscription: string,) => { +export type assetSubscriptionsRetrieveResponseComposite = + | assetSubscriptionsRetrieveResponse200 + | assetSubscriptionsRetrieveResponse404 - +export type assetSubscriptionsRetrieveResponse = assetSubscriptionsRetrieveResponseComposite & { + headers: Headers +} +export const getAssetSubscriptionsRetrieveUrl = (uidAssetSubscription: string) => { return `/api/v2/asset_subscriptions/${uidAssetSubscription}/` } -export const assetSubscriptionsRetrieve = async (uidAssetSubscription: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSubscriptionsRetrieveUrl(uidAssetSubscription), - { +export const assetSubscriptionsRetrieve = async ( + uidAssetSubscription: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetSubscriptionsRetrieveUrl(uidAssetSubscription), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetSubscriptionsRetrieveQueryKey = (uidAssetSubscription: string,) => { - return ['api','v2','asset_subscriptions',uidAssetSubscription] as const; - } +export const getAssetSubscriptionsRetrieveQueryKey = (uidAssetSubscription: string) => { + return ['api', 'v2', 'asset_subscriptions', uidAssetSubscription] as const +} - -export const getAssetSubscriptionsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAssetSubscription: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetSubscriptionsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAssetSubscription: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetSubscriptionsRetrieveQueryKey(uidAssetSubscription); - - + const queryKey = queryOptions?.queryKey ?? getAssetSubscriptionsRetrieveQueryKey(uidAssetSubscription) - const queryFn: QueryFunction>> = ({ signal }) => assetSubscriptionsRetrieve(uidAssetSubscription, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetSubscriptionsRetrieve(uidAssetSubscription, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAssetSubscription), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAssetSubscription, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetSubscriptionsRetrieveQueryResult = NonNullable>> export type AssetSubscriptionsRetrieveQueryError = ErrorDetail +export function useAssetSubscriptionsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAssetSubscription: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetSubscriptionsRetrieveQueryOptions(uidAssetSubscription, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetSubscriptionsRetrieve>, TError = ErrorDetail>( - uidAssetSubscription: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetSubscriptionsRetrieveQueryOptions(uidAssetSubscription,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Delete a subscription to an asset @@ -322,70 +314,76 @@ export type assetSubscriptionsDestroyResponse404 = { data: ErrorDetail status: 404 } - -export type assetSubscriptionsDestroyResponseComposite = assetSubscriptionsDestroyResponse204 | assetSubscriptionsDestroyResponse404; - -export type assetSubscriptionsDestroyResponse = assetSubscriptionsDestroyResponseComposite & { - headers: Headers; -} - -export const getAssetSubscriptionsDestroyUrl = (uidAssetSubscription: string,) => { +export type assetSubscriptionsDestroyResponseComposite = + | assetSubscriptionsDestroyResponse204 + | assetSubscriptionsDestroyResponse404 - +export type assetSubscriptionsDestroyResponse = assetSubscriptionsDestroyResponseComposite & { + headers: Headers +} +export const getAssetSubscriptionsDestroyUrl = (uidAssetSubscription: string) => { return `/api/v2/asset_subscriptions/${uidAssetSubscription}/` } -export const assetSubscriptionsDestroy = async (uidAssetSubscription: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetSubscriptionsDestroyUrl(uidAssetSubscription), - { +export const assetSubscriptionsDestroy = async ( + uidAssetSubscription: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetSubscriptionsDestroyUrl(uidAssetSubscription), { ...options, - method: 'DELETE' - - - } -);} - - - - -export const getAssetSubscriptionsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAssetSubscription: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAssetSubscription: string}, TContext> => { - -const mutationKey = ['assetSubscriptionsDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAssetSubscription: string}> = (props) => { - const {uidAssetSubscription} = props ?? {}; - - return assetSubscriptionsDestroy(uidAssetSubscription,requestOptions) - } - - + method: 'DELETE', + }) +} +export const getAssetSubscriptionsDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAssetSubscription: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAssetSubscription: string }, + TContext +> => { + const mutationKey = ['assetSubscriptionsDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAssetSubscription: string } + > = (props) => { + const { uidAssetSubscription } = props ?? {} + + return assetSubscriptionsDestroy(uidAssetSubscription, requestOptions) + } - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetSubscriptionsDestroyMutationResult = NonNullable>> - - export type AssetSubscriptionsDestroyMutationError = ErrorDetail +export type AssetSubscriptionsDestroyMutationResult = NonNullable>> - export const useAssetSubscriptionsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAssetSubscription: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetSubscriptionsDestroyMutationError = ErrorDetail - const mutationOptions = getAssetSubscriptionsDestroyMutationOptions(options); +export const useAssetSubscriptionsDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAssetSubscription: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetSubscriptionsDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - \ No newline at end of file + return useMutation(mutationOptions) +} diff --git a/jsapp/js/api/react-query/library-collections/msw.ts b/jsapp/js/api/react-query/library-collections/msw.ts index c3298f01d3..bc0298c49d 100644 --- a/jsapp/js/api/react-query/library-collections/msw.ts +++ b/jsapp/js/api/react-query/library-collections/msw.ts @@ -9,70 +9,122 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; +import { http, HttpResponse } from 'msw' -import type { - AssetSubscriptionResponse -} from '../../models/assetSubscriptionResponse'; +import type { AssetSubscriptionResponse } from '../../models/assetSubscriptionResponse' -import type { - PaginatedAssetSubscriptionResponseList -} from '../../models/paginatedAssetSubscriptionResponseList'; +import type { PaginatedAssetSubscriptionResponseList } from '../../models/paginatedAssetSubscriptionResponseList' +export const getApiV2AssetSubscriptionsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetSubscriptionResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) -export const getApiV2AssetSubscriptionsListResponseMock = (overrideResponse: Partial< PaginatedAssetSubscriptionResponseList > = {}): PaginatedAssetSubscriptionResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), asset: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) +export const getApiV2AssetSubscriptionsCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetSubscriptionResponse => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) -export const getApiV2AssetSubscriptionsCreateResponseMock = (overrideResponse: Partial< AssetSubscriptionResponse > = {}): AssetSubscriptionResponse => ({url: faker.internet.url(), asset: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) +export const getApiV2AssetSubscriptionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetSubscriptionResponse => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) -export const getApiV2AssetSubscriptionsRetrieveResponseMock = (overrideResponse: Partial< AssetSubscriptionResponse > = {}): AssetSubscriptionResponse => ({url: faker.internet.url(), asset: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - - -export const getApiV2AssetSubscriptionsListMockHandler = (overrideResponse?: PaginatedAssetSubscriptionResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetSubscriptionResponseList)) => { - return http.get('*/api/v2/asset_subscriptions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetSubscriptionsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetSubscriptionsListMockHandler = ( + overrideResponse?: + | PaginatedAssetSubscriptionResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetSubscriptionResponseList), +) => { + return http.get('*/api/v2/asset_subscriptions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSubscriptionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetSubscriptionsCreateMockHandler = (overrideResponse?: AssetSubscriptionResponse | ((info: Parameters[1]>[0]) => Promise | AssetSubscriptionResponse)) => { - return http.post('*/api/v2/asset_subscriptions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetSubscriptionsCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetSubscriptionsCreateMockHandler = ( + overrideResponse?: + | AssetSubscriptionResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetSubscriptionResponse), +) => { + return http.post('*/api/v2/asset_subscriptions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSubscriptionsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetSubscriptionsRetrieveMockHandler = (overrideResponse?: AssetSubscriptionResponse | ((info: Parameters[1]>[0]) => Promise | AssetSubscriptionResponse)) => { - return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetSubscriptionsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetSubscriptionsRetrieveMockHandler = ( + overrideResponse?: + | AssetSubscriptionResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetSubscriptionResponse), +) => { + return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetSubscriptionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetSubscriptionsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetSubscriptionsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } export const getLibraryCollectionsMock = () => [ getApiV2AssetSubscriptionsListMockHandler(), getApiV2AssetSubscriptionsCreateMockHandler(), getApiV2AssetSubscriptionsRetrieveMockHandler(), - getApiV2AssetSubscriptionsDestroyMockHandler() + getApiV2AssetSubscriptionsDestroyMockHandler(), ] diff --git a/jsapp/js/api/react-query/logging/index.ts b/jsapp/js/api/react-query/logging/index.ts index 51120fbb03..9f5370be03 100644 --- a/jsapp/js/api/react-query/logging/index.ts +++ b/jsapp/js/api/react-query/logging/index.ts @@ -9,61 +9,37 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - AccessLogsMeListParams -} from '../../models/accessLogsMeListParams'; - -import type { - AssetsHistoryListParams -} from '../../models/assetsHistoryListParams'; - -import type { - ErrorDetail -} from '../../models/errorDetail'; - -import type { - ExportCreateResponse -} from '../../models/exportCreateResponse'; +import type { AccessLogsMeListParams } from '../../models/accessLogsMeListParams' -import type { - ExportListResponse -} from '../../models/exportListResponse'; +import type { AssetsHistoryListParams } from '../../models/assetsHistoryListParams' -import type { - HistoryActionResponse -} from '../../models/historyActionResponse'; +import type { ErrorDetail } from '../../models/errorDetail' -import type { - HistoryExportResponse -} from '../../models/historyExportResponse'; +import type { ExportCreateResponse } from '../../models/exportCreateResponse' -import type { - PaginatedAccessLogResponseList -} from '../../models/paginatedAccessLogResponseList'; +import type { ExportListResponse } from '../../models/exportListResponse' -import type { - PaginatedHistoryListResponseList -} from '../../models/paginatedHistoryListResponseList'; +import type { HistoryActionResponse } from '../../models/historyActionResponse' -import { fetchWithAuth } from '../../orval.mutator'; +import type { HistoryExportResponse } from '../../models/historyExportResponse' +import type { PaginatedAccessLogResponseList } from '../../models/paginatedAccessLogResponseList' -type SecondParameter unknown> = Parameters[1]; +import type { PaginatedHistoryListResponseList } from '../../models/paginatedHistoryListResponseList' +import { fetchWithAuth } from '../../orval.mutator' +type SecondParameter unknown> = Parameters[1] /** * ## List all access logs for the authenticated user @@ -99,85 +75,84 @@ export type accessLogsMeListResponse401 = { data: ErrorDetail status: 401 } - -export type accessLogsMeListResponseComposite = accessLogsMeListResponse200 | accessLogsMeListResponse401; - + +export type accessLogsMeListResponseComposite = accessLogsMeListResponse200 | accessLogsMeListResponse401 + export type accessLogsMeListResponse = accessLogsMeListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAccessLogsMeListUrl = (params?: AccessLogsMeListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAccessLogsMeListUrl = (params?: AccessLogsMeListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/access-logs/me/?${stringifiedParams}` : `/api/v2/access-logs/me/` } -export const accessLogsMeList = async (params?: AccessLogsMeListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAccessLogsMeListUrl(params), - { +export const accessLogsMeList = async ( + params?: AccessLogsMeListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAccessLogsMeListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAccessLogsMeListQueryKey = (params?: AccessLogsMeListParams,) => { - return ['api','v2','access-logs','me', ...(params ? [params]: [])] as const; - } +export const getAccessLogsMeListQueryKey = (params?: AccessLogsMeListParams) => { + return ['api', 'v2', 'access-logs', 'me', ...(params ? [params] : [])] as const +} - -export const getAccessLogsMeListQueryOptions = >, TError = ErrorDetail>(params?: AccessLogsMeListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAccessLogsMeListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: AccessLogsMeListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAccessLogsMeListQueryKey(params); - - - - const queryFn: QueryFunction>> = ({ signal }) => accessLogsMeList(params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getAccessLogsMeListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + accessLogsMeList(params, { signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AccessLogsMeListQueryResult = NonNullable>> export type AccessLogsMeListQueryError = ErrorDetail - - export function useAccessLogsMeList>, TError = ErrorDetail>( - params?: AccessLogsMeListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + params?: AccessLogsMeListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAccessLogsMeListQueryOptions(params, options) - const queryOptions = getAccessLogsMeListQueryOptions(params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## List all access logs export tasks for the authenticated user @@ -191,78 +166,70 @@ export type accessLogsMeExportListResponse401 = { data: ErrorDetail status: 401 } - -export type accessLogsMeExportListResponseComposite = accessLogsMeExportListResponse200 | accessLogsMeExportListResponse401; - + +export type accessLogsMeExportListResponseComposite = + | accessLogsMeExportListResponse200 + | accessLogsMeExportListResponse401 + export type accessLogsMeExportListResponse = accessLogsMeExportListResponseComposite & { - headers: Headers; + headers: Headers } export const getAccessLogsMeExportListUrl = () => { - - - - return `/api/v2/access-logs/me/export/` } -export const accessLogsMeExportList = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAccessLogsMeExportListUrl(), - { +export const accessLogsMeExportList = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAccessLogsMeExportListUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAccessLogsMeExportListQueryKey = () => { - return ['api','v2','access-logs','me','export'] as const; - } - - -export const getAccessLogsMeExportListQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAccessLogsMeExportListQueryKey(); - - + return ['api', 'v2', 'access-logs', 'me', 'export'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => accessLogsMeExportList({ signal, ...requestOptions }); +export const getAccessLogsMeExportListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAccessLogsMeExportListQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + accessLogsMeExportList({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AccessLogsMeExportListQueryResult = NonNullable>> export type AccessLogsMeExportListQueryError = ErrorDetail - - -export function useAccessLogsMeExportList>, TError = ErrorDetail>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAccessLogsMeExportList< + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAccessLogsMeExportListQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Create an export task for the authenticated user @@ -276,73 +243,57 @@ export type accessLogsMeExportCreateResponse401 = { data: ErrorDetail status: 401 } - -export type accessLogsMeExportCreateResponseComposite = accessLogsMeExportCreateResponse202 | accessLogsMeExportCreateResponse401; - + +export type accessLogsMeExportCreateResponseComposite = + | accessLogsMeExportCreateResponse202 + | accessLogsMeExportCreateResponse401 + export type accessLogsMeExportCreateResponse = accessLogsMeExportCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getAccessLogsMeExportCreateUrl = () => { - - - - return `/api/v2/access-logs/me/export/` } -export const accessLogsMeExportCreate = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAccessLogsMeExportCreateUrl(), - { +export const accessLogsMeExportCreate = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAccessLogsMeExportCreateUrl(), { ...options, - method: 'POST' - - + method: 'POST', + }) +} + +export const getAccessLogsMeExportCreateMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['accessLogsMeExportCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return accessLogsMeExportCreate(requestOptions) } -);} - - - - -export const getAccessLogsMeExportCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['accessLogsMeExportCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - return accessLogsMeExportCreate(requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AccessLogsMeExportCreateMutationResult = NonNullable>> - - export type AccessLogsMeExportCreateMutationError = ErrorDetail +export type AccessLogsMeExportCreateMutationResult = NonNullable>> - export const useAccessLogsMeExportCreate = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { +export type AccessLogsMeExportCreateMutationError = ErrorDetail - const mutationOptions = getAccessLogsMeExportCreateMutationOptions(options); +export const useAccessLogsMeExportCreate = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}) => { + const mutationOptions = getAccessLogsMeExportCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## List project history logs Lists all project history logs for a single project. @@ -498,90 +449,89 @@ export type assetsHistoryListResponse403 = { data: ErrorDetail status: 403 } - -export type assetsHistoryListResponseComposite = assetsHistoryListResponse200 | assetsHistoryListResponse403; - + +export type assetsHistoryListResponseComposite = assetsHistoryListResponse200 | assetsHistoryListResponse403 + export type assetsHistoryListResponse = assetsHistoryListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsHistoryListUrl = (uidAsset: string, - params?: AssetsHistoryListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsHistoryListUrl = (uidAsset: string, params?: AssetsHistoryListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/history/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/history/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/history/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/history/` } -export const assetsHistoryList = async (uidAsset: string, - params?: AssetsHistoryListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHistoryListUrl(uidAsset,params), - { +export const assetsHistoryList = async ( + uidAsset: string, + params?: AssetsHistoryListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHistoryListUrl(uidAsset, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsHistoryListQueryKey = (uidAsset: string, - params?: AssetsHistoryListParams,) => { - return ['api','v2','assets',uidAsset,'history', ...(params ? [params]: [])] as const; - } +export const getAssetsHistoryListQueryKey = (uidAsset: string, params?: AssetsHistoryListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'history', ...(params ? [params] : [])] as const +} - -export const getAssetsHistoryListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsHistoryListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsHistoryListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsHistoryListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsHistoryListQueryKey(uidAsset,params); + const queryKey = queryOptions?.queryKey ?? getAssetsHistoryListQueryKey(uidAsset, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsHistoryList(uidAsset, params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsHistoryList(uidAsset,params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsHistoryListQueryResult = NonNullable>> export type AssetsHistoryListQueryError = ErrorDetail - - export function useAssetsHistoryList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsHistoryListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsHistoryListQueryOptions(uidAsset,params,options) + uidAsset: string, + params?: AssetsHistoryListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsHistoryListQueryOptions(uidAsset, params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Retrieve distinct actions performed on the project. @@ -595,78 +545,81 @@ export type assetsHistoryActionsRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type assetsHistoryActionsRetrieveResponseComposite = assetsHistoryActionsRetrieveResponse200 | assetsHistoryActionsRetrieveResponse403; - -export type assetsHistoryActionsRetrieveResponse = assetsHistoryActionsRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsHistoryActionsRetrieveUrl = (uidAsset: string,) => { +export type assetsHistoryActionsRetrieveResponseComposite = + | assetsHistoryActionsRetrieveResponse200 + | assetsHistoryActionsRetrieveResponse403 +export type assetsHistoryActionsRetrieveResponse = assetsHistoryActionsRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsHistoryActionsRetrieveUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/history/actions/` } -export const assetsHistoryActionsRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHistoryActionsRetrieveUrl(uidAsset), - { +export const assetsHistoryActionsRetrieve = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHistoryActionsRetrieveUrl(uidAsset), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsHistoryActionsRetrieveQueryKey = (uidAsset: string,) => { - return ['api','v2','assets',uidAsset,'history','actions'] as const; - } +export const getAssetsHistoryActionsRetrieveQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'history', 'actions'] as const +} - -export const getAssetsHistoryActionsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsHistoryActionsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsHistoryActionsRetrieveQueryKey(uidAsset); + const queryKey = queryOptions?.queryKey ?? getAssetsHistoryActionsRetrieveQueryKey(uidAsset) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsHistoryActionsRetrieve(uidAsset, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsHistoryActionsRetrieve(uidAsset, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsHistoryActionsRetrieveQueryResult = NonNullable>> +export type AssetsHistoryActionsRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsHistoryActionsRetrieveQueryError = ErrorDetail +export function useAssetsHistoryActionsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsHistoryActionsRetrieveQueryOptions(uidAsset, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsHistoryActionsRetrieve>, TError = ErrorDetail>( - uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsHistoryActionsRetrieveQueryOptions(uidAsset,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Export current project's history @@ -682,70 +635,75 @@ export type assetsHistoryExportCreateResponse403 = { data: ErrorDetail status: 403 } - -export type assetsHistoryExportCreateResponseComposite = assetsHistoryExportCreateResponse202 | assetsHistoryExportCreateResponse403; - -export type assetsHistoryExportCreateResponse = assetsHistoryExportCreateResponseComposite & { - headers: Headers; -} -export const getAssetsHistoryExportCreateUrl = (uidAsset: string,) => { +export type assetsHistoryExportCreateResponseComposite = + | assetsHistoryExportCreateResponse202 + | assetsHistoryExportCreateResponse403 +export type assetsHistoryExportCreateResponse = assetsHistoryExportCreateResponseComposite & { + headers: Headers +} - - +export const getAssetsHistoryExportCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/history/export/` } -export const assetsHistoryExportCreate = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHistoryExportCreateUrl(uidAsset), - { +export const assetsHistoryExportCreate = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHistoryExportCreateUrl(uidAsset), { ...options, - method: 'POST' - - + method: 'POST', + }) +} + +export const getAssetsHistoryExportCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext +> => { + const mutationKey = ['assetsHistoryExportCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { uidAsset: string }> = ( + props, + ) => { + const { uidAsset } = props ?? {} + + return assetsHistoryExportCreate(uidAsset, requestOptions) } -);} - - - - -export const getAssetsHistoryExportCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { - -const mutationKey = ['assetsHistoryExportCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { - const {uidAsset} = props ?? {}; - - return assetsHistoryExportCreate(uidAsset,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetsHistoryExportCreateMutationResult = NonNullable>> - - export type AssetsHistoryExportCreateMutationError = ErrorDetail +export type AssetsHistoryExportCreateMutationResult = NonNullable>> - export const useAssetsHistoryExportCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsHistoryExportCreateMutationError = ErrorDetail - const mutationOptions = getAssetsHistoryExportCreateMutationOptions(options); +export const useAssetsHistoryExportCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsHistoryExportCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - \ No newline at end of file + return useMutation(mutationOptions) +} diff --git a/jsapp/js/api/react-query/logging/msw.ts b/jsapp/js/api/react-query/logging/msw.ts index 91f47807d8..185e434334 100644 --- a/jsapp/js/api/react-query/logging/msw.ts +++ b/jsapp/js/api/react-query/logging/msw.ts @@ -9,108 +9,392 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; +import { http, HttpResponse } from 'msw' -import type { - ExportCreateResponse -} from '../../models/exportCreateResponse'; +import type { ExportCreateResponse } from '../../models/exportCreateResponse' -import type { - ExportListResponse -} from '../../models/exportListResponse'; +import type { ExportListResponse } from '../../models/exportListResponse' -import type { - HistoryActionResponse -} from '../../models/historyActionResponse'; +import type { HistoryActionResponse } from '../../models/historyActionResponse' -import type { - HistoryExportResponse -} from '../../models/historyExportResponse'; +import type { HistoryExportResponse } from '../../models/historyExportResponse' -import type { - PaginatedAccessLogResponseList -} from '../../models/paginatedAccessLogResponseList'; +import type { PaginatedAccessLogResponseList } from '../../models/paginatedAccessLogResponseList' -import type { - PaginatedHistoryListResponseList -} from '../../models/paginatedHistoryListResponseList'; +import type { PaginatedHistoryListResponseList } from '../../models/paginatedHistoryListResponseList' +export const getApiV2AccessLogsMeListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAccessLogResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + initial_user_username: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + authorized_app_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) -export const getApiV2AccessLogsMeListResponseMock = (overrideResponse: Partial< PaginatedAccessLogResponseList > = {}): PaginatedAccessLogResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, username: faker.string.alpha({length: {min: 10, max: 20}}), metadata: {source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), auth_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), initial_user_username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), authorized_app_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, user_uid: faker.string.alpha({length: {min: 10, max: 20}}), count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), action: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) +export const getApiV2AccessLogsMeExportListResponseMock = (): ExportListResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 24 } }), + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })) -export const getApiV2AccessLogsMeExportListResponseMock = (): ExportListResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 24}}), status: faker.string.alpha({length: {min: 10, max: 32}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`}))) +export const getApiV2AccessLogsMeExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportCreateResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 32 } }), ...overrideResponse }) -export const getApiV2AccessLogsMeExportCreateResponseMock = (overrideResponse: Partial< ExportCreateResponse > = {}): ExportCreateResponse => ({status: faker.string.alpha({length: {min: 10, max: 32}}), ...overrideResponse}) +export const getApiV2AssetsHistoryListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedHistoryListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user: faker.internet.url(), + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + old: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + removed: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + description: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + 'data-table': faker.helpers.arrayElement([ + { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + }, + undefined, + ]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'asset-files': faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + permissions: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + latest_deployed_version_uid: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + submission: faker.helpers.arrayElement([ + { + root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + hook: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + bulk_action: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + params: faker.helpers.arrayElement([{}, undefined]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + total_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + processed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + completed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + failed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + cancelled_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + name: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + shared_fields: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) -export const getApiV2AssetsHistoryListResponseMock = (overrideResponse: Partial< PaginatedHistoryListResponseList > = {}): PaginatedHistoryListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user: faker.internet.url(), user_uid: faker.string.alpha({length: {min: 10, max: 20}}), username: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.string.alpha({length: {min: 10, max: 20}}), metadata: {source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), old: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), country: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), removed: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), description: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country_codes: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), 'data-table': faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined])}, undefined])}, undefined]), asset_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), log_subtype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_owner: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'asset-files': faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), md5_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), download_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), permissions: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), latest_deployed_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submission: faker.helpers.arrayElement([{root_uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submitted_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), hook: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), bulk_action: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), action_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), question_xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), params: faker.helpers.arrayElement([{}, undefined]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cancelled_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), total_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), processed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), completed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), failed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), cancelled_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), name: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), shared_fields: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) +export const getApiV2AssetsHistoryActionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): HistoryActionResponse => ({ + actions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) -export const getApiV2AssetsHistoryActionsRetrieveResponseMock = (overrideResponse: Partial< HistoryActionResponse > = {}): HistoryActionResponse => ({actions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) +export const getApiV2AssetsHistoryExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): HistoryExportResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) -export const getApiV2AssetsHistoryExportCreateResponseMock = (overrideResponse: Partial< HistoryExportResponse > = {}): HistoryExportResponse => ({status: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - - -export const getApiV2AccessLogsMeListMockHandler = (overrideResponse?: PaginatedAccessLogResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAccessLogResponseList)) => { - return http.get('*/api/v2/access-logs/me/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AccessLogsMeListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AccessLogsMeListMockHandler = ( + overrideResponse?: + | PaginatedAccessLogResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAccessLogResponseList), +) => { + return http.get('*/api/v2/access-logs/me/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsMeListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AccessLogsMeExportListMockHandler = (overrideResponse?: ExportListResponse[] | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[])) => { - return http.get('*/api/v2/access-logs/me/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AccessLogsMeExportListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AccessLogsMeExportListMockHandler = ( + overrideResponse?: + | ExportListResponse[] + | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), +) => { + return http.get('*/api/v2/access-logs/me/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsMeExportListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AccessLogsMeExportCreateMockHandler = (overrideResponse?: ExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse)) => { - return http.post('*/api/v2/access-logs/me/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AccessLogsMeExportCreateResponseMock()), - { status: 202, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AccessLogsMeExportCreateMockHandler = ( + overrideResponse?: + | ExportCreateResponse + | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), +) => { + return http.post('*/api/v2/access-logs/me/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsMeExportCreateResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHistoryListMockHandler = (overrideResponse?: PaginatedHistoryListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedHistoryListResponseList)) => { - return http.get('*/api/v2/assets/:uidAsset/history/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHistoryListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHistoryListMockHandler = ( + overrideResponse?: + | PaginatedHistoryListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedHistoryListResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/history/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHistoryListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHistoryActionsRetrieveMockHandler = (overrideResponse?: HistoryActionResponse | ((info: Parameters[1]>[0]) => Promise | HistoryActionResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/history/actions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHistoryActionsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHistoryActionsRetrieveMockHandler = ( + overrideResponse?: + | HistoryActionResponse + | ((info: Parameters[1]>[0]) => Promise | HistoryActionResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/history/actions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHistoryActionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHistoryExportCreateMockHandler = (overrideResponse?: HistoryExportResponse | ((info: Parameters[1]>[0]) => Promise | HistoryExportResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/history/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHistoryExportCreateResponseMock()), - { status: 202, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHistoryExportCreateMockHandler = ( + overrideResponse?: + | HistoryExportResponse + | (( + info: Parameters[1]>[0], + ) => Promise | HistoryExportResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/history/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHistoryExportCreateResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) }) } export const getLoggingMock = () => [ @@ -119,5 +403,5 @@ export const getLoggingMock = () => [ getApiV2AccessLogsMeExportCreateMockHandler(), getApiV2AssetsHistoryListMockHandler(), getApiV2AssetsHistoryActionsRetrieveMockHandler(), - getApiV2AssetsHistoryExportCreateMockHandler() + getApiV2AssetsHistoryExportCreateMockHandler(), ] diff --git a/jsapp/js/api/react-query/manage-permissions/index.ts b/jsapp/js/api/react-query/manage-permissions/index.ts index adcba53f8f..82b8f5bd55 100644 --- a/jsapp/js/api/react-query/manage-permissions/index.ts +++ b/jsapp/js/api/react-query/manage-permissions/index.ts @@ -9,49 +9,31 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - ErrorDetail -} from '../../models/errorDetail'; - -import type { - ErrorObject -} from '../../models/errorObject'; - -import type { - PatchedPermissionAssignmentCloneRequest -} from '../../models/patchedPermissionAssignmentCloneRequest'; +import type { ErrorDetail } from '../../models/errorDetail' -import type { - PermissionAssignmentBulkRequest -} from '../../models/permissionAssignmentBulkRequest'; +import type { ErrorObject } from '../../models/errorObject' -import type { - PermissionAssignmentCreateRequest -} from '../../models/permissionAssignmentCreateRequest'; +import type { PatchedPermissionAssignmentCloneRequest } from '../../models/patchedPermissionAssignmentCloneRequest' -import type { - PermissionAssignmentResponse -} from '../../models/permissionAssignmentResponse'; +import type { PermissionAssignmentBulkRequest } from '../../models/permissionAssignmentBulkRequest' -import { fetchWithAuth } from '../../orval.mutator'; +import type { PermissionAssignmentCreateRequest } from '../../models/permissionAssignmentCreateRequest' +import type { PermissionAssignmentResponse } from '../../models/permissionAssignmentResponse' -type SecondParameter unknown> = Parameters[1]; - +import { fetchWithAuth } from '../../orval.mutator' +type SecondParameter unknown> = Parameters[1] /** * ## List permission assignments @@ -66,78 +48,81 @@ export type assetsPermissionAssignmentsListResponse403 = { data: ErrorDetail status: 403 } - -export type assetsPermissionAssignmentsListResponseComposite = assetsPermissionAssignmentsListResponse200 | assetsPermissionAssignmentsListResponse403; - -export type assetsPermissionAssignmentsListResponse = assetsPermissionAssignmentsListResponseComposite & { - headers: Headers; -} - -export const getAssetsPermissionAssignmentsListUrl = (uidAsset: string,) => { +export type assetsPermissionAssignmentsListResponseComposite = + | assetsPermissionAssignmentsListResponse200 + | assetsPermissionAssignmentsListResponse403 - +export type assetsPermissionAssignmentsListResponse = assetsPermissionAssignmentsListResponseComposite & { + headers: Headers +} +export const getAssetsPermissionAssignmentsListUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/permission-assignments/` } -export const assetsPermissionAssignmentsList = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPermissionAssignmentsListUrl(uidAsset), - { +export const assetsPermissionAssignmentsList = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsPermissionAssignmentsListUrl(uidAsset), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsPermissionAssignmentsListQueryKey = (uidAsset: string,) => { - return ['api','v2','assets',uidAsset,'permission-assignments'] as const; - } +export const getAssetsPermissionAssignmentsListQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'permission-assignments'] as const +} - -export const getAssetsPermissionAssignmentsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsPermissionAssignmentsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getAssetsPermissionAssignmentsListQueryKey(uidAsset) - const queryKey = queryOptions?.queryKey ?? getAssetsPermissionAssignmentsListQueryKey(uidAsset); + const queryFn: QueryFunction>> = ({ signal }) => + assetsPermissionAssignmentsList(uidAsset, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => assetsPermissionAssignmentsList(uidAsset, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsPermissionAssignmentsListQueryResult = NonNullable>> +export type AssetsPermissionAssignmentsListQueryResult = NonNullable< + Awaited> +> export type AssetsPermissionAssignmentsListQueryError = ErrorDetail +export function useAssetsPermissionAssignmentsList< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsPermissionAssignmentsListQueryOptions(uidAsset, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsPermissionAssignmentsList>, TError = ErrorDetail>( - uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsPermissionAssignmentsListQueryOptions(uidAsset,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Assign a permission @@ -161,75 +146,89 @@ export type assetsPermissionAssignmentsCreateResponse403 = { data: ErrorDetail status: 403 } - -export type assetsPermissionAssignmentsCreateResponseComposite = assetsPermissionAssignmentsCreateResponse200 | assetsPermissionAssignmentsCreateResponse400 | assetsPermissionAssignmentsCreateResponse403; - -export type assetsPermissionAssignmentsCreateResponse = assetsPermissionAssignmentsCreateResponseComposite & { - headers: Headers; -} - -export const getAssetsPermissionAssignmentsCreateUrl = (uidAsset: string,) => { +export type assetsPermissionAssignmentsCreateResponseComposite = + | assetsPermissionAssignmentsCreateResponse200 + | assetsPermissionAssignmentsCreateResponse400 + | assetsPermissionAssignmentsCreateResponse403 - +export type assetsPermissionAssignmentsCreateResponse = assetsPermissionAssignmentsCreateResponseComposite & { + headers: Headers +} +export const getAssetsPermissionAssignmentsCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/permission-assignments/` } -export const assetsPermissionAssignmentsCreate = async (uidAsset: string, - permissionAssignmentCreateRequest: PermissionAssignmentCreateRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPermissionAssignmentsCreateUrl(uidAsset), - { +export const assetsPermissionAssignmentsCreate = async ( + uidAsset: string, + permissionAssignmentCreateRequest: PermissionAssignmentCreateRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsPermissionAssignmentsCreateUrl(uidAsset), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - permissionAssignmentCreateRequest,) + body: JSON.stringify(permissionAssignmentCreateRequest), + }) +} + +export const getAssetsPermissionAssignmentsCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PermissionAssignmentCreateRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PermissionAssignmentCreateRequest }, + TContext +> => { + const mutationKey = ['assetsPermissionAssignmentsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: PermissionAssignmentCreateRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsPermissionAssignmentsCreate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsPermissionAssignmentsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentCreateRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentCreateRequest}, TContext> => { - -const mutationKey = ['assetsPermissionAssignmentsCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: PermissionAssignmentCreateRequest}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsPermissionAssignmentsCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsPermissionAssignmentsCreateMutationResult = NonNullable>> - export type AssetsPermissionAssignmentsCreateMutationBody = PermissionAssignmentCreateRequest - export type AssetsPermissionAssignmentsCreateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsPermissionAssignmentsCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentCreateRequest}, TContext>, request?: SecondParameter} - ) => { +export type AssetsPermissionAssignmentsCreateMutationResult = NonNullable< + Awaited> +> +export type AssetsPermissionAssignmentsCreateMutationBody = PermissionAssignmentCreateRequest +export type AssetsPermissionAssignmentsCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsPermissionAssignmentsCreateMutationOptions(options); +export const useAssetsPermissionAssignmentsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PermissionAssignmentCreateRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsPermissionAssignmentsCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retrieve assignments */ @@ -242,83 +241,88 @@ export type assetsPermissionAssignmentsRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type assetsPermissionAssignmentsRetrieveResponseComposite = assetsPermissionAssignmentsRetrieveResponse200 | assetsPermissionAssignmentsRetrieveResponse403; - -export type assetsPermissionAssignmentsRetrieveResponse = assetsPermissionAssignmentsRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsPermissionAssignmentsRetrieveUrl = (uidAsset: string, - uidPermissionAssignment: string,) => { +export type assetsPermissionAssignmentsRetrieveResponseComposite = + | assetsPermissionAssignmentsRetrieveResponse200 + | assetsPermissionAssignmentsRetrieveResponse403 - +export type assetsPermissionAssignmentsRetrieveResponse = assetsPermissionAssignmentsRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsPermissionAssignmentsRetrieveUrl = (uidAsset: string, uidPermissionAssignment: string) => { return `/api/v2/assets/${uidAsset}/permission-assignments/${uidPermissionAssignment}/` } -export const assetsPermissionAssignmentsRetrieve = async (uidAsset: string, - uidPermissionAssignment: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPermissionAssignmentsRetrieveUrl(uidAsset,uidPermissionAssignment), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsPermissionAssignmentsRetrieveQueryKey = (uidAsset: string, - uidPermissionAssignment: string,) => { - return ['api','v2','assets',uidAsset,'permission-assignments',uidPermissionAssignment] as const; - } - - -export const getAssetsPermissionAssignmentsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidPermissionAssignment: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const assetsPermissionAssignmentsRetrieve = async ( + uidAsset: string, + uidPermissionAssignment: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsPermissionAssignmentsRetrieveUrl(uidAsset, uidPermissionAssignment), + { + ...options, + method: 'GET', + }, + ) +} + +export const getAssetsPermissionAssignmentsRetrieveQueryKey = (uidAsset: string, uidPermissionAssignment: string) => { + return ['api', 'v2', 'assets', uidAsset, 'permission-assignments', uidPermissionAssignment] as const +} + +export const getAssetsPermissionAssignmentsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidPermissionAssignment: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsPermissionAssignmentsRetrieveQueryKey(uidAsset,uidPermissionAssignment); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsPermissionAssignmentsRetrieve(uidAsset,uidPermissionAssignment, { signal, ...requestOptions }); + const queryKey = + queryOptions?.queryKey ?? getAssetsPermissionAssignmentsRetrieveQueryKey(uidAsset, uidPermissionAssignment) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsPermissionAssignmentsRetrieve(uidAsset, uidPermissionAssignment, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidPermissionAssignment), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidPermissionAssignment), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsPermissionAssignmentsRetrieveQueryResult = NonNullable>> +export type AssetsPermissionAssignmentsRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsPermissionAssignmentsRetrieveQueryError = ErrorDetail +export function useAssetsPermissionAssignmentsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidPermissionAssignment: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsPermissionAssignmentsRetrieveQueryOptions(uidAsset, uidPermissionAssignment, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsPermissionAssignmentsRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidPermissionAssignment: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsPermissionAssignmentsRetrieveQueryOptions(uidAsset,uidPermissionAssignment,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Remove a permission assignment @@ -332,75 +336,89 @@ export type assetsPermissionAssignmentsDestroyResponse403 = { data: ErrorDetail status: 403 } - -export type assetsPermissionAssignmentsDestroyResponseComposite = assetsPermissionAssignmentsDestroyResponse204 | assetsPermissionAssignmentsDestroyResponse403; - -export type assetsPermissionAssignmentsDestroyResponse = assetsPermissionAssignmentsDestroyResponseComposite & { - headers: Headers; -} - -export const getAssetsPermissionAssignmentsDestroyUrl = (uidAsset: string, - uidPermissionAssignment: string,) => { +export type assetsPermissionAssignmentsDestroyResponseComposite = + | assetsPermissionAssignmentsDestroyResponse204 + | assetsPermissionAssignmentsDestroyResponse403 - +export type assetsPermissionAssignmentsDestroyResponse = assetsPermissionAssignmentsDestroyResponseComposite & { + headers: Headers +} +export const getAssetsPermissionAssignmentsDestroyUrl = (uidAsset: string, uidPermissionAssignment: string) => { return `/api/v2/assets/${uidAsset}/permission-assignments/${uidPermissionAssignment}/` } -export const assetsPermissionAssignmentsDestroy = async (uidAsset: string, - uidPermissionAssignment: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPermissionAssignmentsDestroyUrl(uidAsset,uidPermissionAssignment), - { - ...options, - method: 'DELETE' - - +export const assetsPermissionAssignmentsDestroy = async ( + uidAsset: string, + uidPermissionAssignment: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsPermissionAssignmentsDestroyUrl(uidAsset, uidPermissionAssignment), + { + ...options, + method: 'DELETE', + }, + ) +} + +export const getAssetsPermissionAssignmentsDestroyMutationOptions = < + TError = ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidPermissionAssignment: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidPermissionAssignment: string }, + TContext +> => { + const mutationKey = ['assetsPermissionAssignmentsDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidPermissionAssignment: string } + > = (props) => { + const { uidAsset, uidPermissionAssignment } = props ?? {} + + return assetsPermissionAssignmentsDestroy(uidAsset, uidPermissionAssignment, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} +export type AssetsPermissionAssignmentsDestroyMutationResult = NonNullable< + Awaited> +> -export const getAssetsPermissionAssignmentsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPermissionAssignment: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidPermissionAssignment: string}, TContext> => { - -const mutationKey = ['assetsPermissionAssignmentsDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidPermissionAssignment: string}> = (props) => { - const {uidAsset,uidPermissionAssignment} = props ?? {}; - - return assetsPermissionAssignmentsDestroy(uidAsset,uidPermissionAssignment,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsPermissionAssignmentsDestroyMutationResult = NonNullable>> - - export type AssetsPermissionAssignmentsDestroyMutationError = ErrorDetail - - export const useAssetsPermissionAssignmentsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPermissionAssignment: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsPermissionAssignmentsDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsPermissionAssignmentsDestroyMutationOptions(options); +export const useAssetsPermissionAssignmentsDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidPermissionAssignment: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsPermissionAssignmentsDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Assign multiple permissions at once * Can put both regular and partial permission in the payload @@ -420,75 +438,95 @@ export type assetsPermissionAssignmentsBulkCreateResponse403 = { data: ErrorDetail status: 403 } - -export type assetsPermissionAssignmentsBulkCreateResponseComposite = assetsPermissionAssignmentsBulkCreateResponse200 | assetsPermissionAssignmentsBulkCreateResponse400 | assetsPermissionAssignmentsBulkCreateResponse403; - -export type assetsPermissionAssignmentsBulkCreateResponse = assetsPermissionAssignmentsBulkCreateResponseComposite & { - headers: Headers; -} -export const getAssetsPermissionAssignmentsBulkCreateUrl = (uidAsset: string,) => { +export type assetsPermissionAssignmentsBulkCreateResponseComposite = + | assetsPermissionAssignmentsBulkCreateResponse200 + | assetsPermissionAssignmentsBulkCreateResponse400 + | assetsPermissionAssignmentsBulkCreateResponse403 +export type assetsPermissionAssignmentsBulkCreateResponse = assetsPermissionAssignmentsBulkCreateResponseComposite & { + headers: Headers +} - - +export const getAssetsPermissionAssignmentsBulkCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/permission-assignments/bulk/` } -export const assetsPermissionAssignmentsBulkCreate = async (uidAsset: string, - permissionAssignmentBulkRequest: PermissionAssignmentBulkRequest[], options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPermissionAssignmentsBulkCreateUrl(uidAsset), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - permissionAssignmentBulkRequest,) +export const assetsPermissionAssignmentsBulkCreate = async ( + uidAsset: string, + permissionAssignmentBulkRequest: PermissionAssignmentBulkRequest[], + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsPermissionAssignmentsBulkCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(permissionAssignmentBulkRequest), + }, + ) +} + +export const getAssetsPermissionAssignmentsBulkCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PermissionAssignmentBulkRequest[] }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PermissionAssignmentBulkRequest[] }, + TContext +> => { + const mutationKey = ['assetsPermissionAssignmentsBulkCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: PermissionAssignmentBulkRequest[] } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsPermissionAssignmentsBulkCreate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsPermissionAssignmentsBulkCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentBulkRequest[]}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentBulkRequest[]}, TContext> => { - -const mutationKey = ['assetsPermissionAssignmentsBulkCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: PermissionAssignmentBulkRequest[]}> = (props) => { - const {uidAsset,data} = props ?? {}; - return assetsPermissionAssignmentsBulkCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsPermissionAssignmentsBulkCreateMutationResult = NonNullable>> - export type AssetsPermissionAssignmentsBulkCreateMutationBody = PermissionAssignmentBulkRequest[] - export type AssetsPermissionAssignmentsBulkCreateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsPermissionAssignmentsBulkCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PermissionAssignmentBulkRequest[]}, TContext>, request?: SecondParameter} - ) => { +export type AssetsPermissionAssignmentsBulkCreateMutationResult = NonNullable< + Awaited> +> +export type AssetsPermissionAssignmentsBulkCreateMutationBody = PermissionAssignmentBulkRequest[] +export type AssetsPermissionAssignmentsBulkCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsPermissionAssignmentsBulkCreateMutationOptions(options); +export const useAssetsPermissionAssignmentsBulkCreate = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PermissionAssignmentBulkRequest[] }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsPermissionAssignmentsBulkCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Remove all permission assignments ⚠️ **Warning** @@ -519,73 +557,92 @@ export type assetsPermissionAssignmentsBulkDestroyResponse403 = { data: ErrorDetail status: 403 } - -export type assetsPermissionAssignmentsBulkDestroyResponseComposite = assetsPermissionAssignmentsBulkDestroyResponse204 | assetsPermissionAssignmentsBulkDestroyResponse400 | assetsPermissionAssignmentsBulkDestroyResponse403; - -export type assetsPermissionAssignmentsBulkDestroyResponse = assetsPermissionAssignmentsBulkDestroyResponseComposite & { - headers: Headers; -} -export const getAssetsPermissionAssignmentsBulkDestroyUrl = (uidAsset: string,) => { +export type assetsPermissionAssignmentsBulkDestroyResponseComposite = + | assetsPermissionAssignmentsBulkDestroyResponse204 + | assetsPermissionAssignmentsBulkDestroyResponse400 + | assetsPermissionAssignmentsBulkDestroyResponse403 +export type assetsPermissionAssignmentsBulkDestroyResponse = assetsPermissionAssignmentsBulkDestroyResponseComposite & { + headers: Headers +} - - +export const getAssetsPermissionAssignmentsBulkDestroyUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/permission-assignments/bulk/` } -export const assetsPermissionAssignmentsBulkDestroy = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPermissionAssignmentsBulkDestroyUrl(uidAsset), - { - ...options, - method: 'DELETE' - - +export const assetsPermissionAssignmentsBulkDestroy = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsPermissionAssignmentsBulkDestroyUrl(uidAsset), + { + ...options, + method: 'DELETE', + }, + ) +} + +export const getAssetsPermissionAssignmentsBulkDestroyMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext +> => { + const mutationKey = ['assetsPermissionAssignmentsBulkDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string } + > = (props) => { + const { uidAsset } = props ?? {} + + return assetsPermissionAssignmentsBulkDestroy(uidAsset, requestOptions) } -);} - - - - -export const getAssetsPermissionAssignmentsBulkDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { - -const mutationKey = ['assetsPermissionAssignmentsBulkDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { - const {uidAsset} = props ?? {}; - - return assetsPermissionAssignmentsBulkDestroy(uidAsset,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsPermissionAssignmentsBulkDestroyMutationResult = NonNullable>> - - export type AssetsPermissionAssignmentsBulkDestroyMutationError = ErrorObject | ErrorDetail +export type AssetsPermissionAssignmentsBulkDestroyMutationResult = NonNullable< + Awaited> +> - export const useAssetsPermissionAssignmentsBulkDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsPermissionAssignmentsBulkDestroyMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsPermissionAssignmentsBulkDestroyMutationOptions(options); +export const useAssetsPermissionAssignmentsBulkDestroy = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsPermissionAssignmentsBulkDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Clone permission assignments from another asset using uid Where `clone_from` is the source uid. @@ -605,72 +662,92 @@ export type assetsPermissionAssignmentsClonePartialUpdateResponse403 = { data: ErrorDetail status: 403 } - -export type assetsPermissionAssignmentsClonePartialUpdateResponseComposite = assetsPermissionAssignmentsClonePartialUpdateResponse200 | assetsPermissionAssignmentsClonePartialUpdateResponse400 | assetsPermissionAssignmentsClonePartialUpdateResponse403; - -export type assetsPermissionAssignmentsClonePartialUpdateResponse = assetsPermissionAssignmentsClonePartialUpdateResponseComposite & { - headers: Headers; -} -export const getAssetsPermissionAssignmentsClonePartialUpdateUrl = (uidAsset: string,) => { +export type assetsPermissionAssignmentsClonePartialUpdateResponseComposite = + | assetsPermissionAssignmentsClonePartialUpdateResponse200 + | assetsPermissionAssignmentsClonePartialUpdateResponse400 + | assetsPermissionAssignmentsClonePartialUpdateResponse403 +export type assetsPermissionAssignmentsClonePartialUpdateResponse = + assetsPermissionAssignmentsClonePartialUpdateResponseComposite & { + headers: Headers + } - - +export const getAssetsPermissionAssignmentsClonePartialUpdateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/permission-assignments/clone/` } -export const assetsPermissionAssignmentsClonePartialUpdate = async (uidAsset: string, - patchedPermissionAssignmentCloneRequest: PatchedPermissionAssignmentCloneRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPermissionAssignmentsClonePartialUpdateUrl(uidAsset), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedPermissionAssignmentCloneRequest,) +export const assetsPermissionAssignmentsClonePartialUpdate = async ( + uidAsset: string, + patchedPermissionAssignmentCloneRequest: PatchedPermissionAssignmentCloneRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsPermissionAssignmentsClonePartialUpdateUrl(uidAsset), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedPermissionAssignmentCloneRequest), + }, + ) +} + +export const getAssetsPermissionAssignmentsClonePartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedPermissionAssignmentCloneRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedPermissionAssignmentCloneRequest }, + TContext +> => { + const mutationKey = ['assetsPermissionAssignmentsClonePartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: PatchedPermissionAssignmentCloneRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsPermissionAssignmentsClonePartialUpdate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsPermissionAssignmentsClonePartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedPermissionAssignmentCloneRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: PatchedPermissionAssignmentCloneRequest}, TContext> => { - -const mutationKey = ['assetsPermissionAssignmentsClonePartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: PatchedPermissionAssignmentCloneRequest}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsPermissionAssignmentsClonePartialUpdate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsPermissionAssignmentsClonePartialUpdateMutationResult = NonNullable>> - export type AssetsPermissionAssignmentsClonePartialUpdateMutationBody = PatchedPermissionAssignmentCloneRequest - export type AssetsPermissionAssignmentsClonePartialUpdateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsPermissionAssignmentsClonePartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedPermissionAssignmentCloneRequest}, TContext>, request?: SecondParameter} - ) => { +export type AssetsPermissionAssignmentsClonePartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsPermissionAssignmentsClonePartialUpdateMutationBody = PatchedPermissionAssignmentCloneRequest +export type AssetsPermissionAssignmentsClonePartialUpdateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsPermissionAssignmentsClonePartialUpdateMutationOptions(options); +export const useAssetsPermissionAssignmentsClonePartialUpdate = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedPermissionAssignmentCloneRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsPermissionAssignmentsClonePartialUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - \ No newline at end of file + return useMutation(mutationOptions) +} diff --git a/jsapp/js/api/react-query/manage-permissions/msw.ts b/jsapp/js/api/react-query/manage-permissions/msw.ts index 106e8875ab..f42da318e1 100644 --- a/jsapp/js/api/react-query/manage-permissions/msw.ts +++ b/jsapp/js/api/react-query/manage-permissions/msw.ts @@ -9,94 +9,180 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; - -import { HttpResponse, - http } from 'msw'; - -import type { - PermissionAssignmentResponse -} from '../../models/permissionAssignmentResponse'; - - -export const getApiV2AssetsPermissionAssignmentsListResponseMock = (): PermissionAssignmentResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), user: faker.internet.url(), permission: faker.internet.url(), label: faker.string.alpha({length: {min: 10, max: 20}})}))) - -export const getApiV2AssetsPermissionAssignmentsCreateResponseMock = (overrideResponse: Partial< PermissionAssignmentResponse > = {}): PermissionAssignmentResponse => ({url: faker.internet.url(), user: faker.internet.url(), permission: faker.internet.url(), label: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsPermissionAssignmentsRetrieveResponseMock = (overrideResponse: Partial< PermissionAssignmentResponse > = {}): PermissionAssignmentResponse => ({url: faker.internet.url(), user: faker.internet.url(), permission: faker.internet.url(), label: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock = (): PermissionAssignmentResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), user: faker.internet.url(), permission: faker.internet.url(), label: faker.string.alpha({length: {min: 10, max: 20}})}))) - -export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock = (): PermissionAssignmentResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), user: faker.internet.url(), permission: faker.internet.url(), label: faker.string.alpha({length: {min: 10, max: 20}})}))) - - -export const getApiV2AssetsPermissionAssignmentsListMockHandler = (overrideResponse?: PermissionAssignmentResponse[] | ((info: Parameters[1]>[0]) => Promise | PermissionAssignmentResponse[])) => { - return http.get('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPermissionAssignmentsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import type { PermissionAssignmentResponse } from '../../models/permissionAssignmentResponse' + +export const getApiV2AssetsPermissionAssignmentsListResponseMock = (): PermissionAssignmentResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsPermissionAssignmentsCreateResponseMock = ( + overrideResponse: Partial = {}, +): PermissionAssignmentResponse => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsPermissionAssignmentsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PermissionAssignmentResponse => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock = (): PermissionAssignmentResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock = (): PermissionAssignmentResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + user: faker.internet.url(), + permission: faker.internet.url(), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsPermissionAssignmentsListMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse[]), +) => { + return http.get('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsPermissionAssignmentsCreateMockHandler = (overrideResponse?: PermissionAssignmentResponse | ((info: Parameters[1]>[0]) => Promise | PermissionAssignmentResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPermissionAssignmentsCreateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsPermissionAssignmentsCreateMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = (overrideResponse?: PermissionAssignmentResponse | ((info: Parameters[1]>[0]) => Promise | PermissionAssignmentResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPermissionAssignmentsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsPermissionAssignmentsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsPermissionAssignmentsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = (overrideResponse?: PermissionAssignmentResponse[] | ((info: Parameters[1]>[0]) => Promise | PermissionAssignmentResponse[])) => { - return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse[]), +) => { + return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsBulkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler = (overrideResponse?: PermissionAssignmentResponse[] | ((info: Parameters[1]>[0]) => Promise | PermissionAssignmentResponse[])) => { - return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler = ( + overrideResponse?: + | PermissionAssignmentResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | PermissionAssignmentResponse[]), +) => { + return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPermissionAssignmentsClonePartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } export const getManagePermissionsMock = () => [ @@ -106,5 +192,5 @@ export const getManagePermissionsMock = () => [ getApiV2AssetsPermissionAssignmentsDestroyMockHandler(), getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler(), getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler(), - getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler() + getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler(), ] diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content/index.ts b/jsapp/js/api/react-query/manage-projects-and-library-content/index.ts index 2fa90001ed..9a964a2818 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content/index.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content/index.ts @@ -9,173 +9,93 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - Asset -} from '../../models/asset'; - -import type { - AssetBulkRequest -} from '../../models/assetBulkRequest'; - -import type { - AssetBulkResponse -} from '../../models/assetBulkResponse'; - -import type { - AssetCreateRequest -} from '../../models/assetCreateRequest'; +import type { Asset } from '../../models/asset' -import type { - AssetListCount -} from '../../models/assetListCount'; +import type { AssetBulkRequest } from '../../models/assetBulkRequest' -import type { - AssetMetadataResponse -} from '../../models/assetMetadataResponse'; +import type { AssetBulkResponse } from '../../models/assetBulkResponse' -import type { - AssetsCountsListParams -} from '../../models/assetsCountsListParams'; +import type { AssetCreateRequest } from '../../models/assetCreateRequest' -import type { - AssetsListParams -} from '../../models/assetsListParams'; +import type { AssetListCount } from '../../models/assetListCount' -import type { - AssetsMinimalListRetrieveParams -} from '../../models/assetsMinimalListRetrieveParams'; +import type { AssetMetadataResponse } from '../../models/assetMetadataResponse' -import type { - AssetsRetrieveParams -} from '../../models/assetsRetrieveParams'; +import type { AssetsCountsListParams } from '../../models/assetsCountsListParams' -import type { - AssetsVersionsListParams -} from '../../models/assetsVersionsListParams'; +import type { AssetsListParams } from '../../models/assetsListParams' -import type { - DeploymentCreateRequest -} from '../../models/deploymentCreateRequest'; +import type { AssetsMinimalListRetrieveParams } from '../../models/assetsMinimalListRetrieveParams' -import type { - DeploymentResponse -} from '../../models/deploymentResponse'; +import type { AssetsRetrieveParams } from '../../models/assetsRetrieveParams' -import type { - ErrorDetail -} from '../../models/errorDetail'; +import type { AssetsVersionsListParams } from '../../models/assetsVersionsListParams' -import type { - ErrorObject -} from '../../models/errorObject'; +import type { DeploymentCreateRequest } from '../../models/deploymentCreateRequest' -import type { - HashResponse -} from '../../models/hashResponse'; +import type { DeploymentResponse } from '../../models/deploymentResponse' -import type { - ImportCreateRequest -} from '../../models/importCreateRequest'; +import type { ErrorDetail } from '../../models/errorDetail' -import type { - ImportCreateResponse -} from '../../models/importCreateResponse'; +import type { ErrorObject } from '../../models/errorObject' -import type { - ImportResponse -} from '../../models/importResponse'; +import type { HashResponse } from '../../models/hashResponse' -import type { - ImportsListParams -} from '../../models/importsListParams'; +import type { ImportCreateRequest } from '../../models/importCreateRequest' -import type { - PaginatedAssetCountResponseList -} from '../../models/paginatedAssetCountResponseList'; +import type { ImportCreateResponse } from '../../models/importCreateResponse' -import type { - PaginatedAssetList -} from '../../models/paginatedAssetList'; +import type { ImportResponse } from '../../models/importResponse' -import type { - PaginatedAssetMinimalListList -} from '../../models/paginatedAssetMinimalListList'; +import type { ImportsListParams } from '../../models/importsListParams' -import type { - PaginatedImportResponseList -} from '../../models/paginatedImportResponseList'; +import type { PaginatedAssetCountResponseList } from '../../models/paginatedAssetCountResponseList' -import type { - PaginatedProjectInviteResponseList -} from '../../models/paginatedProjectInviteResponseList'; +import type { PaginatedAssetList } from '../../models/paginatedAssetList' -import type { - PaginatedTagListResponseList -} from '../../models/paginatedTagListResponseList'; +import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' -import type { - PaginatedVersionListResponseList -} from '../../models/paginatedVersionListResponseList'; +import type { PaginatedImportResponseList } from '../../models/paginatedImportResponseList' -import type { - PatchedAssetPatchRequest -} from '../../models/patchedAssetPatchRequest'; +import type { PaginatedProjectInviteResponseList } from '../../models/paginatedProjectInviteResponseList' -import type { - PatchedDeploymentPatchRequest -} from '../../models/patchedDeploymentPatchRequest'; +import type { PaginatedTagListResponseList } from '../../models/paginatedTagListResponseList' -import type { - PatchedInviteUpdatePayload -} from '../../models/patchedInviteUpdatePayload'; +import type { PaginatedVersionListResponseList } from '../../models/paginatedVersionListResponseList' -import type { - ProjectInviteCreatePayload -} from '../../models/projectInviteCreatePayload'; +import type { PatchedAssetPatchRequest } from '../../models/patchedAssetPatchRequest' -import type { - ProjectInviteResponse -} from '../../models/projectInviteResponse'; +import type { PatchedDeploymentPatchRequest } from '../../models/patchedDeploymentPatchRequest' -import type { - ProjectOwnershipInvitesListParams -} from '../../models/projectOwnershipInvitesListParams'; +import type { PatchedInviteUpdatePayload } from '../../models/patchedInviteUpdatePayload' -import type { - TagRetrieveResponse -} from '../../models/tagRetrieveResponse'; +import type { ProjectInviteCreatePayload } from '../../models/projectInviteCreatePayload' -import type { - TagsListParams -} from '../../models/tagsListParams'; +import type { ProjectInviteResponse } from '../../models/projectInviteResponse' -import type { - TransferListResponse -} from '../../models/transferListResponse'; +import type { ProjectOwnershipInvitesListParams } from '../../models/projectOwnershipInvitesListParams' -import type { - VersionRetrieveResponse -} from '../../models/versionRetrieveResponse'; +import type { TagRetrieveResponse } from '../../models/tagRetrieveResponse' -import { fetchWithAuth } from '../../orval.mutator'; +import type { TagsListParams } from '../../models/tagsListParams' +import type { TransferListResponse } from '../../models/transferListResponse' -type SecondParameter unknown> = Parameters[1]; +import type { VersionRetrieveResponse } from '../../models/versionRetrieveResponse' +import { fetchWithAuth } from '../../orval.mutator' +type SecondParameter unknown> = Parameters[1] /** * ## Get user's assets @@ -222,85 +142,78 @@ export type assetsListResponse200 = { data: PaginatedAssetList status: 200 } - -export type assetsListResponseComposite = assetsListResponse200; - + +export type assetsListResponseComposite = assetsListResponse200 + export type assetsListResponse = assetsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsListUrl = (params?: AssetsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsListUrl = (params?: AssetsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/assets/?${stringifiedParams}` : `/api/v2/assets/` } export const assetsList = async (params?: AssetsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsListUrl(params), - { + return fetchWithAuth(getAssetsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsListQueryKey = (params?: AssetsListParams,) => { - return ['api','v2','assets', ...(params ? [params]: [])] as const; - } +export const getAssetsListQueryKey = (params?: AssetsListParams) => { + return ['api', 'v2', 'assets', ...(params ? [params] : [])] as const +} - -export const getAssetsListQueryOptions = >, TError = unknown>(params?: AssetsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsListQueryOptions = >, TError = unknown>( + params?: AssetsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getAssetsListQueryKey(params) - const queryKey = queryOptions?.queryKey ?? getAssetsListQueryKey(params); + const queryFn: QueryFunction>> = ({ signal }) => + assetsList(params, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => assetsList(params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsListQueryResult = NonNullable>> export type AssetsListQueryError = unknown - - export function useAssetsList>, TError = unknown>( - params?: AssetsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + params?: AssetsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsListQueryOptions(params, options) - const queryOptions = getAssetsListQueryOptions(params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Create or clone an asset @@ -337,74 +250,74 @@ export type assetsCreateResponse401 = { data: ErrorDetail status: 401 } - -export type assetsCreateResponseComposite = assetsCreateResponse201 | assetsCreateResponse400 | assetsCreateResponse401; - + +export type assetsCreateResponseComposite = assetsCreateResponse201 | assetsCreateResponse400 | assetsCreateResponse401 + export type assetsCreateResponse = assetsCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getAssetsCreateUrl = () => { - - - - return `/api/v2/assets/` } -export const assetsCreate = async (assetCreateRequest: AssetCreateRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsCreateUrl(), - { +export const assetsCreate = async ( + assetCreateRequest: AssetCreateRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsCreateUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - assetCreateRequest,) + body: JSON.stringify(assetCreateRequest), + }) +} + +export const getAssetsCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetCreateRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, { data: AssetCreateRequest }, TContext> => { + const mutationKey = ['assetsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: AssetCreateRequest }> = ( + props, + ) => { + const { data } = props ?? {} + + return assetsCreate(data, requestOptions) } -);} - - + return { mutationFn, ...mutationOptions } +} -export const getAssetsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetCreateRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: AssetCreateRequest}, TContext> => { - -const mutationKey = ['assetsCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: AssetCreateRequest}> = (props) => { - const {data} = props ?? {}; - - return assetsCreate(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsCreateMutationResult = NonNullable>> - export type AssetsCreateMutationBody = AssetCreateRequest - export type AssetsCreateMutationError = ErrorObject | ErrorDetail - - export const useAssetsCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetCreateRequest}, TContext>, request?: SecondParameter} - ) => { +export type AssetsCreateMutationResult = NonNullable>> +export type AssetsCreateMutationBody = AssetCreateRequest +export type AssetsCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsCreateMutationOptions(options); +export const useAssetsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetCreateRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Get a user's current asset */ @@ -417,90 +330,86 @@ export type assetsRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsRetrieveResponseComposite = assetsRetrieveResponse200 | assetsRetrieveResponse404; - + +export type assetsRetrieveResponseComposite = assetsRetrieveResponse200 | assetsRetrieveResponse404 + export type assetsRetrieveResponse = assetsRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsRetrieveUrl = (uidAsset: string, - params?: AssetsRetrieveParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsRetrieveUrl = (uidAsset: string, params?: AssetsRetrieveParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/` } -export const assetsRetrieve = async (uidAsset: string, - params?: AssetsRetrieveParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsRetrieveUrl(uidAsset,params), - { +export const assetsRetrieve = async ( + uidAsset: string, + params?: AssetsRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsRetrieveUrl(uidAsset, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsRetrieveQueryKey = (uidAsset: string, - params?: AssetsRetrieveParams,) => { - return ['api','v2','assets',uidAsset, ...(params ? [params]: [])] as const; - } +export const getAssetsRetrieveQueryKey = (uidAsset: string, params?: AssetsRetrieveParams) => { + return ['api', 'v2', 'assets', uidAsset, ...(params ? [params] : [])] as const +} - -export const getAssetsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsRetrieveQueryOptions = >, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsRetrieveQueryKey(uidAsset,params); - - + const queryKey = queryOptions?.queryKey ?? getAssetsRetrieveQueryKey(uidAsset, params) - const queryFn: QueryFunction>> = ({ signal }) => assetsRetrieve(uidAsset,params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetsRetrieve(uidAsset, params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsRetrieveQueryResult = NonNullable>> export type AssetsRetrieveQueryError = ErrorDetail - - export function useAssetsRetrieve>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + uidAsset: string, + params?: AssetsRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsRetrieveQueryOptions(uidAsset, params, options) - const queryOptions = getAssetsRetrieveQueryOptions(uidAsset,params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Update or connect a user's asset @@ -528,75 +437,87 @@ export type assetsPartialUpdateResponse401 = { data: ErrorDetail status: 401 } - -export type assetsPartialUpdateResponseComposite = assetsPartialUpdateResponse200 | assetsPartialUpdateResponse400 | assetsPartialUpdateResponse401; - -export type assetsPartialUpdateResponse = assetsPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getAssetsPartialUpdateUrl = (uidAsset: string,) => { +export type assetsPartialUpdateResponseComposite = + | assetsPartialUpdateResponse200 + | assetsPartialUpdateResponse400 + | assetsPartialUpdateResponse401 - +export type assetsPartialUpdateResponse = assetsPartialUpdateResponseComposite & { + headers: Headers +} +export const getAssetsPartialUpdateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/` } -export const assetsPartialUpdate = async (uidAsset: string, - patchedAssetPatchRequest: PatchedAssetPatchRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPartialUpdateUrl(uidAsset), - { +export const assetsPartialUpdate = async ( + uidAsset: string, + patchedAssetPatchRequest: PatchedAssetPatchRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsPartialUpdateUrl(uidAsset), { ...options, method: 'PATCH', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedAssetPatchRequest,) + body: JSON.stringify(patchedAssetPatchRequest), + }) +} + +export const getAssetsPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedAssetPatchRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedAssetPatchRequest }, + TContext +> => { + const mutationKey = ['assetsPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: PatchedAssetPatchRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsPartialUpdate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedAssetPatchRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: PatchedAssetPatchRequest}, TContext> => { - -const mutationKey = ['assetsPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: PatchedAssetPatchRequest}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsPartialUpdate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - export type AssetsPartialUpdateMutationResult = NonNullable>> - export type AssetsPartialUpdateMutationBody = PatchedAssetPatchRequest - export type AssetsPartialUpdateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedAssetPatchRequest}, TContext>, request?: SecondParameter} - ) => { +export type AssetsPartialUpdateMutationResult = NonNullable>> +export type AssetsPartialUpdateMutationBody = PatchedAssetPatchRequest +export type AssetsPartialUpdateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsPartialUpdateMutationOptions(options); +export const useAssetsPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedAssetPatchRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsPartialUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Delete a user's asset */ @@ -609,73 +530,57 @@ export type assetsDestroyResponse401 = { data: ErrorDetail status: 401 } - -export type assetsDestroyResponseComposite = assetsDestroyResponse204 | assetsDestroyResponse401; - -export type assetsDestroyResponse = assetsDestroyResponseComposite & { - headers: Headers; -} -export const getAssetsDestroyUrl = (uidAsset: string,) => { +export type assetsDestroyResponseComposite = assetsDestroyResponse204 | assetsDestroyResponse401 +export type assetsDestroyResponse = assetsDestroyResponseComposite & { + headers: Headers +} - - +export const getAssetsDestroyUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/` } export const assetsDestroy = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDestroyUrl(uidAsset), - { + return fetchWithAuth(getAssetsDestroyUrl(uidAsset), { ...options, - method: 'DELETE' - - - } -);} - - - - -export const getAssetsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { - -const mutationKey = ['assetsDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { - const {uidAsset} = props ?? {}; + method: 'DELETE', + }) +} - return assetsDestroy(uidAsset,requestOptions) - } +export const getAssetsDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, { uidAsset: string }, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, { uidAsset: string }, TContext> => { + const mutationKey = ['assetsDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } - + const mutationFn: MutationFunction>, { uidAsset: string }> = (props) => { + const { uidAsset } = props ?? {} + return assetsDestroy(uidAsset, requestOptions) + } - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetsDestroyMutationResult = NonNullable>> - - export type AssetsDestroyMutationError = ErrorDetail +export type AssetsDestroyMutationResult = NonNullable>> - export const useAssetsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsDestroyMutationOptions(options); +export const useAssetsDestroy = (options?: { + mutation?: UseMutationOptions>, TError, { uidAsset: string }, TContext> + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Count the daily amount of submissions Returns up to the last 31 days of daily counts and total counts of submissions to a survey. @@ -699,90 +604,89 @@ export type assetsCountsListResponse401 = { data: ErrorDetail status: 401 } - -export type assetsCountsListResponseComposite = assetsCountsListResponse200 | assetsCountsListResponse401; - + +export type assetsCountsListResponseComposite = assetsCountsListResponse200 | assetsCountsListResponse401 + export type assetsCountsListResponse = assetsCountsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsCountsListUrl = (uidAsset: string, - params?: AssetsCountsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsCountsListUrl = (uidAsset: string, params?: AssetsCountsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/counts/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/counts/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/counts/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/counts/` } -export const assetsCountsList = async (uidAsset: string, - params?: AssetsCountsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsCountsListUrl(uidAsset,params), - { +export const assetsCountsList = async ( + uidAsset: string, + params?: AssetsCountsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsCountsListUrl(uidAsset, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsCountsListQueryKey = (uidAsset: string, - params?: AssetsCountsListParams,) => { - return ['api','v2','assets',uidAsset,'counts', ...(params ? [params]: [])] as const; - } +export const getAssetsCountsListQueryKey = (uidAsset: string, params?: AssetsCountsListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'counts', ...(params ? [params] : [])] as const +} - -export const getAssetsCountsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsCountsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsCountsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsCountsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getAssetsCountsListQueryKey(uidAsset, params) - const queryKey = queryOptions?.queryKey ?? getAssetsCountsListQueryKey(uidAsset,params); + const queryFn: QueryFunction>> = ({ signal }) => + assetsCountsList(uidAsset, params, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => assetsCountsList(uidAsset,params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsCountsListQueryResult = NonNullable>> export type AssetsCountsListQueryError = ErrorDetail - - export function useAssetsCountsList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsCountsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + uidAsset: string, + params?: AssetsCountsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsCountsListQueryOptions(uidAsset, params, options) - const queryOptions = getAssetsCountsListQueryOptions(uidAsset,params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Retrieve the existing deployment (if any) @@ -796,78 +700,79 @@ export type assetsDeploymentRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDeploymentRetrieveResponseComposite = assetsDeploymentRetrieveResponse200 | assetsDeploymentRetrieveResponse404; - -export type assetsDeploymentRetrieveResponse = assetsDeploymentRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsDeploymentRetrieveUrl = (uidAsset: string,) => { +export type assetsDeploymentRetrieveResponseComposite = + | assetsDeploymentRetrieveResponse200 + | assetsDeploymentRetrieveResponse404 - +export type assetsDeploymentRetrieveResponse = assetsDeploymentRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsDeploymentRetrieveUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/deployment/` } -export const assetsDeploymentRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDeploymentRetrieveUrl(uidAsset), - { +export const assetsDeploymentRetrieve = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDeploymentRetrieveUrl(uidAsset), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsDeploymentRetrieveQueryKey = (uidAsset: string,) => { - return ['api','v2','assets',uidAsset,'deployment'] as const; - } +export const getAssetsDeploymentRetrieveQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'deployment'] as const +} - -export const getAssetsDeploymentRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsDeploymentRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsDeploymentRetrieveQueryKey(uidAsset); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsDeploymentRetrieve(uidAsset, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getAssetsDeploymentRetrieveQueryKey(uidAsset) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsDeploymentRetrieve(uidAsset, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsDeploymentRetrieveQueryResult = NonNullable>> export type AssetsDeploymentRetrieveQueryError = ErrorDetail +export function useAssetsDeploymentRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDeploymentRetrieveQueryOptions(uidAsset, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsDeploymentRetrieve>, TError = ErrorDetail>( - uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getAssetsDeploymentRetrieveQueryOptions(uidAsset,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## (Re)Deploy a form @@ -888,75 +793,87 @@ export type assetsDeploymentCreateResponse401 = { data: ErrorDetail status: 401 } - -export type assetsDeploymentCreateResponseComposite = assetsDeploymentCreateResponse200 | assetsDeploymentCreateResponse400 | assetsDeploymentCreateResponse401; - -export type assetsDeploymentCreateResponse = assetsDeploymentCreateResponseComposite & { - headers: Headers; -} - -export const getAssetsDeploymentCreateUrl = (uidAsset: string,) => { +export type assetsDeploymentCreateResponseComposite = + | assetsDeploymentCreateResponse200 + | assetsDeploymentCreateResponse400 + | assetsDeploymentCreateResponse401 - +export type assetsDeploymentCreateResponse = assetsDeploymentCreateResponseComposite & { + headers: Headers +} +export const getAssetsDeploymentCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/deployment/` } -export const assetsDeploymentCreate = async (uidAsset: string, - deploymentCreateRequest: DeploymentCreateRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDeploymentCreateUrl(uidAsset), - { +export const assetsDeploymentCreate = async ( + uidAsset: string, + deploymentCreateRequest: DeploymentCreateRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDeploymentCreateUrl(uidAsset), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - deploymentCreateRequest,) + body: JSON.stringify(deploymentCreateRequest), + }) +} + +export const getAssetsDeploymentCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: DeploymentCreateRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: DeploymentCreateRequest }, + TContext +> => { + const mutationKey = ['assetsDeploymentCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: DeploymentCreateRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsDeploymentCreate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsDeploymentCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: DeploymentCreateRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: DeploymentCreateRequest}, TContext> => { - -const mutationKey = ['assetsDeploymentCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {uidAsset: string;data: DeploymentCreateRequest}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsDeploymentCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsDeploymentCreateMutationResult = NonNullable>> - export type AssetsDeploymentCreateMutationBody = DeploymentCreateRequest - export type AssetsDeploymentCreateMutationError = ErrorObject | ErrorDetail - - export const useAssetsDeploymentCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: DeploymentCreateRequest}, TContext>, request?: SecondParameter} - ) => { +export type AssetsDeploymentCreateMutationResult = NonNullable>> +export type AssetsDeploymentCreateMutationBody = DeploymentCreateRequest +export type AssetsDeploymentCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsDeploymentCreateMutationOptions(options); +export const useAssetsDeploymentCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: DeploymentCreateRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDeploymentCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## (Un)Archive the existing deployment. Update the `active` field of the existing deployment. @@ -978,75 +895,89 @@ export type assetsDeploymentPartialUpdateResponse401 = { data: ErrorDetail status: 401 } - -export type assetsDeploymentPartialUpdateResponseComposite = assetsDeploymentPartialUpdateResponse200 | assetsDeploymentPartialUpdateResponse400 | assetsDeploymentPartialUpdateResponse401; - -export type assetsDeploymentPartialUpdateResponse = assetsDeploymentPartialUpdateResponseComposite & { - headers: Headers; -} -export const getAssetsDeploymentPartialUpdateUrl = (uidAsset: string,) => { +export type assetsDeploymentPartialUpdateResponseComposite = + | assetsDeploymentPartialUpdateResponse200 + | assetsDeploymentPartialUpdateResponse400 + | assetsDeploymentPartialUpdateResponse401 +export type assetsDeploymentPartialUpdateResponse = assetsDeploymentPartialUpdateResponseComposite & { + headers: Headers +} - - +export const getAssetsDeploymentPartialUpdateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/deployment/` } -export const assetsDeploymentPartialUpdate = async (uidAsset: string, - patchedDeploymentPatchRequest: PatchedDeploymentPatchRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDeploymentPartialUpdateUrl(uidAsset), - { +export const assetsDeploymentPartialUpdate = async ( + uidAsset: string, + patchedDeploymentPatchRequest: PatchedDeploymentPatchRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDeploymentPartialUpdateUrl(uidAsset), { ...options, method: 'PATCH', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedDeploymentPatchRequest,) + body: JSON.stringify(patchedDeploymentPatchRequest), + }) +} + +export const getAssetsDeploymentPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDeploymentPatchRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDeploymentPatchRequest }, + TContext +> => { + const mutationKey = ['assetsDeploymentPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: PatchedDeploymentPatchRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsDeploymentPartialUpdate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsDeploymentPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDeploymentPatchRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: PatchedDeploymentPatchRequest}, TContext> => { - -const mutationKey = ['assetsDeploymentPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: PatchedDeploymentPatchRequest}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsDeploymentPartialUpdate(uidAsset,data,requestOptions) - } - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsDeploymentPartialUpdateMutationResult = NonNullable>> - export type AssetsDeploymentPartialUpdateMutationBody = PatchedDeploymentPatchRequest - export type AssetsDeploymentPartialUpdateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsDeploymentPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDeploymentPatchRequest}, TContext>, request?: SecondParameter} - ) => { +export type AssetsDeploymentPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsDeploymentPartialUpdateMutationBody = PatchedDeploymentPatchRequest +export type AssetsDeploymentPartialUpdateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsDeploymentPartialUpdateMutationOptions(options); +export const useAssetsDeploymentPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDeploymentPatchRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDeploymentPartialUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## List the versions of forms */ @@ -1059,90 +990,89 @@ export type assetsVersionsListResponse404 = { data: ErrorDetail status: 404 } - -export type assetsVersionsListResponseComposite = assetsVersionsListResponse200 | assetsVersionsListResponse404; - + +export type assetsVersionsListResponseComposite = assetsVersionsListResponse200 | assetsVersionsListResponse404 + export type assetsVersionsListResponse = assetsVersionsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsVersionsListUrl = (uidAsset: string, - params?: AssetsVersionsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsVersionsListUrl = (uidAsset: string, params?: AssetsVersionsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/versions/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/versions/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/versions/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/versions/` } -export const assetsVersionsList = async (uidAsset: string, - params?: AssetsVersionsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsVersionsListUrl(uidAsset,params), - { +export const assetsVersionsList = async ( + uidAsset: string, + params?: AssetsVersionsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsVersionsListUrl(uidAsset, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsVersionsListQueryKey = (uidAsset: string, - params?: AssetsVersionsListParams,) => { - return ['api','v2','assets',uidAsset,'versions', ...(params ? [params]: [])] as const; - } +export const getAssetsVersionsListQueryKey = (uidAsset: string, params?: AssetsVersionsListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'versions', ...(params ? [params] : [])] as const +} - -export const getAssetsVersionsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsVersionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsVersionsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsVersionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsVersionsListQueryKey(uidAsset,params); + const queryKey = queryOptions?.queryKey ?? getAssetsVersionsListQueryKey(uidAsset, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsVersionsList(uidAsset, params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsVersionsList(uidAsset,params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsVersionsListQueryResult = NonNullable>> export type AssetsVersionsListQueryError = ErrorDetail - - export function useAssetsVersionsList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsVersionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsVersionsListQueryOptions(uidAsset,params,options) + uidAsset: string, + params?: AssetsVersionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsVersionsListQueryOptions(uidAsset, params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Retrieve asset versions @@ -1158,83 +1088,82 @@ export type assetsVersionsRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsVersionsRetrieveResponseComposite = assetsVersionsRetrieveResponse200 | assetsVersionsRetrieveResponse404; - -export type assetsVersionsRetrieveResponse = assetsVersionsRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsVersionsRetrieveUrl = (uidAsset: string, - uidVersion: string,) => { +export type assetsVersionsRetrieveResponseComposite = + | assetsVersionsRetrieveResponse200 + | assetsVersionsRetrieveResponse404 +export type assetsVersionsRetrieveResponse = assetsVersionsRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsVersionsRetrieveUrl = (uidAsset: string, uidVersion: string) => { return `/api/v2/assets/${uidAsset}/versions/${uidVersion}/` } -export const assetsVersionsRetrieve = async (uidAsset: string, - uidVersion: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsVersionsRetrieveUrl(uidAsset,uidVersion), - { +export const assetsVersionsRetrieve = async ( + uidAsset: string, + uidVersion: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsVersionsRetrieveUrl(uidAsset, uidVersion), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsVersionsRetrieveQueryKey = (uidAsset: string, - uidVersion: string,) => { - return ['api','v2','assets',uidAsset,'versions',uidVersion] as const; - } +export const getAssetsVersionsRetrieveQueryKey = (uidAsset: string, uidVersion: string) => { + return ['api', 'v2', 'assets', uidAsset, 'versions', uidVersion] as const +} - -export const getAssetsVersionsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidVersion: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsVersionsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidVersion: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsVersionsRetrieveQueryKey(uidAsset,uidVersion); + const queryKey = queryOptions?.queryKey ?? getAssetsVersionsRetrieveQueryKey(uidAsset, uidVersion) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsVersionsRetrieve(uidAsset, uidVersion, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsVersionsRetrieve(uidAsset,uidVersion, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidVersion), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidVersion), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsVersionsRetrieveQueryResult = NonNullable>> export type AssetsVersionsRetrieveQueryError = ErrorDetail +export function useAssetsVersionsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidVersion: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsVersionsRetrieveQueryOptions(uidAsset, uidVersion, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsVersionsRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidVersion: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsVersionsRetrieveQueryOptions(uidAsset,uidVersion,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## This route will render the XForm into syntax-highlighted HTML. @@ -1250,78 +1179,74 @@ export type assetsXformRetrieveResponse404 = { data: void status: 404 } - -export type assetsXformRetrieveResponseComposite = assetsXformRetrieveResponse200 | assetsXformRetrieveResponse404; - + +export type assetsXformRetrieveResponseComposite = assetsXformRetrieveResponse200 | assetsXformRetrieveResponse404 + export type assetsXformRetrieveResponse = assetsXformRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsXformRetrieveUrl = (uidAsset: string,) => { +export const getAssetsXformRetrieveUrl = (uidAsset: string) => { + return `/api/v2/assets/${uidAsset}/xform/` +} - - - - return `/api/v2/assets/${uidAsset}/xform/` -} - -export const assetsXformRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsXformRetrieveUrl(uidAsset), - { +export const assetsXformRetrieve = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsXformRetrieveUrl(uidAsset), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsXformRetrieveQueryKey = (uidAsset: string,) => { - return ['api','v2','assets',uidAsset,'xform'] as const; - } +export const getAssetsXformRetrieveQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'xform'] as const +} - -export const getAssetsXformRetrieveQueryOptions = >, TError = void>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsXformRetrieveQueryOptions = < + TData = Awaited>, + TError = void, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getAssetsXformRetrieveQueryKey(uidAsset) - const queryKey = queryOptions?.queryKey ?? getAssetsXformRetrieveQueryKey(uidAsset); + const queryFn: QueryFunction>> = ({ signal }) => + assetsXformRetrieve(uidAsset, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => assetsXformRetrieve(uidAsset, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsXformRetrieveQueryResult = NonNullable>> export type AssetsXformRetrieveQueryError = void - - export function useAssetsXformRetrieve>, TError = void>( - uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsXformRetrieveQueryOptions(uidAsset, options) - const queryOptions = getAssetsXformRetrieveQueryOptions(uidAsset,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Perform bulk actions on assets @@ -1342,74 +1267,74 @@ export type assetsBulkCreateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsBulkCreateResponseComposite = assetsBulkCreateResponse200 | assetsBulkCreateResponse404; - + +export type assetsBulkCreateResponseComposite = assetsBulkCreateResponse200 | assetsBulkCreateResponse404 + export type assetsBulkCreateResponse = assetsBulkCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getAssetsBulkCreateUrl = () => { - - - - return `/api/v2/assets/bulk/` } -export const assetsBulkCreate = async (assetBulkRequest: AssetBulkRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsBulkCreateUrl(), - { +export const assetsBulkCreate = async ( + assetBulkRequest: AssetBulkRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsBulkCreateUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - assetBulkRequest,) + body: JSON.stringify(assetBulkRequest), + }) +} + +export const getAssetsBulkCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetBulkRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, { data: AssetBulkRequest }, TContext> => { + const mutationKey = ['assetsBulkCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: AssetBulkRequest }> = ( + props, + ) => { + const { data } = props ?? {} + + return assetsBulkCreate(data, requestOptions) } -);} - - - - -export const getAssetsBulkCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetBulkRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: AssetBulkRequest}, TContext> => { - -const mutationKey = ['assetsBulkCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: AssetBulkRequest}> = (props) => { - const {data} = props ?? {}; - return assetsBulkCreate(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsBulkCreateMutationResult = NonNullable>> - export type AssetsBulkCreateMutationBody = AssetBulkRequest - export type AssetsBulkCreateMutationError = ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsBulkCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: AssetBulkRequest}, TContext>, request?: SecondParameter} - ) => { +export type AssetsBulkCreateMutationResult = NonNullable>> +export type AssetsBulkCreateMutationBody = AssetBulkRequest +export type AssetsBulkCreateMutationError = ErrorDetail - const mutationOptions = getAssetsBulkCreateMutationOptions(options); +export const useAssetsBulkCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: AssetBulkRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsBulkCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Return counts of deployed, archived, and draft assets */ @@ -1417,78 +1342,68 @@ export type assetsCountsRetrieveResponse200 = { data: AssetListCount status: 200 } - -export type assetsCountsRetrieveResponseComposite = assetsCountsRetrieveResponse200; - + +export type assetsCountsRetrieveResponseComposite = assetsCountsRetrieveResponse200 + export type assetsCountsRetrieveResponse = assetsCountsRetrieveResponseComposite & { - headers: Headers; + headers: Headers } export const getAssetsCountsRetrieveUrl = () => { - - - - return `/api/v2/assets/counts/` } -export const assetsCountsRetrieve = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsCountsRetrieveUrl(), - { +export const assetsCountsRetrieve = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAssetsCountsRetrieveUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAssetsCountsRetrieveQueryKey = () => { - return ['api','v2','assets','counts'] as const; - } - - -export const getAssetsCountsRetrieveQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsCountsRetrieveQueryKey(); - - + return ['api', 'v2', 'assets', 'counts'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => assetsCountsRetrieve({ signal, ...requestOptions }); +export const getAssetsCountsRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAssetsCountsRetrieveQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + assetsCountsRetrieve({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsCountsRetrieveQueryResult = NonNullable>> export type AssetsCountsRetrieveQueryError = unknown - - -export function useAssetsCountsRetrieve>, TError = unknown>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAssetsCountsRetrieve< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAssetsCountsRetrieveQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Get a hash of all `version_id`s of all accessible assets by the current user. @@ -1504,78 +1419,68 @@ export type assetsHashRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type assetsHashRetrieveResponseComposite = assetsHashRetrieveResponse200 | assetsHashRetrieveResponse401; - + +export type assetsHashRetrieveResponseComposite = assetsHashRetrieveResponse200 | assetsHashRetrieveResponse401 + export type assetsHashRetrieveResponse = assetsHashRetrieveResponseComposite & { - headers: Headers; + headers: Headers } export const getAssetsHashRetrieveUrl = () => { - - - - return `/api/v2/assets/hash/` } -export const assetsHashRetrieve = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHashRetrieveUrl(), - { +export const assetsHashRetrieve = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAssetsHashRetrieveUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAssetsHashRetrieveQueryKey = () => { - return ['api','v2','assets','hash'] as const; - } - - -export const getAssetsHashRetrieveQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsHashRetrieveQueryKey(); - - + return ['api', 'v2', 'assets', 'hash'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => assetsHashRetrieve({ signal, ...requestOptions }); +export const getAssetsHashRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAssetsHashRetrieveQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + assetsHashRetrieve({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsHashRetrieveQueryResult = NonNullable>> export type AssetsHashRetrieveQueryError = ErrorDetail - - -export function useAssetsHashRetrieve>, TError = ErrorDetail>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAssetsHashRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAssetsHashRetrieveQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Get metadata for all authenticated user' assets @@ -1584,78 +1489,68 @@ export type assetsMetadataRetrieveResponse200 = { data: AssetMetadataResponse status: 200 } - -export type assetsMetadataRetrieveResponseComposite = assetsMetadataRetrieveResponse200; - + +export type assetsMetadataRetrieveResponseComposite = assetsMetadataRetrieveResponse200 + export type assetsMetadataRetrieveResponse = assetsMetadataRetrieveResponseComposite & { - headers: Headers; + headers: Headers } export const getAssetsMetadataRetrieveUrl = () => { - - - - return `/api/v2/assets/metadata/` } -export const assetsMetadataRetrieve = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsMetadataRetrieveUrl(), - { +export const assetsMetadataRetrieve = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAssetsMetadataRetrieveUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAssetsMetadataRetrieveQueryKey = () => { - return ['api','v2','assets','metadata'] as const; - } - - -export const getAssetsMetadataRetrieveQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsMetadataRetrieveQueryKey(); - - + return ['api', 'v2', 'assets', 'metadata'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => assetsMetadataRetrieve({ signal, ...requestOptions }); +export const getAssetsMetadataRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getAssetsMetadataRetrieveQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + assetsMetadataRetrieve({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsMetadataRetrieveQueryResult = NonNullable>> export type AssetsMetadataRetrieveQueryError = unknown - - -export function useAssetsMetadataRetrieve>, TError = unknown>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAssetsMetadataRetrieve< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAssetsMetadataRetrieveQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Return a minimal listing of assets with their deployment status @@ -1670,85 +1565,89 @@ export type assetsMinimalListRetrieveResponse200 = { data: PaginatedAssetMinimalListList status: 200 } - -export type assetsMinimalListRetrieveResponseComposite = assetsMinimalListRetrieveResponse200; - + +export type assetsMinimalListRetrieveResponseComposite = assetsMinimalListRetrieveResponse200 + export type assetsMinimalListRetrieveResponse = assetsMinimalListRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsMinimalListRetrieveUrl = (params?: AssetsMinimalListRetrieveParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsMinimalListRetrieveUrl = (params?: AssetsMinimalListRetrieveParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/minimal-list/?${stringifiedParams}` : `/api/v2/assets/minimal-list/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/minimal-list/?${stringifiedParams}` + : `/api/v2/assets/minimal-list/` } -export const assetsMinimalListRetrieve = async (params?: AssetsMinimalListRetrieveParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsMinimalListRetrieveUrl(params), - { +export const assetsMinimalListRetrieve = async ( + params?: AssetsMinimalListRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsMinimalListRetrieveUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsMinimalListRetrieveQueryKey = (params?: AssetsMinimalListRetrieveParams,) => { - return ['api','v2','assets','minimal-list', ...(params ? [params]: [])] as const; - } +export const getAssetsMinimalListRetrieveQueryKey = (params?: AssetsMinimalListRetrieveParams) => { + return ['api', 'v2', 'assets', 'minimal-list', ...(params ? [params] : [])] as const +} - -export const getAssetsMinimalListRetrieveQueryOptions = >, TError = unknown>(params?: AssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsMinimalListRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: AssetsMinimalListRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsMinimalListRetrieveQueryKey(params); + const queryKey = queryOptions?.queryKey ?? getAssetsMinimalListRetrieveQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsMinimalListRetrieve(params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsMinimalListRetrieve(params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsMinimalListRetrieveQueryResult = NonNullable>> export type AssetsMinimalListRetrieveQueryError = unknown +export function useAssetsMinimalListRetrieve< + TData = Awaited>, + TError = unknown, +>( + params?: AssetsMinimalListRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsMinimalListRetrieveQueryOptions(params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsMinimalListRetrieve>, TError = unknown>( - params?: AssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsMinimalListRetrieveQueryOptions(params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## List imported files @@ -1762,85 +1661,78 @@ export type importsListResponse401 = { data: ErrorDetail status: 401 } - -export type importsListResponseComposite = importsListResponse200 | importsListResponse401; - + +export type importsListResponseComposite = importsListResponse200 | importsListResponse401 + export type importsListResponse = importsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getImportsListUrl = (params?: ImportsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getImportsListUrl = (params?: ImportsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/imports/?${stringifiedParams}` : `/api/v2/imports/` } export const importsList = async (params?: ImportsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getImportsListUrl(params), - { + return fetchWithAuth(getImportsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getImportsListQueryKey = (params?: ImportsListParams,) => { - return ['api','v2','imports', ...(params ? [params]: [])] as const; - } +export const getImportsListQueryKey = (params?: ImportsListParams) => { + return ['api', 'v2', 'imports', ...(params ? [params] : [])] as const +} - -export const getImportsListQueryOptions = >, TError = ErrorDetail>(params?: ImportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getImportsListQueryOptions = >, TError = ErrorDetail>( + params?: ImportsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getImportsListQueryKey(params); - - + const queryKey = queryOptions?.queryKey ?? getImportsListQueryKey(params) - const queryFn: QueryFunction>> = ({ signal }) => importsList(params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + importsList(params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ImportsListQueryResult = NonNullable>> export type ImportsListQueryError = ErrorDetail - - export function useImportsList>, TError = ErrorDetail>( - params?: ImportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getImportsListQueryOptions(params,options) + params?: ImportsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getImportsListQueryOptions(params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Import file @@ -1861,81 +1753,84 @@ export type importsCreateResponse401 = { data: ErrorDetail status: 401 } - -export type importsCreateResponseComposite = importsCreateResponse201 | importsCreateResponse400 | importsCreateResponse401; - + +export type importsCreateResponseComposite = + | importsCreateResponse201 + | importsCreateResponse400 + | importsCreateResponse401 + export type importsCreateResponse = importsCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getImportsCreateUrl = () => { - - - - return `/api/v2/imports/` } -export const importsCreate = async (importCreateRequest: ImportCreateRequest, options?: RequestInit): Promise => { - const formData = new FormData(); -formData.append(`destination`, importCreateRequest.destination) -formData.append(`url`, importCreateRequest.url) -if(importCreateRequest.name !== undefined) { - formData.append(`name`, importCreateRequest.name) - } -formData.append(`assetUid`, importCreateRequest.assetUid) +export const importsCreate = async ( + importCreateRequest: ImportCreateRequest, + options?: RequestInit, +): Promise => { + const formData = new FormData() + formData.append(`destination`, importCreateRequest.destination) + formData.append(`url`, importCreateRequest.url) + if (importCreateRequest.name !== undefined) { + formData.append(`name`, importCreateRequest.name) + } + formData.append(`assetUid`, importCreateRequest.assetUid) - return fetchWithAuth(getImportsCreateUrl(), - { + return fetchWithAuth(getImportsCreateUrl(), { ...options, - method: 'POST' - , - body: - formData, + method: 'POST', + body: formData, + }) +} + +export const getImportsCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ImportCreateRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, { data: ImportCreateRequest }, TContext> => { + const mutationKey = ['importsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: ImportCreateRequest }> = ( + props, + ) => { + const { data } = props ?? {} + + return importsCreate(data, requestOptions) } -);} - - - - -export const getImportsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ImportCreateRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ImportCreateRequest}, TContext> => { -const mutationKey = ['importsCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ImportCreateRequest}> = (props) => { - const {data} = props ?? {}; - - return importsCreate(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type ImportsCreateMutationResult = NonNullable>> - export type ImportsCreateMutationBody = ImportCreateRequest - export type ImportsCreateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useImportsCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: ImportCreateRequest}, TContext>, request?: SecondParameter} - ) => { +export type ImportsCreateMutationResult = NonNullable>> +export type ImportsCreateMutationBody = ImportCreateRequest +export type ImportsCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getImportsCreateMutationOptions(options); +export const useImportsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ImportCreateRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getImportsCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retrieve imported files */ @@ -1948,78 +1843,71 @@ export type importsRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type importsRetrieveResponseComposite = importsRetrieveResponse200 | importsRetrieveResponse401; - -export type importsRetrieveResponse = importsRetrieveResponseComposite & { - headers: Headers; -} -export const getImportsRetrieveUrl = (uidImport: string,) => { +export type importsRetrieveResponseComposite = importsRetrieveResponse200 | importsRetrieveResponse401 +export type importsRetrieveResponse = importsRetrieveResponseComposite & { + headers: Headers +} - - +export const getImportsRetrieveUrl = (uidImport: string) => { return `/api/v2/imports/${uidImport}/` } export const importsRetrieve = async (uidImport: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getImportsRetrieveUrl(uidImport), - { + return fetchWithAuth(getImportsRetrieveUrl(uidImport), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getImportsRetrieveQueryKey = (uidImport: string,) => { - return ['api','v2','imports',uidImport] as const; - } +export const getImportsRetrieveQueryKey = (uidImport: string) => { + return ['api', 'v2', 'imports', uidImport] as const +} - -export const getImportsRetrieveQueryOptions = >, TError = ErrorDetail>(uidImport: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getImportsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidImport: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getImportsRetrieveQueryKey(uidImport); - - - - const queryFn: QueryFunction>> = ({ signal }) => importsRetrieve(uidImport, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getImportsRetrieveQueryKey(uidImport) - + const queryFn: QueryFunction>> = ({ signal }) => + importsRetrieve(uidImport, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidImport), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidImport, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ImportsRetrieveQueryResult = NonNullable>> export type ImportsRetrieveQueryError = ErrorDetail - - export function useImportsRetrieve>, TError = ErrorDetail>( - uidImport: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getImportsRetrieveQueryOptions(uidImport,options) + uidImport: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getImportsRetrieveQueryOptions(uidImport, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## List of invites @@ -2042,85 +1930,93 @@ export type projectOwnershipInvitesListResponse403 = { data: ErrorDetail status: 403 } - -export type projectOwnershipInvitesListResponseComposite = projectOwnershipInvitesListResponse200 | projectOwnershipInvitesListResponse403; - + +export type projectOwnershipInvitesListResponseComposite = + | projectOwnershipInvitesListResponse200 + | projectOwnershipInvitesListResponse403 + export type projectOwnershipInvitesListResponse = projectOwnershipInvitesListResponseComposite & { - headers: Headers; + headers: Headers } -export const getProjectOwnershipInvitesListUrl = (params?: ProjectOwnershipInvitesListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getProjectOwnershipInvitesListUrl = (params?: ProjectOwnershipInvitesListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/project-ownership/invites/?${stringifiedParams}` : `/api/v2/project-ownership/invites/` + return stringifiedParams.length > 0 + ? `/api/v2/project-ownership/invites/?${stringifiedParams}` + : `/api/v2/project-ownership/invites/` } -export const projectOwnershipInvitesList = async (params?: ProjectOwnershipInvitesListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectOwnershipInvitesListUrl(params), - { +export const projectOwnershipInvitesList = async ( + params?: ProjectOwnershipInvitesListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectOwnershipInvitesListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getProjectOwnershipInvitesListQueryKey = (params?: ProjectOwnershipInvitesListParams,) => { - return ['api','v2','project-ownership','invites', ...(params ? [params]: [])] as const; - } +export const getProjectOwnershipInvitesListQueryKey = (params?: ProjectOwnershipInvitesListParams) => { + return ['api', 'v2', 'project-ownership', 'invites', ...(params ? [params] : [])] as const +} - -export const getProjectOwnershipInvitesListQueryOptions = >, TError = ErrorDetail>(params?: ProjectOwnershipInvitesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getProjectOwnershipInvitesListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: ProjectOwnershipInvitesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesListQueryKey(params); - - - - const queryFn: QueryFunction>> = ({ signal }) => projectOwnershipInvitesList(params, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + projectOwnershipInvitesList(params, { signal, ...requestOptions }) - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type ProjectOwnershipInvitesListQueryResult = NonNullable>> +export type ProjectOwnershipInvitesListQueryResult = NonNullable< + Awaited> +> export type ProjectOwnershipInvitesListQueryError = ErrorDetail +export function useProjectOwnershipInvitesList< + TData = Awaited>, + TError = ErrorDetail, +>( + params?: ProjectOwnershipInvitesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectOwnershipInvitesListQueryOptions(params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useProjectOwnershipInvitesList>, TError = ErrorDetail>( - params?: ProjectOwnershipInvitesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getProjectOwnershipInvitesListQueryOptions(params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Create (send) an invite @@ -2143,74 +2039,88 @@ export type projectOwnershipInvitesCreateResponse403 = { data: ErrorDetail status: 403 } - -export type projectOwnershipInvitesCreateResponseComposite = projectOwnershipInvitesCreateResponse201 | projectOwnershipInvitesCreateResponse400 | projectOwnershipInvitesCreateResponse403; - + +export type projectOwnershipInvitesCreateResponseComposite = + | projectOwnershipInvitesCreateResponse201 + | projectOwnershipInvitesCreateResponse400 + | projectOwnershipInvitesCreateResponse403 + export type projectOwnershipInvitesCreateResponse = projectOwnershipInvitesCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getProjectOwnershipInvitesCreateUrl = () => { - - - - return `/api/v2/project-ownership/invites/` } -export const projectOwnershipInvitesCreate = async (projectInviteCreatePayload: ProjectInviteCreatePayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectOwnershipInvitesCreateUrl(), - { +export const projectOwnershipInvitesCreate = async ( + projectInviteCreatePayload: ProjectInviteCreatePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectOwnershipInvitesCreateUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - projectInviteCreatePayload,) + body: JSON.stringify(projectInviteCreatePayload), + }) +} + +export const getProjectOwnershipInvitesCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProjectInviteCreatePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ProjectInviteCreatePayload }, + TContext +> => { + const mutationKey = ['projectOwnershipInvitesCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ProjectInviteCreatePayload } + > = (props) => { + const { data } = props ?? {} + + return projectOwnershipInvitesCreate(data, requestOptions) } -);} - - - - -export const getProjectOwnershipInvitesCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: ProjectInviteCreatePayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: ProjectInviteCreatePayload}, TContext> => { - -const mutationKey = ['projectOwnershipInvitesCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: ProjectInviteCreatePayload}> = (props) => { - const {data} = props ?? {}; - - return projectOwnershipInvitesCreate(data,requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} - - export type ProjectOwnershipInvitesCreateMutationResult = NonNullable>> - export type ProjectOwnershipInvitesCreateMutationBody = ProjectInviteCreatePayload - export type ProjectOwnershipInvitesCreateMutationError = ErrorObject | ErrorDetail - - export const useProjectOwnershipInvitesCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: ProjectInviteCreatePayload}, TContext>, request?: SecondParameter} - ) => { +export type ProjectOwnershipInvitesCreateMutationResult = NonNullable< + Awaited> +> +export type ProjectOwnershipInvitesCreateMutationBody = ProjectInviteCreatePayload +export type ProjectOwnershipInvitesCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getProjectOwnershipInvitesCreateMutationOptions(options); +export const useProjectOwnershipInvitesCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ProjectInviteCreatePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getProjectOwnershipInvitesCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Invite detail It can be useful to monitor the invite status while the transfer is being processed @@ -2225,78 +2135,81 @@ export type projectOwnershipInvitesRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type projectOwnershipInvitesRetrieveResponseComposite = projectOwnershipInvitesRetrieveResponse200 | projectOwnershipInvitesRetrieveResponse403; - -export type projectOwnershipInvitesRetrieveResponse = projectOwnershipInvitesRetrieveResponseComposite & { - headers: Headers; -} - -export const getProjectOwnershipInvitesRetrieveUrl = (uidInvite: string,) => { +export type projectOwnershipInvitesRetrieveResponseComposite = + | projectOwnershipInvitesRetrieveResponse200 + | projectOwnershipInvitesRetrieveResponse403 - +export type projectOwnershipInvitesRetrieveResponse = projectOwnershipInvitesRetrieveResponseComposite & { + headers: Headers +} +export const getProjectOwnershipInvitesRetrieveUrl = (uidInvite: string) => { return `/api/v2/project-ownership/invites/${uidInvite}/` } -export const projectOwnershipInvitesRetrieve = async (uidInvite: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectOwnershipInvitesRetrieveUrl(uidInvite), - { +export const projectOwnershipInvitesRetrieve = async ( + uidInvite: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectOwnershipInvitesRetrieveUrl(uidInvite), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getProjectOwnershipInvitesRetrieveQueryKey = (uidInvite: string,) => { - return ['api','v2','project-ownership','invites',uidInvite] as const; - } +export const getProjectOwnershipInvitesRetrieveQueryKey = (uidInvite: string) => { + return ['api', 'v2', 'project-ownership', 'invites', uidInvite] as const +} - -export const getProjectOwnershipInvitesRetrieveQueryOptions = >, TError = ErrorDetail>(uidInvite: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getProjectOwnershipInvitesRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidInvite: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesRetrieveQueryKey(uidInvite); - - - - const queryFn: QueryFunction>> = ({ signal }) => projectOwnershipInvitesRetrieve(uidInvite, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesRetrieveQueryKey(uidInvite) - + const queryFn: QueryFunction>> = ({ signal }) => + projectOwnershipInvitesRetrieve(uidInvite, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidInvite), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidInvite, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type ProjectOwnershipInvitesRetrieveQueryResult = NonNullable>> +export type ProjectOwnershipInvitesRetrieveQueryResult = NonNullable< + Awaited> +> export type ProjectOwnershipInvitesRetrieveQueryError = ErrorDetail +export function useProjectOwnershipInvitesRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidInvite: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectOwnershipInvitesRetrieveQueryOptions(uidInvite, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useProjectOwnershipInvitesRetrieve>, TError = ErrorDetail>( - uidInvite: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getProjectOwnershipInvitesRetrieveQueryOptions(uidInvite,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Update an invite status @@ -2327,75 +2240,95 @@ export type projectOwnershipInvitesPartialUpdateResponse403 = { data: ErrorDetail status: 403 } - -export type projectOwnershipInvitesPartialUpdateResponseComposite = projectOwnershipInvitesPartialUpdateResponse200 | projectOwnershipInvitesPartialUpdateResponse400 | projectOwnershipInvitesPartialUpdateResponse403; - -export type projectOwnershipInvitesPartialUpdateResponse = projectOwnershipInvitesPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getProjectOwnershipInvitesPartialUpdateUrl = (uidInvite: string,) => { +export type projectOwnershipInvitesPartialUpdateResponseComposite = + | projectOwnershipInvitesPartialUpdateResponse200 + | projectOwnershipInvitesPartialUpdateResponse400 + | projectOwnershipInvitesPartialUpdateResponse403 - +export type projectOwnershipInvitesPartialUpdateResponse = projectOwnershipInvitesPartialUpdateResponseComposite & { + headers: Headers +} +export const getProjectOwnershipInvitesPartialUpdateUrl = (uidInvite: string) => { return `/api/v2/project-ownership/invites/${uidInvite}/` } -export const projectOwnershipInvitesPartialUpdate = async (uidInvite: string, - patchedInviteUpdatePayload: PatchedInviteUpdatePayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectOwnershipInvitesPartialUpdateUrl(uidInvite), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedInviteUpdatePayload,) +export const projectOwnershipInvitesPartialUpdate = async ( + uidInvite: string, + patchedInviteUpdatePayload: PatchedInviteUpdatePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getProjectOwnershipInvitesPartialUpdateUrl(uidInvite), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedInviteUpdatePayload), + }, + ) +} + +export const getProjectOwnershipInvitesPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidInvite: string; data: PatchedInviteUpdatePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidInvite: string; data: PatchedInviteUpdatePayload }, + TContext +> => { + const mutationKey = ['projectOwnershipInvitesPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidInvite: string; data: PatchedInviteUpdatePayload } + > = (props) => { + const { uidInvite, data } = props ?? {} + + return projectOwnershipInvitesPartialUpdate(uidInvite, data, requestOptions) } -);} - - - - -export const getProjectOwnershipInvitesPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidInvite: string;data: PatchedInviteUpdatePayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidInvite: string;data: PatchedInviteUpdatePayload}, TContext> => { - -const mutationKey = ['projectOwnershipInvitesPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidInvite: string;data: PatchedInviteUpdatePayload}> = (props) => { - const {uidInvite,data} = props ?? {}; - return projectOwnershipInvitesPartialUpdate(uidInvite,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type ProjectOwnershipInvitesPartialUpdateMutationResult = NonNullable>> - export type ProjectOwnershipInvitesPartialUpdateMutationBody = PatchedInviteUpdatePayload - export type ProjectOwnershipInvitesPartialUpdateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useProjectOwnershipInvitesPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidInvite: string;data: PatchedInviteUpdatePayload}, TContext>, request?: SecondParameter} - ) => { +export type ProjectOwnershipInvitesPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type ProjectOwnershipInvitesPartialUpdateMutationBody = PatchedInviteUpdatePayload +export type ProjectOwnershipInvitesPartialUpdateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getProjectOwnershipInvitesPartialUpdateMutationOptions(options); +export const useProjectOwnershipInvitesPartialUpdate = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidInvite: string; data: PatchedInviteUpdatePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getProjectOwnershipInvitesPartialUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Delete invite */ @@ -2408,73 +2341,82 @@ export type projectOwnershipInvitesDestroyResponse403 = { data: ErrorDetail status: 403 } - -export type projectOwnershipInvitesDestroyResponseComposite = projectOwnershipInvitesDestroyResponse204 | projectOwnershipInvitesDestroyResponse403; - -export type projectOwnershipInvitesDestroyResponse = projectOwnershipInvitesDestroyResponseComposite & { - headers: Headers; -} - -export const getProjectOwnershipInvitesDestroyUrl = (uidInvite: string,) => { +export type projectOwnershipInvitesDestroyResponseComposite = + | projectOwnershipInvitesDestroyResponse204 + | projectOwnershipInvitesDestroyResponse403 - +export type projectOwnershipInvitesDestroyResponse = projectOwnershipInvitesDestroyResponseComposite & { + headers: Headers +} +export const getProjectOwnershipInvitesDestroyUrl = (uidInvite: string) => { return `/api/v2/project-ownership/invites/${uidInvite}/` } -export const projectOwnershipInvitesDestroy = async (uidInvite: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectOwnershipInvitesDestroyUrl(uidInvite), - { +export const projectOwnershipInvitesDestroy = async ( + uidInvite: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectOwnershipInvitesDestroyUrl(uidInvite), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getProjectOwnershipInvitesDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidInvite: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidInvite: string }, + TContext +> => { + const mutationKey = ['projectOwnershipInvitesDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidInvite: string } + > = (props) => { + const { uidInvite } = props ?? {} + + return projectOwnershipInvitesDestroy(uidInvite, requestOptions) } -);} - - - - -export const getProjectOwnershipInvitesDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidInvite: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidInvite: string}, TContext> => { - -const mutationKey = ['projectOwnershipInvitesDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidInvite: string}> = (props) => { - const {uidInvite} = props ?? {}; - - return projectOwnershipInvitesDestroy(uidInvite,requestOptions) - } - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type ProjectOwnershipInvitesDestroyMutationResult = NonNullable>> - - export type ProjectOwnershipInvitesDestroyMutationError = ErrorDetail +export type ProjectOwnershipInvitesDestroyMutationResult = NonNullable< + Awaited> +> - export const useProjectOwnershipInvitesDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidInvite: string}, TContext>, request?: SecondParameter} - ) => { +export type ProjectOwnershipInvitesDestroyMutationError = ErrorDetail - const mutationOptions = getProjectOwnershipInvitesDestroyMutationOptions(options); +export const useProjectOwnershipInvitesDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidInvite: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getProjectOwnershipInvitesDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retrieve transfer details */ @@ -2487,83 +2429,88 @@ export type projectOwnershipInvitesTransfersRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type projectOwnershipInvitesTransfersRetrieveResponseComposite = projectOwnershipInvitesTransfersRetrieveResponse200 | projectOwnershipInvitesTransfersRetrieveResponse401; - -export type projectOwnershipInvitesTransfersRetrieveResponse = projectOwnershipInvitesTransfersRetrieveResponseComposite & { - headers: Headers; -} - -export const getProjectOwnershipInvitesTransfersRetrieveUrl = (uidInvite: string, - uidTransfer: string,) => { +export type projectOwnershipInvitesTransfersRetrieveResponseComposite = + | projectOwnershipInvitesTransfersRetrieveResponse200 + | projectOwnershipInvitesTransfersRetrieveResponse401 - +export type projectOwnershipInvitesTransfersRetrieveResponse = + projectOwnershipInvitesTransfersRetrieveResponseComposite & { + headers: Headers + } +export const getProjectOwnershipInvitesTransfersRetrieveUrl = (uidInvite: string, uidTransfer: string) => { return `/api/v2/project-ownership/invites/${uidInvite}/transfers/${uidTransfer}/` } -export const projectOwnershipInvitesTransfersRetrieve = async (uidInvite: string, - uidTransfer: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectOwnershipInvitesTransfersRetrieveUrl(uidInvite,uidTransfer), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getProjectOwnershipInvitesTransfersRetrieveQueryKey = (uidInvite: string, - uidTransfer: string,) => { - return ['api','v2','project-ownership','invites',uidInvite,'transfers',uidTransfer] as const; - } - - -export const getProjectOwnershipInvitesTransfersRetrieveQueryOptions = >, TError = ErrorDetail>(uidInvite: string, - uidTransfer: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const projectOwnershipInvitesTransfersRetrieve = async ( + uidInvite: string, + uidTransfer: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getProjectOwnershipInvitesTransfersRetrieveUrl(uidInvite, uidTransfer), + { + ...options, + method: 'GET', + }, + ) +} + +export const getProjectOwnershipInvitesTransfersRetrieveQueryKey = (uidInvite: string, uidTransfer: string) => { + return ['api', 'v2', 'project-ownership', 'invites', uidInvite, 'transfers', uidTransfer] as const +} + +export const getProjectOwnershipInvitesTransfersRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidInvite: string, + uidTransfer: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesTransfersRetrieveQueryKey(uidInvite, uidTransfer) - const queryKey = queryOptions?.queryKey ?? getProjectOwnershipInvitesTransfersRetrieveQueryKey(uidInvite,uidTransfer); + const queryFn: QueryFunction>> = ({ signal }) => + projectOwnershipInvitesTransfersRetrieve(uidInvite, uidTransfer, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => projectOwnershipInvitesTransfersRetrieve(uidInvite,uidTransfer, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidInvite && uidTransfer), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidInvite && uidTransfer), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type ProjectOwnershipInvitesTransfersRetrieveQueryResult = NonNullable>> +export type ProjectOwnershipInvitesTransfersRetrieveQueryResult = NonNullable< + Awaited> +> export type ProjectOwnershipInvitesTransfersRetrieveQueryError = ErrorDetail +export function useProjectOwnershipInvitesTransfersRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidInvite: string, + uidTransfer: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectOwnershipInvitesTransfersRetrieveQueryOptions(uidInvite, uidTransfer, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useProjectOwnershipInvitesTransfersRetrieve>, TError = ErrorDetail>( - uidInvite: string, - uidTransfer: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getProjectOwnershipInvitesTransfersRetrieveQueryOptions(uidInvite,uidTransfer,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## List current user's assets' tags @@ -2577,85 +2524,78 @@ export type tagsListResponse401 = { data: ErrorDetail status: 401 } - -export type tagsListResponseComposite = tagsListResponse200 | tagsListResponse401; - + +export type tagsListResponseComposite = tagsListResponse200 | tagsListResponse401 + export type tagsListResponse = tagsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getTagsListUrl = (params?: TagsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getTagsListUrl = (params?: TagsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/tags/?${stringifiedParams}` : `/api/v2/tags/` } export const tagsList = async (params?: TagsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getTagsListUrl(params), - { + return fetchWithAuth(getTagsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getTagsListQueryKey = (params?: TagsListParams,) => { - return ['api','v2','tags', ...(params ? [params]: [])] as const; - } +export const getTagsListQueryKey = (params?: TagsListParams) => { + return ['api', 'v2', 'tags', ...(params ? [params] : [])] as const +} - -export const getTagsListQueryOptions = >, TError = ErrorDetail>(params?: TagsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getTagsListQueryOptions = >, TError = ErrorDetail>( + params?: TagsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getTagsListQueryKey(params); - - - - const queryFn: QueryFunction>> = ({ signal }) => tagsList(params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getTagsListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + tagsList(params, { signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type TagsListQueryResult = NonNullable>> export type TagsListQueryError = ErrorDetail - - export function useTagsList>, TError = ErrorDetail>( - params?: TagsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getTagsListQueryOptions(params,options) + params?: TagsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getTagsListQueryOptions(params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Retrieve a tag's data @@ -2669,75 +2609,64 @@ export type tagsRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type tagsRetrieveResponseComposite = tagsRetrieveResponse200 | tagsRetrieveResponse401; - -export type tagsRetrieveResponse = tagsRetrieveResponseComposite & { - headers: Headers; -} - -export const getTagsRetrieveUrl = (taguidUid: string,) => { +export type tagsRetrieveResponseComposite = tagsRetrieveResponse200 | tagsRetrieveResponse401 - +export type tagsRetrieveResponse = tagsRetrieveResponseComposite & { + headers: Headers +} +export const getTagsRetrieveUrl = (taguidUid: string) => { return `/api/v2/tags/${taguidUid}/` } export const tagsRetrieve = async (taguidUid: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getTagsRetrieveUrl(taguidUid), - { + return fetchWithAuth(getTagsRetrieveUrl(taguidUid), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getTagsRetrieveQueryKey = (taguidUid: string,) => { - return ['api','v2','tags',taguidUid] as const; - } +export const getTagsRetrieveQueryKey = (taguidUid: string) => { + return ['api', 'v2', 'tags', taguidUid] as const +} - -export const getTagsRetrieveQueryOptions = >, TError = ErrorDetail>(taguidUid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getTagsRetrieveQueryOptions = >, TError = ErrorDetail>( + taguidUid: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getTagsRetrieveQueryKey(taguidUid) - const queryKey = queryOptions?.queryKey ?? getTagsRetrieveQueryKey(taguidUid); + const queryFn: QueryFunction>> = ({ signal }) => + tagsRetrieve(taguidUid, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => tagsRetrieve(taguidUid, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(taguidUid), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!taguidUid, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type TagsRetrieveQueryResult = NonNullable>> export type TagsRetrieveQueryError = ErrorDetail - - export function useTagsRetrieve>, TError = ErrorDetail>( - taguidUid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getTagsRetrieveQueryOptions(taguidUid,options) + taguidUid: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getTagsRetrieveQueryOptions(taguidUid, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - - diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts b/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts index 71eeec3c38..9027cb565d 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts @@ -9,472 +9,5151 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; +import { http, HttpResponse } from 'msw' -import type { - Asset -} from '../../models/asset'; - -import type { - AssetBulkResponse -} from '../../models/assetBulkResponse'; - -import { - AssetDeploymentStatusEnum -} from '../../models/assetDeploymentStatusEnum'; - -import type { - AssetListCount -} from '../../models/assetListCount'; - -import type { - AssetMetadataResponse -} from '../../models/assetMetadataResponse'; - -import { - AssetTypeEnum -} from '../../models/assetTypeEnum'; - -import type { - DeploymentResponse -} from '../../models/deploymentResponse'; - -import type { - HashResponse -} from '../../models/hashResponse'; - -import type { - ImportCreateResponse -} from '../../models/importCreateResponse'; - -import type { - ImportResponse -} from '../../models/importResponse'; - -import { - InviteStatusChoicesEnum -} from '../../models/inviteStatusChoicesEnum'; - -import type { - PaginatedAssetCountResponseList -} from '../../models/paginatedAssetCountResponseList'; - -import type { - PaginatedAssetList -} from '../../models/paginatedAssetList'; - -import type { - PaginatedAssetMinimalListList -} from '../../models/paginatedAssetMinimalListList'; - -import type { - PaginatedImportResponseList -} from '../../models/paginatedImportResponseList'; - -import type { - PaginatedProjectInviteResponseList -} from '../../models/paginatedProjectInviteResponseList'; - -import type { - PaginatedTagListResponseList -} from '../../models/paginatedTagListResponseList'; +import type { Asset } from '../../models/asset' -import type { - PaginatedVersionListResponseList -} from '../../models/paginatedVersionListResponseList'; +import type { AssetBulkResponse } from '../../models/assetBulkResponse' -import type { - ProjectInviteResponse -} from '../../models/projectInviteResponse'; +import { AssetDeploymentStatusEnum } from '../../models/assetDeploymentStatusEnum' -import type { - TagRetrieveResponse -} from '../../models/tagRetrieveResponse'; +import type { AssetListCount } from '../../models/assetListCount' -import type { - TransferListResponse -} from '../../models/transferListResponse'; +import type { AssetMetadataResponse } from '../../models/assetMetadataResponse' -import type { - VersionRetrieveResponse -} from '../../models/versionRetrieveResponse'; +import { AssetTypeEnum } from '../../models/assetTypeEnum' +import type { DeploymentResponse } from '../../models/deploymentResponse' -export const getApiV2AssetsListResponseMock = (overrideResponse: Partial< PaginatedAssetList > = {}): PaginatedAssetList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {} - })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { - [faker.string.alphanumeric(5)]: {} - }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { - [faker.string.alphanumeric(5)]: {} - }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), ...overrideResponse}) +import type { HashResponse } from '../../models/hashResponse' -export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial< Asset > = {}): Asset => ({url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {} - })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { - [faker.string.alphanumeric(5)]: {} - }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { - [faker.string.alphanumeric(5)]: {} - }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), ...overrideResponse}) +import type { ImportCreateResponse } from '../../models/importCreateResponse' -export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial< Asset > = {}): Asset => ({url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {} - })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { - [faker.string.alphanumeric(5)]: {} - }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { - [faker.string.alphanumeric(5)]: {} - }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), ...overrideResponse}) +import type { ImportResponse } from '../../models/importResponse' -export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partial< Asset > = {}): Asset => ({url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {} - })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { - [faker.string.alphanumeric(5)]: {} - }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { - [faker.string.alphanumeric(5)]: {} - }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), ...overrideResponse}) +import { InviteStatusChoicesEnum } from '../../models/inviteStatusChoicesEnum' -export const getApiV2AssetsCountsListResponseMock = (overrideResponse: Partial< PaginatedAssetCountResponseList > = {}): PaginatedAssetCountResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({daily_submission_count: {'2020-10-20': faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, total_submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})})), ...overrideResponse}) +import type { PaginatedAssetCountResponseList } from '../../models/paginatedAssetCountResponseList' -export const getApiV2AssetsDeploymentRetrieveResponseMock = (overrideResponse: Partial< DeploymentResponse > = {}): DeploymentResponse => ({backend: faker.string.alpha({length: {min: 10, max: 20}}), active: faker.datatype.boolean(), version_id: faker.string.alpha({length: {min: 10, max: 20}}), asset: {url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {} - })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { - [faker.string.alphanumeric(5)]: {} - }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { - [faker.string.alphanumeric(5)]: {} - }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}, ...overrideResponse}) +import type { PaginatedAssetList } from '../../models/paginatedAssetList' -export const getApiV2AssetsDeploymentCreateResponseMock = (overrideResponse: Partial< DeploymentResponse > = {}): DeploymentResponse => ({backend: faker.string.alpha({length: {min: 10, max: 20}}), active: faker.datatype.boolean(), version_id: faker.string.alpha({length: {min: 10, max: 20}}), asset: {url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {} - })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { - [faker.string.alphanumeric(5)]: {} - }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { - [faker.string.alphanumeric(5)]: {} - }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}, ...overrideResponse}) +import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' -export const getApiV2AssetsDeploymentPartialUpdateResponseMock = (overrideResponse: Partial< DeploymentResponse > = {}): DeploymentResponse => ({backend: faker.string.alpha({length: {min: 10, max: 20}}), active: faker.datatype.boolean(), version_id: faker.string.alpha({length: {min: 10, max: 20}}), asset: {url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {} - })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { - [faker.string.alphanumeric(5)]: {} - }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { - [faker.string.alphanumeric(5)]: {} - }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}, ...overrideResponse}) +import type { PaginatedImportResponseList } from '../../models/paginatedImportResponseList' -export const getApiV2AssetsVersionsListResponseMock = (overrideResponse: Partial< PaginatedVersionListResponseList > = {}): PaginatedVersionListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) +import type { PaginatedProjectInviteResponseList } from '../../models/paginatedProjectInviteResponseList' -export const getApiV2AssetsVersionsRetrieveResponseMock = (overrideResponse: Partial< VersionRetrieveResponse > = {}): VersionRetrieveResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, content: {schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $kuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{default_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translation: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, ...overrideResponse}) +import type { PaginatedTagListResponseList } from '../../models/paginatedTagListResponseList' -export const getApiV2AssetsXformRetrieveResponseMock = (): string => (faker.word.sample()) +import type { PaginatedVersionListResponseList } from '../../models/paginatedVersionListResponseList' -export const getApiV2AssetsBulkCreateResponseMock = (overrideResponse: Partial< AssetBulkResponse > = {}): AssetBulkResponse => ({detail: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) +import type { ProjectInviteResponse } from '../../models/projectInviteResponse' -export const getApiV2AssetsCountsRetrieveResponseMock = (overrideResponse: Partial< AssetListCount > = {}): AssetListCount => ({deployed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), archived_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), draft_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), ...overrideResponse}) +import type { TagRetrieveResponse } from '../../models/tagRetrieveResponse' -export const getApiV2AssetsHashRetrieveResponseMock = (overrideResponse: Partial< HashResponse > = {}): HashResponse => ({hash: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) +import type { TransferListResponse } from '../../models/transferListResponse' -export const getApiV2AssetsMetadataRetrieveResponseMock = (overrideResponse: Partial< AssetMetadataResponse > = {}): AssetMetadataResponse => ({languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), sectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))))), organizations: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) +import type { VersionRetrieveResponse } from '../../models/versionRetrieveResponse' -export const getApiV2AssetsMinimalListRetrieveResponseMock = (overrideResponse: Partial< PaginatedAssetMinimalListList > = {}): PaginatedAssetMinimalListList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 22}}), name: faker.string.alpha({length: {min: 10, max: 20}}), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum))})), ...overrideResponse}) +export const getApiV2AssetsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployed_versions: { + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: { + csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls: faker.string.alpha({ length: { min: 10, max: 20 } }), + zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + null, + ]), + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([ + { + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_styles: faker.helpers.arrayElement([ + { + colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + analysis_form_json: { + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + })), + undefined, + ]), + })), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + ...overrideResponse, +}) -export const getApiV2ImportsListResponseMock = (overrideResponse: Partial< PaginatedImportResponseList > = {}): PaginatedImportResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), messages: {updated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kind: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), summary: faker.helpers.arrayElement([{geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), language: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), first: faker.helpers.arrayElement([{}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), owner__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), 'audit-logs': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset_id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), new_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_owner: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, uid: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) +export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial = {}): Asset => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployed_versions: { + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: { + csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls: faker.string.alpha({ length: { min: 10, max: 20 } }), + zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + null, + ]), + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([ + { + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_styles: faker.helpers.arrayElement([ + { + colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + analysis_form_json: { + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + })), + undefined, + ]), + })), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ...overrideResponse, +}) -export const getApiV2ImportsCreateResponseMock = (overrideResponse: Partial< ImportCreateResponse > = {}): ImportCreateResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) +export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial = {}): Asset => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployed_versions: { + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: { + csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls: faker.string.alpha({ length: { min: 10, max: 20 } }), + zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + null, + ]), + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([ + { + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_styles: faker.helpers.arrayElement([ + { + colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + analysis_form_json: { + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + })), + undefined, + ]), + })), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ...overrideResponse, +}) -export const getApiV2ImportsRetrieveResponseMock = (overrideResponse: Partial< ImportResponse > = {}): ImportResponse => ({url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), messages: {updated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kind: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), summary: faker.helpers.arrayElement([{geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), language: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), first: faker.helpers.arrayElement([{}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), owner__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), 'audit-logs': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset_id: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), new_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_owner: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, uid: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, ...overrideResponse}) +export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partial = {}): Asset => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployed_versions: { + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: { + csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls: faker.string.alpha({ length: { min: 10, max: 20 } }), + zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + null, + ]), + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([ + { + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_styles: faker.helpers.arrayElement([ + { + colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + analysis_form_json: { + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + })), + undefined, + ]), + })), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ...overrideResponse, +}) -export const getApiV2ProjectOwnershipInvitesListResponseMock = (overrideResponse: Partial< PaginatedProjectInviteResponseList > = {}): PaginatedProjectInviteResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), 'sender | recipient': faker.internet.url(), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.internet.url(), undefined]), asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined])}))})), ...overrideResponse}) +export const getApiV2AssetsCountsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetCountResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + daily_submission_count: { + '2020-10-20': faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + total_submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + })), + ...overrideResponse, +}) -export const getApiV2ProjectOwnershipInvitesCreateResponseMock = (overrideResponse: Partial< ProjectInviteResponse > = {}): ProjectInviteResponse => ({url: faker.internet.url(), 'sender | recipient': faker.internet.url(), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.internet.url(), undefined]), asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined])})), ...overrideResponse}) +export const getApiV2AssetsDeploymentRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): DeploymentResponse => ({ + backend: faker.string.alpha({ length: { min: 10, max: 20 } }), + active: faker.datatype.boolean(), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + asset: { + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployed_versions: { + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: { + csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls: faker.string.alpha({ length: { min: 10, max: 20 } }), + zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + null, + ]), + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([ + { + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_styles: faker.helpers.arrayElement([ + { + colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + analysis_form_json: { + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + })), + undefined, + ]), + })), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + ...overrideResponse, +}) -export const getApiV2ProjectOwnershipInvitesRetrieveResponseMock = (overrideResponse: Partial< ProjectInviteResponse > = {}): ProjectInviteResponse => ({url: faker.internet.url(), 'sender | recipient': faker.internet.url(), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.internet.url(), undefined]), asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined])})), ...overrideResponse}) +export const getApiV2AssetsDeploymentCreateResponseMock = ( + overrideResponse: Partial = {}, +): DeploymentResponse => ({ + backend: faker.string.alpha({ length: { min: 10, max: 20 } }), + active: faker.datatype.boolean(), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + asset: { + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployed_versions: { + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: { + csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls: faker.string.alpha({ length: { min: 10, max: 20 } }), + zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + null, + ]), + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([ + { + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_styles: faker.helpers.arrayElement([ + { + colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + analysis_form_json: { + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + })), + undefined, + ]), + })), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + ...overrideResponse, +}) -export const getApiV2ProjectOwnershipInvitesPartialUpdateResponseMock = (overrideResponse: Partial< ProjectInviteResponse > = {}): ProjectInviteResponse => ({url: faker.internet.url(), 'sender | recipient': faker.internet.url(), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.internet.url(), undefined]), asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined])})), ...overrideResponse}) +export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DeploymentResponse => ({ + backend: faker.string.alpha({ length: { min: 10, max: 20 } }), + active: faker.datatype.boolean(), + version_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + asset: { + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployed_versions: { + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: { + csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls: faker.string.alpha({ length: { min: 10, max: 20 } }), + zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + null, + ]), + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([ + { + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_styles: faker.helpers.arrayElement([ + { + colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + analysis_form_json: { + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + })), + undefined, + ]), + })), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + ...overrideResponse, +}) -export const getApiV2ProjectOwnershipInvitesTransfersRetrieveResponseMock = (overrideResponse: Partial< TransferListResponse > = {}): TransferListResponse => ({url: faker.internet.url(), asset: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), error: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), ...overrideResponse}) +export const getApiV2AssetsVersionsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedVersionListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) -export const getApiV2TagsListResponseMock = (overrideResponse: Partial< PaginatedTagListResponseList > = {}): PaginatedTagListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url()})), ...overrideResponse}) +export const getApiV2AssetsVersionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): VersionRetrieveResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + default_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translation: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + ...overrideResponse, +}) -export const getApiV2TagsRetrieveResponseMock = (overrideResponse: Partial< TagRetrieveResponse > = {}): TagRetrieveResponse => ({name: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), assets: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.internet.url())), parent: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) +export const getApiV2AssetsXformRetrieveResponseMock = (): string => faker.word.sample() +export const getApiV2AssetsBulkCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetBulkResponse => ({ detail: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) -export const getApiV2AssetsListMockHandler = (overrideResponse?: PaginatedAssetList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList)) => { - return http.get('*/api/v2/assets/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsCountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetListCount => ({ + deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2AssetsHashRetrieveResponseMock = (overrideResponse: Partial = {}): HashResponse => ({ + hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsMetadataRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetMetadataResponse => ({ + languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + sectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ), + organizations: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsMinimalListRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetMinimalListList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 22 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2ImportsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedImportResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + messages: { + updated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kind: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + summary: faker.helpers.arrayElement([ + { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + language: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + first: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + owner__username: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + 'audit-logs': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset_id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + new_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) + +export const getApiV2ImportsCreateResponseMock = ( + overrideResponse: Partial = {}, +): ImportCreateResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2ImportsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ImportResponse => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + messages: { + updated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kind: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + summary: faker.helpers.arrayElement([ + { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + language: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + first: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + owner__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + 'audit-logs': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset_id: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + new_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + ...overrideResponse, +}) + +export const getApiV2ProjectOwnershipInvitesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectInviteResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + 'sender | recipient': faker.internet.url(), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectOwnershipInvitesCreateResponseMock = ( + overrideResponse: Partial = {}, +): ProjectInviteResponse => ({ + url: faker.internet.url(), + 'sender | recipient': faker.internet.url(), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectOwnershipInvitesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ProjectInviteResponse => ({ + url: faker.internet.url(), + 'sender | recipient': faker.internet.url(), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectOwnershipInvitesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): ProjectInviteResponse => ({ + url: faker.internet.url(), + 'sender | recipient': faker.internet.url(), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + transfers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + asset: faker.helpers.arrayElement([faker.internet.url(), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectOwnershipInvitesTransfersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TransferListResponse => ({ + url: faker.internet.url(), + asset: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2TagsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedTagListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2TagsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TagRetrieveResponse => ({ + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + assets: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + parent: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsListMockHandler = ( + overrideResponse?: + | PaginatedAssetList + | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), +) => { + return http.get('*/api/v2/assets/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsCreateMockHandler = (overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset)) => { - return http.post('*/api/v2/assets/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsCreateMockHandler = ( + overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), +) => { + return http.post('*/api/v2/assets/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsRetrieveMockHandler = (overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset)) => { - return http.get('*/api/v2/assets/:uidAsset/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsRetrieveMockHandler = ( + overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), +) => { + return http.get('*/api/v2/assets/:uidAsset/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsPartialUpdateMockHandler = (overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset)) => { - return http.patch('*/api/v2/assets/:uidAsset/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsPartialUpdateMockHandler = ( + overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), +) => { + return http.patch('*/api/v2/assets/:uidAsset/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsCountsListMockHandler = (overrideResponse?: PaginatedAssetCountResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetCountResponseList)) => { - return http.get('*/api/v2/assets/:uidAsset/counts/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsCountsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsCountsListMockHandler = ( + overrideResponse?: + | PaginatedAssetCountResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetCountResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/counts/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsCountsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDeploymentRetrieveMockHandler = (overrideResponse?: DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/deployment/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDeploymentRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDeploymentRetrieveMockHandler = ( + overrideResponse?: + | DeploymentResponse + | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/deployment/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDeploymentRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDeploymentCreateMockHandler = (overrideResponse?: DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/deployment/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDeploymentCreateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDeploymentCreateMockHandler = ( + overrideResponse?: + | DeploymentResponse + | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/deployment/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDeploymentCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDeploymentPartialUpdateMockHandler = (overrideResponse?: DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse)) => { - return http.patch('*/api/v2/assets/:uidAsset/deployment/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDeploymentPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDeploymentPartialUpdateMockHandler = ( + overrideResponse?: + | DeploymentResponse + | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/deployment/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDeploymentPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsVersionsListMockHandler = (overrideResponse?: PaginatedVersionListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedVersionListResponseList)) => { - return http.get('*/api/v2/assets/:uidAsset/versions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsVersionsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsVersionsListMockHandler = ( + overrideResponse?: + | PaginatedVersionListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedVersionListResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/versions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsVersionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsVersionsRetrieveMockHandler = (overrideResponse?: VersionRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | VersionRetrieveResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsVersionsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsVersionsRetrieveMockHandler = ( + overrideResponse?: + | VersionRetrieveResponse + | (( + info: Parameters[1]>[0], + ) => Promise | VersionRetrieveResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsVersionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsXformRetrieveMockHandler = (overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string)) => { - return http.get('*/api/v2/assets/:uidAsset/xform/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsXformRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsXformRetrieveMockHandler = ( + overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), +) => { + return http.get('*/api/v2/assets/:uidAsset/xform/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsXformRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsBulkCreateMockHandler = (overrideResponse?: AssetBulkResponse | ((info: Parameters[1]>[0]) => Promise | AssetBulkResponse)) => { - return http.post('*/api/v2/assets/bulk/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsBulkCreateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsBulkCreateMockHandler = ( + overrideResponse?: + | AssetBulkResponse + | ((info: Parameters[1]>[0]) => Promise | AssetBulkResponse), +) => { + return http.post('*/api/v2/assets/bulk/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsBulkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsCountsRetrieveMockHandler = (overrideResponse?: AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount)) => { - return http.get('*/api/v2/assets/counts/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsCountsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsCountsRetrieveMockHandler = ( + overrideResponse?: + | AssetListCount + | ((info: Parameters[1]>[0]) => Promise | AssetListCount), +) => { + return http.get('*/api/v2/assets/counts/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsCountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHashRetrieveMockHandler = (overrideResponse?: HashResponse | ((info: Parameters[1]>[0]) => Promise | HashResponse)) => { - return http.get('*/api/v2/assets/hash/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHashRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHashRetrieveMockHandler = ( + overrideResponse?: + | HashResponse + | ((info: Parameters[1]>[0]) => Promise | HashResponse), +) => { + return http.get('*/api/v2/assets/hash/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHashRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsMetadataRetrieveMockHandler = (overrideResponse?: AssetMetadataResponse | ((info: Parameters[1]>[0]) => Promise | AssetMetadataResponse)) => { - return http.get('*/api/v2/assets/metadata/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsMetadataRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsMetadataRetrieveMockHandler = ( + overrideResponse?: + | AssetMetadataResponse + | ((info: Parameters[1]>[0]) => Promise | AssetMetadataResponse), +) => { + return http.get('*/api/v2/assets/metadata/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsMetadataRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsMinimalListRetrieveMockHandler = (overrideResponse?: PaginatedAssetMinimalListList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetMinimalListList)) => { - return http.get('*/api/v2/assets/minimal-list/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsMinimalListRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsMinimalListRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetMinimalListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetMinimalListList), +) => { + return http.get('*/api/v2/assets/minimal-list/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsMinimalListRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ImportsListMockHandler = (overrideResponse?: PaginatedImportResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedImportResponseList)) => { - return http.get('*/api/v2/imports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ImportsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ImportsListMockHandler = ( + overrideResponse?: + | PaginatedImportResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedImportResponseList), +) => { + return http.get('*/api/v2/imports/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ImportsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ImportsCreateMockHandler = (overrideResponse?: ImportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ImportCreateResponse)) => { - return http.post('*/api/v2/imports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ImportsCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ImportsCreateMockHandler = ( + overrideResponse?: + | ImportCreateResponse + | ((info: Parameters[1]>[0]) => Promise | ImportCreateResponse), +) => { + return http.post('*/api/v2/imports/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ImportsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ImportsRetrieveMockHandler = (overrideResponse?: ImportResponse | ((info: Parameters[1]>[0]) => Promise | ImportResponse)) => { - return http.get('*/api/v2/imports/:uidImport/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ImportsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ImportsRetrieveMockHandler = ( + overrideResponse?: + | ImportResponse + | ((info: Parameters[1]>[0]) => Promise | ImportResponse), +) => { + return http.get('*/api/v2/imports/:uidImport/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ImportsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectOwnershipInvitesListMockHandler = (overrideResponse?: PaginatedProjectInviteResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedProjectInviteResponseList)) => { - return http.get('*/api/v2/project-ownership/invites/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectOwnershipInvitesListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectOwnershipInvitesListMockHandler = ( + overrideResponse?: + | PaginatedProjectInviteResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectInviteResponseList), +) => { + return http.get('*/api/v2/project-ownership/invites/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectOwnershipInvitesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectOwnershipInvitesCreateMockHandler = (overrideResponse?: ProjectInviteResponse | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse)) => { - return http.post('*/api/v2/project-ownership/invites/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectOwnershipInvitesCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectOwnershipInvitesCreateMockHandler = ( + overrideResponse?: + | ProjectInviteResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectInviteResponse), +) => { + return http.post('*/api/v2/project-ownership/invites/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectOwnershipInvitesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectOwnershipInvitesRetrieveMockHandler = (overrideResponse?: ProjectInviteResponse | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse)) => { - return http.get('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectOwnershipInvitesRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectOwnershipInvitesRetrieveMockHandler = ( + overrideResponse?: + | ProjectInviteResponse + | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse), +) => { + return http.get('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectOwnershipInvitesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = (overrideResponse?: ProjectInviteResponse | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse)) => { - return http.patch('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectOwnershipInvitesPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = ( + overrideResponse?: + | ProjectInviteResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectInviteResponse), +) => { + return http.patch('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectOwnershipInvitesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectOwnershipInvitesDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2ProjectOwnershipInvitesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler = (overrideResponse?: TransferListResponse | ((info: Parameters[1]>[0]) => Promise | TransferListResponse)) => { - return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectOwnershipInvitesTransfersRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler = ( + overrideResponse?: + | TransferListResponse + | ((info: Parameters[1]>[0]) => Promise | TransferListResponse), +) => { + return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectOwnershipInvitesTransfersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2TagsListMockHandler = (overrideResponse?: PaginatedTagListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedTagListResponseList)) => { - return http.get('*/api/v2/tags/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2TagsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2TagsListMockHandler = ( + overrideResponse?: + | PaginatedTagListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedTagListResponseList), +) => { + return http.get('*/api/v2/tags/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TagsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2TagsRetrieveMockHandler = (overrideResponse?: TagRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | TagRetrieveResponse)) => { - return http.get('*/api/v2/tags/:taguidUid/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2TagsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2TagsRetrieveMockHandler = ( + overrideResponse?: + | TagRetrieveResponse + | ((info: Parameters[1]>[0]) => Promise | TagRetrieveResponse), +) => { + return http.get('*/api/v2/tags/:taguidUid/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TagsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } export const getManageProjectsAndLibraryContentMock = () => [ @@ -505,5 +5184,5 @@ export const getManageProjectsAndLibraryContentMock = () => [ getApiV2ProjectOwnershipInvitesDestroyMockHandler(), getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler(), getApiV2TagsListMockHandler(), - getApiV2TagsRetrieveMockHandler() + getApiV2TagsRetrieveMockHandler(), ] diff --git a/jsapp/js/api/react-query/other/index.ts b/jsapp/js/api/react-query/other/index.ts index 6dd906a653..90e69d0c30 100644 --- a/jsapp/js/api/react-query/other/index.ts +++ b/jsapp/js/api/react-query/other/index.ts @@ -9,133 +9,73 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - ChangePlan -} from '../../models/changePlan'; - -import type { - CheckoutLink -} from '../../models/checkoutLink'; - -import type { - CustomerPortal -} from '../../models/customerPortal'; - -import type { - CustomerPortalPostResponse -} from '../../models/customerPortalPostResponse'; +import type { ChangePlan } from '../../models/changePlan' -import type { - ErrorDetail -} from '../../models/errorDetail'; +import type { CheckoutLink } from '../../models/checkoutLink' -import type { - ErrorObject -} from '../../models/errorObject'; +import type { CustomerPortal } from '../../models/customerPortal' -import type { - Language -} from '../../models/language'; +import type { CustomerPortalPostResponse } from '../../models/customerPortalPostResponse' -import type { - LanguagesListParams -} from '../../models/languagesListParams'; +import type { ErrorDetail } from '../../models/errorDetail' -import type { - OneTimeAddOn -} from '../../models/oneTimeAddOn'; +import type { ErrorObject } from '../../models/errorObject' -import type { - PaginatedLanguageListList -} from '../../models/paginatedLanguageListList'; +import type { Language } from '../../models/language' -import type { - PaginatedOneTimeAddOnList -} from '../../models/paginatedOneTimeAddOnList'; +import type { LanguagesListParams } from '../../models/languagesListParams' -import type { - PaginatedPermissionResponseList -} from '../../models/paginatedPermissionResponseList'; +import type { OneTimeAddOn } from '../../models/oneTimeAddOn' -import type { - PaginatedProductList -} from '../../models/paginatedProductList'; +import type { PaginatedLanguageListList } from '../../models/paginatedLanguageListList' -import type { - PaginatedSubscriptionList -} from '../../models/paginatedSubscriptionList'; +import type { PaginatedOneTimeAddOnList } from '../../models/paginatedOneTimeAddOnList' -import type { - PaginatedTranscriptionServiceList -} from '../../models/paginatedTranscriptionServiceList'; +import type { PaginatedPermissionResponseList } from '../../models/paginatedPermissionResponseList' -import type { - PaginatedTranslationServiceList -} from '../../models/paginatedTranslationServiceList'; +import type { PaginatedProductList } from '../../models/paginatedProductList' -import type { - PermissionResponse -} from '../../models/permissionResponse'; +import type { PaginatedSubscriptionList } from '../../models/paginatedSubscriptionList' -import type { - PermissionsListParams -} from '../../models/permissionsListParams'; +import type { PaginatedTranscriptionServiceList } from '../../models/paginatedTranscriptionServiceList' -import type { - StripeAddonsListParams -} from '../../models/stripeAddonsListParams'; +import type { PaginatedTranslationServiceList } from '../../models/paginatedTranslationServiceList' -import type { - StripeProductsListParams -} from '../../models/stripeProductsListParams'; +import type { PermissionResponse } from '../../models/permissionResponse' -import type { - StripeSubscriptionsListParams -} from '../../models/stripeSubscriptionsListParams'; +import type { PermissionsListParams } from '../../models/permissionsListParams' -import type { - Subscription -} from '../../models/subscription'; +import type { StripeAddonsListParams } from '../../models/stripeAddonsListParams' -import type { - TermsOfServiceResponse -} from '../../models/termsOfServiceResponse'; +import type { StripeProductsListParams } from '../../models/stripeProductsListParams' -import type { - TranscriptionService -} from '../../models/transcriptionService'; +import type { StripeSubscriptionsListParams } from '../../models/stripeSubscriptionsListParams' -import type { - TranscriptionServicesListParams -} from '../../models/transcriptionServicesListParams'; +import type { Subscription } from '../../models/subscription' -import type { - TranslationService -} from '../../models/translationService'; +import type { TermsOfServiceResponse } from '../../models/termsOfServiceResponse' -import type { - TranslationServicesListParams -} from '../../models/translationServicesListParams'; +import type { TranscriptionService } from '../../models/transcriptionService' -import { fetchWithAuth } from '../../orval.mutator'; +import type { TranscriptionServicesListParams } from '../../models/transcriptionServicesListParams' +import type { TranslationService } from '../../models/translationService' -type SecondParameter unknown> = Parameters[1]; +import type { TranslationServicesListParams } from '../../models/translationServicesListParams' +import { fetchWithAuth } from '../../orval.mutator' +type SecondParameter unknown> = Parameters[1] /** * ## List the languages accessible to requesting (authenticated) user. @@ -166,85 +106,81 @@ export type languagesListResponse401 = { data: ErrorDetail status: 401 } - -export type languagesListResponseComposite = languagesListResponse200 | languagesListResponse401; - + +export type languagesListResponseComposite = languagesListResponse200 | languagesListResponse401 + export type languagesListResponse = languagesListResponseComposite & { - headers: Headers; + headers: Headers } -export const getLanguagesListUrl = (params?: LanguagesListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getLanguagesListUrl = (params?: LanguagesListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/languages/?${stringifiedParams}` : `/api/v2/languages/` } -export const languagesList = async (params?: LanguagesListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getLanguagesListUrl(params), - { +export const languagesList = async ( + params?: LanguagesListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getLanguagesListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getLanguagesListQueryKey = (params?: LanguagesListParams,) => { - return ['api','v2','languages', ...(params ? [params]: [])] as const; - } +export const getLanguagesListQueryKey = (params?: LanguagesListParams) => { + return ['api', 'v2', 'languages', ...(params ? [params] : [])] as const +} - -export const getLanguagesListQueryOptions = >, TError = ErrorDetail>(params?: LanguagesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getLanguagesListQueryOptions = >, TError = ErrorDetail>( + params?: LanguagesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getLanguagesListQueryKey(params); - - - - const queryFn: QueryFunction>> = ({ signal }) => languagesList(params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getLanguagesListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + languagesList(params, { signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type LanguagesListQueryResult = NonNullable>> export type LanguagesListQueryError = ErrorDetail - - export function useLanguagesList>, TError = ErrorDetail>( - params?: LanguagesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getLanguagesListQueryOptions(params,options) + params?: LanguagesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getLanguagesListQueryOptions(params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Retrieve one language @@ -260,78 +196,71 @@ export type languagesRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type languagesRetrieveResponseComposite = languagesRetrieveResponse200 | languagesRetrieveResponse401; - -export type languagesRetrieveResponse = languagesRetrieveResponseComposite & { - headers: Headers; -} - -export const getLanguagesRetrieveUrl = (code: string,) => { +export type languagesRetrieveResponseComposite = languagesRetrieveResponse200 | languagesRetrieveResponse401 - +export type languagesRetrieveResponse = languagesRetrieveResponseComposite & { + headers: Headers +} +export const getLanguagesRetrieveUrl = (code: string) => { return `/api/v2/languages/${code}/` } export const languagesRetrieve = async (code: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getLanguagesRetrieveUrl(code), - { + return fetchWithAuth(getLanguagesRetrieveUrl(code), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getLanguagesRetrieveQueryKey = (code: string,) => { - return ['api','v2','languages',code] as const; - } +export const getLanguagesRetrieveQueryKey = (code: string) => { + return ['api', 'v2', 'languages', code] as const +} - -export const getLanguagesRetrieveQueryOptions = >, TError = ErrorDetail>(code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getLanguagesRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + code: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getLanguagesRetrieveQueryKey(code); - - + const queryKey = queryOptions?.queryKey ?? getLanguagesRetrieveQueryKey(code) - const queryFn: QueryFunction>> = ({ signal }) => languagesRetrieve(code, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + languagesRetrieve(code, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(code), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!code, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type LanguagesRetrieveQueryResult = NonNullable>> export type LanguagesRetrieveQueryError = ErrorDetail - - export function useLanguagesRetrieve>, TError = ErrorDetail>( - code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getLanguagesRetrieveQueryOptions(code,options) + code: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getLanguagesRetrieveQueryOptions(code, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## List all assignable permissions for `Asset` @@ -347,85 +276,81 @@ export type permissionsListResponse200 = { data: PaginatedPermissionResponseList status: 200 } - -export type permissionsListResponseComposite = permissionsListResponse200; - + +export type permissionsListResponseComposite = permissionsListResponse200 + export type permissionsListResponse = permissionsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getPermissionsListUrl = (params?: PermissionsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getPermissionsListUrl = (params?: PermissionsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/permissions/?${stringifiedParams}` : `/api/v2/permissions/` } -export const permissionsList = async (params?: PermissionsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getPermissionsListUrl(params), - { +export const permissionsList = async ( + params?: PermissionsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getPermissionsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getPermissionsListQueryKey = (params?: PermissionsListParams,) => { - return ['api','v2','permissions', ...(params ? [params]: [])] as const; - } +export const getPermissionsListQueryKey = (params?: PermissionsListParams) => { + return ['api', 'v2', 'permissions', ...(params ? [params] : [])] as const +} - -export const getPermissionsListQueryOptions = >, TError = unknown>(params?: PermissionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getPermissionsListQueryOptions = >, TError = unknown>( + params?: PermissionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getPermissionsListQueryKey(params); - - - - const queryFn: QueryFunction>> = ({ signal }) => permissionsList(params, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getPermissionsListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + permissionsList(params, { signal, ...requestOptions }) - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type PermissionsListQueryResult = NonNullable>> export type PermissionsListQueryError = unknown - - export function usePermissionsList>, TError = unknown>( - params?: PermissionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + params?: PermissionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getPermissionsListQueryOptions(params, options) - const queryOptions = getPermissionsListQueryOptions(params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Retrieve a codename's permissions @@ -434,78 +359,74 @@ export type permissionsRetrieveResponse200 = { data: PermissionResponse status: 200 } - -export type permissionsRetrieveResponseComposite = permissionsRetrieveResponse200; - -export type permissionsRetrieveResponse = permissionsRetrieveResponseComposite & { - headers: Headers; -} - -export const getPermissionsRetrieveUrl = (codename: string,) => { +export type permissionsRetrieveResponseComposite = permissionsRetrieveResponse200 - +export type permissionsRetrieveResponse = permissionsRetrieveResponseComposite & { + headers: Headers +} +export const getPermissionsRetrieveUrl = (codename: string) => { return `/api/v2/permissions/${codename}/` } -export const permissionsRetrieve = async (codename: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getPermissionsRetrieveUrl(codename), - { +export const permissionsRetrieve = async ( + codename: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getPermissionsRetrieveUrl(codename), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getPermissionsRetrieveQueryKey = (codename: string,) => { - return ['api','v2','permissions',codename] as const; - } +export const getPermissionsRetrieveQueryKey = (codename: string) => { + return ['api', 'v2', 'permissions', codename] as const +} - -export const getPermissionsRetrieveQueryOptions = >, TError = unknown>(codename: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getPermissionsRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + codename: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getPermissionsRetrieveQueryKey(codename) - const queryKey = queryOptions?.queryKey ?? getPermissionsRetrieveQueryKey(codename); + const queryFn: QueryFunction>> = ({ signal }) => + permissionsRetrieve(codename, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => permissionsRetrieve(codename, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(codename), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!codename, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type PermissionsRetrieveQueryResult = NonNullable>> export type PermissionsRetrieveQueryError = unknown - - export function usePermissionsRetrieve>, TError = unknown>( - codename: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + codename: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getPermissionsRetrieveQueryOptions(codename, options) - const queryOptions = getPermissionsRetrieveQueryOptions(codename,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * Lists the one-time add-ons for the authenticated user's organization. */ @@ -513,85 +434,81 @@ export type stripeAddonsListResponse200 = { data: PaginatedOneTimeAddOnList status: 200 } - -export type stripeAddonsListResponseComposite = stripeAddonsListResponse200; - + +export type stripeAddonsListResponseComposite = stripeAddonsListResponse200 + export type stripeAddonsListResponse = stripeAddonsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getStripeAddonsListUrl = (params?: StripeAddonsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getStripeAddonsListUrl = (params?: StripeAddonsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/stripe/addons/?${stringifiedParams}` : `/api/v2/stripe/addons/` } -export const stripeAddonsList = async (params?: StripeAddonsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getStripeAddonsListUrl(params), - { +export const stripeAddonsList = async ( + params?: StripeAddonsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getStripeAddonsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getStripeAddonsListQueryKey = (params?: StripeAddonsListParams,) => { - return ['api','v2','stripe','addons', ...(params ? [params]: [])] as const; - } +export const getStripeAddonsListQueryKey = (params?: StripeAddonsListParams) => { + return ['api', 'v2', 'stripe', 'addons', ...(params ? [params] : [])] as const +} - -export const getStripeAddonsListQueryOptions = >, TError = unknown>(params?: StripeAddonsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getStripeAddonsListQueryOptions = >, TError = unknown>( + params?: StripeAddonsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getStripeAddonsListQueryKey(params); + const queryKey = queryOptions?.queryKey ?? getStripeAddonsListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + stripeAddonsList(params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => stripeAddonsList(params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type StripeAddonsListQueryResult = NonNullable>> export type StripeAddonsListQueryError = unknown - - export function useStripeAddonsList>, TError = unknown>( - params?: StripeAddonsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getStripeAddonsListQueryOptions(params,options) + params?: StripeAddonsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getStripeAddonsListQueryOptions(params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Lists the one-time add-ons for the authenticated user's organization. */ @@ -599,78 +516,74 @@ export type stripeAddonsRetrieveResponse200 = { data: OneTimeAddOn status: 200 } - -export type stripeAddonsRetrieveResponseComposite = stripeAddonsRetrieveResponse200; - -export type stripeAddonsRetrieveResponse = stripeAddonsRetrieveResponseComposite & { - headers: Headers; -} - -export const getStripeAddonsRetrieveUrl = (id: string,) => { +export type stripeAddonsRetrieveResponseComposite = stripeAddonsRetrieveResponse200 - +export type stripeAddonsRetrieveResponse = stripeAddonsRetrieveResponseComposite & { + headers: Headers +} +export const getStripeAddonsRetrieveUrl = (id: string) => { return `/api/v2/stripe/addons/${id}/` } -export const stripeAddonsRetrieve = async (id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getStripeAddonsRetrieveUrl(id), - { +export const stripeAddonsRetrieve = async ( + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getStripeAddonsRetrieveUrl(id), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getStripeAddonsRetrieveQueryKey = (id: string,) => { - return ['api','v2','stripe','addons',id] as const; - } +export const getStripeAddonsRetrieveQueryKey = (id: string) => { + return ['api', 'v2', 'stripe', 'addons', id] as const +} - -export const getStripeAddonsRetrieveQueryOptions = >, TError = unknown>(id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getStripeAddonsRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getStripeAddonsRetrieveQueryKey(id); - - + const queryKey = queryOptions?.queryKey ?? getStripeAddonsRetrieveQueryKey(id) - const queryFn: QueryFunction>> = ({ signal }) => stripeAddonsRetrieve(id, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + stripeAddonsRetrieve(id, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!id, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type StripeAddonsRetrieveQueryResult = NonNullable>> export type StripeAddonsRetrieveQueryError = unknown - - export function useStripeAddonsRetrieve>, TError = unknown>( - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getStripeAddonsRetrieveQueryOptions(id,options) + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getStripeAddonsRetrieveQueryOptions(id, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Change an existing subscription to a new price. @@ -703,150 +616,145 @@ export type stripeChangePlanRetrieveResponse200 = { data: ChangePlan status: 200 } - -export type stripeChangePlanRetrieveResponseComposite = stripeChangePlanRetrieveResponse200; - + +export type stripeChangePlanRetrieveResponseComposite = stripeChangePlanRetrieveResponse200 + export type stripeChangePlanRetrieveResponse = stripeChangePlanRetrieveResponseComposite & { - headers: Headers; + headers: Headers } export const getStripeChangePlanRetrieveUrl = () => { - - - - return `/api/v2/stripe/change-plan` } -export const stripeChangePlanRetrieve = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getStripeChangePlanRetrieveUrl(), - { +export const stripeChangePlanRetrieve = async (options?: RequestInit): Promise => { + return fetchWithAuth(getStripeChangePlanRetrieveUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getStripeChangePlanRetrieveQueryKey = () => { - return ['api','v2','stripe','change-plan'] as const; - } - - -export const getStripeChangePlanRetrieveQueryOptions = >, TError = unknown>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getStripeChangePlanRetrieveQueryKey(); - - + return ['api', 'v2', 'stripe', 'change-plan'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => stripeChangePlanRetrieve({ signal, ...requestOptions }); +export const getStripeChangePlanRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getStripeChangePlanRetrieveQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + stripeChangePlanRetrieve({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type StripeChangePlanRetrieveQueryResult = NonNullable>> export type StripeChangePlanRetrieveQueryError = unknown - - -export function useStripeChangePlanRetrieve>, TError = unknown>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useStripeChangePlanRetrieve< + TData = Awaited>, + TError = unknown, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getStripeChangePlanRetrieveQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - export type stripeCheckoutLinkCreateResponse200 = { data: CheckoutLink status: 200 } - -export type stripeCheckoutLinkCreateResponseComposite = stripeCheckoutLinkCreateResponse200; - + +export type stripeCheckoutLinkCreateResponseComposite = stripeCheckoutLinkCreateResponse200 + export type stripeCheckoutLinkCreateResponse = stripeCheckoutLinkCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getStripeCheckoutLinkCreateUrl = () => { - - - - return `/api/v2/stripe/checkout-link` } -export const stripeCheckoutLinkCreate = async (checkoutLink: CheckoutLink, options?: RequestInit): Promise => { - - return fetchWithAuth(getStripeCheckoutLinkCreateUrl(), - { +export const stripeCheckoutLinkCreate = async ( + checkoutLink: CheckoutLink, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getStripeCheckoutLinkCreateUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - checkoutLink,) + body: JSON.stringify(checkoutLink), + }) +} + +export const getStripeCheckoutLinkCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CheckoutLink }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: CheckoutLink }, + TContext +> => { + const mutationKey = ['stripeCheckoutLinkCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: CheckoutLink }> = ( + props, + ) => { + const { data } = props ?? {} + + return stripeCheckoutLinkCreate(data, requestOptions) } -);} + return { mutationFn, ...mutationOptions } +} +export type StripeCheckoutLinkCreateMutationResult = NonNullable>> +export type StripeCheckoutLinkCreateMutationBody = CheckoutLink +export type StripeCheckoutLinkCreateMutationError = unknown +export const useStripeCheckoutLinkCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CheckoutLink }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getStripeCheckoutLinkCreateMutationOptions(options) -export const getStripeCheckoutLinkCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: CheckoutLink}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: CheckoutLink}, TContext> => { - -const mutationKey = ['stripeCheckoutLinkCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: CheckoutLink}> = (props) => { - const {data} = props ?? {}; - - return stripeCheckoutLinkCreate(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type StripeCheckoutLinkCreateMutationResult = NonNullable>> - export type StripeCheckoutLinkCreateMutationBody = CheckoutLink - export type StripeCheckoutLinkCreateMutationError = unknown - - export const useStripeCheckoutLinkCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: CheckoutLink}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getStripeCheckoutLinkCreateMutationOptions(options); - - return useMutation(mutationOptions ); - } - export type stripeCustomerPortalCreateResponse200 = { + return useMutation(mutationOptions) +} +export type stripeCustomerPortalCreateResponse200 = { data: CustomerPortalPostResponse status: 200 } @@ -860,74 +768,88 @@ export type stripeCustomerPortalCreateResponse401 = { data: ErrorDetail status: 401 } - -export type stripeCustomerPortalCreateResponseComposite = stripeCustomerPortalCreateResponse200 | stripeCustomerPortalCreateResponse400 | stripeCustomerPortalCreateResponse401; - + +export type stripeCustomerPortalCreateResponseComposite = + | stripeCustomerPortalCreateResponse200 + | stripeCustomerPortalCreateResponse400 + | stripeCustomerPortalCreateResponse401 + export type stripeCustomerPortalCreateResponse = stripeCustomerPortalCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getStripeCustomerPortalCreateUrl = () => { - - - - return `/api/v2/stripe/customer-portal` } -export const stripeCustomerPortalCreate = async (customerPortal: CustomerPortal, options?: RequestInit): Promise => { - - return fetchWithAuth(getStripeCustomerPortalCreateUrl(), - { +export const stripeCustomerPortalCreate = async ( + customerPortal: CustomerPortal, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getStripeCustomerPortalCreateUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - customerPortal,) + body: JSON.stringify(customerPortal), + }) +} + +export const getStripeCustomerPortalCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CustomerPortal }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: CustomerPortal }, + TContext +> => { + const mutationKey = ['stripeCustomerPortalCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: CustomerPortal } + > = (props) => { + const { data } = props ?? {} + + return stripeCustomerPortalCreate(data, requestOptions) } -);} - - - -export const getStripeCustomerPortalCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: CustomerPortal}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: CustomerPortal}, TContext> => { - -const mutationKey = ['stripeCustomerPortalCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: CustomerPortal}> = (props) => { - const {data} = props ?? {}; - - return stripeCustomerPortalCreate(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type StripeCustomerPortalCreateMutationResult = NonNullable>> - export type StripeCustomerPortalCreateMutationBody = CustomerPortal - export type StripeCustomerPortalCreateMutationError = ErrorObject | ErrorDetail - - export const useStripeCustomerPortalCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: CustomerPortal}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getStripeCustomerPortalCreateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type StripeCustomerPortalCreateMutationResult = NonNullable< + Awaited> +> +export type StripeCustomerPortalCreateMutationBody = CustomerPortal +export type StripeCustomerPortalCreateMutationError = ErrorObject | ErrorDetail + +export const useStripeCustomerPortalCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CustomerPortal }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getStripeCustomerPortalCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * Returns Product and Price Lists, sorted from the product with the lowest price to highest This endpoint is cached for an amount of time determined by ENDPOINT_CACHE_DURATION @@ -987,85 +909,84 @@ export type stripeProductsListResponse200 = { data: PaginatedProductList status: 200 } - -export type stripeProductsListResponseComposite = stripeProductsListResponse200; - + +export type stripeProductsListResponseComposite = stripeProductsListResponse200 + export type stripeProductsListResponse = stripeProductsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getStripeProductsListUrl = (params?: StripeProductsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getStripeProductsListUrl = (params?: StripeProductsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/stripe/products/?${stringifiedParams}` : `/api/v2/stripe/products/` } -export const stripeProductsList = async (params?: StripeProductsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getStripeProductsListUrl(params), - { +export const stripeProductsList = async ( + params?: StripeProductsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getStripeProductsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getStripeProductsListQueryKey = (params?: StripeProductsListParams,) => { - return ['api','v2','stripe','products', ...(params ? [params]: [])] as const; - } +export const getStripeProductsListQueryKey = (params?: StripeProductsListParams) => { + return ['api', 'v2', 'stripe', 'products', ...(params ? [params] : [])] as const +} - -export const getStripeProductsListQueryOptions = >, TError = unknown>(params?: StripeProductsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getStripeProductsListQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + params?: StripeProductsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getStripeProductsListQueryKey(params) - const queryKey = queryOptions?.queryKey ?? getStripeProductsListQueryKey(params); + const queryFn: QueryFunction>> = ({ signal }) => + stripeProductsList(params, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => stripeProductsList(params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type StripeProductsListQueryResult = NonNullable>> export type StripeProductsListQueryError = unknown - - export function useStripeProductsList>, TError = unknown>( - params?: StripeProductsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + params?: StripeProductsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getStripeProductsListQueryOptions(params, options) - const queryOptions = getStripeProductsListQueryOptions(params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - export type stripeSubscriptionsListResponse200 = { data: PaginatedSubscriptionList status: 200 @@ -1075,161 +996,168 @@ export type stripeSubscriptionsListResponse401 = { data: ErrorDetail status: 401 } - -export type stripeSubscriptionsListResponseComposite = stripeSubscriptionsListResponse200 | stripeSubscriptionsListResponse401; - + +export type stripeSubscriptionsListResponseComposite = + | stripeSubscriptionsListResponse200 + | stripeSubscriptionsListResponse401 + export type stripeSubscriptionsListResponse = stripeSubscriptionsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getStripeSubscriptionsListUrl = (params?: StripeSubscriptionsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getStripeSubscriptionsListUrl = (params?: StripeSubscriptionsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/stripe/subscriptions/?${stringifiedParams}` : `/api/v2/stripe/subscriptions/` + return stringifiedParams.length > 0 + ? `/api/v2/stripe/subscriptions/?${stringifiedParams}` + : `/api/v2/stripe/subscriptions/` } -export const stripeSubscriptionsList = async (params?: StripeSubscriptionsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getStripeSubscriptionsListUrl(params), - { +export const stripeSubscriptionsList = async ( + params?: StripeSubscriptionsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getStripeSubscriptionsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getStripeSubscriptionsListQueryKey = (params?: StripeSubscriptionsListParams,) => { - return ['api','v2','stripe','subscriptions', ...(params ? [params]: [])] as const; - } +export const getStripeSubscriptionsListQueryKey = (params?: StripeSubscriptionsListParams) => { + return ['api', 'v2', 'stripe', 'subscriptions', ...(params ? [params] : [])] as const +} - -export const getStripeSubscriptionsListQueryOptions = >, TError = ErrorDetail>(params?: StripeSubscriptionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getStripeSubscriptionsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: StripeSubscriptionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getStripeSubscriptionsListQueryKey(params); + const queryKey = queryOptions?.queryKey ?? getStripeSubscriptionsListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + stripeSubscriptionsList(params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => stripeSubscriptionsList(params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type StripeSubscriptionsListQueryResult = NonNullable>> export type StripeSubscriptionsListQueryError = ErrorDetail +export function useStripeSubscriptionsList< + TData = Awaited>, + TError = ErrorDetail, +>( + params?: StripeSubscriptionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getStripeSubscriptionsListQueryOptions(params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useStripeSubscriptionsList>, TError = ErrorDetail>( - params?: StripeSubscriptionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getStripeSubscriptionsListQueryOptions(params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - export type stripeSubscriptionsRetrieveResponse200 = { data: Subscription status: 200 } - -export type stripeSubscriptionsRetrieveResponseComposite = stripeSubscriptionsRetrieveResponse200; - -export type stripeSubscriptionsRetrieveResponse = stripeSubscriptionsRetrieveResponseComposite & { - headers: Headers; -} - -export const getStripeSubscriptionsRetrieveUrl = (id: string,) => { +export type stripeSubscriptionsRetrieveResponseComposite = stripeSubscriptionsRetrieveResponse200 - +export type stripeSubscriptionsRetrieveResponse = stripeSubscriptionsRetrieveResponseComposite & { + headers: Headers +} +export const getStripeSubscriptionsRetrieveUrl = (id: string) => { return `/api/v2/stripe/subscriptions/${id}/` } -export const stripeSubscriptionsRetrieve = async (id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getStripeSubscriptionsRetrieveUrl(id), - { +export const stripeSubscriptionsRetrieve = async ( + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getStripeSubscriptionsRetrieveUrl(id), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getStripeSubscriptionsRetrieveQueryKey = (id: string,) => { - return ['api','v2','stripe','subscriptions',id] as const; - } +export const getStripeSubscriptionsRetrieveQueryKey = (id: string) => { + return ['api', 'v2', 'stripe', 'subscriptions', id] as const +} - -export const getStripeSubscriptionsRetrieveQueryOptions = >, TError = unknown>(id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getStripeSubscriptionsRetrieveQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getStripeSubscriptionsRetrieveQueryKey(id); - - + const queryKey = queryOptions?.queryKey ?? getStripeSubscriptionsRetrieveQueryKey(id) - const queryFn: QueryFunction>> = ({ signal }) => stripeSubscriptionsRetrieve(id, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + stripeSubscriptionsRetrieve(id, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!id, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type StripeSubscriptionsRetrieveQueryResult = NonNullable>> +export type StripeSubscriptionsRetrieveQueryResult = NonNullable< + Awaited> +> export type StripeSubscriptionsRetrieveQueryError = unknown +export function useStripeSubscriptionsRetrieve< + TData = Awaited>, + TError = unknown, +>( + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getStripeSubscriptionsRetrieveQueryOptions(id, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useStripeSubscriptionsRetrieve>, TError = unknown>( - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getStripeSubscriptionsRetrieveQueryOptions(id,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## List the different terms of service @@ -1243,78 +1171,68 @@ export type termsOfServiceListResponse401 = { data: ErrorDetail status: 401 } - -export type termsOfServiceListResponseComposite = termsOfServiceListResponse200 | termsOfServiceListResponse401; - + +export type termsOfServiceListResponseComposite = termsOfServiceListResponse200 | termsOfServiceListResponse401 + export type termsOfServiceListResponse = termsOfServiceListResponseComposite & { - headers: Headers; + headers: Headers } export const getTermsOfServiceListUrl = () => { - - - - return `/api/v2/terms-of-service/` } -export const termsOfServiceList = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getTermsOfServiceListUrl(), - { +export const termsOfServiceList = async (options?: RequestInit): Promise => { + return fetchWithAuth(getTermsOfServiceListUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getTermsOfServiceListQueryKey = () => { - return ['api','v2','terms-of-service'] as const; - } - - -export const getTermsOfServiceListQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getTermsOfServiceListQueryKey(); - - + return ['api', 'v2', 'terms-of-service'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => termsOfServiceList({ signal, ...requestOptions }); +export const getTermsOfServiceListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getTermsOfServiceListQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + termsOfServiceList({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type TermsOfServiceListQueryResult = NonNullable>> export type TermsOfServiceListQueryError = ErrorDetail - - -export function useTermsOfServiceList>, TError = ErrorDetail>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useTermsOfServiceList< + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getTermsOfServiceListQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Retrieve a specific terms of service @@ -1328,78 +1246,79 @@ export type termsOfServiceRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type termsOfServiceRetrieveResponseComposite = termsOfServiceRetrieveResponse200 | termsOfServiceRetrieveResponse401; - -export type termsOfServiceRetrieveResponse = termsOfServiceRetrieveResponseComposite & { - headers: Headers; -} - -export const getTermsOfServiceRetrieveUrl = (slug: string,) => { +export type termsOfServiceRetrieveResponseComposite = + | termsOfServiceRetrieveResponse200 + | termsOfServiceRetrieveResponse401 - +export type termsOfServiceRetrieveResponse = termsOfServiceRetrieveResponseComposite & { + headers: Headers +} +export const getTermsOfServiceRetrieveUrl = (slug: string) => { return `/api/v2/terms-of-service/${slug}/` } -export const termsOfServiceRetrieve = async (slug: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getTermsOfServiceRetrieveUrl(slug), - { +export const termsOfServiceRetrieve = async ( + slug: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getTermsOfServiceRetrieveUrl(slug), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getTermsOfServiceRetrieveQueryKey = (slug: string,) => { - return ['api','v2','terms-of-service',slug] as const; - } +export const getTermsOfServiceRetrieveQueryKey = (slug: string) => { + return ['api', 'v2', 'terms-of-service', slug] as const +} - -export const getTermsOfServiceRetrieveQueryOptions = >, TError = ErrorDetail>(slug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getTermsOfServiceRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + slug: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getTermsOfServiceRetrieveQueryKey(slug); - - - - const queryFn: QueryFunction>> = ({ signal }) => termsOfServiceRetrieve(slug, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getTermsOfServiceRetrieveQueryKey(slug) - + const queryFn: QueryFunction>> = ({ signal }) => + termsOfServiceRetrieve(slug, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(slug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!slug, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type TermsOfServiceRetrieveQueryResult = NonNullable>> export type TermsOfServiceRetrieveQueryError = ErrorDetail +export function useTermsOfServiceRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + slug: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getTermsOfServiceRetrieveQueryOptions(slug, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useTermsOfServiceRetrieve>, TError = ErrorDetail>( - slug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getTermsOfServiceRetrieveQueryOptions(slug,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## List the transcription services accessible to requesting user. @@ -1417,85 +1336,91 @@ export type transcriptionServicesListResponse401 = { data: ErrorDetail status: 401 } - -export type transcriptionServicesListResponseComposite = transcriptionServicesListResponse200 | transcriptionServicesListResponse401; - + +export type transcriptionServicesListResponseComposite = + | transcriptionServicesListResponse200 + | transcriptionServicesListResponse401 + export type transcriptionServicesListResponse = transcriptionServicesListResponseComposite & { - headers: Headers; + headers: Headers } -export const getTranscriptionServicesListUrl = (params?: TranscriptionServicesListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getTranscriptionServicesListUrl = (params?: TranscriptionServicesListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/transcription-services/?${stringifiedParams}` : `/api/v2/transcription-services/` + return stringifiedParams.length > 0 + ? `/api/v2/transcription-services/?${stringifiedParams}` + : `/api/v2/transcription-services/` } -export const transcriptionServicesList = async (params?: TranscriptionServicesListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getTranscriptionServicesListUrl(params), - { +export const transcriptionServicesList = async ( + params?: TranscriptionServicesListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getTranscriptionServicesListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getTranscriptionServicesListQueryKey = (params?: TranscriptionServicesListParams,) => { - return ['api','v2','transcription-services', ...(params ? [params]: [])] as const; - } +export const getTranscriptionServicesListQueryKey = (params?: TranscriptionServicesListParams) => { + return ['api', 'v2', 'transcription-services', ...(params ? [params] : [])] as const +} - -export const getTranscriptionServicesListQueryOptions = >, TError = ErrorDetail>(params?: TranscriptionServicesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getTranscriptionServicesListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: TranscriptionServicesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getTranscriptionServicesListQueryKey(params); - - + const queryKey = queryOptions?.queryKey ?? getTranscriptionServicesListQueryKey(params) - const queryFn: QueryFunction>> = ({ signal }) => transcriptionServicesList(params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + transcriptionServicesList(params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type TranscriptionServicesListQueryResult = NonNullable>> export type TranscriptionServicesListQueryError = ErrorDetail +export function useTranscriptionServicesList< + TData = Awaited>, + TError = ErrorDetail, +>( + params?: TranscriptionServicesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getTranscriptionServicesListQueryOptions(params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useTranscriptionServicesList>, TError = ErrorDetail>( - params?: TranscriptionServicesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getTranscriptionServicesListQueryOptions(params,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## retrieve a transcription service @@ -1511,78 +1436,81 @@ export type transcriptionServicesRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type transcriptionServicesRetrieveResponseComposite = transcriptionServicesRetrieveResponse200 | transcriptionServicesRetrieveResponse401; - -export type transcriptionServicesRetrieveResponse = transcriptionServicesRetrieveResponseComposite & { - headers: Headers; -} -export const getTranscriptionServicesRetrieveUrl = (code: string,) => { +export type transcriptionServicesRetrieveResponseComposite = + | transcriptionServicesRetrieveResponse200 + | transcriptionServicesRetrieveResponse401 +export type transcriptionServicesRetrieveResponse = transcriptionServicesRetrieveResponseComposite & { + headers: Headers +} - - +export const getTranscriptionServicesRetrieveUrl = (code: string) => { return `/api/v2/transcription-services/${code}/` } -export const transcriptionServicesRetrieve = async (code: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getTranscriptionServicesRetrieveUrl(code), - { +export const transcriptionServicesRetrieve = async ( + code: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getTranscriptionServicesRetrieveUrl(code), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getTranscriptionServicesRetrieveQueryKey = (code: string,) => { - return ['api','v2','transcription-services',code] as const; - } +export const getTranscriptionServicesRetrieveQueryKey = (code: string) => { + return ['api', 'v2', 'transcription-services', code] as const +} - -export const getTranscriptionServicesRetrieveQueryOptions = >, TError = ErrorDetail>(code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getTranscriptionServicesRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + code: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getTranscriptionServicesRetrieveQueryKey(code); - - + const queryKey = queryOptions?.queryKey ?? getTranscriptionServicesRetrieveQueryKey(code) - const queryFn: QueryFunction>> = ({ signal }) => transcriptionServicesRetrieve(code, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + transcriptionServicesRetrieve(code, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(code), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!code, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type TranscriptionServicesRetrieveQueryResult = NonNullable>> +export type TranscriptionServicesRetrieveQueryResult = NonNullable< + Awaited> +> export type TranscriptionServicesRetrieveQueryError = ErrorDetail +export function useTranscriptionServicesRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + code: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getTranscriptionServicesRetrieveQueryOptions(code, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useTranscriptionServicesRetrieve>, TError = ErrorDetail>( - code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getTranscriptionServicesRetrieveQueryOptions(code,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## List the translation services accessible to requesting (authenticated) user. @@ -1606,85 +1534,92 @@ export type translationServicesListResponse401 = { data: ErrorDetail status: 401 } - -export type translationServicesListResponseComposite = translationServicesListResponse200 | translationServicesListResponse400 | translationServicesListResponse401; - + +export type translationServicesListResponseComposite = + | translationServicesListResponse200 + | translationServicesListResponse400 + | translationServicesListResponse401 + export type translationServicesListResponse = translationServicesListResponseComposite & { - headers: Headers; + headers: Headers } -export const getTranslationServicesListUrl = (params?: TranslationServicesListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getTranslationServicesListUrl = (params?: TranslationServicesListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/translation-services/?${stringifiedParams}` : `/api/v2/translation-services/` + return stringifiedParams.length > 0 + ? `/api/v2/translation-services/?${stringifiedParams}` + : `/api/v2/translation-services/` } -export const translationServicesList = async (params?: TranslationServicesListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getTranslationServicesListUrl(params), - { +export const translationServicesList = async ( + params?: TranslationServicesListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getTranslationServicesListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getTranslationServicesListQueryKey = (params?: TranslationServicesListParams,) => { - return ['api','v2','translation-services', ...(params ? [params]: [])] as const; - } +export const getTranslationServicesListQueryKey = (params?: TranslationServicesListParams) => { + return ['api', 'v2', 'translation-services', ...(params ? [params] : [])] as const +} - -export const getTranslationServicesListQueryOptions = >, TError = ErrorObject | ErrorDetail>(params?: TranslationServicesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getTranslationServicesListQueryOptions = < + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + params?: TranslationServicesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getTranslationServicesListQueryKey(params); - - + const queryKey = queryOptions?.queryKey ?? getTranslationServicesListQueryKey(params) - const queryFn: QueryFunction>> = ({ signal }) => translationServicesList(params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + translationServicesList(params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type TranslationServicesListQueryResult = NonNullable>> export type TranslationServicesListQueryError = ErrorObject | ErrorDetail +export function useTranslationServicesList< + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + params?: TranslationServicesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getTranslationServicesListQueryOptions(params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useTranslationServicesList>, TError = ErrorObject | ErrorDetail>( - params?: TranslationServicesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getTranslationServicesListQueryOptions(params,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Retrieve a translation service @@ -1700,75 +1635,77 @@ export type translationServicesRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type translationServicesRetrieveResponseComposite = translationServicesRetrieveResponse200 | translationServicesRetrieveResponse401; - -export type translationServicesRetrieveResponse = translationServicesRetrieveResponseComposite & { - headers: Headers; -} -export const getTranslationServicesRetrieveUrl = (code: string,) => { +export type translationServicesRetrieveResponseComposite = + | translationServicesRetrieveResponse200 + | translationServicesRetrieveResponse401 +export type translationServicesRetrieveResponse = translationServicesRetrieveResponseComposite & { + headers: Headers +} - - +export const getTranslationServicesRetrieveUrl = (code: string) => { return `/api/v2/translation-services/${code}/` } -export const translationServicesRetrieve = async (code: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getTranslationServicesRetrieveUrl(code), - { +export const translationServicesRetrieve = async ( + code: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getTranslationServicesRetrieveUrl(code), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getTranslationServicesRetrieveQueryKey = (code: string,) => { - return ['api','v2','translation-services',code] as const; - } +export const getTranslationServicesRetrieveQueryKey = (code: string) => { + return ['api', 'v2', 'translation-services', code] as const +} - -export const getTranslationServicesRetrieveQueryOptions = >, TError = ErrorDetail>(code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getTranslationServicesRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + code: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getTranslationServicesRetrieveQueryKey(code) - const queryKey = queryOptions?.queryKey ?? getTranslationServicesRetrieveQueryKey(code); + const queryFn: QueryFunction>> = ({ signal }) => + translationServicesRetrieve(code, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => translationServicesRetrieve(code, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(code), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!code, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type TranslationServicesRetrieveQueryResult = NonNullable>> +export type TranslationServicesRetrieveQueryResult = NonNullable< + Awaited> +> export type TranslationServicesRetrieveQueryError = ErrorDetail +export function useTranslationServicesRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + code: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getTranslationServicesRetrieveQueryOptions(code, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useTranslationServicesRetrieve>, TError = ErrorDetail>( - code: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getTranslationServicesRetrieveQueryOptions(code,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - - diff --git a/jsapp/js/api/react-query/other/msw.ts b/jsapp/js/api/react-query/other/msw.ts index a9a53458d3..073484048d 100644 --- a/jsapp/js/api/react-query/other/msw.ts +++ b/jsapp/js/api/react-query/other/msw.ts @@ -9,354 +9,1024 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; +import { http, HttpResponse } from 'msw' -import { - BlankEnum -} from '../../models/blankEnum'; +import { BlankEnum } from '../../models/blankEnum' -import type { - ChangePlan -} from '../../models/changePlan'; +import type { ChangePlan } from '../../models/changePlan' -import type { - CheckoutLink -} from '../../models/checkoutLink'; +import type { CheckoutLink } from '../../models/checkoutLink' -import { - CollectionMethodEnum -} from '../../models/collectionMethodEnum'; +import { CollectionMethodEnum } from '../../models/collectionMethodEnum' -import type { - CustomerPortalPostResponse -} from '../../models/customerPortalPostResponse'; +import type { CustomerPortalPostResponse } from '../../models/customerPortalPostResponse' -import type { - Language -} from '../../models/language'; +import type { Language } from '../../models/language' -import type { - OneTimeAddOn -} from '../../models/oneTimeAddOn'; +import type { OneTimeAddOn } from '../../models/oneTimeAddOn' -import type { - PaginatedLanguageListList -} from '../../models/paginatedLanguageListList'; +import type { PaginatedLanguageListList } from '../../models/paginatedLanguageListList' -import type { - PaginatedOneTimeAddOnList -} from '../../models/paginatedOneTimeAddOnList'; +import type { PaginatedOneTimeAddOnList } from '../../models/paginatedOneTimeAddOnList' -import type { - PaginatedPermissionResponseList -} from '../../models/paginatedPermissionResponseList'; +import type { PaginatedPermissionResponseList } from '../../models/paginatedPermissionResponseList' -import type { - PaginatedProductList -} from '../../models/paginatedProductList'; +import type { PaginatedProductList } from '../../models/paginatedProductList' -import type { - PaginatedSubscriptionList -} from '../../models/paginatedSubscriptionList'; - -import type { - PaginatedTranscriptionServiceList -} from '../../models/paginatedTranscriptionServiceList'; - -import type { - PaginatedTranslationServiceList -} from '../../models/paginatedTranslationServiceList'; - -import type { - PermissionResponse -} from '../../models/permissionResponse'; - -import { - ProrationBehaviorEnum -} from '../../models/prorationBehaviorEnum'; - -import { - StripeIntervalEnum -} from '../../models/stripeIntervalEnum'; - -import { - StripePriceType -} from '../../models/stripePriceType'; - -import { - StripeProductType -} from '../../models/stripeProductType'; - -import { - StripeUsageType -} from '../../models/stripeUsageType'; - -import type { - Subscription -} from '../../models/subscription'; - -import { - SubscriptionScheduleStatusEnum -} from '../../models/subscriptionScheduleStatusEnum'; - -import { - SubscriptionStatusEnum -} from '../../models/subscriptionStatusEnum'; - -import type { - TermsOfServiceResponse -} from '../../models/termsOfServiceResponse'; - -import type { - TranscriptionService -} from '../../models/transcriptionService'; - -import type { - TranslationService -} from '../../models/translationService'; - - -export const getApiV2LanguagesListResponseMock = (overrideResponse: Partial< PaginatedLanguageListList > = {}): PaginatedLanguageListList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 200}}), code: faker.string.alpha({length: {min: 10, max: 10}}), featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), transcription_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), translation_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), url: faker.internet.url()})), ...overrideResponse}) - -export const getApiV2LanguagesRetrieveResponseMock = (overrideResponse: Partial< Language > = {}): Language => ({name: faker.string.alpha({length: {min: 10, max: 200}}), code: faker.string.alpha({length: {min: 10, max: 10}}), featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), transcription_services: { - [faker.string.alphanumeric(5)]: { - [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) - } - }, translation_services: { - [faker.string.alphanumeric(5)]: { - [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) - } - }, regions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({code: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 200}})})), ...overrideResponse}) - -export const getApiV2PermissionsListResponseMock = (overrideResponse: Partial< PaginatedPermissionResponseList > = {}): PaginatedPermissionResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), codename: faker.string.alpha({length: {min: 10, max: 20}}), implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.internet.url())), contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.internet.url())), name: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) - -export const getApiV2PermissionsRetrieveResponseMock = (overrideResponse: Partial< PermissionResponse > = {}): PermissionResponse => ({url: faker.internet.url(), codename: faker.string.alpha({length: {min: 10, max: 20}}), implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.internet.url())), contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.internet.url())), name: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2StripeAddonsListResponseMock = (overrideResponse: Partial< PaginatedOneTimeAddOnList > = {}): PaginatedOneTimeAddOnList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 27}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, is_available: faker.datatype.boolean(), usage_limits: faker.helpers.arrayElement([{}, undefined]), total_usage_limits: { - [faker.string.alphanumeric(5)]: {} - }, limits_remaining: faker.helpers.arrayElement([{}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), product: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])})), ...overrideResponse}) - -export const getApiV2StripeAddonsRetrieveResponseMock = (overrideResponse: Partial< OneTimeAddOn > = {}): OneTimeAddOn => ({id: faker.string.alpha({length: {min: 10, max: 27}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, is_available: faker.datatype.boolean(), usage_limits: faker.helpers.arrayElement([{}, undefined]), total_usage_limits: { - [faker.string.alphanumeric(5)]: {} - }, limits_remaining: faker.helpers.arrayElement([{}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), product: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), ...overrideResponse}) - -export const getApiV2StripeChangePlanRetrieveResponseMock = (overrideResponse: Partial< ChangePlan > = {}): ChangePlan => ({price_id: faker.string.alpha({length: {min: 10, max: 20}}), subscription_id: faker.string.alpha({length: {min: 10, max: 20}}), quantity: faker.helpers.arrayElement([faker.number.int({min: 1, max: undefined, multipleOf: undefined}), undefined]), ...overrideResponse}) - -export const getApiV2StripeCheckoutLinkCreateResponseMock = (overrideResponse: Partial< CheckoutLink > = {}): CheckoutLink => ({price_id: faker.string.alpha({length: {min: 10, max: 20}}), organization_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), quantity: faker.helpers.arrayElement([faker.number.int({min: 1, max: undefined, multipleOf: undefined}), undefined]), ...overrideResponse}) - -export const getApiV2StripeCustomerPortalCreateResponseMock = (overrideResponse: Partial< CustomerPortalPostResponse > = {}): CustomerPortalPostResponse => ({url: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2StripeProductsListResponseMock = (overrideResponse: Partial< PaginatedProductList > = {}): PaginatedProductList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 255}}), name: faker.string.alpha({length: {min: 10, max: 5000}}), description: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), type: faker.helpers.arrayElement(Object.values(StripeProductType)), prices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 255}}), nickname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 250}}), undefined]), currency: faker.string.alpha({length: {min: 10, max: 3}}), type: faker.helpers.arrayElement(Object.values(StripePriceType)), recurring: {...{interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), interval_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), meter: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType))},}, unit_amount: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined}), null]), undefined]), human_readable_price: faker.string.alpha({length: {min: 10, max: 20}}), metadata: faker.helpers.arrayElement([{}, undefined]), active: faker.datatype.boolean(), product: faker.string.alpha({length: {min: 10, max: 20}}), transform_quantity: faker.helpers.arrayElement([{}, undefined])})), metadata: { - [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) - }})), ...overrideResponse}) - -export const getApiV2StripeSubscriptionsListResponseMock = (overrideResponse: Partial< PaginatedSubscriptionList > = {}): PaginatedSubscriptionList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 255}}), price: {id: faker.string.alpha({length: {min: 10, max: 255}}), nickname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 250}}), undefined]), currency: faker.string.alpha({length: {min: 10, max: 3}}), type: faker.helpers.arrayElement(Object.values(StripePriceType)), recurring: {...{interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), interval_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), meter: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType))},}, unit_amount: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined}), null]), undefined]), human_readable_price: faker.string.alpha({length: {min: 10, max: 20}}), metadata: faker.helpers.arrayElement([{}, undefined]), active: faker.datatype.boolean(), product: {id: faker.string.alpha({length: {min: 10, max: 255}}), name: faker.string.alpha({length: {min: 10, max: 5000}}), description: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), type: faker.helpers.arrayElement(Object.values(StripeProductType)), metadata: { - [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) - }}, transform_quantity: faker.helpers.arrayElement([{}, undefined])}, quantity: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: 0, max: 2147483647, multipleOf: undefined}), null]), undefined])})), schedule: {phases: { - [faker.string.alphanumeric(5)]: {} - }, status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum))}, application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?\d{0,3}(?:\.\d{0,2})?$'), null]), djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, stripe_data: faker.helpers.arrayElement([{}, undefined]), id: faker.string.alpha({length: {min: 10, max: 255}}), livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), created: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), metadata: faker.helpers.arrayElement([{}, undefined]), description: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), billing_cycle_anchor: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), billing_thresholds: faker.helpers.arrayElement([{}, undefined]), cancel_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), canceled_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, days_until_due: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -2147483648, max: 2147483647, multipleOf: undefined}), null]), undefined]), discount: faker.helpers.arrayElement([{}, undefined]), ended_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), next_pending_invoice_item_invoice: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), pause_collection: faker.helpers.arrayElement([{}, undefined]), pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), pending_update: faker.helpers.arrayElement([{}, undefined]), proration_behavior: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)),faker.helpers.arrayElement(Object.values(BlankEnum)),]), undefined]), proration_date: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), quantity: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -2147483648, max: 2147483647, multipleOf: undefined}), null]), undefined]), start_date: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), trial_end: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), trial_start: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), djstripe_owner_account: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), customer: faker.string.alpha({length: {min: 10, max: 20}}), default_payment_method: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), default_source: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), latest_invoice: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_setup_intent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), plan: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), undefined]), default_tax_rates: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.number.int({min: undefined, max: undefined, multipleOf: undefined}))), undefined])})), ...overrideResponse}) - -export const getApiV2StripeSubscriptionsRetrieveResponseMock = (overrideResponse: Partial< Subscription > = {}): Subscription => ({items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 255}}), price: {id: faker.string.alpha({length: {min: 10, max: 255}}), nickname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 250}}), undefined]), currency: faker.string.alpha({length: {min: 10, max: 3}}), type: faker.helpers.arrayElement(Object.values(StripePriceType)), recurring: {...{interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), interval_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), meter: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType))},}, unit_amount: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined}), null]), undefined]), human_readable_price: faker.string.alpha({length: {min: 10, max: 20}}), metadata: faker.helpers.arrayElement([{}, undefined]), active: faker.datatype.boolean(), product: {id: faker.string.alpha({length: {min: 10, max: 255}}), name: faker.string.alpha({length: {min: 10, max: 5000}}), description: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), type: faker.helpers.arrayElement(Object.values(StripeProductType)), metadata: { - [faker.string.alphanumeric(5)]: faker.string.alpha({length: {min: 10, max: 20}}) - }}, transform_quantity: faker.helpers.arrayElement([{}, undefined])}, quantity: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: 0, max: 2147483647, multipleOf: undefined}), null]), undefined])})), schedule: {phases: { - [faker.string.alphanumeric(5)]: {} - }, status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum))}, application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?\d{0,3}(?:\.\d{0,2})?$'), null]), djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, stripe_data: faker.helpers.arrayElement([{}, undefined]), id: faker.string.alpha({length: {min: 10, max: 255}}), livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), created: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), metadata: faker.helpers.arrayElement([{}, undefined]), description: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), billing_cycle_anchor: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), billing_thresholds: faker.helpers.arrayElement([{}, undefined]), cancel_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), canceled_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, days_until_due: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -2147483648, max: 2147483647, multipleOf: undefined}), null]), undefined]), discount: faker.helpers.arrayElement([{}, undefined]), ended_at: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), next_pending_invoice_item_invoice: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), pause_collection: faker.helpers.arrayElement([{}, undefined]), pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), pending_update: faker.helpers.arrayElement([{}, undefined]), proration_behavior: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)),faker.helpers.arrayElement(Object.values(BlankEnum)),]), undefined]), proration_date: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), quantity: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: -2147483648, max: 2147483647, multipleOf: undefined}), null]), undefined]), start_date: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), trial_end: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), trial_start: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), djstripe_owner_account: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), customer: faker.string.alpha({length: {min: 10, max: 20}}), default_payment_method: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), default_source: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), latest_invoice: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_setup_intent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), plan: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), undefined]), default_tax_rates: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.number.int({min: undefined, max: undefined, multipleOf: undefined}))), undefined]), ...overrideResponse}) - -export const getApiV2TermsOfServiceListResponseMock = (): TermsOfServiceResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), slug: faker.string.alpha({length: {min: 10, max: 20}}), body: faker.string.alpha({length: {min: 10, max: 20}})}))) - -export const getApiV2TermsOfServiceRetrieveResponseMock = (overrideResponse: Partial< TermsOfServiceResponse > = {}): TermsOfServiceResponse => ({url: faker.internet.url(), slug: faker.string.alpha({length: {min: 10, max: 20}}), body: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2TranscriptionServicesListResponseMock = (overrideResponse: Partial< PaginatedTranscriptionServiceList > = {}): PaginatedTranscriptionServiceList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 100}}), code: faker.string.alpha({length: {min: 10, max: 10}})})), ...overrideResponse}) - -export const getApiV2TranscriptionServicesRetrieveResponseMock = (overrideResponse: Partial< TranscriptionService > = {}): TranscriptionService => ({name: faker.string.alpha({length: {min: 10, max: 100}}), code: faker.string.alpha({length: {min: 10, max: 10}}), ...overrideResponse}) - -export const getApiV2TranslationServicesListResponseMock = (overrideResponse: Partial< PaginatedTranslationServiceList > = {}): PaginatedTranslationServiceList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.string.alpha({length: {min: 10, max: 100}}), code: faker.string.alpha({length: {min: 10, max: 10}})})), ...overrideResponse}) - -export const getApiV2TranslationServicesRetrieveResponseMock = (overrideResponse: Partial< TranslationService > = {}): TranslationService => ({name: faker.string.alpha({length: {min: 10, max: 100}}), code: faker.string.alpha({length: {min: 10, max: 10}}), ...overrideResponse}) - - -export const getApiV2LanguagesListMockHandler = (overrideResponse?: PaginatedLanguageListList | ((info: Parameters[1]>[0]) => Promise | PaginatedLanguageListList)) => { - return http.get('*/api/v2/languages/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2LanguagesListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +import type { PaginatedSubscriptionList } from '../../models/paginatedSubscriptionList' + +import type { PaginatedTranscriptionServiceList } from '../../models/paginatedTranscriptionServiceList' + +import type { PaginatedTranslationServiceList } from '../../models/paginatedTranslationServiceList' + +import type { PermissionResponse } from '../../models/permissionResponse' + +import { ProrationBehaviorEnum } from '../../models/prorationBehaviorEnum' + +import { StripeIntervalEnum } from '../../models/stripeIntervalEnum' + +import { StripePriceType } from '../../models/stripePriceType' + +import { StripeProductType } from '../../models/stripeProductType' + +import { StripeUsageType } from '../../models/stripeUsageType' + +import type { Subscription } from '../../models/subscription' + +import { SubscriptionScheduleStatusEnum } from '../../models/subscriptionScheduleStatusEnum' + +import { SubscriptionStatusEnum } from '../../models/subscriptionStatusEnum' + +import type { TermsOfServiceResponse } from '../../models/termsOfServiceResponse' + +import type { TranscriptionService } from '../../models/transcriptionService' + +import type { TranslationService } from '../../models/translationService' + +export const getApiV2LanguagesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedLanguageListList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + transcription_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + translation_services: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + url: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2LanguagesRetrieveResponseMock = (overrideResponse: Partial = {}): Language => ({ + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + featured: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + transcription_services: { + [faker.string.alphanumeric(5)]: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + translation_services: { + [faker.string.alphanumeric(5)]: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + regions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + code: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + })), + ...overrideResponse, +}) + +export const getApiV2PermissionsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedPermissionResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + codename: faker.string.alpha({ length: { min: 10, max: 20 } }), + implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2PermissionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PermissionResponse => ({ + url: faker.internet.url(), + codename: faker.string.alpha({ length: { min: 10, max: 20 } }), + implied: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + contradictory: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.internet.url(), + ), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2StripeAddonsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedOneTimeAddOnList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 27 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_available: faker.datatype.boolean(), + usage_limits: faker.helpers.arrayElement([{}, undefined]), + total_usage_limits: { + [faker.string.alphanumeric(5)]: {}, + }, + limits_remaining: faker.helpers.arrayElement([{}, undefined]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + product: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2StripeAddonsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OneTimeAddOn => ({ + id: faker.string.alpha({ length: { min: 10, max: 27 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_available: faker.datatype.boolean(), + usage_limits: faker.helpers.arrayElement([{}, undefined]), + total_usage_limits: { + [faker.string.alphanumeric(5)]: {}, + }, + limits_remaining: faker.helpers.arrayElement([{}, undefined]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + product: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2StripeChangePlanRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ChangePlan => ({ + price_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + subscription_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: 1, max: undefined, multipleOf: undefined }), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2StripeCheckoutLinkCreateResponseMock = ( + overrideResponse: Partial = {}, +): CheckoutLink => ({ + price_id: faker.string.alpha({ length: { min: 10, max: 20 } }), + organization_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: 1, max: undefined, multipleOf: undefined }), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2StripeCustomerPortalCreateResponseMock = ( + overrideResponse: Partial = {}, +): CustomerPortalPostResponse => ({ url: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2StripeProductsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProductList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + name: faker.string.alpha({ length: { min: 10, max: 5000 } }), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + type: faker.helpers.arrayElement(Object.values(StripeProductType)), + prices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), + currency: faker.string.alpha({ length: { min: 10, max: 3 } }), + type: faker.helpers.arrayElement(Object.values(StripePriceType)), + recurring: { + ...{ + interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), + interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + meter: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), + }, + }, + unit_amount: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), + null, + ]), + undefined, + ]), + human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.datatype.boolean(), + product: faker.string.alpha({ length: { min: 10, max: 20 } }), + transform_quantity: faker.helpers.arrayElement([{}, undefined]), + })), + metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + })), + ...overrideResponse, +}) + +export const getApiV2StripeSubscriptionsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedSubscriptionList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + price: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), + currency: faker.string.alpha({ length: { min: 10, max: 3 } }), + type: faker.helpers.arrayElement(Object.values(StripePriceType)), + recurring: { + ...{ + interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), + interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + meter: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), + }, + }, + unit_amount: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), + null, + ]), + undefined, + ]), + human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.datatype.boolean(), + product: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + name: faker.string.alpha({ length: { min: 10, max: 5000 } }), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + type: faker.helpers.arrayElement(Object.values(StripeProductType)), + metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + transform_quantity: faker.helpers.arrayElement([{}, undefined]), + }, + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + })), + schedule: { + phases: { + [faker.string.alphanumeric(5)]: {}, + }, + status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum)), + }, + application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?d{0,3}(?:.d{0,2})?$'), null]), + djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + stripe_data: faker.helpers.arrayElement([{}, undefined]), + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + created: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + metadata: faker.helpers.arrayElement([{}, undefined]), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + billing_cycle_anchor: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + billing_thresholds: faker.helpers.arrayElement([{}, undefined]), + cancel_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + canceled_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + days_until_due: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), + null, + ]), + undefined, + ]), + discount: faker.helpers.arrayElement([{}, undefined]), + ended_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + next_pending_invoice_item_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + pause_collection: faker.helpers.arrayElement([{}, undefined]), + pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), + pending_update: faker.helpers.arrayElement([{}, undefined]), + proration_behavior: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)), + faker.helpers.arrayElement(Object.values(BlankEnum)), + ]), + undefined, + ]), + proration_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), + null, + ]), + undefined, + ]), + start_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), + trial_end: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + trial_start: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + djstripe_owner_account: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + customer: faker.string.alpha({ length: { min: 10, max: 20 } }), + default_payment_method: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + default_source: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + latest_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_setup_intent: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + plan: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), null]), + undefined, + ]), + default_tax_rates: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2StripeSubscriptionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): Subscription => ({ + items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + price: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 250 } }), undefined]), + currency: faker.string.alpha({ length: { min: 10, max: 3 } }), + type: faker.helpers.arrayElement(Object.values(StripePriceType)), + recurring: { + ...{ + interval: faker.helpers.arrayElement(Object.values(StripeIntervalEnum)), + interval_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + meter: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + usage_type: faker.helpers.arrayElement(Object.values(StripeUsageType)), + }, + }, + unit_amount: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.number.int({ min: -9223372036854776000, max: 9223372036854776000, multipleOf: undefined }), + null, + ]), + undefined, + ]), + human_readable_price: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.datatype.boolean(), + product: { + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + name: faker.string.alpha({ length: { min: 10, max: 5000 } }), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + type: faker.helpers.arrayElement(Object.values(StripeProductType)), + metadata: { + [faker.string.alphanumeric(5)]: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + transform_quantity: faker.helpers.arrayElement([{}, undefined]), + }, + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + })), + schedule: { + phases: { + [faker.string.alphanumeric(5)]: {}, + }, + status: faker.helpers.arrayElement(Object.values(SubscriptionScheduleStatusEnum)), + }, + application_fee_percent: faker.helpers.arrayElement([faker.helpers.fromRegExp('^-?d{0,3}(?:.d{0,2})?$'), null]), + djstripe_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + djstripe_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + stripe_data: faker.helpers.arrayElement([{}, undefined]), + id: faker.string.alpha({ length: { min: 10, max: 255 } }), + livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + created: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + metadata: faker.helpers.arrayElement([{}, undefined]), + description: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + billing_cycle_anchor: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + billing_thresholds: faker.helpers.arrayElement([{}, undefined]), + cancel_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + canceled_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + collection_method: faker.helpers.arrayElement(Object.values(CollectionMethodEnum)), + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + days_until_due: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + discount: faker.helpers.arrayElement([{}, undefined]), + ended_at: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + next_pending_invoice_item_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + pause_collection: faker.helpers.arrayElement([{}, undefined]), + pending_invoice_item_interval: faker.helpers.arrayElement([{}, undefined]), + pending_update: faker.helpers.arrayElement([{}, undefined]), + proration_behavior: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.helpers.arrayElement(Object.values(ProrationBehaviorEnum)), + faker.helpers.arrayElement(Object.values(BlankEnum)), + ]), + undefined, + ]), + proration_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + quantity: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: -2147483648, max: 2147483647, multipleOf: undefined }), null]), + undefined, + ]), + start_date: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + status: faker.helpers.arrayElement(Object.values(SubscriptionStatusEnum)), + trial_end: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + trial_start: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + djstripe_owner_account: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + customer: faker.string.alpha({ length: { min: 10, max: 20 } }), + default_payment_method: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + default_source: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + latest_invoice: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_setup_intent: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + plan: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), null]), + undefined, + ]), + default_tax_rates: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2TermsOfServiceListResponseMock = (): TermsOfServiceResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + slug: faker.string.alpha({ length: { min: 10, max: 20 } }), + body: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2TermsOfServiceRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TermsOfServiceResponse => ({ + url: faker.internet.url(), + slug: faker.string.alpha({ length: { min: 10, max: 20 } }), + body: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2TranscriptionServicesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedTranscriptionServiceList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + })), + ...overrideResponse, +}) + +export const getApiV2TranscriptionServicesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TranscriptionService => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + ...overrideResponse, +}) + +export const getApiV2TranslationServicesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedTranslationServiceList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + })), + ...overrideResponse, +}) + +export const getApiV2TranslationServicesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): TranslationService => ({ + name: faker.string.alpha({ length: { min: 10, max: 100 } }), + code: faker.string.alpha({ length: { min: 10, max: 10 } }), + ...overrideResponse, +}) + +export const getApiV2LanguagesListMockHandler = ( + overrideResponse?: + | PaginatedLanguageListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedLanguageListList), +) => { + return http.get('*/api/v2/languages/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2LanguagesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2LanguagesRetrieveMockHandler = (overrideResponse?: Language | ((info: Parameters[1]>[0]) => Promise | Language)) => { - return http.get('*/api/v2/languages/:code/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2LanguagesRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2LanguagesRetrieveMockHandler = ( + overrideResponse?: Language | ((info: Parameters[1]>[0]) => Promise | Language), +) => { + return http.get('*/api/v2/languages/:code/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2LanguagesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2PermissionsListMockHandler = (overrideResponse?: PaginatedPermissionResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedPermissionResponseList)) => { - return http.get('*/api/v2/permissions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2PermissionsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2PermissionsListMockHandler = ( + overrideResponse?: + | PaginatedPermissionResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedPermissionResponseList), +) => { + return http.get('*/api/v2/permissions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2PermissionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2PermissionsRetrieveMockHandler = (overrideResponse?: PermissionResponse | ((info: Parameters[1]>[0]) => Promise | PermissionResponse)) => { - return http.get('*/api/v2/permissions/:codename/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2PermissionsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2PermissionsRetrieveMockHandler = ( + overrideResponse?: + | PermissionResponse + | ((info: Parameters[1]>[0]) => Promise | PermissionResponse), +) => { + return http.get('*/api/v2/permissions/:codename/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2PermissionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2StripeAddonsListMockHandler = (overrideResponse?: PaginatedOneTimeAddOnList | ((info: Parameters[1]>[0]) => Promise | PaginatedOneTimeAddOnList)) => { - return http.get('*/api/v2/stripe/addons/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2StripeAddonsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2StripeAddonsListMockHandler = ( + overrideResponse?: + | PaginatedOneTimeAddOnList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedOneTimeAddOnList), +) => { + return http.get('*/api/v2/stripe/addons/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeAddonsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2StripeAddonsRetrieveMockHandler = (overrideResponse?: OneTimeAddOn | ((info: Parameters[1]>[0]) => Promise | OneTimeAddOn)) => { - return http.get('*/api/v2/stripe/addons/:id/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2StripeAddonsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2StripeAddonsRetrieveMockHandler = ( + overrideResponse?: + | OneTimeAddOn + | ((info: Parameters[1]>[0]) => Promise | OneTimeAddOn), +) => { + return http.get('*/api/v2/stripe/addons/:id/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeAddonsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2StripeChangePlanRetrieveMockHandler = (overrideResponse?: ChangePlan | ((info: Parameters[1]>[0]) => Promise | ChangePlan)) => { - return http.get('*/api/v2/stripe/change-plan', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2StripeChangePlanRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2StripeChangePlanRetrieveMockHandler = ( + overrideResponse?: + | ChangePlan + | ((info: Parameters[1]>[0]) => Promise | ChangePlan), +) => { + return http.get('*/api/v2/stripe/change-plan', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeChangePlanRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2StripeCheckoutLinkCreateMockHandler = (overrideResponse?: CheckoutLink | ((info: Parameters[1]>[0]) => Promise | CheckoutLink)) => { - return http.post('*/api/v2/stripe/checkout-link', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2StripeCheckoutLinkCreateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2StripeCheckoutLinkCreateMockHandler = ( + overrideResponse?: + | CheckoutLink + | ((info: Parameters[1]>[0]) => Promise | CheckoutLink), +) => { + return http.post('*/api/v2/stripe/checkout-link', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeCheckoutLinkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2StripeCustomerPortalCreateMockHandler = (overrideResponse?: CustomerPortalPostResponse | ((info: Parameters[1]>[0]) => Promise | CustomerPortalPostResponse)) => { - return http.post('*/api/v2/stripe/customer-portal', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2StripeCustomerPortalCreateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2StripeCustomerPortalCreateMockHandler = ( + overrideResponse?: + | CustomerPortalPostResponse + | (( + info: Parameters[1]>[0], + ) => Promise | CustomerPortalPostResponse), +) => { + return http.post('*/api/v2/stripe/customer-portal', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeCustomerPortalCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2StripeProductsListMockHandler = (overrideResponse?: PaginatedProductList | ((info: Parameters[1]>[0]) => Promise | PaginatedProductList)) => { - return http.get('*/api/v2/stripe/products/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2StripeProductsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2StripeProductsListMockHandler = ( + overrideResponse?: + | PaginatedProductList + | ((info: Parameters[1]>[0]) => Promise | PaginatedProductList), +) => { + return http.get('*/api/v2/stripe/products/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeProductsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2StripeSubscriptionsListMockHandler = (overrideResponse?: PaginatedSubscriptionList | ((info: Parameters[1]>[0]) => Promise | PaginatedSubscriptionList)) => { - return http.get('*/api/v2/stripe/subscriptions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2StripeSubscriptionsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2StripeSubscriptionsListMockHandler = ( + overrideResponse?: + | PaginatedSubscriptionList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedSubscriptionList), +) => { + return http.get('*/api/v2/stripe/subscriptions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeSubscriptionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2StripeSubscriptionsRetrieveMockHandler = (overrideResponse?: Subscription | ((info: Parameters[1]>[0]) => Promise | Subscription)) => { - return http.get('*/api/v2/stripe/subscriptions/:id/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2StripeSubscriptionsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2StripeSubscriptionsRetrieveMockHandler = ( + overrideResponse?: + | Subscription + | ((info: Parameters[1]>[0]) => Promise | Subscription), +) => { + return http.get('*/api/v2/stripe/subscriptions/:id/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2StripeSubscriptionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2TermsOfServiceListMockHandler = (overrideResponse?: TermsOfServiceResponse[] | ((info: Parameters[1]>[0]) => Promise | TermsOfServiceResponse[])) => { - return http.get('*/api/v2/terms-of-service/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2TermsOfServiceListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2TermsOfServiceListMockHandler = ( + overrideResponse?: + | TermsOfServiceResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | TermsOfServiceResponse[]), +) => { + return http.get('*/api/v2/terms-of-service/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TermsOfServiceListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2TermsOfServiceRetrieveMockHandler = (overrideResponse?: TermsOfServiceResponse | ((info: Parameters[1]>[0]) => Promise | TermsOfServiceResponse)) => { - return http.get('*/api/v2/terms-of-service/:slug/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2TermsOfServiceRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2TermsOfServiceRetrieveMockHandler = ( + overrideResponse?: + | TermsOfServiceResponse + | (( + info: Parameters[1]>[0], + ) => Promise | TermsOfServiceResponse), +) => { + return http.get('*/api/v2/terms-of-service/:slug/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TermsOfServiceRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2TranscriptionServicesListMockHandler = (overrideResponse?: PaginatedTranscriptionServiceList | ((info: Parameters[1]>[0]) => Promise | PaginatedTranscriptionServiceList)) => { - return http.get('*/api/v2/transcription-services/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2TranscriptionServicesListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2TranscriptionServicesListMockHandler = ( + overrideResponse?: + | PaginatedTranscriptionServiceList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedTranscriptionServiceList), +) => { + return http.get('*/api/v2/transcription-services/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranscriptionServicesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2TranscriptionServicesRetrieveMockHandler = (overrideResponse?: TranscriptionService | ((info: Parameters[1]>[0]) => Promise | TranscriptionService)) => { - return http.get('*/api/v2/transcription-services/:code/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2TranscriptionServicesRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2TranscriptionServicesRetrieveMockHandler = ( + overrideResponse?: + | TranscriptionService + | ((info: Parameters[1]>[0]) => Promise | TranscriptionService), +) => { + return http.get('*/api/v2/transcription-services/:code/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranscriptionServicesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2TranslationServicesListMockHandler = (overrideResponse?: PaginatedTranslationServiceList | ((info: Parameters[1]>[0]) => Promise | PaginatedTranslationServiceList)) => { - return http.get('*/api/v2/translation-services/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2TranslationServicesListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2TranslationServicesListMockHandler = ( + overrideResponse?: + | PaginatedTranslationServiceList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedTranslationServiceList), +) => { + return http.get('*/api/v2/translation-services/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranslationServicesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2TranslationServicesRetrieveMockHandler = (overrideResponse?: TranslationService | ((info: Parameters[1]>[0]) => Promise | TranslationService)) => { - return http.get('*/api/v2/translation-services/:code/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2TranslationServicesRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2TranslationServicesRetrieveMockHandler = ( + overrideResponse?: + | TranslationService + | ((info: Parameters[1]>[0]) => Promise | TranslationService), +) => { + return http.get('*/api/v2/translation-services/:code/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2TranslationServicesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } export const getOtherMock = () => [ @@ -377,5 +1047,5 @@ export const getOtherMock = () => [ getApiV2TranscriptionServicesListMockHandler(), getApiV2TranscriptionServicesRetrieveMockHandler(), getApiV2TranslationServicesListMockHandler(), - getApiV2TranslationServicesRetrieveMockHandler() + getApiV2TranslationServicesRetrieveMockHandler(), ] diff --git a/jsapp/js/api/react-query/scim/index.ts b/jsapp/js/api/react-query/scim/index.ts index 4597a58076..bc1385070e 100644 --- a/jsapp/js/api/react-query/scim/index.ts +++ b/jsapp/js/api/react-query/scim/index.ts @@ -9,112 +9,66 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - PaginatedScimGroupList -} from '../../models/paginatedScimGroupList'; +import type { PaginatedScimGroupList } from '../../models/paginatedScimGroupList' -import type { - PaginatedScimUserList -} from '../../models/paginatedScimUserList'; +import type { PaginatedScimUserList } from '../../models/paginatedScimUserList' -import type { - PatchedScimGroup -} from '../../models/patchedScimGroup'; +import type { PatchedScimGroup } from '../../models/patchedScimGroup' -import type { - PatchedScimUser -} from '../../models/patchedScimUser'; +import type { PatchedScimUser } from '../../models/patchedScimUser' -import type { - ScimError -} from '../../models/scimError'; +import type { ScimError } from '../../models/scimError' -import type { - ScimGroup -} from '../../models/scimGroup'; +import type { ScimGroup } from '../../models/scimGroup' -import type { - ScimUser -} from '../../models/scimUser'; +import type { ScimUser } from '../../models/scimUser' -import type { - ScimV2GroupsListParams -} from '../../models/scimV2GroupsListParams'; +import type { ScimV2GroupsListParams } from '../../models/scimV2GroupsListParams' -import type { - ScimV2ResourceTypesRetrieve200 -} from '../../models/scimV2ResourceTypesRetrieve200'; +import type { ScimV2ResourceTypesRetrieve200 } from '../../models/scimV2ResourceTypesRetrieve200' -import type { - ScimV2SchemasRetrieve200 -} from '../../models/scimV2SchemasRetrieve200'; +import type { ScimV2SchemasRetrieve200 } from '../../models/scimV2SchemasRetrieve200' -import type { - ScimV2ServiceProviderConfigRetrieve200 -} from '../../models/scimV2ServiceProviderConfigRetrieve200'; +import type { ScimV2ServiceProviderConfigRetrieve200 } from '../../models/scimV2ServiceProviderConfigRetrieve200' -import type { - ScimV2UsersCreate400 -} from '../../models/scimV2UsersCreate400'; +import type { ScimV2UsersCreate400 } from '../../models/scimV2UsersCreate400' -import type { - ScimV2UsersCreate409 -} from '../../models/scimV2UsersCreate409'; +import type { ScimV2UsersCreate409 } from '../../models/scimV2UsersCreate409' -import type { - ScimV2UsersListParams -} from '../../models/scimV2UsersListParams'; +import type { ScimV2UsersListParams } from '../../models/scimV2UsersListParams' -import type { - ScimV2UsersUpdate409 -} from '../../models/scimV2UsersUpdate409'; +import type { ScimV2UsersUpdate409 } from '../../models/scimV2UsersUpdate409' -import { fetchWithAuth } from '../../orval.mutator'; +import { fetchWithAuth } from '../../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = (() => T extends X ? 1 : 2) extends < -T, ->() => T extends Y ? 1 : 2 -? A -: B; +type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B type WritableKeys = { -[P in keyof T]-?: IfEquals< - { [Q in P]: T[P] }, - { -readonly [Q in P]: T[P] }, - P ->; -}[keyof T]; + [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P> +}[keyof T] -type UnionToIntersection = - (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never; -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; - -type Writable = Pick>; -type NonReadonly = [T] extends [UnionToIntersection] ? { - [P in keyof Writable]: T[P] extends object - ? NonReadonly> - : T[P]; -} : DistributeReadOnlyOverUnions; - - - -type SecondParameter unknown> = Parameters[1]; +type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never +type Writable = Pick> +type NonReadonly = [T] extends [UnionToIntersection] + ? { + [P in keyof Writable]: T[P] extends object ? NonReadonly> : T[P] + } + : DistributeReadOnlyOverUnions +type SecondParameter unknown> = Parameters[1] /** * Returns a list of SCIM groups. @@ -128,90 +82,89 @@ export type scimV2GroupsListResponse401 = { data: ScimError status: 401 } - -export type scimV2GroupsListResponseComposite = scimV2GroupsListResponse200 | scimV2GroupsListResponse401; - + +export type scimV2GroupsListResponseComposite = scimV2GroupsListResponse200 | scimV2GroupsListResponse401 + export type scimV2GroupsListResponse = scimV2GroupsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getScimV2GroupsListUrl = (idpSlug: string, - params?: ScimV2GroupsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getScimV2GroupsListUrl = (idpSlug: string, params?: ScimV2GroupsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/scim/v2/${idpSlug}/Groups?${stringifiedParams}` : `/api/v2/scim/v2/${idpSlug}/Groups` + return stringifiedParams.length > 0 + ? `/api/v2/scim/v2/${idpSlug}/Groups?${stringifiedParams}` + : `/api/v2/scim/v2/${idpSlug}/Groups` } -export const scimV2GroupsList = async (idpSlug: string, - params?: ScimV2GroupsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2GroupsListUrl(idpSlug,params), - { +export const scimV2GroupsList = async ( + idpSlug: string, + params?: ScimV2GroupsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2GroupsListUrl(idpSlug, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getScimV2GroupsListQueryKey = (idpSlug: string, - params?: ScimV2GroupsListParams,) => { - return ['api','v2','scim','v2',idpSlug,'Groups', ...(params ? [params]: [])] as const; - } +export const getScimV2GroupsListQueryKey = (idpSlug: string, params?: ScimV2GroupsListParams) => { + return ['api', 'v2', 'scim', 'v2', idpSlug, 'Groups', ...(params ? [params] : [])] as const +} - -export const getScimV2GroupsListQueryOptions = >, TError = ScimError>(idpSlug: string, - params?: ScimV2GroupsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getScimV2GroupsListQueryOptions = < + TData = Awaited>, + TError = ScimError, +>( + idpSlug: string, + params?: ScimV2GroupsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getScimV2GroupsListQueryKey(idpSlug,params); - - + const queryKey = queryOptions?.queryKey ?? getScimV2GroupsListQueryKey(idpSlug, params) - const queryFn: QueryFunction>> = ({ signal }) => scimV2GroupsList(idpSlug,params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + scimV2GroupsList(idpSlug, params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(idpSlug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!idpSlug, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ScimV2GroupsListQueryResult = NonNullable>> export type ScimV2GroupsListQueryError = ScimError - - export function useScimV2GroupsList>, TError = ScimError>( - idpSlug: string, - params?: ScimV2GroupsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getScimV2GroupsListQueryOptions(idpSlug,params,options) + idpSlug: string, + params?: ScimV2GroupsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getScimV2GroupsListQueryOptions(idpSlug, params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Creates a new SCIM group. */ @@ -224,75 +177,81 @@ export type scimV2GroupsCreateResponse401 = { data: ScimError status: 401 } - -export type scimV2GroupsCreateResponseComposite = scimV2GroupsCreateResponse201 | scimV2GroupsCreateResponse401; - -export type scimV2GroupsCreateResponse = scimV2GroupsCreateResponseComposite & { - headers: Headers; -} - -export const getScimV2GroupsCreateUrl = (idpSlug: string,) => { +export type scimV2GroupsCreateResponseComposite = scimV2GroupsCreateResponse201 | scimV2GroupsCreateResponse401 - +export type scimV2GroupsCreateResponse = scimV2GroupsCreateResponseComposite & { + headers: Headers +} +export const getScimV2GroupsCreateUrl = (idpSlug: string) => { return `/api/v2/scim/v2/${idpSlug}/Groups` } -export const scimV2GroupsCreate = async (idpSlug: string, - scimGroup: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2GroupsCreateUrl(idpSlug), - { +export const scimV2GroupsCreate = async ( + idpSlug: string, + scimGroup: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2GroupsCreateUrl(idpSlug), { ...options, method: 'POST', headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify( - scimGroup,) + body: JSON.stringify(scimGroup), + }) +} + +export const getScimV2GroupsCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; data: NonReadonly }, + TContext +> => { + const mutationKey = ['scimV2GroupsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { idpSlug: string; data: NonReadonly } + > = (props) => { + const { idpSlug, data } = props ?? {} + + return scimV2GroupsCreate(idpSlug, data, requestOptions) } -);} - - - - -export const getScimV2GroupsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext> => { - -const mutationKey = ['scimV2GroupsCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {idpSlug: string;data: NonReadonly}> = (props) => { - const {idpSlug,data} = props ?? {}; - return scimV2GroupsCreate(idpSlug,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type ScimV2GroupsCreateMutationResult = NonNullable>> - export type ScimV2GroupsCreateMutationBody = NonReadonly - export type ScimV2GroupsCreateMutationError = ScimError + return { mutationFn, ...mutationOptions } +} - export const useScimV2GroupsCreate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { +export type ScimV2GroupsCreateMutationResult = NonNullable>> +export type ScimV2GroupsCreateMutationBody = NonReadonly +export type ScimV2GroupsCreateMutationError = ScimError - const mutationOptions = getScimV2GroupsCreateMutationOptions(options); +export const useScimV2GroupsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getScimV2GroupsCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Returns a specific SCIM group. */ export type scimV2GroupsRetrieveResponse200 = { @@ -304,83 +263,77 @@ export type scimV2GroupsRetrieveResponse401 = { data: ScimError status: 401 } - -export type scimV2GroupsRetrieveResponseComposite = scimV2GroupsRetrieveResponse200 | scimV2GroupsRetrieveResponse401; - -export type scimV2GroupsRetrieveResponse = scimV2GroupsRetrieveResponseComposite & { - headers: Headers; -} -export const getScimV2GroupsRetrieveUrl = (idpSlug: string, - id: string,) => { +export type scimV2GroupsRetrieveResponseComposite = scimV2GroupsRetrieveResponse200 | scimV2GroupsRetrieveResponse401 +export type scimV2GroupsRetrieveResponse = scimV2GroupsRetrieveResponseComposite & { + headers: Headers +} - - +export const getScimV2GroupsRetrieveUrl = (idpSlug: string, id: string) => { return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` } -export const scimV2GroupsRetrieve = async (idpSlug: string, - id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2GroupsRetrieveUrl(idpSlug,id), - { +export const scimV2GroupsRetrieve = async ( + idpSlug: string, + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2GroupsRetrieveUrl(idpSlug, id), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getScimV2GroupsRetrieveQueryKey = (idpSlug: string, - id: string,) => { - return ['api','v2','scim','v2',idpSlug,'Groups',id] as const; - } +export const getScimV2GroupsRetrieveQueryKey = (idpSlug: string, id: string) => { + return ['api', 'v2', 'scim', 'v2', idpSlug, 'Groups', id] as const +} - -export const getScimV2GroupsRetrieveQueryOptions = >, TError = ScimError>(idpSlug: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getScimV2GroupsRetrieveQueryOptions = < + TData = Awaited>, + TError = ScimError, +>( + idpSlug: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getScimV2GroupsRetrieveQueryKey(idpSlug,id); + const queryKey = queryOptions?.queryKey ?? getScimV2GroupsRetrieveQueryKey(idpSlug, id) - + const queryFn: QueryFunction>> = ({ signal }) => + scimV2GroupsRetrieve(idpSlug, id, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => scimV2GroupsRetrieve(idpSlug,id, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(idpSlug && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(idpSlug && id), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ScimV2GroupsRetrieveQueryResult = NonNullable>> export type ScimV2GroupsRetrieveQueryError = ScimError - - export function useScimV2GroupsRetrieve>, TError = ScimError>( - idpSlug: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + idpSlug: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getScimV2GroupsRetrieveQueryOptions(idpSlug, id, options) - const queryOptions = getScimV2GroupsRetrieveQueryOptions(idpSlug,id,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * Replaces a SCIM group entirely. */ @@ -393,77 +346,82 @@ export type scimV2GroupsUpdateResponse401 = { data: ScimError status: 401 } - -export type scimV2GroupsUpdateResponseComposite = scimV2GroupsUpdateResponse200 | scimV2GroupsUpdateResponse401; - -export type scimV2GroupsUpdateResponse = scimV2GroupsUpdateResponseComposite & { - headers: Headers; -} -export const getScimV2GroupsUpdateUrl = (idpSlug: string, - id: string,) => { +export type scimV2GroupsUpdateResponseComposite = scimV2GroupsUpdateResponse200 | scimV2GroupsUpdateResponse401 +export type scimV2GroupsUpdateResponse = scimV2GroupsUpdateResponseComposite & { + headers: Headers +} - - +export const getScimV2GroupsUpdateUrl = (idpSlug: string, id: string) => { return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` } -export const scimV2GroupsUpdate = async (idpSlug: string, - id: string, - scimGroup: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2GroupsUpdateUrl(idpSlug,id), - { +export const scimV2GroupsUpdate = async ( + idpSlug: string, + id: string, + scimGroup: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2GroupsUpdateUrl(idpSlug, id), { ...options, method: 'PUT', headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify( - scimGroup,) + body: JSON.stringify(scimGroup), + }) +} + +export const getScimV2GroupsUpdateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: string; data: NonReadonly }, + TContext +> => { + const mutationKey = ['scimV2GroupsUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { idpSlug: string; id: string; data: NonReadonly } + > = (props) => { + const { idpSlug, id, data } = props ?? {} + + return scimV2GroupsUpdate(idpSlug, id, data, requestOptions) } -);} - - - - -export const getScimV2GroupsUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext> => { - -const mutationKey = ['scimV2GroupsUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {idpSlug: string;id: string;data: NonReadonly}> = (props) => { - const {idpSlug,id,data} = props ?? {}; - - return scimV2GroupsUpdate(idpSlug,id,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type ScimV2GroupsUpdateMutationResult = NonNullable>> - export type ScimV2GroupsUpdateMutationBody = NonReadonly - export type ScimV2GroupsUpdateMutationError = ScimError + return { mutationFn, ...mutationOptions } +} - export const useScimV2GroupsUpdate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { +export type ScimV2GroupsUpdateMutationResult = NonNullable>> +export type ScimV2GroupsUpdateMutationBody = NonReadonly +export type ScimV2GroupsUpdateMutationError = ScimError - const mutationOptions = getScimV2GroupsUpdateMutationOptions(options); +export const useScimV2GroupsUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getScimV2GroupsUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Updates a SCIM group. Supports adding/removing members via patch operations. */ export type scimV2GroupsPartialUpdateResponse200 = { @@ -475,77 +433,84 @@ export type scimV2GroupsPartialUpdateResponse401 = { data: ScimError status: 401 } - -export type scimV2GroupsPartialUpdateResponseComposite = scimV2GroupsPartialUpdateResponse200 | scimV2GroupsPartialUpdateResponse401; - -export type scimV2GroupsPartialUpdateResponse = scimV2GroupsPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getScimV2GroupsPartialUpdateUrl = (idpSlug: string, - id: string,) => { +export type scimV2GroupsPartialUpdateResponseComposite = + | scimV2GroupsPartialUpdateResponse200 + | scimV2GroupsPartialUpdateResponse401 - +export type scimV2GroupsPartialUpdateResponse = scimV2GroupsPartialUpdateResponseComposite & { + headers: Headers +} +export const getScimV2GroupsPartialUpdateUrl = (idpSlug: string, id: string) => { return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` } -export const scimV2GroupsPartialUpdate = async (idpSlug: string, - id: string, - patchedScimGroup: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2GroupsPartialUpdateUrl(idpSlug,id), - { +export const scimV2GroupsPartialUpdate = async ( + idpSlug: string, + id: string, + patchedScimGroup: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2GroupsPartialUpdateUrl(idpSlug, id), { ...options, method: 'PATCH', headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify( - patchedScimGroup,) + body: JSON.stringify(patchedScimGroup), + }) +} + +export const getScimV2GroupsPartialUpdateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: string; data: NonReadonly }, + TContext +> => { + const mutationKey = ['scimV2GroupsPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { idpSlug: string; id: string; data: NonReadonly } + > = (props) => { + const { idpSlug, id, data } = props ?? {} + + return scimV2GroupsPartialUpdate(idpSlug, id, data, requestOptions) } -);} - - - - -export const getScimV2GroupsPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext> => { - -const mutationKey = ['scimV2GroupsPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {idpSlug: string;id: string;data: NonReadonly}> = (props) => { - const {idpSlug,id,data} = props ?? {}; - - return scimV2GroupsPartialUpdate(idpSlug,id,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type ScimV2GroupsPartialUpdateMutationResult = NonNullable>> - export type ScimV2GroupsPartialUpdateMutationBody = NonReadonly - export type ScimV2GroupsPartialUpdateMutationError = ScimError - - export const useScimV2GroupsPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string;data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { +export type ScimV2GroupsPartialUpdateMutationResult = NonNullable>> +export type ScimV2GroupsPartialUpdateMutationBody = NonReadonly +export type ScimV2GroupsPartialUpdateMutationError = ScimError - const mutationOptions = getScimV2GroupsPartialUpdateMutationOptions(options); +export const useScimV2GroupsPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getScimV2GroupsPartialUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Deletes a SCIM group. */ export type scimV2GroupsDestroyResponse204 = { @@ -557,75 +522,79 @@ export type scimV2GroupsDestroyResponse401 = { data: ScimError status: 401 } - -export type scimV2GroupsDestroyResponseComposite = scimV2GroupsDestroyResponse204 | scimV2GroupsDestroyResponse401; - -export type scimV2GroupsDestroyResponse = scimV2GroupsDestroyResponseComposite & { - headers: Headers; -} - -export const getScimV2GroupsDestroyUrl = (idpSlug: string, - id: string,) => { +export type scimV2GroupsDestroyResponseComposite = scimV2GroupsDestroyResponse204 | scimV2GroupsDestroyResponse401 - +export type scimV2GroupsDestroyResponse = scimV2GroupsDestroyResponseComposite & { + headers: Headers +} +export const getScimV2GroupsDestroyUrl = (idpSlug: string, id: string) => { return `/api/v2/scim/v2/${idpSlug}/Groups/${id}` } -export const scimV2GroupsDestroy = async (idpSlug: string, - id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2GroupsDestroyUrl(idpSlug,id), - { +export const scimV2GroupsDestroy = async ( + idpSlug: string, + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2GroupsDestroyUrl(idpSlug, id), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getScimV2GroupsDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: string }, + TContext +> => { + const mutationKey = ['scimV2GroupsDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { idpSlug: string; id: string } + > = (props) => { + const { idpSlug, id } = props ?? {} + + return scimV2GroupsDestroy(idpSlug, id, requestOptions) } -);} - - - - -export const getScimV2GroupsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{idpSlug: string;id: string}, TContext> => { - -const mutationKey = ['scimV2GroupsDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {idpSlug: string;id: string}> = (props) => { - const {idpSlug,id} = props ?? {}; - - return scimV2GroupsDestroy(idpSlug,id,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type ScimV2GroupsDestroyMutationResult = NonNullable>> - - export type ScimV2GroupsDestroyMutationError = ScimError +export type ScimV2GroupsDestroyMutationResult = NonNullable>> - export const useScimV2GroupsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: string}, TContext>, request?: SecondParameter} - ) => { +export type ScimV2GroupsDestroyMutationError = ScimError - const mutationOptions = getScimV2GroupsDestroyMutationOptions(options); +export const useScimV2GroupsDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getScimV2GroupsDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Returns the SCIM supported ResourceTypes. */ export type scimV2ResourceTypesRetrieveResponse200 = { @@ -637,78 +606,81 @@ export type scimV2ResourceTypesRetrieveResponse401 = { data: ScimError status: 401 } - -export type scimV2ResourceTypesRetrieveResponseComposite = scimV2ResourceTypesRetrieveResponse200 | scimV2ResourceTypesRetrieveResponse401; - -export type scimV2ResourceTypesRetrieveResponse = scimV2ResourceTypesRetrieveResponseComposite & { - headers: Headers; -} - -export const getScimV2ResourceTypesRetrieveUrl = (idpSlug: string,) => { +export type scimV2ResourceTypesRetrieveResponseComposite = + | scimV2ResourceTypesRetrieveResponse200 + | scimV2ResourceTypesRetrieveResponse401 - +export type scimV2ResourceTypesRetrieveResponse = scimV2ResourceTypesRetrieveResponseComposite & { + headers: Headers +} +export const getScimV2ResourceTypesRetrieveUrl = (idpSlug: string) => { return `/api/v2/scim/v2/${idpSlug}/ResourceTypes` } -export const scimV2ResourceTypesRetrieve = async (idpSlug: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2ResourceTypesRetrieveUrl(idpSlug), - { +export const scimV2ResourceTypesRetrieve = async ( + idpSlug: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2ResourceTypesRetrieveUrl(idpSlug), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getScimV2ResourceTypesRetrieveQueryKey = (idpSlug: string,) => { - return ['api','v2','scim','v2',idpSlug,'ResourceTypes'] as const; - } +export const getScimV2ResourceTypesRetrieveQueryKey = (idpSlug: string) => { + return ['api', 'v2', 'scim', 'v2', idpSlug, 'ResourceTypes'] as const +} - -export const getScimV2ResourceTypesRetrieveQueryOptions = >, TError = ScimError>(idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getScimV2ResourceTypesRetrieveQueryOptions = < + TData = Awaited>, + TError = ScimError, +>( + idpSlug: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getScimV2ResourceTypesRetrieveQueryKey(idpSlug); - - - - const queryFn: QueryFunction>> = ({ signal }) => scimV2ResourceTypesRetrieve(idpSlug, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getScimV2ResourceTypesRetrieveQueryKey(idpSlug) - + const queryFn: QueryFunction>> = ({ signal }) => + scimV2ResourceTypesRetrieve(idpSlug, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(idpSlug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!idpSlug, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type ScimV2ResourceTypesRetrieveQueryResult = NonNullable>> +export type ScimV2ResourceTypesRetrieveQueryResult = NonNullable< + Awaited> +> export type ScimV2ResourceTypesRetrieveQueryError = ScimError +export function useScimV2ResourceTypesRetrieve< + TData = Awaited>, + TError = ScimError, +>( + idpSlug: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getScimV2ResourceTypesRetrieveQueryOptions(idpSlug, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useScimV2ResourceTypesRetrieve>, TError = ScimError>( - idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getScimV2ResourceTypesRetrieveQueryOptions(idpSlug,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * Returns the SCIM supported Schemas. */ @@ -721,78 +693,74 @@ export type scimV2SchemasRetrieveResponse401 = { data: ScimError status: 401 } - -export type scimV2SchemasRetrieveResponseComposite = scimV2SchemasRetrieveResponse200 | scimV2SchemasRetrieveResponse401; - -export type scimV2SchemasRetrieveResponse = scimV2SchemasRetrieveResponseComposite & { - headers: Headers; -} - -export const getScimV2SchemasRetrieveUrl = (idpSlug: string,) => { +export type scimV2SchemasRetrieveResponseComposite = scimV2SchemasRetrieveResponse200 | scimV2SchemasRetrieveResponse401 - +export type scimV2SchemasRetrieveResponse = scimV2SchemasRetrieveResponseComposite & { + headers: Headers +} +export const getScimV2SchemasRetrieveUrl = (idpSlug: string) => { return `/api/v2/scim/v2/${idpSlug}/Schemas` } -export const scimV2SchemasRetrieve = async (idpSlug: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2SchemasRetrieveUrl(idpSlug), - { +export const scimV2SchemasRetrieve = async ( + idpSlug: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2SchemasRetrieveUrl(idpSlug), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getScimV2SchemasRetrieveQueryKey = (idpSlug: string,) => { - return ['api','v2','scim','v2',idpSlug,'Schemas'] as const; - } +export const getScimV2SchemasRetrieveQueryKey = (idpSlug: string) => { + return ['api', 'v2', 'scim', 'v2', idpSlug, 'Schemas'] as const +} - -export const getScimV2SchemasRetrieveQueryOptions = >, TError = ScimError>(idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getScimV2SchemasRetrieveQueryOptions = < + TData = Awaited>, + TError = ScimError, +>( + idpSlug: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getScimV2SchemasRetrieveQueryKey(idpSlug); - - - - const queryFn: QueryFunction>> = ({ signal }) => scimV2SchemasRetrieve(idpSlug, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getScimV2SchemasRetrieveQueryKey(idpSlug) - + const queryFn: QueryFunction>> = ({ signal }) => + scimV2SchemasRetrieve(idpSlug, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(idpSlug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!idpSlug, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ScimV2SchemasRetrieveQueryResult = NonNullable>> export type ScimV2SchemasRetrieveQueryError = ScimError - - export function useScimV2SchemasRetrieve>, TError = ScimError>( - idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getScimV2SchemasRetrieveQueryOptions(idpSlug,options) + idpSlug: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getScimV2SchemasRetrieveQueryOptions(idpSlug, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Returns the SCIM Service Provider Configuration. */ @@ -805,78 +773,84 @@ export type scimV2ServiceProviderConfigRetrieveResponse401 = { data: ScimError status: 401 } - -export type scimV2ServiceProviderConfigRetrieveResponseComposite = scimV2ServiceProviderConfigRetrieveResponse200 | scimV2ServiceProviderConfigRetrieveResponse401; - -export type scimV2ServiceProviderConfigRetrieveResponse = scimV2ServiceProviderConfigRetrieveResponseComposite & { - headers: Headers; -} - -export const getScimV2ServiceProviderConfigRetrieveUrl = (idpSlug: string,) => { +export type scimV2ServiceProviderConfigRetrieveResponseComposite = + | scimV2ServiceProviderConfigRetrieveResponse200 + | scimV2ServiceProviderConfigRetrieveResponse401 - +export type scimV2ServiceProviderConfigRetrieveResponse = scimV2ServiceProviderConfigRetrieveResponseComposite & { + headers: Headers +} +export const getScimV2ServiceProviderConfigRetrieveUrl = (idpSlug: string) => { return `/api/v2/scim/v2/${idpSlug}/ServiceProviderConfig` } -export const scimV2ServiceProviderConfigRetrieve = async (idpSlug: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2ServiceProviderConfigRetrieveUrl(idpSlug), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getScimV2ServiceProviderConfigRetrieveQueryKey = (idpSlug: string,) => { - return ['api','v2','scim','v2',idpSlug,'ServiceProviderConfig'] as const; - } - - -export const getScimV2ServiceProviderConfigRetrieveQueryOptions = >, TError = ScimError>(idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const scimV2ServiceProviderConfigRetrieve = async ( + idpSlug: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getScimV2ServiceProviderConfigRetrieveUrl(idpSlug), + { + ...options, + method: 'GET', + }, + ) +} + +export const getScimV2ServiceProviderConfigRetrieveQueryKey = (idpSlug: string) => { + return ['api', 'v2', 'scim', 'v2', idpSlug, 'ServiceProviderConfig'] as const +} + +export const getScimV2ServiceProviderConfigRetrieveQueryOptions = < + TData = Awaited>, + TError = ScimError, +>( + idpSlug: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getScimV2ServiceProviderConfigRetrieveQueryKey(idpSlug); - - - - const queryFn: QueryFunction>> = ({ signal }) => scimV2ServiceProviderConfigRetrieve(idpSlug, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getScimV2ServiceProviderConfigRetrieveQueryKey(idpSlug) - + const queryFn: QueryFunction>> = ({ signal }) => + scimV2ServiceProviderConfigRetrieve(idpSlug, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(idpSlug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!idpSlug, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type ScimV2ServiceProviderConfigRetrieveQueryResult = NonNullable>> +export type ScimV2ServiceProviderConfigRetrieveQueryResult = NonNullable< + Awaited> +> export type ScimV2ServiceProviderConfigRetrieveQueryError = ScimError +export function useScimV2ServiceProviderConfigRetrieve< + TData = Awaited>, + TError = ScimError, +>( + idpSlug: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getScimV2ServiceProviderConfigRetrieveQueryOptions(idpSlug, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useScimV2ServiceProviderConfigRetrieve>, TError = ScimError>( - idpSlug: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getScimV2ServiceProviderConfigRetrieveQueryOptions(idpSlug,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * Returns a list of SCIM users matching the optional query */ @@ -889,90 +863,86 @@ export type scimV2UsersListResponse401 = { data: ScimError status: 401 } - -export type scimV2UsersListResponseComposite = scimV2UsersListResponse200 | scimV2UsersListResponse401; - + +export type scimV2UsersListResponseComposite = scimV2UsersListResponse200 | scimV2UsersListResponse401 + export type scimV2UsersListResponse = scimV2UsersListResponseComposite & { - headers: Headers; + headers: Headers } -export const getScimV2UsersListUrl = (idpSlug: string, - params?: ScimV2UsersListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getScimV2UsersListUrl = (idpSlug: string, params?: ScimV2UsersListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/scim/v2/${idpSlug}/Users?${stringifiedParams}` : `/api/v2/scim/v2/${idpSlug}/Users` + return stringifiedParams.length > 0 + ? `/api/v2/scim/v2/${idpSlug}/Users?${stringifiedParams}` + : `/api/v2/scim/v2/${idpSlug}/Users` } -export const scimV2UsersList = async (idpSlug: string, - params?: ScimV2UsersListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2UsersListUrl(idpSlug,params), - { +export const scimV2UsersList = async ( + idpSlug: string, + params?: ScimV2UsersListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2UsersListUrl(idpSlug, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getScimV2UsersListQueryKey = (idpSlug: string, - params?: ScimV2UsersListParams,) => { - return ['api','v2','scim','v2',idpSlug,'Users', ...(params ? [params]: [])] as const; - } +export const getScimV2UsersListQueryKey = (idpSlug: string, params?: ScimV2UsersListParams) => { + return ['api', 'v2', 'scim', 'v2', idpSlug, 'Users', ...(params ? [params] : [])] as const +} - -export const getScimV2UsersListQueryOptions = >, TError = ScimError>(idpSlug: string, - params?: ScimV2UsersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getScimV2UsersListQueryOptions = >, TError = ScimError>( + idpSlug: string, + params?: ScimV2UsersListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getScimV2UsersListQueryKey(idpSlug,params); + const queryKey = queryOptions?.queryKey ?? getScimV2UsersListQueryKey(idpSlug, params) - + const queryFn: QueryFunction>> = ({ signal }) => + scimV2UsersList(idpSlug, params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => scimV2UsersList(idpSlug,params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(idpSlug), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!idpSlug, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ScimV2UsersListQueryResult = NonNullable>> export type ScimV2UsersListQueryError = ScimError - - export function useScimV2UsersList>, TError = ScimError>( - idpSlug: string, - params?: ScimV2UsersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + idpSlug: string, + params?: ScimV2UsersListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getScimV2UsersListQueryOptions(idpSlug, params, options) - const queryOptions = getScimV2UsersListQueryOptions(idpSlug,params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * Handle POST requests (user provisioning from IdP). */ @@ -995,75 +965,91 @@ export type scimV2UsersCreateResponse409 = { data: ScimV2UsersCreate409 status: 409 } - -export type scimV2UsersCreateResponseComposite = scimV2UsersCreateResponse201 | scimV2UsersCreateResponse400 | scimV2UsersCreateResponse401 | scimV2UsersCreateResponse409; - -export type scimV2UsersCreateResponse = scimV2UsersCreateResponseComposite & { - headers: Headers; -} -export const getScimV2UsersCreateUrl = (idpSlug: string,) => { +export type scimV2UsersCreateResponseComposite = + | scimV2UsersCreateResponse201 + | scimV2UsersCreateResponse400 + | scimV2UsersCreateResponse401 + | scimV2UsersCreateResponse409 +export type scimV2UsersCreateResponse = scimV2UsersCreateResponseComposite & { + headers: Headers +} - - +export const getScimV2UsersCreateUrl = (idpSlug: string) => { return `/api/v2/scim/v2/${idpSlug}/Users` } -export const scimV2UsersCreate = async (idpSlug: string, - scimUser: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2UsersCreateUrl(idpSlug), - { +export const scimV2UsersCreate = async ( + idpSlug: string, + scimUser: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2UsersCreateUrl(idpSlug), { ...options, method: 'POST', headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify( - scimUser,) + body: JSON.stringify(scimUser), + }) +} + +export const getScimV2UsersCreateMutationOptions = < + TError = ScimV2UsersCreate400 | ScimError | ScimV2UsersCreate409, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; data: NonReadonly }, + TContext +> => { + const mutationKey = ['scimV2UsersCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { idpSlug: string; data: NonReadonly } + > = (props) => { + const { idpSlug, data } = props ?? {} + + return scimV2UsersCreate(idpSlug, data, requestOptions) } -);} - - - - -export const getScimV2UsersCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext> => { - -const mutationKey = ['scimV2UsersCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {idpSlug: string;data: NonReadonly}> = (props) => { - const {idpSlug,data} = props ?? {}; - - return scimV2UsersCreate(idpSlug,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type ScimV2UsersCreateMutationResult = NonNullable>> - export type ScimV2UsersCreateMutationBody = NonReadonly - export type ScimV2UsersCreateMutationError = ScimV2UsersCreate400 | ScimError | ScimV2UsersCreate409 + return { mutationFn, ...mutationOptions } +} - export const useScimV2UsersCreate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { +export type ScimV2UsersCreateMutationResult = NonNullable>> +export type ScimV2UsersCreateMutationBody = NonReadonly +export type ScimV2UsersCreateMutationError = ScimV2UsersCreate400 | ScimError | ScimV2UsersCreate409 - const mutationOptions = getScimV2UsersCreateMutationOptions(options); +export const useScimV2UsersCreate = < + TError = ScimV2UsersCreate400 | ScimError | ScimV2UsersCreate409, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getScimV2UsersCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Returns a specific SCIM user. */ export type scimV2UsersRetrieveResponse200 = { @@ -1075,83 +1061,77 @@ export type scimV2UsersRetrieveResponse401 = { data: ScimError status: 401 } - -export type scimV2UsersRetrieveResponseComposite = scimV2UsersRetrieveResponse200 | scimV2UsersRetrieveResponse401; - -export type scimV2UsersRetrieveResponse = scimV2UsersRetrieveResponseComposite & { - headers: Headers; -} - -export const getScimV2UsersRetrieveUrl = (idpSlug: string, - id: number,) => { +export type scimV2UsersRetrieveResponseComposite = scimV2UsersRetrieveResponse200 | scimV2UsersRetrieveResponse401 - +export type scimV2UsersRetrieveResponse = scimV2UsersRetrieveResponseComposite & { + headers: Headers +} +export const getScimV2UsersRetrieveUrl = (idpSlug: string, id: number) => { return `/api/v2/scim/v2/${idpSlug}/Users/${id}` } -export const scimV2UsersRetrieve = async (idpSlug: string, - id: number, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2UsersRetrieveUrl(idpSlug,id), - { +export const scimV2UsersRetrieve = async ( + idpSlug: string, + id: number, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2UsersRetrieveUrl(idpSlug, id), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getScimV2UsersRetrieveQueryKey = (idpSlug: string, - id: number,) => { - return ['api','v2','scim','v2',idpSlug,'Users',id] as const; - } +export const getScimV2UsersRetrieveQueryKey = (idpSlug: string, id: number) => { + return ['api', 'v2', 'scim', 'v2', idpSlug, 'Users', id] as const +} - -export const getScimV2UsersRetrieveQueryOptions = >, TError = ScimError>(idpSlug: string, - id: number, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getScimV2UsersRetrieveQueryOptions = < + TData = Awaited>, + TError = ScimError, +>( + idpSlug: string, + id: number, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getScimV2UsersRetrieveQueryKey(idpSlug, id) - const queryKey = queryOptions?.queryKey ?? getScimV2UsersRetrieveQueryKey(idpSlug,id); + const queryFn: QueryFunction>> = ({ signal }) => + scimV2UsersRetrieve(idpSlug, id, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => scimV2UsersRetrieve(idpSlug,id, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(idpSlug && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(idpSlug && id), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ScimV2UsersRetrieveQueryResult = NonNullable>> export type ScimV2UsersRetrieveQueryError = ScimError - - export function useScimV2UsersRetrieve>, TError = ScimError>( - idpSlug: string, - id: number, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getScimV2UsersRetrieveQueryOptions(idpSlug,id,options) + idpSlug: string, + id: number, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getScimV2UsersRetrieveQueryOptions(idpSlug, id, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * Handle PUT requests (user update from IdP). Authentik can send a PUT request to update a user's details. If it tries to @@ -1172,77 +1152,88 @@ export type scimV2UsersUpdateResponse409 = { data: ScimV2UsersUpdate409 status: 409 } - -export type scimV2UsersUpdateResponseComposite = scimV2UsersUpdateResponse200 | scimV2UsersUpdateResponse401 | scimV2UsersUpdateResponse409; - -export type scimV2UsersUpdateResponse = scimV2UsersUpdateResponseComposite & { - headers: Headers; -} - -export const getScimV2UsersUpdateUrl = (idpSlug: string, - id: number,) => { +export type scimV2UsersUpdateResponseComposite = + | scimV2UsersUpdateResponse200 + | scimV2UsersUpdateResponse401 + | scimV2UsersUpdateResponse409 - +export type scimV2UsersUpdateResponse = scimV2UsersUpdateResponseComposite & { + headers: Headers +} +export const getScimV2UsersUpdateUrl = (idpSlug: string, id: number) => { return `/api/v2/scim/v2/${idpSlug}/Users/${id}` } -export const scimV2UsersUpdate = async (idpSlug: string, - id: number, - scimUser: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2UsersUpdateUrl(idpSlug,id), - { +export const scimV2UsersUpdate = async ( + idpSlug: string, + id: number, + scimUser: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2UsersUpdateUrl(idpSlug, id), { ...options, method: 'PUT', headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify( - scimUser,) + body: JSON.stringify(scimUser), + }) +} + +export const getScimV2UsersUpdateMutationOptions = < + TError = ScimError | ScimV2UsersUpdate409, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: number; data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ['scimV2UsersUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { idpSlug: string; id: number; data: NonReadonly } + > = (props) => { + const { idpSlug, id, data } = props ?? {} + + return scimV2UsersUpdate(idpSlug, id, data, requestOptions) } -);} - - - - -export const getScimV2UsersUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext> => { - -const mutationKey = ['scimV2UsersUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {idpSlug: string;id: number;data: NonReadonly}> = (props) => { - const {idpSlug,id,data} = props ?? {}; - - return scimV2UsersUpdate(idpSlug,id,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type ScimV2UsersUpdateMutationResult = NonNullable>> - export type ScimV2UsersUpdateMutationBody = NonReadonly - export type ScimV2UsersUpdateMutationError = ScimError | ScimV2UsersUpdate409 - - export const useScimV2UsersUpdate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { +export type ScimV2UsersUpdateMutationResult = NonNullable>> +export type ScimV2UsersUpdateMutationBody = NonReadonly +export type ScimV2UsersUpdateMutationError = ScimError | ScimV2UsersUpdate409 - const mutationOptions = getScimV2UsersUpdateMutationOptions(options); +export const useScimV2UsersUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: number; data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getScimV2UsersUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Updates a SCIM user. Currently only supports deactivation via the `active` attribute. */ export type scimV2UsersPartialUpdateResponse200 = { @@ -1254,77 +1245,84 @@ export type scimV2UsersPartialUpdateResponse401 = { data: ScimError status: 401 } - -export type scimV2UsersPartialUpdateResponseComposite = scimV2UsersPartialUpdateResponse200 | scimV2UsersPartialUpdateResponse401; - -export type scimV2UsersPartialUpdateResponse = scimV2UsersPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getScimV2UsersPartialUpdateUrl = (idpSlug: string, - id: number,) => { +export type scimV2UsersPartialUpdateResponseComposite = + | scimV2UsersPartialUpdateResponse200 + | scimV2UsersPartialUpdateResponse401 - +export type scimV2UsersPartialUpdateResponse = scimV2UsersPartialUpdateResponseComposite & { + headers: Headers +} +export const getScimV2UsersPartialUpdateUrl = (idpSlug: string, id: number) => { return `/api/v2/scim/v2/${idpSlug}/Users/${id}` } -export const scimV2UsersPartialUpdate = async (idpSlug: string, - id: number, - patchedScimUser: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2UsersPartialUpdateUrl(idpSlug,id), - { +export const scimV2UsersPartialUpdate = async ( + idpSlug: string, + id: number, + patchedScimUser: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2UsersPartialUpdateUrl(idpSlug, id), { ...options, method: 'PATCH', headers: { 'Content-Type': 'application/scim+json', ...options?.headers }, - body: JSON.stringify( - patchedScimUser,) + body: JSON.stringify(patchedScimUser), + }) +} + +export const getScimV2UsersPartialUpdateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: number; data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: number; data: NonReadonly }, + TContext +> => { + const mutationKey = ['scimV2UsersPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { idpSlug: string; id: number; data: NonReadonly } + > = (props) => { + const { idpSlug, id, data } = props ?? {} + + return scimV2UsersPartialUpdate(idpSlug, id, data, requestOptions) } -);} - - - - -export const getScimV2UsersPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext> => { - -const mutationKey = ['scimV2UsersPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {idpSlug: string;id: number;data: NonReadonly}> = (props) => { - const {idpSlug,id,data} = props ?? {}; - - return scimV2UsersPartialUpdate(idpSlug,id,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type ScimV2UsersPartialUpdateMutationResult = NonNullable>> - export type ScimV2UsersPartialUpdateMutationBody = NonReadonly - export type ScimV2UsersPartialUpdateMutationError = ScimError + return { mutationFn, ...mutationOptions } +} - export const useScimV2UsersPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number;data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { +export type ScimV2UsersPartialUpdateMutationResult = NonNullable>> +export type ScimV2UsersPartialUpdateMutationBody = NonReadonly +export type ScimV2UsersPartialUpdateMutationError = ScimError - const mutationOptions = getScimV2UsersPartialUpdateMutationOptions(options); +export const useScimV2UsersPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: number; data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getScimV2UsersPartialUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * Deactivates all Kobo accounts linked to the user's email address. */ export type scimV2UsersDestroyResponse204 = { @@ -1336,72 +1334,75 @@ export type scimV2UsersDestroyResponse401 = { data: ScimError status: 401 } - -export type scimV2UsersDestroyResponseComposite = scimV2UsersDestroyResponse204 | scimV2UsersDestroyResponse401; - -export type scimV2UsersDestroyResponse = scimV2UsersDestroyResponseComposite & { - headers: Headers; -} -export const getScimV2UsersDestroyUrl = (idpSlug: string, - id: number,) => { +export type scimV2UsersDestroyResponseComposite = scimV2UsersDestroyResponse204 | scimV2UsersDestroyResponse401 +export type scimV2UsersDestroyResponse = scimV2UsersDestroyResponseComposite & { + headers: Headers +} - - +export const getScimV2UsersDestroyUrl = (idpSlug: string, id: number) => { return `/api/v2/scim/v2/${idpSlug}/Users/${id}` } -export const scimV2UsersDestroy = async (idpSlug: string, - id: number, options?: RequestInit): Promise => { - - return fetchWithAuth(getScimV2UsersDestroyUrl(idpSlug,id), - { +export const scimV2UsersDestroy = async ( + idpSlug: string, + id: number, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getScimV2UsersDestroyUrl(idpSlug, id), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getScimV2UsersDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: number }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: number }, + TContext +> => { + const mutationKey = ['scimV2UsersDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { idpSlug: string; id: number } + > = (props) => { + const { idpSlug, id } = props ?? {} + + return scimV2UsersDestroy(idpSlug, id, requestOptions) } -);} - - - - -export const getScimV2UsersDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{idpSlug: string;id: number}, TContext> => { -const mutationKey = ['scimV2UsersDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {idpSlug: string;id: number}> = (props) => { - const {idpSlug,id} = props ?? {}; - - return scimV2UsersDestroy(idpSlug,id,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type ScimV2UsersDestroyMutationResult = NonNullable>> - - export type ScimV2UsersDestroyMutationError = ScimError +export type ScimV2UsersDestroyMutationResult = NonNullable>> - export const useScimV2UsersDestroy = (options?: { mutation?:UseMutationOptions>, TError,{idpSlug: string;id: number}, TContext>, request?: SecondParameter} - ) => { +export type ScimV2UsersDestroyMutationError = ScimError - const mutationOptions = getScimV2UsersDestroyMutationOptions(options); +export const useScimV2UsersDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { idpSlug: string; id: number }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getScimV2UsersDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - \ No newline at end of file + return useMutation(mutationOptions) +} diff --git a/jsapp/js/api/react-query/scim/msw.ts b/jsapp/js/api/react-query/scim/msw.ts index 74b87e08ec..ec33e2a8a2 100644 --- a/jsapp/js/api/react-query/scim/msw.ts +++ b/jsapp/js/api/react-query/scim/msw.ts @@ -9,250 +9,463 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; - -import { HttpResponse, - http } from 'msw'; - -import type { - PaginatedScimGroupList -} from '../../models/paginatedScimGroupList'; - -import type { - PaginatedScimUserList -} from '../../models/paginatedScimUserList'; - -import type { - ScimGroup -} from '../../models/scimGroup'; - -import type { - ScimUser -} from '../../models/scimUser'; - -import type { - ScimV2ResourceTypesRetrieve200 -} from '../../models/scimV2ResourceTypesRetrieve200'; - -import type { - ScimV2SchemasRetrieve200 -} from '../../models/scimV2SchemasRetrieve200'; - -import type { - ScimV2ServiceProviderConfigRetrieve200 -} from '../../models/scimV2ServiceProviderConfigRetrieve200'; - - -export const getApiV2ScimV2GroupsListResponseMock = (overrideResponse: Partial< PaginatedScimGroupList > = {}): PaginatedScimGroupList => ({schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), totalResults: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), itemsPerPage: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), startIndex: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), displayName: faker.string.alpha({length: {min: 10, max: 20}}), externalId: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), members: {}, meta: { - [faker.string.alphanumeric(5)]: {} - }})), ...overrideResponse}) - -export const getApiV2ScimV2GroupsCreateResponseMock = (overrideResponse: Partial< ScimGroup > = {}): ScimGroup => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), displayName: faker.string.alpha({length: {min: 10, max: 20}}), externalId: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), members: {}, meta: { - [faker.string.alphanumeric(5)]: {} - }, ...overrideResponse}) - -export const getApiV2ScimV2GroupsRetrieveResponseMock = (overrideResponse: Partial< ScimGroup > = {}): ScimGroup => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), displayName: faker.string.alpha({length: {min: 10, max: 20}}), externalId: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), members: {}, meta: { - [faker.string.alphanumeric(5)]: {} - }, ...overrideResponse}) - -export const getApiV2ScimV2GroupsUpdateResponseMock = (overrideResponse: Partial< ScimGroup > = {}): ScimGroup => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), displayName: faker.string.alpha({length: {min: 10, max: 20}}), externalId: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), members: {}, meta: { - [faker.string.alphanumeric(5)]: {} - }, ...overrideResponse}) - -export const getApiV2ScimV2GroupsPartialUpdateResponseMock = (overrideResponse: Partial< ScimGroup > = {}): ScimGroup => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), displayName: faker.string.alpha({length: {min: 10, max: 20}}), externalId: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), members: {}, meta: { - [faker.string.alphanumeric(5)]: {} - }, ...overrideResponse}) +import { faker } from '@faker-js/faker' + +import { http, HttpResponse } from 'msw' + +import type { PaginatedScimGroupList } from '../../models/paginatedScimGroupList' + +import type { PaginatedScimUserList } from '../../models/paginatedScimUserList' + +import type { ScimGroup } from '../../models/scimGroup' + +import type { ScimUser } from '../../models/scimUser' + +import type { ScimV2ResourceTypesRetrieve200 } from '../../models/scimV2ResourceTypesRetrieve200' + +import type { ScimV2SchemasRetrieve200 } from '../../models/scimV2SchemasRetrieve200' + +import type { ScimV2ServiceProviderConfigRetrieve200 } from '../../models/scimV2ServiceProviderConfigRetrieve200' + +export const getApiV2ScimV2GroupsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedScimGroupList => ({ + schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + totalResults: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + itemsPerPage: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + startIndex: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsCreateResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsRetrieveResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsUpdateResponseMock = (overrideResponse: Partial = {}): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): ScimGroup => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + displayName: faker.string.alpha({ length: { min: 10, max: 20 } }), + externalId: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + members: {}, + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) export const getApiV2ScimV2ResourceTypesRetrieveResponseMock = (): ScimV2ResourceTypesRetrieve200 => ({ - [faker.string.alphanumeric(5)]: {} - }) + [faker.string.alphanumeric(5)]: {}, +}) export const getApiV2ScimV2SchemasRetrieveResponseMock = (): ScimV2SchemasRetrieve200 => ({ - [faker.string.alphanumeric(5)]: {} - }) + [faker.string.alphanumeric(5)]: {}, +}) export const getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock = (): ScimV2ServiceProviderConfigRetrieve200 => ({ - [faker.string.alphanumeric(5)]: {} - }) - -export const getApiV2ScimV2UsersListResponseMock = (overrideResponse: Partial< PaginatedScimUserList > = {}): PaginatedScimUserList => ({schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), totalResults: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), itemsPerPage: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), startIndex: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), userName: faker.string.alpha({length: {min: 10, max: 20}}), name: { - [faker.string.alphanumeric(5)]: {} - }, emails: {}, active: faker.datatype.boolean(), meta: { - [faker.string.alphanumeric(5)]: {} - }})), ...overrideResponse}) - -export const getApiV2ScimV2UsersCreateResponseMock = (overrideResponse: Partial< ScimUser > = {}): ScimUser => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), userName: faker.string.alpha({length: {min: 10, max: 20}}), name: { - [faker.string.alphanumeric(5)]: {} - }, emails: {}, active: faker.datatype.boolean(), meta: { - [faker.string.alphanumeric(5)]: {} - }, ...overrideResponse}) - -export const getApiV2ScimV2UsersRetrieveResponseMock = (overrideResponse: Partial< ScimUser > = {}): ScimUser => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), userName: faker.string.alpha({length: {min: 10, max: 20}}), name: { - [faker.string.alphanumeric(5)]: {} - }, emails: {}, active: faker.datatype.boolean(), meta: { - [faker.string.alphanumeric(5)]: {} - }, ...overrideResponse}) - -export const getApiV2ScimV2UsersUpdateResponseMock = (overrideResponse: Partial< ScimUser > = {}): ScimUser => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), userName: faker.string.alpha({length: {min: 10, max: 20}}), name: { - [faker.string.alphanumeric(5)]: {} - }, emails: {}, active: faker.datatype.boolean(), meta: { - [faker.string.alphanumeric(5)]: {} - }, ...overrideResponse}) - -export const getApiV2ScimV2UsersPartialUpdateResponseMock = (overrideResponse: Partial< ScimUser > = {}): ScimUser => ({schemas: {}, id: faker.string.alpha({length: {min: 10, max: 20}}), userName: faker.string.alpha({length: {min: 10, max: 20}}), name: { - [faker.string.alphanumeric(5)]: {} - }, emails: {}, active: faker.datatype.boolean(), meta: { - [faker.string.alphanumeric(5)]: {} - }, ...overrideResponse}) - - -export const getApiV2ScimV2GroupsListMockHandler = (overrideResponse?: PaginatedScimGroupList | ((info: Parameters[1]>[0]) => Promise | PaginatedScimGroupList)) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2GroupsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) + [faker.string.alphanumeric(5)]: {}, +}) + +export const getApiV2ScimV2UsersListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedScimUserList => ({ + schemas: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + totalResults: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + itemsPerPage: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + startIndex: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + Resources: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersCreateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersRetrieveResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersUpdateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2UsersPartialUpdateResponseMock = (overrideResponse: Partial = {}): ScimUser => ({ + schemas: {}, + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + userName: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: { + [faker.string.alphanumeric(5)]: {}, + }, + emails: {}, + active: faker.datatype.boolean(), + meta: { + [faker.string.alphanumeric(5)]: {}, + }, + ...overrideResponse, +}) + +export const getApiV2ScimV2GroupsListMockHandler = ( + overrideResponse?: + | PaginatedScimGroupList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedScimGroupList), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2GroupsCreateMockHandler = (overrideResponse?: ScimGroup | ((info: Parameters[1]>[0]) => Promise | ScimGroup)) => { - return http.post('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2GroupsCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2GroupsCreateMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.post('*/api/v2/scim/v2/:idpSlug/Groups', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2GroupsRetrieveMockHandler = (overrideResponse?: ScimGroup | ((info: Parameters[1]>[0]) => Promise | ScimGroup)) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2GroupsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2GroupsRetrieveMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2GroupsUpdateMockHandler = (overrideResponse?: ScimGroup | ((info: Parameters[1]>[0]) => Promise | ScimGroup)) => { - return http.put('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2GroupsUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2GroupsUpdateMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.put('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2GroupsPartialUpdateMockHandler = (overrideResponse?: ScimGroup | ((info: Parameters[1]>[0]) => Promise | ScimGroup)) => { - return http.patch('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2GroupsPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2GroupsPartialUpdateMockHandler = ( + overrideResponse?: + | ScimGroup + | ((info: Parameters[1]>[0]) => Promise | ScimGroup), +) => { + return http.patch('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2GroupsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2GroupsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2ScimV2GroupsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/scim/v2/:idpSlug/Groups/:id', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2ScimV2ResourceTypesRetrieveMockHandler = (overrideResponse?: ScimV2ResourceTypesRetrieve200 | ((info: Parameters[1]>[0]) => Promise | ScimV2ResourceTypesRetrieve200)) => { - return http.get('*/api/v2/scim/v2/:idpSlug/ResourceTypes', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2ResourceTypesRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2ResourceTypesRetrieveMockHandler = ( + overrideResponse?: + | ScimV2ResourceTypesRetrieve200 + | (( + info: Parameters[1]>[0], + ) => Promise | ScimV2ResourceTypesRetrieve200), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/ResourceTypes', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2ResourceTypesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2SchemasRetrieveMockHandler = (overrideResponse?: ScimV2SchemasRetrieve200 | ((info: Parameters[1]>[0]) => Promise | ScimV2SchemasRetrieve200)) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Schemas', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2SchemasRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2SchemasRetrieveMockHandler = ( + overrideResponse?: + | ScimV2SchemasRetrieve200 + | (( + info: Parameters[1]>[0], + ) => Promise | ScimV2SchemasRetrieve200), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Schemas', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2SchemasRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler = (overrideResponse?: ScimV2ServiceProviderConfigRetrieve200 | ((info: Parameters[1]>[0]) => Promise | ScimV2ServiceProviderConfigRetrieve200)) => { - return http.get('*/api/v2/scim/v2/:idpSlug/ServiceProviderConfig', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2ServiceProviderConfigRetrieveMockHandler = ( + overrideResponse?: + | ScimV2ServiceProviderConfigRetrieve200 + | (( + info: Parameters[1]>[0], + ) => Promise | ScimV2ServiceProviderConfigRetrieve200), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/ServiceProviderConfig', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2ServiceProviderConfigRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2UsersListMockHandler = (overrideResponse?: PaginatedScimUserList | ((info: Parameters[1]>[0]) => Promise | PaginatedScimUserList)) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Users', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2UsersListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2UsersListMockHandler = ( + overrideResponse?: + | PaginatedScimUserList + | ((info: Parameters[1]>[0]) => Promise | PaginatedScimUserList), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2UsersCreateMockHandler = (overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser)) => { - return http.post('*/api/v2/scim/v2/:idpSlug/Users', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2UsersCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2UsersCreateMockHandler = ( + overrideResponse?: + | ScimUser + | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.post('*/api/v2/scim/v2/:idpSlug/Users', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2UsersRetrieveMockHandler = (overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser)) => { - return http.get('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2UsersRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2UsersRetrieveMockHandler = ( + overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.get('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2UsersUpdateMockHandler = (overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser)) => { - return http.put('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2UsersUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2UsersUpdateMockHandler = ( + overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.put('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2UsersPartialUpdateMockHandler = (overrideResponse?: ScimUser | ((info: Parameters[1]>[0]) => Promise | ScimUser)) => { - return http.patch('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ScimV2UsersPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ScimV2UsersPartialUpdateMockHandler = ( + overrideResponse?: + | ScimUser + | ((info: Parameters[1]>[0]) => Promise | ScimUser), +) => { + return http.patch('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ScimV2UsersPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ScimV2UsersDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2ScimV2UsersDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/scim/v2/:idpSlug/Users/:id', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } export const getScimMock = () => [ @@ -270,5 +483,5 @@ export const getScimMock = () => [ getApiV2ScimV2UsersRetrieveMockHandler(), getApiV2ScimV2UsersUpdateMockHandler(), getApiV2ScimV2UsersPartialUpdateMockHandler(), - getApiV2ScimV2UsersDestroyMockHandler() + getApiV2ScimV2UsersDestroyMockHandler(), ] diff --git a/jsapp/js/api/react-query/server-logs-superusers/index.ts b/jsapp/js/api/react-query/server-logs-superusers/index.ts index e07153ced9..d753203c53 100644 --- a/jsapp/js/api/react-query/server-logs-superusers/index.ts +++ b/jsapp/js/api/react-query/server-logs-superusers/index.ts @@ -9,77 +9,45 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - AccessLogsListParams -} from '../../models/accessLogsListParams'; +import type { AccessLogsListParams } from '../../models/accessLogsListParams' -import type { - AuditLogsListParams -} from '../../models/auditLogsListParams'; +import type { AuditLogsListParams } from '../../models/auditLogsListParams' -import type { - ErrorDetail -} from '../../models/errorDetail'; +import type { ErrorDetail } from '../../models/errorDetail' -import type { - ErrorObject -} from '../../models/errorObject'; +import type { ErrorObject } from '../../models/errorObject' -import type { - ExportCreateResponse -} from '../../models/exportCreateResponse'; +import type { ExportCreateResponse } from '../../models/exportCreateResponse' -import type { - ExportHistoryResponse -} from '../../models/exportHistoryResponse'; +import type { ExportHistoryResponse } from '../../models/exportHistoryResponse' -import type { - ExportListResponse -} from '../../models/exportListResponse'; +import type { ExportListResponse } from '../../models/exportListResponse' -import type { - PaginatedAuditLogResponseList -} from '../../models/paginatedAuditLogResponseList'; +import type { PaginatedAuditLogResponseList } from '../../models/paginatedAuditLogResponseList' -import type { - PaginatedProjectHistoryLogResponseList -} from '../../models/paginatedProjectHistoryLogResponseList'; +import type { PaginatedProjectHistoryLogResponseList } from '../../models/paginatedProjectHistoryLogResponseList' -import type { - PaginatedSuperUserAccessLogResponseList -} from '../../models/paginatedSuperUserAccessLogResponseList'; +import type { PaginatedSuperUserAccessLogResponseList } from '../../models/paginatedSuperUserAccessLogResponseList' -import type { - PaginatedUserReportsListResponseList -} from '../../models/paginatedUserReportsListResponseList'; +import type { PaginatedUserReportsListResponseList } from '../../models/paginatedUserReportsListResponseList' -import type { - ProjectHistoryLogsListParams -} from '../../models/projectHistoryLogsListParams'; - -import type { - UserReportsListParams -} from '../../models/userReportsListParams'; - -import { fetchWithAuth } from '../../orval.mutator'; +import type { ProjectHistoryLogsListParams } from '../../models/projectHistoryLogsListParams' +import type { UserReportsListParams } from '../../models/userReportsListParams' -type SecondParameter unknown> = Parameters[1]; - +import { fetchWithAuth } from '../../orval.mutator' +type SecondParameter unknown> = Parameters[1] /** * ## List all access logs for all users @@ -118,85 +86,81 @@ export type accessLogsListResponse403 = { data: ErrorDetail status: 403 } - -export type accessLogsListResponseComposite = accessLogsListResponse200 | accessLogsListResponse403; - + +export type accessLogsListResponseComposite = accessLogsListResponse200 | accessLogsListResponse403 + export type accessLogsListResponse = accessLogsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAccessLogsListUrl = (params?: AccessLogsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAccessLogsListUrl = (params?: AccessLogsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/access-logs/?${stringifiedParams}` : `/api/v2/access-logs/` } -export const accessLogsList = async (params?: AccessLogsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAccessLogsListUrl(params), - { +export const accessLogsList = async ( + params?: AccessLogsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAccessLogsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAccessLogsListQueryKey = (params?: AccessLogsListParams,) => { - return ['api','v2','access-logs', ...(params ? [params]: [])] as const; - } +export const getAccessLogsListQueryKey = (params?: AccessLogsListParams) => { + return ['api', 'v2', 'access-logs', ...(params ? [params] : [])] as const +} - -export const getAccessLogsListQueryOptions = >, TError = ErrorDetail>(params?: AccessLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAccessLogsListQueryOptions = >, TError = ErrorDetail>( + params?: AccessLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAccessLogsListQueryKey(params); - - + const queryKey = queryOptions?.queryKey ?? getAccessLogsListQueryKey(params) - const queryFn: QueryFunction>> = ({ signal }) => accessLogsList(params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + accessLogsList(params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AccessLogsListQueryResult = NonNullable>> export type AccessLogsListQueryError = ErrorDetail - - export function useAccessLogsList>, TError = ErrorDetail>( - params?: AccessLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAccessLogsListQueryOptions(params,options) + params?: AccessLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAccessLogsListQueryOptions(params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## List all access logs export tasks for all users @@ -212,78 +176,68 @@ export type accessLogsExportListResponse403 = { data: ErrorDetail status: 403 } - -export type accessLogsExportListResponseComposite = accessLogsExportListResponse200 | accessLogsExportListResponse403; - + +export type accessLogsExportListResponseComposite = accessLogsExportListResponse200 | accessLogsExportListResponse403 + export type accessLogsExportListResponse = accessLogsExportListResponseComposite & { - headers: Headers; + headers: Headers } export const getAccessLogsExportListUrl = () => { - - - - return `/api/v2/access-logs/export/` } -export const accessLogsExportList = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAccessLogsExportListUrl(), - { +export const accessLogsExportList = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAccessLogsExportListUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getAccessLogsExportListQueryKey = () => { - return ['api','v2','access-logs','export'] as const; - } - - -export const getAccessLogsExportListQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAccessLogsExportListQueryKey(); - - - - const queryFn: QueryFunction>> = ({ signal }) => accessLogsExportList({ signal, ...requestOptions }); - - - - + return ['api', 'v2', 'access-logs', 'export'] as const +} - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +export const getAccessLogsExportListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getAccessLogsExportListQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + accessLogsExportList({ signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AccessLogsExportListQueryResult = NonNullable>> export type AccessLogsExportListQueryError = ErrorDetail - - -export function useAccessLogsExportList>, TError = ErrorDetail>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useAccessLogsExportList< + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getAccessLogsExportListQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Create an export task for all users @@ -299,73 +253,57 @@ export type accessLogsExportCreateResponse401 = { data: ErrorDetail status: 401 } - -export type accessLogsExportCreateResponseComposite = accessLogsExportCreateResponse202 | accessLogsExportCreateResponse401; - + +export type accessLogsExportCreateResponseComposite = + | accessLogsExportCreateResponse202 + | accessLogsExportCreateResponse401 + export type accessLogsExportCreateResponse = accessLogsExportCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getAccessLogsExportCreateUrl = () => { - - - - return `/api/v2/access-logs/export/` } -export const accessLogsExportCreate = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getAccessLogsExportCreateUrl(), - { +export const accessLogsExportCreate = async (options?: RequestInit): Promise => { + return fetchWithAuth(getAccessLogsExportCreateUrl(), { ...options, - method: 'POST' - - - } -);} - - - - -export const getAccessLogsExportCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['accessLogsExportCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return accessLogsExportCreate(requestOptions) - } - - + method: 'POST', + }) +} +export const getAccessLogsExportCreateMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['accessLogsExportCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return accessLogsExportCreate(requestOptions) + } - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AccessLogsExportCreateMutationResult = NonNullable>> - - export type AccessLogsExportCreateMutationError = ErrorDetail +export type AccessLogsExportCreateMutationResult = NonNullable>> - export const useAccessLogsExportCreate = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { +export type AccessLogsExportCreateMutationError = ErrorDetail - const mutationOptions = getAccessLogsExportCreateMutationOptions(options); +export const useAccessLogsExportCreate = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}) => { + const mutationOptions = getAccessLogsExportCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## List actions performed by users. ⚠️ _Only available to superusers_ @@ -431,85 +369,81 @@ export type auditLogsListResponse403 = { data: ErrorDetail status: 403 } - -export type auditLogsListResponseComposite = auditLogsListResponse200 | auditLogsListResponse403; - + +export type auditLogsListResponseComposite = auditLogsListResponse200 | auditLogsListResponse403 + export type auditLogsListResponse = auditLogsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAuditLogsListUrl = (params?: AuditLogsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAuditLogsListUrl = (params?: AuditLogsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/audit-logs/?${stringifiedParams}` : `/api/v2/audit-logs/` } -export const auditLogsList = async (params?: AuditLogsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAuditLogsListUrl(params), - { +export const auditLogsList = async ( + params?: AuditLogsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAuditLogsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAuditLogsListQueryKey = (params?: AuditLogsListParams,) => { - return ['api','v2','audit-logs', ...(params ? [params]: [])] as const; - } +export const getAuditLogsListQueryKey = (params?: AuditLogsListParams) => { + return ['api', 'v2', 'audit-logs', ...(params ? [params] : [])] as const +} - -export const getAuditLogsListQueryOptions = >, TError = ErrorDetail>(params?: AuditLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAuditLogsListQueryOptions = >, TError = ErrorDetail>( + params?: AuditLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAuditLogsListQueryKey(params); - - + const queryKey = queryOptions?.queryKey ?? getAuditLogsListQueryKey(params) - const queryFn: QueryFunction>> = ({ signal }) => auditLogsList(params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + auditLogsList(params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AuditLogsListQueryResult = NonNullable>> export type AuditLogsListQueryError = ErrorDetail - - export function useAuditLogsList>, TError = ErrorDetail>( - params?: AuditLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAuditLogsListQueryOptions(params,options) + params?: AuditLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAuditLogsListQueryOptions(params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## List all project history logs for all projects. @@ -707,85 +641,91 @@ export type projectHistoryLogsListResponse403 = { data: ErrorDetail status: 403 } - -export type projectHistoryLogsListResponseComposite = projectHistoryLogsListResponse200 | projectHistoryLogsListResponse403; - + +export type projectHistoryLogsListResponseComposite = + | projectHistoryLogsListResponse200 + | projectHistoryLogsListResponse403 + export type projectHistoryLogsListResponse = projectHistoryLogsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getProjectHistoryLogsListUrl = (params?: ProjectHistoryLogsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getProjectHistoryLogsListUrl = (params?: ProjectHistoryLogsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/project-history-logs/?${stringifiedParams}` : `/api/v2/project-history-logs/` + return stringifiedParams.length > 0 + ? `/api/v2/project-history-logs/?${stringifiedParams}` + : `/api/v2/project-history-logs/` } -export const projectHistoryLogsList = async (params?: ProjectHistoryLogsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectHistoryLogsListUrl(params), - { +export const projectHistoryLogsList = async ( + params?: ProjectHistoryLogsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectHistoryLogsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getProjectHistoryLogsListQueryKey = (params?: ProjectHistoryLogsListParams,) => { - return ['api','v2','project-history-logs', ...(params ? [params]: [])] as const; - } +export const getProjectHistoryLogsListQueryKey = (params?: ProjectHistoryLogsListParams) => { + return ['api', 'v2', 'project-history-logs', ...(params ? [params] : [])] as const +} - -export const getProjectHistoryLogsListQueryOptions = >, TError = ErrorDetail>(params?: ProjectHistoryLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getProjectHistoryLogsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: ProjectHistoryLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsListQueryKey(params); - - + const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsListQueryKey(params) - const queryFn: QueryFunction>> = ({ signal }) => projectHistoryLogsList(params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + projectHistoryLogsList(params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ProjectHistoryLogsListQueryResult = NonNullable>> export type ProjectHistoryLogsListQueryError = ErrorDetail +export function useProjectHistoryLogsList< + TData = Awaited>, + TError = ErrorDetail, +>( + params?: ProjectHistoryLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectHistoryLogsListQueryOptions(params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useProjectHistoryLogsList>, TError = ErrorDetail>( - params?: ProjectHistoryLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getProjectHistoryLogsListQueryOptions(params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## List of Project History Exports @@ -801,78 +741,74 @@ export type projectHistoryLogsExportRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type projectHistoryLogsExportRetrieveResponseComposite = projectHistoryLogsExportRetrieveResponse202 | projectHistoryLogsExportRetrieveResponse403; - + +export type projectHistoryLogsExportRetrieveResponseComposite = + | projectHistoryLogsExportRetrieveResponse202 + | projectHistoryLogsExportRetrieveResponse403 + export type projectHistoryLogsExportRetrieveResponse = projectHistoryLogsExportRetrieveResponseComposite & { - headers: Headers; + headers: Headers } export const getProjectHistoryLogsExportRetrieveUrl = () => { - - - - return `/api/v2/project-history-logs/export/` } -export const projectHistoryLogsExportRetrieve = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectHistoryLogsExportRetrieveUrl(), - { +export const projectHistoryLogsExportRetrieve = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectHistoryLogsExportRetrieveUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getProjectHistoryLogsExportRetrieveQueryKey = () => { - return ['api','v2','project-history-logs','export'] as const; - } - - -export const getProjectHistoryLogsExportRetrieveQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsExportRetrieveQueryKey(); - - - - const queryFn: QueryFunction>> = ({ signal }) => projectHistoryLogsExportRetrieve({ signal, ...requestOptions }); - - - - + return ['api', 'v2', 'project-history-logs', 'export'] as const +} - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +export const getProjectHistoryLogsExportRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getProjectHistoryLogsExportRetrieveQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + projectHistoryLogsExportRetrieve({ signal, ...requestOptions }) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type ProjectHistoryLogsExportRetrieveQueryResult = NonNullable>> +export type ProjectHistoryLogsExportRetrieveQueryResult = NonNullable< + Awaited> +> export type ProjectHistoryLogsExportRetrieveQueryError = ErrorDetail - - -export function useProjectHistoryLogsExportRetrieve>, TError = ErrorDetail>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useProjectHistoryLogsExportRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getProjectHistoryLogsExportRetrieveQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Create an export of projects history logs @@ -890,73 +826,61 @@ export type projectHistoryLogsExportCreateResponse403 = { data: ErrorDetail status: 403 } - -export type projectHistoryLogsExportCreateResponseComposite = projectHistoryLogsExportCreateResponse202 | projectHistoryLogsExportCreateResponse403; - + +export type projectHistoryLogsExportCreateResponseComposite = + | projectHistoryLogsExportCreateResponse202 + | projectHistoryLogsExportCreateResponse403 + export type projectHistoryLogsExportCreateResponse = projectHistoryLogsExportCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getProjectHistoryLogsExportCreateUrl = () => { - - - - return `/api/v2/project-history-logs/export/` } -export const projectHistoryLogsExportCreate = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectHistoryLogsExportCreateUrl(), - { +export const projectHistoryLogsExportCreate = async ( + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectHistoryLogsExportCreateUrl(), { ...options, - method: 'POST' - - - } -);} - - - - -export const getProjectHistoryLogsExportCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['projectHistoryLogsExportCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, void> = () => { - - - return projectHistoryLogsExportCreate(requestOptions) - } - - + method: 'POST', + }) +} +export const getProjectHistoryLogsExportCreateMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['projectHistoryLogsExportCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return projectHistoryLogsExportCreate(requestOptions) + } - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type ProjectHistoryLogsExportCreateMutationResult = NonNullable>> - - export type ProjectHistoryLogsExportCreateMutationError = ErrorDetail +export type ProjectHistoryLogsExportCreateMutationResult = NonNullable< + Awaited> +> - export const useProjectHistoryLogsExportCreate = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { +export type ProjectHistoryLogsExportCreateMutationError = ErrorDetail - const mutationOptions = getProjectHistoryLogsExportCreateMutationOptions(options); +export const useProjectHistoryLogsExportCreate = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}) => { + const mutationOptions = getProjectHistoryLogsExportCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * # List user reports ⚠️ _Only available to superusers_ @@ -1070,82 +994,86 @@ export type userReportsListResponse403 = { data: ErrorDetail status: 403 } - -export type userReportsListResponseComposite = userReportsListResponse200 | userReportsListResponse400 | userReportsListResponse403; - + +export type userReportsListResponseComposite = + | userReportsListResponse200 + | userReportsListResponse400 + | userReportsListResponse403 + export type userReportsListResponse = userReportsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getUserReportsListUrl = (params?: UserReportsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getUserReportsListUrl = (params?: UserReportsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/user-reports/?${stringifiedParams}` : `/api/v2/user-reports/` } -export const userReportsList = async (params?: UserReportsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getUserReportsListUrl(params), - { +export const userReportsList = async ( + params?: UserReportsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getUserReportsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getUserReportsListQueryKey = (params?: UserReportsListParams,) => { - return ['api','v2','user-reports', ...(params ? [params]: [])] as const; - } +export const getUserReportsListQueryKey = (params?: UserReportsListParams) => { + return ['api', 'v2', 'user-reports', ...(params ? [params] : [])] as const +} - -export const getUserReportsListQueryOptions = >, TError = ErrorObject | ErrorDetail>(params?: UserReportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getUserReportsListQueryOptions = < + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + params?: UserReportsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getUserReportsListQueryKey(params); - - + const queryKey = queryOptions?.queryKey ?? getUserReportsListQueryKey(params) - const queryFn: QueryFunction>> = ({ signal }) => userReportsList(params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + userReportsList(params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type UserReportsListQueryResult = NonNullable>> export type UserReportsListQueryError = ErrorObject | ErrorDetail +export function useUserReportsList< + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + params?: UserReportsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getUserReportsListQueryOptions(params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useUserReportsList>, TError = ErrorObject | ErrorDetail>( - params?: UserReportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getUserReportsListQueryOptions(params,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - - diff --git a/jsapp/js/api/react-query/server-logs-superusers/msw.ts b/jsapp/js/api/react-query/server-logs-superusers/msw.ts index 66ca28f3ae..4b094c7f3a 100644 --- a/jsapp/js/api/react-query/server-logs-superusers/msw.ts +++ b/jsapp/js/api/react-query/server-logs-superusers/msw.ts @@ -9,142 +9,1045 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; +import { http, HttpResponse } from 'msw' -import type { - ExportCreateResponse -} from '../../models/exportCreateResponse'; +import type { ExportCreateResponse } from '../../models/exportCreateResponse' -import type { - ExportHistoryResponse -} from '../../models/exportHistoryResponse'; +import type { ExportHistoryResponse } from '../../models/exportHistoryResponse' -import type { - ExportListResponse -} from '../../models/exportListResponse'; +import type { ExportListResponse } from '../../models/exportListResponse' -import type { - PaginatedAuditLogResponseList -} from '../../models/paginatedAuditLogResponseList'; +import type { PaginatedAuditLogResponseList } from '../../models/paginatedAuditLogResponseList' -import type { - PaginatedProjectHistoryLogResponseList -} from '../../models/paginatedProjectHistoryLogResponseList'; +import type { PaginatedProjectHistoryLogResponseList } from '../../models/paginatedProjectHistoryLogResponseList' -import type { - PaginatedSuperUserAccessLogResponseList -} from '../../models/paginatedSuperUserAccessLogResponseList'; +import type { PaginatedSuperUserAccessLogResponseList } from '../../models/paginatedSuperUserAccessLogResponseList' -import type { - PaginatedUserReportsListResponseList -} from '../../models/paginatedUserReportsListResponseList'; +import type { PaginatedUserReportsListResponseList } from '../../models/paginatedUserReportsListResponseList' -import type { - ServiceUsageBalanceData -} from '../../models/serviceUsageBalanceData'; +import type { ServiceUsageBalanceData } from '../../models/serviceUsageBalanceData' +export const getApiV2AccessLogsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedSuperUserAccessLogResponseList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + initial_user_username: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + authorized_app_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) -export const getApiV2AccessLogsListResponseMock = (overrideResponse: Partial< PaginatedSuperUserAccessLogResponseList > = {}): PaginatedSuperUserAccessLogResponseList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, username: faker.string.alpha({length: {min: 10, max: 20}}), metadata: {source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), auth_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), initial_user_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), initial_user_username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), authorized_app_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, user_uid: faker.string.alpha({length: {min: 10, max: 20}}), count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), action: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) +export const getApiV2AccessLogsExportListResponseMock = (): ExportListResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 24 } }), + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })) -export const getApiV2AccessLogsExportListResponseMock = (): ExportListResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 24}}), status: faker.string.alpha({length: {min: 10, max: 32}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`}))) +export const getApiV2AccessLogsExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportCreateResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 32 } }), ...overrideResponse }) -export const getApiV2AccessLogsExportCreateResponseMock = (overrideResponse: Partial< ExportCreateResponse > = {}): ExportCreateResponse => ({status: faker.string.alpha({length: {min: 10, max: 32}}), ...overrideResponse}) +export const getApiV2AuditLogsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAuditLogResponseList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + app_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + model_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.internet.url(), + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + old: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + removed: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + description: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + 'data-table': faker.helpers.arrayElement([ + { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + }, + undefined, + ]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + auth_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'asset-files': faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + permissions: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + latest_deployed_version_uid: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + submission: faker.helpers.arrayElement([ + { + root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + hook: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + bulk_action: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + params: faker.helpers.arrayElement([{}, undefined]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + total_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + processed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + completed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + failed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + cancelled_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + name: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + shared_fields: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + log_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) -export const getApiV2AuditLogsListResponseMock = (overrideResponse: Partial< PaginatedAuditLogResponseList > = {}): PaginatedAuditLogResponseList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({app_label: faker.string.alpha({length: {min: 10, max: 20}}), model_name: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.internet.url(), user_uid: faker.string.alpha({length: {min: 10, max: 20}}), username: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.string.alpha({length: {min: 10, max: 20}}), metadata: {source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), old: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), country: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), removed: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), description: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country_codes: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), 'data-table': faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined])}, undefined])}, undefined]), asset_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), auth_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), log_subtype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_owner: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'asset-files': faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), md5_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), download_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), permissions: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), latest_deployed_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submission: faker.helpers.arrayElement([{root_uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submitted_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), hook: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), bulk_action: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), action_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), question_xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), params: faker.helpers.arrayElement([{}, undefined]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cancelled_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), total_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), processed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), completed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), failed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), cancelled_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), name: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), shared_fields: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, log_type: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) +export const getApiV2ProjectHistoryLogsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectHistoryLogResponseList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user: faker.internet.url(), + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.string.alpha({ length: { min: 10, max: 20 } }), + metadata: { + source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ip_address: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cloned_from: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + log_subtype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'paired-data': faker.helpers.arrayElement([ + { + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + old: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + removed: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + description: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + 'data-table': faker.helpers.arrayElement([ + { new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined]) }, + undefined, + ]), + }, + undefined, + ]), + 'asset-files': faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + md5_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + download_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + permissions: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + project_owner: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + submission: faker.helpers.arrayElement([ + { + root_uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + submitted_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + hook: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + bulk_action: faker.helpers.arrayElement([ + { + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + action_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + question_xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + params: faker.helpers.arrayElement([{}, undefined]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancelled_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + total_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + processed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + completed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + failed_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + cancelled_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + name: faker.helpers.arrayElement([ + { + new: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + old: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + shared_fields: faker.helpers.arrayElement([ + { + added: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + removed: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) -export const getApiV2ProjectHistoryLogsListResponseMock = (overrideResponse: Partial< PaginatedProjectHistoryLogResponseList > = {}): PaginatedProjectHistoryLogResponseList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user: faker.internet.url(), user_uid: faker.string.alpha({length: {min: 10, max: 20}}), username: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.string.alpha({length: {min: 10, max: 20}}), metadata: {source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ip_address: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cloned_from: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), log_subtype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'paired-data': faker.helpers.arrayElement([{fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), source_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), old: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), country: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), removed: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), description: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country_codes: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), 'data-table': faker.helpers.arrayElement([{new: faker.helpers.arrayElement([{}, undefined]), old: faker.helpers.arrayElement([{}, undefined])}, undefined])}, undefined]), 'asset-files': faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), md5_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), download_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), permissions: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), project_owner: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_version_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submission: faker.helpers.arrayElement([{root_uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), submitted_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), hook: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), bulk_action: faker.helpers.arrayElement([{uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), action_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), question_xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), params: faker.helpers.arrayElement([{}, undefined]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cancelled_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), total_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), processed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), completed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), failed_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), cancelled_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), name: faker.helpers.arrayElement([{new: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), old: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), shared_fields: faker.helpers.arrayElement([{added: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), removed: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) +export const getApiV2ProjectHistoryLogsExportRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExportHistoryResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) -export const getApiV2ProjectHistoryLogsExportRetrieveResponseMock = (overrideResponse: Partial< ExportHistoryResponse > = {}): ExportHistoryResponse => ({status: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) +export const getApiV2ProjectHistoryLogsExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportHistoryResponse => ({ status: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) -export const getApiV2ProjectHistoryLogsExportCreateResponseMock = (overrideResponse: Partial< ExportHistoryResponse > = {}): ExportHistoryResponse => ({status: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) +export const getApiV2UserReportsListResponseServiceUsageBalanceDataMock = ( + overrideResponse: Partial = {}, +): ServiceUsageBalanceData => ({ + ...{ + effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + exceeded: faker.datatype.boolean(), + }, + ...overrideResponse, +}) -export const getApiV2UserReportsListResponseServiceUsageBalanceDataMock = (overrideResponse: Partial = {}): ServiceUsageBalanceData => ({...{effective_limit: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_value: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_percent: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), exceeded: faker.datatype.boolean()}, ...overrideResponse}); +export const getApiV2UserReportsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedUserReportsListResponseList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + user_uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.internet.email(), + is_superuser: faker.datatype.boolean(), + is_staff: faker.datatype.boolean(), + is_active: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + validated_email: faker.datatype.boolean(), + mfa_is_active: faker.datatype.boolean(), + sso_is_active: faker.datatype.boolean(), + accepted_tos: faker.datatype.boolean(), + social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + email: faker.helpers.arrayElement([faker.internet.email(), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + organizations: { + organization_name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + role: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + extra_details: { + data: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + organization_type: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + organization_website: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + newsletter_subscription: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + date_removed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + validated_password: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + password_date_changed: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + date_removal_requested: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + }, + subscriptions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + items: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + price: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + nickname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + currency: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + recurring: faker.helpers.arrayElement([ + { + meter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + interval: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + usage_type: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + interval_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + aggregate_usage: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + trial_period_days: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + unit_amount: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + human_readable_price: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + metadata: faker.helpers.arrayElement([{}, undefined]), + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + product: faker.helpers.arrayElement([ + { + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([ + { + product_type: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + storage_bytes_limit: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + transform_quantity: faker.helpers.arrayElement([ + { + divide_by: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + round: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + })), + undefined, + ]), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + })), + undefined, + ]), + schedule: faker.helpers.arrayElement([ + { + phases: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + items: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + plan: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + price: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + tax_rates: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ), + undefined, + ]), + billing_thresholds: faker.helpers.arrayElement([{}, undefined]), + })), + undefined, + ]), + coupon: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + currency: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + end_date: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + metadata: faker.helpers.arrayElement([{}, undefined]), + trial_end: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + start_date: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + description: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + on_behalf_of: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + automatic_tax: faker.helpers.arrayElement([{}, undefined]), + transfer_data: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + invoice_settings: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + add_invoice_items: faker.helpers.arrayElement([{}, undefined]), + collection_method: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_tax_rates: faker.helpers.arrayElement([{}, undefined]), + billing_thresholds: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + proration_behavior: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + billing_cycle_anchor: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + default_payment_method: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + application_fee_percent: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + })), + undefined, + ]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + djstripe_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + djstripe_updated: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([ + { + request_url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_id: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + kpi_owner_user_id: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + kpi_owner_username: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + application_fee_percent: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + billing_cycle_anchor: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + billing_thresholds: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancel_at: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + canceled_at: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collection_method: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + current_period_end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + current_period_start: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + days_until_due: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + discount: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + ended_at: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + next_pending_invoice_item_invoice: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + pause_collection: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + pending_invoice_item_interval: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + pending_update: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + proration_behavior: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + proration_date: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + quantity: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + start_date: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + trial_end: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + trial_start: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + djstripe_owner_account: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + customer: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + default_payment_method: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_source: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + latest_invoice: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + pending_setup_intent: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + plan: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + default_tax_rates: faker.helpers.arrayElement([{}, undefined]), + })), + service_usage: { + total_nlp_usage: { + asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_submission_count: { + retention_days: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + cumulative: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + current_period: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + balances: { + submission: faker.helpers.arrayElement([ + { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, + null, + ]), + storage_bytes: faker.helpers.arrayElement([ + { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, + null, + ]), + asr_seconds: faker.helpers.arrayElement([ + { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, + null, + ]), + mt_characters: faker.helpers.arrayElement([ + { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, + null, + ]), + llm_requests: faker.helpers.arrayElement([ + { ...getApiV2UserReportsListResponseServiceUsageBalanceDataMock() }, + null, + ]), + }, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + }, + account_restricted: faker.datatype.boolean(), + asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + active_project_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) -export const getApiV2UserReportsListResponseMock = (overrideResponse: Partial< PaginatedUserReportsListResponseList > = {}): PaginatedUserReportsListResponseList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({user_uid: faker.string.alpha({length: {min: 10, max: 20}}), username: faker.string.alpha({length: {min: 10, max: 20}}), first_name: faker.string.alpha({length: {min: 10, max: 20}}), last_name: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.internet.email(), is_superuser: faker.datatype.boolean(), is_staff: faker.datatype.boolean(), is_active: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, validated_email: faker.datatype.boolean(), mfa_is_active: faker.datatype.boolean(), sso_is_active: faker.datatype.boolean(), accepted_tos: faker.datatype.boolean(), social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({provider: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), email: faker.helpers.arrayElement([faker.internet.email(), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), organizations: {organization_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), role: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, extra_details: {data: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), sector: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_ui_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_website: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), newsletter_subscription: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), date_removed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), validated_password: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), password_date_changed: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_removal_requested: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined])}, subscriptions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({items: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), price: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), nickname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), currency: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), recurring: faker.helpers.arrayElement([{meter: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), interval: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), usage_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), interval_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), aggregate_usage: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), trial_period_days: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), unit_amount: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), human_readable_price: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined]), active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), product: faker.helpers.arrayElement([{id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{product_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), storage_bytes_limit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), transform_quantity: faker.helpers.arrayElement([{divide_by: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), round: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])})), undefined]), quantity: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])})), undefined]), schedule: faker.helpers.arrayElement([{phases: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({items: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({plan: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), price: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined]), quantity: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), tax_rates: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.number.int({min: undefined, max: undefined, multipleOf: undefined}))), undefined]), billing_thresholds: faker.helpers.arrayElement([{}, undefined])})), undefined]), coupon: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), currency: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), end_date: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined]), trial_end: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), start_date: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), on_behalf_of: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), automatic_tax: faker.helpers.arrayElement([{}, undefined]), transfer_data: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), invoice_settings: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), add_invoice_items: faker.helpers.arrayElement([{}, undefined]), collection_method: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_tax_rates: faker.helpers.arrayElement([{}, undefined]), billing_thresholds: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), proration_behavior: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), billing_cycle_anchor: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), default_payment_method: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), application_fee_percent: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])})), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), djstripe_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), djstripe_updated: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), livemode: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{request_url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kpi_owner_user_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kpi_owner_username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), application_fee_percent: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined]), billing_cycle_anchor: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), billing_thresholds: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cancel_at: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), cancel_at_period_end: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), canceled_at: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collection_method: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), current_period_end: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), current_period_start: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), days_until_due: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), discount: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), ended_at: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), next_pending_invoice_item_invoice: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), pause_collection: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), pending_invoice_item_interval: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), pending_update: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), proration_behavior: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), proration_date: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), quantity: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), start_date: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), trial_end: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), trial_start: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), djstripe_owner_account: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), customer: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_payment_method: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_source: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), latest_invoice: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), pending_setup_intent: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), plan: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), default_tax_rates: faker.helpers.arrayElement([{}, undefined])})), service_usage: {total_nlp_usage: {asr_seconds_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), asr_seconds_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, total_storage_bytes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_submission_count: {retention_days: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), cumulative: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), current_period: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, balances: {submission: faker.helpers.arrayElement([{...getApiV2UserReportsListResponseServiceUsageBalanceDataMock()},null,]), storage_bytes: faker.helpers.arrayElement([{...getApiV2UserReportsListResponseServiceUsageBalanceDataMock()},null,]), asr_seconds: faker.helpers.arrayElement([{...getApiV2UserReportsListResponseServiceUsageBalanceDataMock()},null,]), mt_characters: faker.helpers.arrayElement([{...getApiV2UserReportsListResponseServiceUsageBalanceDataMock()},null,]), llm_requests: faker.helpers.arrayElement([{...getApiV2UserReportsListResponseServiceUsageBalanceDataMock()},null,])}, current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`}, account_restricted: faker.datatype.boolean(), asset_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), active_project_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) - - -export const getApiV2AccessLogsListMockHandler = (overrideResponse?: PaginatedSuperUserAccessLogResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedSuperUserAccessLogResponseList)) => { - return http.get('*/api/v2/access-logs/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AccessLogsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AccessLogsListMockHandler = ( + overrideResponse?: + | PaginatedSuperUserAccessLogResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedSuperUserAccessLogResponseList), +) => { + return http.get('*/api/v2/access-logs/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AccessLogsExportListMockHandler = (overrideResponse?: ExportListResponse[] | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[])) => { - return http.get('*/api/v2/access-logs/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AccessLogsExportListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AccessLogsExportListMockHandler = ( + overrideResponse?: + | ExportListResponse[] + | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), +) => { + return http.get('*/api/v2/access-logs/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsExportListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AccessLogsExportCreateMockHandler = (overrideResponse?: ExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse)) => { - return http.post('*/api/v2/access-logs/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AccessLogsExportCreateResponseMock()), - { status: 202, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AccessLogsExportCreateMockHandler = ( + overrideResponse?: + | ExportCreateResponse + | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), +) => { + return http.post('*/api/v2/access-logs/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AccessLogsExportCreateResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AuditLogsListMockHandler = (overrideResponse?: PaginatedAuditLogResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAuditLogResponseList)) => { - return http.get('*/api/v2/audit-logs/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AuditLogsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AuditLogsListMockHandler = ( + overrideResponse?: + | PaginatedAuditLogResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAuditLogResponseList), +) => { + return http.get('*/api/v2/audit-logs/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AuditLogsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectHistoryLogsListMockHandler = (overrideResponse?: PaginatedProjectHistoryLogResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedProjectHistoryLogResponseList)) => { - return http.get('*/api/v2/project-history-logs/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectHistoryLogsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectHistoryLogsListMockHandler = ( + overrideResponse?: + | PaginatedProjectHistoryLogResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectHistoryLogResponseList), +) => { + return http.get('*/api/v2/project-history-logs/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectHistoryLogsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectHistoryLogsExportRetrieveMockHandler = (overrideResponse?: ExportHistoryResponse | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse)) => { - return http.get('*/api/v2/project-history-logs/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectHistoryLogsExportRetrieveResponseMock()), - { status: 202, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectHistoryLogsExportRetrieveMockHandler = ( + overrideResponse?: + | ExportHistoryResponse + | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse), +) => { + return http.get('*/api/v2/project-history-logs/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectHistoryLogsExportRetrieveResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectHistoryLogsExportCreateMockHandler = (overrideResponse?: ExportHistoryResponse | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse)) => { - return http.post('*/api/v2/project-history-logs/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectHistoryLogsExportCreateResponseMock()), - { status: 202, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectHistoryLogsExportCreateMockHandler = ( + overrideResponse?: + | ExportHistoryResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ExportHistoryResponse), +) => { + return http.post('*/api/v2/project-history-logs/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectHistoryLogsExportCreateResponseMock(), + ), + { status: 202, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2UserReportsListMockHandler = (overrideResponse?: PaginatedUserReportsListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedUserReportsListResponseList)) => { - return http.get('*/api/v2/user-reports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2UserReportsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2UserReportsListMockHandler = ( + overrideResponse?: + | PaginatedUserReportsListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedUserReportsListResponseList), +) => { + return http.get('*/api/v2/user-reports/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2UserReportsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } export const getServerLogsSuperusersMock = () => [ @@ -155,5 +1058,5 @@ export const getServerLogsSuperusersMock = () => [ getApiV2ProjectHistoryLogsListMockHandler(), getApiV2ProjectHistoryLogsExportRetrieveMockHandler(), getApiV2ProjectHistoryLogsExportCreateMockHandler(), - getApiV2UserReportsListMockHandler() + getApiV2UserReportsListMockHandler(), ] diff --git a/jsapp/js/api/react-query/survey-data-rest-services/index.ts b/jsapp/js/api/react-query/survey-data-rest-services/index.ts index 43d7068cd7..61387a7e2e 100644 --- a/jsapp/js/api/react-query/survey-data-rest-services/index.ts +++ b/jsapp/js/api/react-query/survey-data-rest-services/index.ts @@ -9,100 +9,60 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - AssetsHooksListParams -} from '../../models/assetsHooksListParams'; +import type { AssetsHooksListParams } from '../../models/assetsHooksListParams' -import type { - AssetsHooksLogsListParams -} from '../../models/assetsHooksLogsListParams'; +import type { AssetsHooksLogsListParams } from '../../models/assetsHooksLogsListParams' -import type { - ErrorDetail -} from '../../models/errorDetail'; +import type { ErrorDetail } from '../../models/errorDetail' -import type { - ErrorObject -} from '../../models/errorObject'; +import type { ErrorObject } from '../../models/errorObject' -import type { - Hook -} from '../../models/hook'; +import type { Hook } from '../../models/hook' -import type { - HookLog -} from '../../models/hookLog'; +import type { HookLog } from '../../models/hookLog' -import type { - HookRetryResponse -} from '../../models/hookRetryResponse'; +import type { HookRetryResponse } from '../../models/hookRetryResponse' -import type { - LogsRetryResponse -} from '../../models/logsRetryResponse'; +import type { LogsRetryResponse } from '../../models/logsRetryResponse' -import type { - PaginatedHookList -} from '../../models/paginatedHookList'; +import type { PaginatedHookList } from '../../models/paginatedHookList' -import type { - PaginatedHookLogList -} from '../../models/paginatedHookLogList'; +import type { PaginatedHookLogList } from '../../models/paginatedHookLogList' -import type { - PatchedHook -} from '../../models/patchedHook'; +import type { PatchedHook } from '../../models/patchedHook' -import type { - PatchedHookLog -} from '../../models/patchedHookLog'; +import type { PatchedHookLog } from '../../models/patchedHookLog' -import { fetchWithAuth } from '../../orval.mutator'; +import { fetchWithAuth } from '../../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = (() => T extends X ? 1 : 2) extends < -T, ->() => T extends Y ? 1 : 2 -? A -: B; +type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B type WritableKeys = { -[P in keyof T]-?: IfEquals< - { [Q in P]: T[P] }, - { -readonly [Q in P]: T[P] }, - P ->; -}[keyof T]; - -type UnionToIntersection = - (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never; -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; + [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P> +}[keyof T] -type Writable = Pick>; -type NonReadonly = [T] extends [UnionToIntersection] ? { - [P in keyof Writable]: T[P] extends object - ? NonReadonly> - : T[P]; -} : DistributeReadOnlyOverUnions; - - - -type SecondParameter unknown> = Parameters[1]; +type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never +type Writable = Pick> +type NonReadonly = [T] extends [UnionToIntersection] + ? { + [P in keyof Writable]: T[P] extends object ? NonReadonly> : T[P] + } + : DistributeReadOnlyOverUnions +type SecondParameter unknown> = Parameters[1] /** * ## List external services @@ -119,90 +79,89 @@ export type assetsHooksListResponse404 = { data: ErrorDetail status: 404 } - -export type assetsHooksListResponseComposite = assetsHooksListResponse200 | assetsHooksListResponse404; - + +export type assetsHooksListResponseComposite = assetsHooksListResponse200 | assetsHooksListResponse404 + export type assetsHooksListResponse = assetsHooksListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsHooksListUrl = (uidAsset: string, - params?: AssetsHooksListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsHooksListUrl = (uidAsset: string, params?: AssetsHooksListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/hooks/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/hooks/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/hooks/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/hooks/` } -export const assetsHooksList = async (uidAsset: string, - params?: AssetsHooksListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHooksListUrl(uidAsset,params), - { +export const assetsHooksList = async ( + uidAsset: string, + params?: AssetsHooksListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHooksListUrl(uidAsset, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsHooksListQueryKey = (uidAsset: string, - params?: AssetsHooksListParams,) => { - return ['api','v2','assets',uidAsset,'hooks', ...(params ? [params]: [])] as const; - } +export const getAssetsHooksListQueryKey = (uidAsset: string, params?: AssetsHooksListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'hooks', ...(params ? [params] : [])] as const +} - -export const getAssetsHooksListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsHooksListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsHooksListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsHooksListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getAssetsHooksListQueryKey(uidAsset, params) - const queryKey = queryOptions?.queryKey ?? getAssetsHooksListQueryKey(uidAsset,params); + const queryFn: QueryFunction>> = ({ signal }) => + assetsHooksList(uidAsset, params, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => assetsHooksList(uidAsset,params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsHooksListQueryResult = NonNullable>> export type AssetsHooksListQueryError = ErrorDetail - - export function useAssetsHooksList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsHooksListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsHooksListQueryOptions(uidAsset,params,options) + uidAsset: string, + params?: AssetsHooksListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsHooksListQueryOptions(uidAsset, params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Add an external service to asset. @@ -251,75 +210,84 @@ export type assetsHooksCreateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsHooksCreateResponseComposite = assetsHooksCreateResponse201 | assetsHooksCreateResponse400 | assetsHooksCreateResponse404; - -export type assetsHooksCreateResponse = assetsHooksCreateResponseComposite & { - headers: Headers; -} - -export const getAssetsHooksCreateUrl = (uidAsset: string,) => { +export type assetsHooksCreateResponseComposite = + | assetsHooksCreateResponse201 + | assetsHooksCreateResponse400 + | assetsHooksCreateResponse404 - +export type assetsHooksCreateResponse = assetsHooksCreateResponseComposite & { + headers: Headers +} +export const getAssetsHooksCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/hooks/` } -export const assetsHooksCreate = async (uidAsset: string, - hook: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHooksCreateUrl(uidAsset), - { +export const assetsHooksCreate = async ( + uidAsset: string, + hook: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHooksCreateUrl(uidAsset), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - hook,) + body: JSON.stringify(hook), + }) +} + +export const getAssetsHooksCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: NonReadonly }, + TContext +> => { + const mutationKey = ['assetsHooksCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: NonReadonly } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsHooksCreate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsHooksCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext> => { - -const mutationKey = ['assetsHooksCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: NonReadonly}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsHooksCreate(uidAsset,data,requestOptions) - } - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsHooksCreateMutationResult = NonNullable>> - export type AssetsHooksCreateMutationBody = NonReadonly - export type AssetsHooksCreateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsHooksCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { +export type AssetsHooksCreateMutationResult = NonNullable>> +export type AssetsHooksCreateMutationBody = NonReadonly +export type AssetsHooksCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsHooksCreateMutationOptions(options); +export const useAssetsHooksCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsHooksCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retrieve an external service */ @@ -332,83 +300,77 @@ export type assetsHooksRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsHooksRetrieveResponseComposite = assetsHooksRetrieveResponse200 | assetsHooksRetrieveResponse404; - -export type assetsHooksRetrieveResponse = assetsHooksRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsHooksRetrieveUrl = (uidAsset: string, - uidHook: string,) => { +export type assetsHooksRetrieveResponseComposite = assetsHooksRetrieveResponse200 | assetsHooksRetrieveResponse404 +export type assetsHooksRetrieveResponse = assetsHooksRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsHooksRetrieveUrl = (uidAsset: string, uidHook: string) => { return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/` } -export const assetsHooksRetrieve = async (uidAsset: string, - uidHook: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHooksRetrieveUrl(uidAsset,uidHook), - { +export const assetsHooksRetrieve = async ( + uidAsset: string, + uidHook: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHooksRetrieveUrl(uidAsset, uidHook), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsHooksRetrieveQueryKey = (uidAsset: string, - uidHook: string,) => { - return ['api','v2','assets',uidAsset,'hooks',uidHook] as const; - } +export const getAssetsHooksRetrieveQueryKey = (uidAsset: string, uidHook: string) => { + return ['api', 'v2', 'assets', uidAsset, 'hooks', uidHook] as const +} - -export const getAssetsHooksRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidHook: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsHooksRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidHook: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsHooksRetrieveQueryKey(uidAsset,uidHook); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsHooksRetrieve(uidAsset,uidHook, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetsHooksRetrieveQueryKey(uidAsset, uidHook) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsHooksRetrieve(uidAsset, uidHook, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidHook), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidHook), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsHooksRetrieveQueryResult = NonNullable>> export type AssetsHooksRetrieveQueryError = ErrorDetail - - export function useAssetsHooksRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidHook: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + uidAsset: string, + uidHook: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsHooksRetrieveQueryOptions(uidAsset, uidHook, options) - const queryOptions = getAssetsHooksRetrieveQueryOptions(uidAsset,uidHook,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Update an external service. @@ -427,77 +389,88 @@ export type assetsHooksPartialUpdateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsHooksPartialUpdateResponseComposite = assetsHooksPartialUpdateResponse200 | assetsHooksPartialUpdateResponse400 | assetsHooksPartialUpdateResponse404; - -export type assetsHooksPartialUpdateResponse = assetsHooksPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getAssetsHooksPartialUpdateUrl = (uidAsset: string, - uidHook: string,) => { +export type assetsHooksPartialUpdateResponseComposite = + | assetsHooksPartialUpdateResponse200 + | assetsHooksPartialUpdateResponse400 + | assetsHooksPartialUpdateResponse404 - +export type assetsHooksPartialUpdateResponse = assetsHooksPartialUpdateResponseComposite & { + headers: Headers +} +export const getAssetsHooksPartialUpdateUrl = (uidAsset: string, uidHook: string) => { return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/` } -export const assetsHooksPartialUpdate = async (uidAsset: string, - uidHook: string, - patchedHook: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHooksPartialUpdateUrl(uidAsset,uidHook), - { +export const assetsHooksPartialUpdate = async ( + uidAsset: string, + uidHook: string, + patchedHook: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHooksPartialUpdateUrl(uidAsset, uidHook), { ...options, method: 'PATCH', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedHook,) + body: JSON.stringify(patchedHook), + }) +} + +export const getAssetsHooksPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string; data: NonReadonly }, + TContext +> => { + const mutationKey = ['assetsHooksPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidHook: string; data: NonReadonly } + > = (props) => { + const { uidAsset, uidHook, data } = props ?? {} + + return assetsHooksPartialUpdate(uidAsset, uidHook, data, requestOptions) } -);} - - - - -export const getAssetsHooksPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string;data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidHook: string;data: NonReadonly}, TContext> => { - -const mutationKey = ['assetsHooksPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidHook: string;data: NonReadonly}> = (props) => { - const {uidAsset,uidHook,data} = props ?? {}; - - return assetsHooksPartialUpdate(uidAsset,uidHook,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsHooksPartialUpdateMutationResult = NonNullable>> - export type AssetsHooksPartialUpdateMutationBody = NonReadonly - export type AssetsHooksPartialUpdateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsHooksPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string;data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { +export type AssetsHooksPartialUpdateMutationResult = NonNullable>> +export type AssetsHooksPartialUpdateMutationBody = NonReadonly +export type AssetsHooksPartialUpdateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsHooksPartialUpdateMutationOptions(options); +export const useAssetsHooksPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsHooksPartialUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Delete an external service. */ @@ -510,75 +483,79 @@ export type assetsHooksDestroyResponse404 = { data: ErrorDetail status: 404 } - -export type assetsHooksDestroyResponseComposite = assetsHooksDestroyResponse204 | assetsHooksDestroyResponse404; - -export type assetsHooksDestroyResponse = assetsHooksDestroyResponseComposite & { - headers: Headers; -} - -export const getAssetsHooksDestroyUrl = (uidAsset: string, - uidHook: string,) => { +export type assetsHooksDestroyResponseComposite = assetsHooksDestroyResponse204 | assetsHooksDestroyResponse404 - +export type assetsHooksDestroyResponse = assetsHooksDestroyResponseComposite & { + headers: Headers +} +export const getAssetsHooksDestroyUrl = (uidAsset: string, uidHook: string) => { return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/` } -export const assetsHooksDestroy = async (uidAsset: string, - uidHook: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHooksDestroyUrl(uidAsset,uidHook), - { +export const assetsHooksDestroy = async ( + uidAsset: string, + uidHook: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHooksDestroyUrl(uidAsset, uidHook), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getAssetsHooksDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string }, + TContext +> => { + const mutationKey = ['assetsHooksDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidHook: string } + > = (props) => { + const { uidAsset, uidHook } = props ?? {} + + return assetsHooksDestroy(uidAsset, uidHook, requestOptions) } -);} - - - - -export const getAssetsHooksDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext> => { - -const mutationKey = ['assetsHooksDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidHook: string}> = (props) => { - const {uidAsset,uidHook} = props ?? {}; - - return assetsHooksDestroy(uidAsset,uidHook,requestOptions) - } - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetsHooksDestroyMutationResult = NonNullable>> - - export type AssetsHooksDestroyMutationError = ErrorDetail +export type AssetsHooksDestroyMutationResult = NonNullable>> - export const useAssetsHooksDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsHooksDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsHooksDestroyMutationOptions(options); +export const useAssetsHooksDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsHooksDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## List logs of an external services endpoints accessible to requesting user ⚠️ The `page` query parameter is deprecated, use `start` and `limit` instead. @@ -611,95 +588,96 @@ export type assetsHooksLogsListResponse403 = { data: ErrorDetail status: 403 } - -export type assetsHooksLogsListResponseComposite = assetsHooksLogsListResponse200 | assetsHooksLogsListResponse403; - + +export type assetsHooksLogsListResponseComposite = assetsHooksLogsListResponse200 | assetsHooksLogsListResponse403 + export type assetsHooksLogsListResponse = assetsHooksLogsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsHooksLogsListUrl = (uidAsset: string, - uidHook: string, - params?: AssetsHooksLogsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsHooksLogsListUrl = (uidAsset: string, uidHook: string, params?: AssetsHooksLogsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/` } -export const assetsHooksLogsList = async (uidAsset: string, - uidHook: string, - params?: AssetsHooksLogsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHooksLogsListUrl(uidAsset,uidHook,params), - { +export const assetsHooksLogsList = async ( + uidAsset: string, + uidHook: string, + params?: AssetsHooksLogsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHooksLogsListUrl(uidAsset, uidHook, params), { ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsHooksLogsListQueryKey = (uidAsset: string, - uidHook: string, - params?: AssetsHooksLogsListParams,) => { - return ['api','v2','assets',uidAsset,'hooks',uidHook,'logs', ...(params ? [params]: [])] as const; - } + method: 'GET', + }) +} - -export const getAssetsHooksLogsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidHook: string, - params?: AssetsHooksLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsHooksLogsListQueryKey = ( + uidAsset: string, + uidHook: string, + params?: AssetsHooksLogsListParams, ) => { + return ['api', 'v2', 'assets', uidAsset, 'hooks', uidHook, 'logs', ...(params ? [params] : [])] as const +} + +export const getAssetsHooksLogsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidHook: string, + params?: AssetsHooksLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsHooksLogsListQueryKey(uidAsset,uidHook,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsHooksLogsList(uidAsset,uidHook,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getAssetsHooksLogsListQueryKey(uidAsset, uidHook, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsHooksLogsList(uidAsset, uidHook, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidAsset && uidHook), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidHook), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsHooksLogsListQueryResult = NonNullable>> export type AssetsHooksLogsListQueryError = ErrorDetail - - export function useAssetsHooksLogsList>, TError = ErrorDetail>( - uidAsset: string, - uidHook: string, - params?: AssetsHooksLogsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + uidAsset: string, + uidHook: string, + params?: AssetsHooksLogsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsHooksLogsListQueryOptions(uidAsset, uidHook, params, options) - const queryOptions = getAssetsHooksLogsListQueryOptions(uidAsset,uidHook,params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Retrieve an external service endpoint log @@ -713,88 +691,85 @@ export type assetsHooksLogsRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type assetsHooksLogsRetrieveResponseComposite = assetsHooksLogsRetrieveResponse200 | assetsHooksLogsRetrieveResponse403; - -export type assetsHooksLogsRetrieveResponse = assetsHooksLogsRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsHooksLogsRetrieveUrl = (uidAsset: string, - uidHook: string, - uidLog: string,) => { +export type assetsHooksLogsRetrieveResponseComposite = + | assetsHooksLogsRetrieveResponse200 + | assetsHooksLogsRetrieveResponse403 - +export type assetsHooksLogsRetrieveResponse = assetsHooksLogsRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsHooksLogsRetrieveUrl = (uidAsset: string, uidHook: string, uidLog: string) => { return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/${uidLog}/` } -export const assetsHooksLogsRetrieve = async (uidAsset: string, - uidHook: string, - uidLog: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHooksLogsRetrieveUrl(uidAsset,uidHook,uidLog), - { +export const assetsHooksLogsRetrieve = async ( + uidAsset: string, + uidHook: string, + uidLog: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHooksLogsRetrieveUrl(uidAsset, uidHook, uidLog), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsHooksLogsRetrieveQueryKey = (uidAsset: string, - uidHook: string, - uidLog: string,) => { - return ['api','v2','assets',uidAsset,'hooks',uidHook,'logs',uidLog] as const; - } +export const getAssetsHooksLogsRetrieveQueryKey = (uidAsset: string, uidHook: string, uidLog: string) => { + return ['api', 'v2', 'assets', uidAsset, 'hooks', uidHook, 'logs', uidLog] as const +} - -export const getAssetsHooksLogsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidHook: string, - uidLog: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsHooksLogsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidHook: string, + uidLog: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsHooksLogsRetrieveQueryKey(uidAsset,uidHook,uidLog); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsHooksLogsRetrieve(uidAsset,uidHook,uidLog, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getAssetsHooksLogsRetrieveQueryKey(uidAsset, uidHook, uidLog) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsHooksLogsRetrieve(uidAsset, uidHook, uidLog, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidAsset && uidHook && uidLog), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidHook && uidLog), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsHooksLogsRetrieveQueryResult = NonNullable>> export type AssetsHooksLogsRetrieveQueryError = ErrorDetail +export function useAssetsHooksLogsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidHook: string, + uidLog: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsHooksLogsRetrieveQueryOptions(uidAsset, uidHook, uidLog, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsHooksLogsRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidHook: string, - uidLog: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getAssetsHooksLogsRetrieveQueryOptions(uidAsset,uidHook,uidLog,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Retry a failed submission attempt @@ -808,79 +783,93 @@ export type assetsHooksLogsRetryPartialUpdateResponse403 = { data: ErrorDetail status: 403 } - -export type assetsHooksLogsRetryPartialUpdateResponseComposite = assetsHooksLogsRetryPartialUpdateResponse200 | assetsHooksLogsRetryPartialUpdateResponse403; - -export type assetsHooksLogsRetryPartialUpdateResponse = assetsHooksLogsRetryPartialUpdateResponseComposite & { - headers: Headers; -} -export const getAssetsHooksLogsRetryPartialUpdateUrl = (uidAsset: string, - uidHook: string, - uidLog: string,) => { +export type assetsHooksLogsRetryPartialUpdateResponseComposite = + | assetsHooksLogsRetryPartialUpdateResponse200 + | assetsHooksLogsRetryPartialUpdateResponse403 +export type assetsHooksLogsRetryPartialUpdateResponse = assetsHooksLogsRetryPartialUpdateResponseComposite & { + headers: Headers +} - - +export const getAssetsHooksLogsRetryPartialUpdateUrl = (uidAsset: string, uidHook: string, uidLog: string) => { return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/logs/${uidLog}/retry/` } -export const assetsHooksLogsRetryPartialUpdate = async (uidAsset: string, - uidHook: string, - uidLog: string, - patchedHookLog: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHooksLogsRetryPartialUpdateUrl(uidAsset,uidHook,uidLog), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedHookLog,) +export const assetsHooksLogsRetryPartialUpdate = async ( + uidAsset: string, + uidHook: string, + uidLog: string, + patchedHookLog: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsHooksLogsRetryPartialUpdateUrl(uidAsset, uidHook, uidLog), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedHookLog), + }, + ) +} + +export const getAssetsHooksLogsRetryPartialUpdateMutationOptions = < + TError = ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string; uidLog: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string; uidLog: string; data: NonReadonly }, + TContext +> => { + const mutationKey = ['assetsHooksLogsRetryPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidHook: string; uidLog: string; data: NonReadonly } + > = (props) => { + const { uidAsset, uidHook, uidLog, data } = props ?? {} + + return assetsHooksLogsRetryPartialUpdate(uidAsset, uidHook, uidLog, data, requestOptions) } -);} - - - - -export const getAssetsHooksLogsRetryPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string;uidLog: string;data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidHook: string;uidLog: string;data: NonReadonly}, TContext> => { - -const mutationKey = ['assetsHooksLogsRetryPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidHook: string;uidLog: string;data: NonReadonly}> = (props) => { - const {uidAsset,uidHook,uidLog,data} = props ?? {}; - - return assetsHooksLogsRetryPartialUpdate(uidAsset,uidHook,uidLog,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - export type AssetsHooksLogsRetryPartialUpdateMutationResult = NonNullable>> - export type AssetsHooksLogsRetryPartialUpdateMutationBody = NonReadonly - export type AssetsHooksLogsRetryPartialUpdateMutationError = ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsHooksLogsRetryPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string;uidLog: string;data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { +export type AssetsHooksLogsRetryPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsHooksLogsRetryPartialUpdateMutationBody = NonReadonly +export type AssetsHooksLogsRetryPartialUpdateMutationError = ErrorDetail - const mutationOptions = getAssetsHooksLogsRetryPartialUpdateMutationOptions(options); +export const useAssetsHooksLogsRetryPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string; uidLog: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsHooksLogsRetryPartialUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retries all failed attempts **This call is asynchronous. Job is sent to Celery to be run in background** @@ -897,72 +886,79 @@ export type assetsHooksRetryPartialUpdateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsHooksRetryPartialUpdateResponseComposite = assetsHooksRetryPartialUpdateResponse200 | assetsHooksRetryPartialUpdateResponse404; - -export type assetsHooksRetryPartialUpdateResponse = assetsHooksRetryPartialUpdateResponseComposite & { - headers: Headers; -} -export const getAssetsHooksRetryPartialUpdateUrl = (uidAsset: string, - uidHook: string,) => { +export type assetsHooksRetryPartialUpdateResponseComposite = + | assetsHooksRetryPartialUpdateResponse200 + | assetsHooksRetryPartialUpdateResponse404 +export type assetsHooksRetryPartialUpdateResponse = assetsHooksRetryPartialUpdateResponseComposite & { + headers: Headers +} - - +export const getAssetsHooksRetryPartialUpdateUrl = (uidAsset: string, uidHook: string) => { return `/api/v2/assets/${uidAsset}/hooks/${uidHook}/retry/` } -export const assetsHooksRetryPartialUpdate = async (uidAsset: string, - uidHook: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsHooksRetryPartialUpdateUrl(uidAsset,uidHook), - { +export const assetsHooksRetryPartialUpdate = async ( + uidAsset: string, + uidHook: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsHooksRetryPartialUpdateUrl(uidAsset, uidHook), { ...options, - method: 'PATCH' - - + method: 'PATCH', + }) +} + +export const getAssetsHooksRetryPartialUpdateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string }, + TContext +> => { + const mutationKey = ['assetsHooksRetryPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidHook: string } + > = (props) => { + const { uidAsset, uidHook } = props ?? {} + + return assetsHooksRetryPartialUpdate(uidAsset, uidHook, requestOptions) } -);} - - + return { mutationFn, ...mutationOptions } +} -export const getAssetsHooksRetryPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext> => { - -const mutationKey = ['assetsHooksRetryPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidHook: string}> = (props) => { - const {uidAsset,uidHook} = props ?? {}; - - return assetsHooksRetryPartialUpdate(uidAsset,uidHook,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsHooksRetryPartialUpdateMutationResult = NonNullable>> - - export type AssetsHooksRetryPartialUpdateMutationError = ErrorDetail +export type AssetsHooksRetryPartialUpdateMutationResult = NonNullable< + Awaited> +> - export const useAssetsHooksRetryPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidHook: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsHooksRetryPartialUpdateMutationError = ErrorDetail - const mutationOptions = getAssetsHooksRetryPartialUpdateMutationOptions(options); +export const useAssetsHooksRetryPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidHook: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsHooksRetryPartialUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - \ No newline at end of file + return useMutation(mutationOptions) +} diff --git a/jsapp/js/api/react-query/survey-data-rest-services/msw.ts b/jsapp/js/api/react-query/survey-data-rest-services/msw.ts index f1fc72154e..3de9d07081 100644 --- a/jsapp/js/api/react-query/survey-data-rest-services/msw.ts +++ b/jsapp/js/api/react-query/survey-data-rest-services/msw.ts @@ -9,149 +9,415 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; +import { http, HttpResponse } from 'msw' -import { - AuthLevelEnum -} from '../../models/authLevelEnum'; +import { AuthLevelEnum } from '../../models/authLevelEnum' -import { - ExportTypeEnum -} from '../../models/exportTypeEnum'; +import { ExportTypeEnum } from '../../models/exportTypeEnum' -import type { - Hook -} from '../../models/hook'; +import type { Hook } from '../../models/hook' -import type { - HookLog -} from '../../models/hookLog'; +import type { HookLog } from '../../models/hookLog' -import type { - HookRetryResponse -} from '../../models/hookRetryResponse'; +import type { HookRetryResponse } from '../../models/hookRetryResponse' -import type { - LogsRetryResponse -} from '../../models/logsRetryResponse'; +import type { LogsRetryResponse } from '../../models/logsRetryResponse' -import type { - PaginatedHookList -} from '../../models/paginatedHookList'; +import type { PaginatedHookList } from '../../models/paginatedHookList' -import type { - PaginatedHookLogList -} from '../../models/paginatedHookLogList'; +import type { PaginatedHookLogList } from '../../models/paginatedHookLogList' +export const getApiV2AssetsHooksListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedHookList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + })), + ...overrideResponse, +}) -export const getApiV2AssetsHooksListResponseMock = (overrideResponse: Partial< PaginatedHookList > = {}): PaginatedHookList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), asset: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.string.alpha({length: {min: 10, max: 500}}), export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), failed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), logs_url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 255}}), payload_template: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), settings: faker.helpers.arrayElement([{password: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), custom_headers: faker.helpers.arrayElement([{value_field: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value_field_2: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), subset_fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), success_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url()})), ...overrideResponse}) +export const getApiV2AssetsHooksCreateResponseMock = (overrideResponse: Partial = {}): Hook => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) -export const getApiV2AssetsHooksCreateResponseMock = (overrideResponse: Partial< Hook > = {}): Hook => ({active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), asset: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.string.alpha({length: {min: 10, max: 500}}), export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), failed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), logs_url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 255}}), payload_template: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), settings: faker.helpers.arrayElement([{password: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), custom_headers: faker.helpers.arrayElement([{value_field: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value_field_2: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), subset_fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), success_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) +export const getApiV2AssetsHooksRetrieveResponseMock = (overrideResponse: Partial = {}): Hook => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) -export const getApiV2AssetsHooksRetrieveResponseMock = (overrideResponse: Partial< Hook > = {}): Hook => ({active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), asset: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.string.alpha({length: {min: 10, max: 500}}), export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), failed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), logs_url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 255}}), payload_template: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), settings: faker.helpers.arrayElement([{password: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), custom_headers: faker.helpers.arrayElement([{value_field: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value_field_2: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), subset_fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), success_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) +export const getApiV2AssetsHooksPartialUpdateResponseMock = (overrideResponse: Partial = {}): Hook => ({ + active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + asset: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + endpoint: faker.string.alpha({ length: { min: 10, max: 500 } }), + export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), + failed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + logs_url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 255 } }), + payload_template: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + pending_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + settings: faker.helpers.arrayElement([ + { + password: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + custom_headers: faker.helpers.arrayElement([ + { + value_field: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value_field_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + subset_fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + success_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) -export const getApiV2AssetsHooksPartialUpdateResponseMock = (overrideResponse: Partial< Hook > = {}): Hook => ({active: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), asset: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), auth_level: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(AuthLevelEnum)), undefined]), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, email_notification: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), endpoint: faker.string.alpha({length: {min: 10, max: 500}}), export_type: faker.helpers.arrayElement([faker.helpers.arrayElement(Object.values(ExportTypeEnum)), undefined]), failed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), logs_url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 255}}), payload_template: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), pending_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), settings: faker.helpers.arrayElement([{password: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), custom_headers: faker.helpers.arrayElement([{value_field: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value_field_2: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), subset_fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), success_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) +export const getApiV2AssetsHooksLogsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedHookLogList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + tries: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.helpers.arrayElement([0, 1, 3, 2] as const), + status_str: faker.string.alpha({ length: { min: 10, max: 20 } }), + status_code: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + message: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + ...overrideResponse, +}) -export const getApiV2AssetsHooksLogsListResponseMock = (overrideResponse: Partial< PaginatedHookLogList > = {}): PaginatedHookLogList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), submission_id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), tries: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.helpers.arrayElement([0,1,3,2] as const), status_str: faker.string.alpha({length: {min: 10, max: 20}}), status_code: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), message: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`})), ...overrideResponse}) +export const getApiV2AssetsHooksLogsRetrieveResponseMock = (overrideResponse: Partial = {}): HookLog => ({ + url: faker.internet.url(), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + tries: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.helpers.arrayElement([0, 1, 3, 2] as const), + status_str: faker.string.alpha({ length: { min: 10, max: 20 } }), + status_code: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + message: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + ...overrideResponse, +}) -export const getApiV2AssetsHooksLogsRetrieveResponseMock = (overrideResponse: Partial< HookLog > = {}): HookLog => ({url: faker.internet.url(), uid: faker.string.alpha({length: {min: 10, max: 20}}), submission_id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), tries: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.helpers.arrayElement([0,1,3,2] as const), status_str: faker.string.alpha({length: {min: 10, max: 20}}), status_code: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), message: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, ...overrideResponse}) +export const getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): LogsRetryResponse => ({ + detail: faker.string.alpha({ length: { min: 10, max: 20 } }), + pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) -export const getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock = (overrideResponse: Partial< LogsRetryResponse > = {}): LogsRetryResponse => ({detail: faker.string.alpha({length: {min: 10, max: 20}}), pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) +export const getApiV2AssetsHooksRetryPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): HookRetryResponse => ({ + detail: faker.string.alpha({ length: { min: 10, max: 20 } }), + pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) -export const getApiV2AssetsHooksRetryPartialUpdateResponseMock = (overrideResponse: Partial< HookRetryResponse > = {}): HookRetryResponse => ({detail: faker.string.alpha({length: {min: 10, max: 20}}), pending_uids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) - - -export const getApiV2AssetsHooksListMockHandler = (overrideResponse?: PaginatedHookList | ((info: Parameters[1]>[0]) => Promise | PaginatedHookList)) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHooksListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHooksListMockHandler = ( + overrideResponse?: + | PaginatedHookList + | ((info: Parameters[1]>[0]) => Promise | PaginatedHookList), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHooksCreateMockHandler = (overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook)) => { - return http.post('*/api/v2/assets/:uidAsset/hooks/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHooksCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHooksCreateMockHandler = ( + overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), +) => { + return http.post('*/api/v2/assets/:uidAsset/hooks/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHooksRetrieveMockHandler = (overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook)) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHooksRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHooksRetrieveMockHandler = ( + overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHooksPartialUpdateMockHandler = (overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook)) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHooksPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHooksPartialUpdateMockHandler = ( + overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), +) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHooksDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsHooksDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsHooksLogsListMockHandler = (overrideResponse?: PaginatedHookLogList | ((info: Parameters[1]>[0]) => Promise | PaginatedHookLogList)) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHooksLogsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHooksLogsListMockHandler = ( + overrideResponse?: + | PaginatedHookLogList + | ((info: Parameters[1]>[0]) => Promise | PaginatedHookLogList), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksLogsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHooksLogsRetrieveMockHandler = (overrideResponse?: HookLog | ((info: Parameters[1]>[0]) => Promise | HookLog)) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHooksLogsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHooksLogsRetrieveMockHandler = ( + overrideResponse?: HookLog | ((info: Parameters[1]>[0]) => Promise | HookLog), +) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksLogsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler = (overrideResponse?: LogsRetryResponse | ((info: Parameters[1]>[0]) => Promise | LogsRetryResponse)) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler = ( + overrideResponse?: + | LogsRetryResponse + | ((info: Parameters[1]>[0]) => Promise | LogsRetryResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksLogsRetryPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsHooksRetryPartialUpdateMockHandler = (overrideResponse?: HookRetryResponse | ((info: Parameters[1]>[0]) => Promise | HookRetryResponse)) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsHooksRetryPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsHooksRetryPartialUpdateMockHandler = ( + overrideResponse?: + | HookRetryResponse + | ((info: Parameters[1]>[0]) => Promise | HookRetryResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsHooksRetryPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } export const getSurveyDataRestServicesMock = () => [ @@ -163,5 +429,5 @@ export const getSurveyDataRestServicesMock = () => [ getApiV2AssetsHooksLogsListMockHandler(), getApiV2AssetsHooksLogsRetrieveMockHandler(), getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler(), - getApiV2AssetsHooksRetryPartialUpdateMockHandler() + getApiV2AssetsHooksRetryPartialUpdateMockHandler(), ] diff --git a/jsapp/js/api/react-query/survey-data/index.ts b/jsapp/js/api/react-query/survey-data/index.ts index 1d9ffef1e5..a5852dc26e 100644 --- a/jsapp/js/api/react-query/survey-data/index.ts +++ b/jsapp/js/api/react-query/survey-data/index.ts @@ -9,268 +9,144 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - AdvancedFeatureCreateResponse -} from '../../models/advancedFeatureCreateResponse'; +import type { AdvancedFeatureCreateResponse } from '../../models/advancedFeatureCreateResponse' -import type { - AdvancedFeaturePostRequest -} from '../../models/advancedFeaturePostRequest'; +import type { AdvancedFeaturePostRequest } from '../../models/advancedFeaturePostRequest' -import type { - AdvancedFeatureResponse -} from '../../models/advancedFeatureResponse'; +import type { AdvancedFeatureResponse } from '../../models/advancedFeatureResponse' -import type { - AssetAttachmentAudioDurationRequest -} from '../../models/assetAttachmentAudioDurationRequest'; +import type { AssetAttachmentAudioDurationRequest } from '../../models/assetAttachmentAudioDurationRequest' -import type { - AssetAttachmentAudioDurationResponse -} from '../../models/assetAttachmentAudioDurationResponse'; +import type { AssetAttachmentAudioDurationResponse } from '../../models/assetAttachmentAudioDurationResponse' -import type { - AssetsAdvancedFeaturesBulkActionsListParams -} from '../../models/assetsAdvancedFeaturesBulkActionsListParams'; +import type { AssetsAdvancedFeaturesBulkActionsListParams } from '../../models/assetsAdvancedFeaturesBulkActionsListParams' -import type { - AssetsDataAttachmentsListParams -} from '../../models/assetsDataAttachmentsListParams'; +import type { AssetsDataAttachmentsListParams } from '../../models/assetsDataAttachmentsListParams' -import type { - AssetsDataListParams -} from '../../models/assetsDataListParams'; +import type { AssetsDataListParams } from '../../models/assetsDataListParams' -import type { - AssetsDataRetrieveParams -} from '../../models/assetsDataRetrieveParams'; +import type { AssetsDataRetrieveParams } from '../../models/assetsDataRetrieveParams' -import type { - AssetsExportSettingsDataRetrieveParams -} from '../../models/assetsExportSettingsDataRetrieveParams'; +import type { AssetsExportSettingsDataRetrieveParams } from '../../models/assetsExportSettingsDataRetrieveParams' -import type { - AssetsExportSettingsListParams -} from '../../models/assetsExportSettingsListParams'; +import type { AssetsExportSettingsListParams } from '../../models/assetsExportSettingsListParams' -import type { - AssetsExportsListParams -} from '../../models/assetsExportsListParams'; +import type { AssetsExportsListParams } from '../../models/assetsExportsListParams' -import type { - AssetsFilesListParams -} from '../../models/assetsFilesListParams'; +import type { AssetsFilesListParams } from '../../models/assetsFilesListParams' -import type { - AssetsPairedDataListParams -} from '../../models/assetsPairedDataListParams'; +import type { AssetsPairedDataListParams } from '../../models/assetsPairedDataListParams' -import type { - AttachmentRetrieveParams -} from '../../models/attachmentRetrieveParams'; +import type { AttachmentRetrieveParams } from '../../models/attachmentRetrieveParams' -import type { - BulkAcceptRequest -} from '../../models/bulkAcceptRequest'; +import type { BulkAcceptRequest } from '../../models/bulkAcceptRequest' -import type { - BulkAcceptResponse -} from '../../models/bulkAcceptResponse'; +import type { BulkAcceptResponse } from '../../models/bulkAcceptResponse' -import type { - BulkActionCreateRequest -} from '../../models/bulkActionCreateRequest'; +import type { BulkActionCreateRequest } from '../../models/bulkActionCreateRequest' -import type { - BulkActionCreateResponse -} from '../../models/bulkActionCreateResponse'; +import type { BulkActionCreateResponse } from '../../models/bulkActionCreateResponse' -import type { - BulkActionListResponse -} from '../../models/bulkActionListResponse'; +import type { BulkActionListResponse } from '../../models/bulkActionListResponse' -import type { - BulkActionResponse -} from '../../models/bulkActionResponse'; +import type { BulkActionResponse } from '../../models/bulkActionResponse' -import type { - CreateFilePayload -} from '../../models/createFilePayload'; +import type { CreateFilePayload } from '../../models/createFilePayload' -import type { - DataBulkDelete -} from '../../models/dataBulkDelete'; +import type { DataBulkDelete } from '../../models/dataBulkDelete' -import type { - DataBulkUpdateResponse -} from '../../models/dataBulkUpdateResponse'; +import type { DataBulkUpdateResponse } from '../../models/dataBulkUpdateResponse' -import type { - DataResponse -} from '../../models/dataResponse'; +import type { DataResponse } from '../../models/dataResponse' -import type { - DataStatusesUpdate -} from '../../models/dataStatusesUpdate'; +import type { DataStatusesUpdate } from '../../models/dataStatusesUpdate' -import type { - DataSupplementResponse -} from '../../models/dataSupplementResponse'; +import type { DataSupplementResponse } from '../../models/dataSupplementResponse' -import type { - DataValidationStatusUpdateResponse -} from '../../models/dataValidationStatusUpdateResponse'; +import type { DataValidationStatusUpdateResponse } from '../../models/dataValidationStatusUpdateResponse' -import type { - EnketoEditResponse -} from '../../models/enketoEditResponse'; +import type { EnketoEditResponse } from '../../models/enketoEditResponse' -import type { - EnketoViewResponse -} from '../../models/enketoViewResponse'; +import type { EnketoViewResponse } from '../../models/enketoViewResponse' -import type { - ErrorDetail -} from '../../models/errorDetail'; +import type { ErrorDetail } from '../../models/errorDetail' -import type { - ErrorObject -} from '../../models/errorObject'; +import type { ErrorObject } from '../../models/errorObject' -import type { - ExportCreatePayload -} from '../../models/exportCreatePayload'; +import type { ExportCreatePayload } from '../../models/exportCreatePayload' -import type { - ExportResponse -} from '../../models/exportResponse'; +import type { ExportResponse } from '../../models/exportResponse' -import type { - ExportSettingCreatePayload -} from '../../models/exportSettingCreatePayload'; +import type { ExportSettingCreatePayload } from '../../models/exportSettingCreatePayload' -import type { - ExportSettingResponse -} from '../../models/exportSettingResponse'; +import type { ExportSettingResponse } from '../../models/exportSettingResponse' -import type { - ExternalResponse -} from '../../models/externalResponse'; +import type { ExternalResponse } from '../../models/externalResponse' -import type { - FilesResponse -} from '../../models/filesResponse'; +import type { FilesResponse } from '../../models/filesResponse' -import type { - PaginatedDataResponseList -} from '../../models/paginatedDataResponseList'; +import type { PaginatedDataResponseList } from '../../models/paginatedDataResponseList' -import type { - PaginatedExportResponseList -} from '../../models/paginatedExportResponseList'; +import type { PaginatedExportResponseList } from '../../models/paginatedExportResponseList' -import type { - PaginatedExportSettingResponseList -} from '../../models/paginatedExportSettingResponseList'; +import type { PaginatedExportSettingResponseList } from '../../models/paginatedExportSettingResponseList' -import type { - PaginatedFilesResponseList -} from '../../models/paginatedFilesResponseList'; +import type { PaginatedFilesResponseList } from '../../models/paginatedFilesResponseList' -import type { - PaginatedPairedDataResponseList -} from '../../models/paginatedPairedDataResponseList'; +import type { PaginatedPairedDataResponseList } from '../../models/paginatedPairedDataResponseList' -import type { - PairedData -} from '../../models/pairedData'; +import type { PairedData } from '../../models/pairedData' -import type { - PairedDataResponse -} from '../../models/pairedDataResponse'; +import type { PairedDataResponse } from '../../models/pairedDataResponse' -import type { - PatchedAdvancedFeaturePatchRequest -} from '../../models/patchedAdvancedFeaturePatchRequest'; +import type { PatchedAdvancedFeaturePatchRequest } from '../../models/patchedAdvancedFeaturePatchRequest' -import type { - PatchedBulkActionPatchRequest -} from '../../models/patchedBulkActionPatchRequest'; +import type { PatchedBulkActionPatchRequest } from '../../models/patchedBulkActionPatchRequest' -import type { - PatchedDataBulkUpdate -} from '../../models/patchedDataBulkUpdate'; +import type { PatchedDataBulkUpdate } from '../../models/patchedDataBulkUpdate' -import type { - PatchedDataSupplementPayload -} from '../../models/patchedDataSupplementPayload'; +import type { PatchedDataSupplementPayload } from '../../models/patchedDataSupplementPayload' -import type { - PatchedDataValidationStatusUpdatePayload -} from '../../models/patchedDataValidationStatusUpdatePayload'; +import type { PatchedDataValidationStatusUpdatePayload } from '../../models/patchedDataValidationStatusUpdatePayload' -import type { - PatchedDataValidationStatusesUpdatePayload -} from '../../models/patchedDataValidationStatusesUpdatePayload'; +import type { PatchedDataValidationStatusesUpdatePayload } from '../../models/patchedDataValidationStatusesUpdatePayload' -import type { - PatchedExportSettingUpdatePayload -} from '../../models/patchedExportSettingUpdatePayload'; +import type { PatchedExportSettingUpdatePayload } from '../../models/patchedExportSettingUpdatePayload' -import type { - PatchedPairedDataPatchPayload -} from '../../models/patchedPairedDataPatchPayload'; +import type { PatchedPairedDataPatchPayload } from '../../models/patchedPairedDataPatchPayload' -import type { - ReportResponse -} from '../../models/reportResponse'; +import type { ReportResponse } from '../../models/reportResponse' -import { fetchWithAuth } from '../../orval.mutator'; +import { fetchWithAuth } from '../../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = (() => T extends X ? 1 : 2) extends < -T, ->() => T extends Y ? 1 : 2 -? A -: B; +type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B type WritableKeys = { -[P in keyof T]-?: IfEquals< - { [Q in P]: T[P] }, - { -readonly [Q in P]: T[P] }, - P ->; -}[keyof T]; - -type UnionToIntersection = - (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never; -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; + [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P> +}[keyof T] -type Writable = Pick>; -type NonReadonly = [T] extends [UnionToIntersection] ? { - [P in keyof Writable]: T[P] extends object - ? NonReadonly> - : T[P]; -} : DistributeReadOnlyOverUnions; - - - -type SecondParameter unknown> = Parameters[1]; +type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never +type Writable = Pick> +type NonReadonly = [T] extends [UnionToIntersection] + ? { + [P in keyof Writable]: T[P] extends object ? NonReadonly> : T[P] + } + : DistributeReadOnlyOverUnions +type SecondParameter unknown> = Parameters[1] /** * ## List all advanced features on an asset @@ -287,78 +163,79 @@ export type assetsAdvancedFeaturesListResponse404 = { data: ErrorDetail status: 404 } - -export type assetsAdvancedFeaturesListResponseComposite = assetsAdvancedFeaturesListResponse200 | assetsAdvancedFeaturesListResponse404; - -export type assetsAdvancedFeaturesListResponse = assetsAdvancedFeaturesListResponseComposite & { - headers: Headers; -} - -export const getAssetsAdvancedFeaturesListUrl = (uidAsset: string,) => { +export type assetsAdvancedFeaturesListResponseComposite = + | assetsAdvancedFeaturesListResponse200 + | assetsAdvancedFeaturesListResponse404 - +export type assetsAdvancedFeaturesListResponse = assetsAdvancedFeaturesListResponseComposite & { + headers: Headers +} +export const getAssetsAdvancedFeaturesListUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/advanced-features/` } -export const assetsAdvancedFeaturesList = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAdvancedFeaturesListUrl(uidAsset), - { +export const assetsAdvancedFeaturesList = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsAdvancedFeaturesListUrl(uidAsset), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsAdvancedFeaturesListQueryKey = (uidAsset: string,) => { - return ['api','v2','assets',uidAsset,'advanced-features'] as const; - } +export const getAssetsAdvancedFeaturesListQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'advanced-features'] as const +} - -export const getAssetsAdvancedFeaturesListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsAdvancedFeaturesListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesListQueryKey(uidAsset) - const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesListQueryKey(uidAsset); + const queryFn: QueryFunction>> = ({ signal }) => + assetsAdvancedFeaturesList(uidAsset, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => assetsAdvancedFeaturesList(uidAsset, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsAdvancedFeaturesListQueryResult = NonNullable>> export type AssetsAdvancedFeaturesListQueryError = ErrorDetail +export function useAssetsAdvancedFeaturesList< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsAdvancedFeaturesListQueryOptions(uidAsset, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsAdvancedFeaturesList>, TError = ErrorDetail>( - uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsAdvancedFeaturesListQueryOptions(uidAsset,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Add an advanced action to an asset @@ -389,75 +266,89 @@ export type assetsAdvancedFeaturesCreateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsAdvancedFeaturesCreateResponseComposite = assetsAdvancedFeaturesCreateResponse201 | assetsAdvancedFeaturesCreateResponse400 | assetsAdvancedFeaturesCreateResponse404; - -export type assetsAdvancedFeaturesCreateResponse = assetsAdvancedFeaturesCreateResponseComposite & { - headers: Headers; -} - -export const getAssetsAdvancedFeaturesCreateUrl = (uidAsset: string,) => { +export type assetsAdvancedFeaturesCreateResponseComposite = + | assetsAdvancedFeaturesCreateResponse201 + | assetsAdvancedFeaturesCreateResponse400 + | assetsAdvancedFeaturesCreateResponse404 - +export type assetsAdvancedFeaturesCreateResponse = assetsAdvancedFeaturesCreateResponseComposite & { + headers: Headers +} +export const getAssetsAdvancedFeaturesCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/advanced-features/` } -export const assetsAdvancedFeaturesCreate = async (uidAsset: string, - advancedFeaturePostRequest: AdvancedFeaturePostRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAdvancedFeaturesCreateUrl(uidAsset), - { +export const assetsAdvancedFeaturesCreate = async ( + uidAsset: string, + advancedFeaturePostRequest: AdvancedFeaturePostRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsAdvancedFeaturesCreateUrl(uidAsset), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - advancedFeaturePostRequest,) + body: JSON.stringify(advancedFeaturePostRequest), + }) +} + +export const getAssetsAdvancedFeaturesCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: AdvancedFeaturePostRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: AdvancedFeaturePostRequest }, + TContext +> => { + const mutationKey = ['assetsAdvancedFeaturesCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: AdvancedFeaturePostRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsAdvancedFeaturesCreate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsAdvancedFeaturesCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: AdvancedFeaturePostRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: AdvancedFeaturePostRequest}, TContext> => { - -const mutationKey = ['assetsAdvancedFeaturesCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: AdvancedFeaturePostRequest}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsAdvancedFeaturesCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsAdvancedFeaturesCreateMutationResult = NonNullable>> - export type AssetsAdvancedFeaturesCreateMutationBody = AdvancedFeaturePostRequest - export type AssetsAdvancedFeaturesCreateMutationError = ErrorObject | ErrorDetail - - export const useAssetsAdvancedFeaturesCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: AdvancedFeaturePostRequest}, TContext>, request?: SecondParameter} - ) => { - const mutationOptions = getAssetsAdvancedFeaturesCreateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetsAdvancedFeaturesCreateMutationResult = NonNullable< + Awaited> +> +export type AssetsAdvancedFeaturesCreateMutationBody = AdvancedFeaturePostRequest +export type AssetsAdvancedFeaturesCreateMutationError = ErrorObject | ErrorDetail + +export const useAssetsAdvancedFeaturesCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: AdvancedFeaturePostRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsAdvancedFeaturesCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Retrieve advanced feature configuration for a question on an asset Gets the params for one advanced action for one question in an asset @@ -472,83 +363,87 @@ export type assetsAdvancedFeaturesRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsAdvancedFeaturesRetrieveResponseComposite = assetsAdvancedFeaturesRetrieveResponse200 | assetsAdvancedFeaturesRetrieveResponse404; - -export type assetsAdvancedFeaturesRetrieveResponse = assetsAdvancedFeaturesRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsAdvancedFeaturesRetrieveUrl = (uidAsset: string, - uidAdvancedFeature: string,) => { +export type assetsAdvancedFeaturesRetrieveResponseComposite = + | assetsAdvancedFeaturesRetrieveResponse200 + | assetsAdvancedFeaturesRetrieveResponse404 - +export type assetsAdvancedFeaturesRetrieveResponse = assetsAdvancedFeaturesRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsAdvancedFeaturesRetrieveUrl = (uidAsset: string, uidAdvancedFeature: string) => { return `/api/v2/assets/${uidAsset}/advanced-features/${uidAdvancedFeature}/` } -export const assetsAdvancedFeaturesRetrieve = async (uidAsset: string, - uidAdvancedFeature: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAdvancedFeaturesRetrieveUrl(uidAsset,uidAdvancedFeature), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsAdvancedFeaturesRetrieveQueryKey = (uidAsset: string, - uidAdvancedFeature: string,) => { - return ['api','v2','assets',uidAsset,'advanced-features',uidAdvancedFeature] as const; - } - - -export const getAssetsAdvancedFeaturesRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidAdvancedFeature: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const assetsAdvancedFeaturesRetrieve = async ( + uidAsset: string, + uidAdvancedFeature: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsAdvancedFeaturesRetrieveUrl(uidAsset, uidAdvancedFeature), + { + ...options, + method: 'GET', + }, + ) +} + +export const getAssetsAdvancedFeaturesRetrieveQueryKey = (uidAsset: string, uidAdvancedFeature: string) => { + return ['api', 'v2', 'assets', uidAsset, 'advanced-features', uidAdvancedFeature] as const +} + +export const getAssetsAdvancedFeaturesRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidAdvancedFeature: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesRetrieveQueryKey(uidAsset,uidAdvancedFeature); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsAdvancedFeaturesRetrieve(uidAsset,uidAdvancedFeature, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesRetrieveQueryKey(uidAsset, uidAdvancedFeature) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsAdvancedFeaturesRetrieve(uidAsset, uidAdvancedFeature, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidAdvancedFeature), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidAdvancedFeature), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsAdvancedFeaturesRetrieveQueryResult = NonNullable>> +export type AssetsAdvancedFeaturesRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsAdvancedFeaturesRetrieveQueryError = ErrorDetail +export function useAssetsAdvancedFeaturesRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidAdvancedFeature: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsAdvancedFeaturesRetrieveQueryOptions(uidAsset, uidAdvancedFeature, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsAdvancedFeaturesRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidAdvancedFeature: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsAdvancedFeaturesRetrieveQueryOptions(uidAsset,uidAdvancedFeature,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Update an advanced action on an asset @@ -581,77 +476,96 @@ export type assetsAdvancedFeaturesPartialUpdateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsAdvancedFeaturesPartialUpdateResponseComposite = assetsAdvancedFeaturesPartialUpdateResponse200 | assetsAdvancedFeaturesPartialUpdateResponse400 | assetsAdvancedFeaturesPartialUpdateResponse404; - -export type assetsAdvancedFeaturesPartialUpdateResponse = assetsAdvancedFeaturesPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getAssetsAdvancedFeaturesPartialUpdateUrl = (uidAsset: string, - uidAdvancedFeature: string,) => { +export type assetsAdvancedFeaturesPartialUpdateResponseComposite = + | assetsAdvancedFeaturesPartialUpdateResponse200 + | assetsAdvancedFeaturesPartialUpdateResponse400 + | assetsAdvancedFeaturesPartialUpdateResponse404 - +export type assetsAdvancedFeaturesPartialUpdateResponse = assetsAdvancedFeaturesPartialUpdateResponseComposite & { + headers: Headers +} +export const getAssetsAdvancedFeaturesPartialUpdateUrl = (uidAsset: string, uidAdvancedFeature: string) => { return `/api/v2/assets/${uidAsset}/advanced-features/${uidAdvancedFeature}/` } -export const assetsAdvancedFeaturesPartialUpdate = async (uidAsset: string, - uidAdvancedFeature: string, - patchedAdvancedFeaturePatchRequest: PatchedAdvancedFeaturePatchRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAdvancedFeaturesPartialUpdateUrl(uidAsset,uidAdvancedFeature), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedAdvancedFeaturePatchRequest,) +export const assetsAdvancedFeaturesPartialUpdate = async ( + uidAsset: string, + uidAdvancedFeature: string, + patchedAdvancedFeaturePatchRequest: PatchedAdvancedFeaturePatchRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsAdvancedFeaturesPartialUpdateUrl(uidAsset, uidAdvancedFeature), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedAdvancedFeaturePatchRequest), + }, + ) +} + +export const getAssetsAdvancedFeaturesPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidAdvancedFeature: string; data: PatchedAdvancedFeaturePatchRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidAdvancedFeature: string; data: PatchedAdvancedFeaturePatchRequest }, + TContext +> => { + const mutationKey = ['assetsAdvancedFeaturesPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidAdvancedFeature: string; data: PatchedAdvancedFeaturePatchRequest } + > = (props) => { + const { uidAsset, uidAdvancedFeature, data } = props ?? {} + + return assetsAdvancedFeaturesPartialUpdate(uidAsset, uidAdvancedFeature, data, requestOptions) } -);} - - - - -export const getAssetsAdvancedFeaturesPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidAdvancedFeature: string;data: PatchedAdvancedFeaturePatchRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidAdvancedFeature: string;data: PatchedAdvancedFeaturePatchRequest}, TContext> => { - -const mutationKey = ['assetsAdvancedFeaturesPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidAdvancedFeature: string;data: PatchedAdvancedFeaturePatchRequest}> = (props) => { - const {uidAsset,uidAdvancedFeature,data} = props ?? {}; - - return assetsAdvancedFeaturesPartialUpdate(uidAsset,uidAdvancedFeature,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsAdvancedFeaturesPartialUpdateMutationResult = NonNullable>> - export type AssetsAdvancedFeaturesPartialUpdateMutationBody = PatchedAdvancedFeaturePatchRequest - export type AssetsAdvancedFeaturesPartialUpdateMutationError = ErrorObject | ErrorDetail - - export const useAssetsAdvancedFeaturesPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidAdvancedFeature: string;data: PatchedAdvancedFeaturePatchRequest}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsAdvancedFeaturesPartialUpdateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetsAdvancedFeaturesPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsAdvancedFeaturesPartialUpdateMutationBody = PatchedAdvancedFeaturePatchRequest +export type AssetsAdvancedFeaturesPartialUpdateMutationError = ErrorObject | ErrorDetail + +export const useAssetsAdvancedFeaturesPartialUpdate = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidAdvancedFeature: string; data: PatchedAdvancedFeaturePatchRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsAdvancedFeaturesPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## List bulk processing jobs on an asset Returns paginated bulk processing jobs associated with the specified asset. Each @@ -687,90 +601,105 @@ export type assetsAdvancedFeaturesBulkActionsListResponse404 = { data: ErrorDetail status: 404 } - -export type assetsAdvancedFeaturesBulkActionsListResponseComposite = assetsAdvancedFeaturesBulkActionsListResponse200 | assetsAdvancedFeaturesBulkActionsListResponse404; - + +export type assetsAdvancedFeaturesBulkActionsListResponseComposite = + | assetsAdvancedFeaturesBulkActionsListResponse200 + | assetsAdvancedFeaturesBulkActionsListResponse404 + export type assetsAdvancedFeaturesBulkActionsListResponse = assetsAdvancedFeaturesBulkActionsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsAdvancedFeaturesBulkActionsListUrl = (uidAsset: string, - params?: AssetsAdvancedFeaturesBulkActionsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsAdvancedFeaturesBulkActionsListUrl = ( + uidAsset: string, + params?: AssetsAdvancedFeaturesBulkActionsListParams, +) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/` } -export const assetsAdvancedFeaturesBulkActionsList = async (uidAsset: string, - params?: AssetsAdvancedFeaturesBulkActionsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAdvancedFeaturesBulkActionsListUrl(uidAsset,params), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsAdvancedFeaturesBulkActionsListQueryKey = (uidAsset: string, - params?: AssetsAdvancedFeaturesBulkActionsListParams,) => { - return ['api','v2','assets',uidAsset,'advanced-features','bulk-actions', ...(params ? [params]: [])] as const; - } +export const assetsAdvancedFeaturesBulkActionsList = async ( + uidAsset: string, + params?: AssetsAdvancedFeaturesBulkActionsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsAdvancedFeaturesBulkActionsListUrl(uidAsset, params), + { + ...options, + method: 'GET', + }, + ) +} - -export const getAssetsAdvancedFeaturesBulkActionsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsAdvancedFeaturesBulkActionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsAdvancedFeaturesBulkActionsListQueryKey = ( + uidAsset: string, + params?: AssetsAdvancedFeaturesBulkActionsListParams, ) => { + return ['api', 'v2', 'assets', uidAsset, 'advanced-features', 'bulk-actions', ...(params ? [params] : [])] as const +} + +export const getAssetsAdvancedFeaturesBulkActionsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsAdvancedFeaturesBulkActionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesBulkActionsListQueryKey(uidAsset,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsAdvancedFeaturesBulkActionsList(uidAsset,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesBulkActionsListQueryKey(uidAsset, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsAdvancedFeaturesBulkActionsList(uidAsset, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsAdvancedFeaturesBulkActionsListQueryResult = NonNullable>> +export type AssetsAdvancedFeaturesBulkActionsListQueryResult = NonNullable< + Awaited> +> export type AssetsAdvancedFeaturesBulkActionsListQueryError = ErrorDetail +export function useAssetsAdvancedFeaturesBulkActionsList< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsAdvancedFeaturesBulkActionsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsAdvancedFeaturesBulkActionsListQueryOptions(uidAsset, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsAdvancedFeaturesBulkActionsList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsAdvancedFeaturesBulkActionsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsAdvancedFeaturesBulkActionsListQueryOptions(uidAsset,params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Create a bulk processing job @@ -809,75 +738,96 @@ export type assetsAdvancedFeaturesBulkActionsCreateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsAdvancedFeaturesBulkActionsCreateResponseComposite = assetsAdvancedFeaturesBulkActionsCreateResponse201 | assetsAdvancedFeaturesBulkActionsCreateResponse400 | assetsAdvancedFeaturesBulkActionsCreateResponse404; - -export type assetsAdvancedFeaturesBulkActionsCreateResponse = assetsAdvancedFeaturesBulkActionsCreateResponseComposite & { - headers: Headers; -} -export const getAssetsAdvancedFeaturesBulkActionsCreateUrl = (uidAsset: string,) => { +export type assetsAdvancedFeaturesBulkActionsCreateResponseComposite = + | assetsAdvancedFeaturesBulkActionsCreateResponse201 + | assetsAdvancedFeaturesBulkActionsCreateResponse400 + | assetsAdvancedFeaturesBulkActionsCreateResponse404 +export type assetsAdvancedFeaturesBulkActionsCreateResponse = + assetsAdvancedFeaturesBulkActionsCreateResponseComposite & { + headers: Headers + } - - +export const getAssetsAdvancedFeaturesBulkActionsCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/` } -export const assetsAdvancedFeaturesBulkActionsCreate = async (uidAsset: string, - bulkActionCreateRequest: BulkActionCreateRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAdvancedFeaturesBulkActionsCreateUrl(uidAsset), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - bulkActionCreateRequest,) +export const assetsAdvancedFeaturesBulkActionsCreate = async ( + uidAsset: string, + bulkActionCreateRequest: BulkActionCreateRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsAdvancedFeaturesBulkActionsCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(bulkActionCreateRequest), + }, + ) +} + +export const getAssetsAdvancedFeaturesBulkActionsCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: BulkActionCreateRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: BulkActionCreateRequest }, + TContext +> => { + const mutationKey = ['assetsAdvancedFeaturesBulkActionsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: BulkActionCreateRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsAdvancedFeaturesBulkActionsCreate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsAdvancedFeaturesBulkActionsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: BulkActionCreateRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: BulkActionCreateRequest}, TContext> => { - -const mutationKey = ['assetsAdvancedFeaturesBulkActionsCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: BulkActionCreateRequest}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsAdvancedFeaturesBulkActionsCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsAdvancedFeaturesBulkActionsCreateMutationResult = NonNullable>> - export type AssetsAdvancedFeaturesBulkActionsCreateMutationBody = BulkActionCreateRequest - export type AssetsAdvancedFeaturesBulkActionsCreateMutationError = ErrorObject | ErrorDetail - - export const useAssetsAdvancedFeaturesBulkActionsCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: BulkActionCreateRequest}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsAdvancedFeaturesBulkActionsCreateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetsAdvancedFeaturesBulkActionsCreateMutationResult = NonNullable< + Awaited> +> +export type AssetsAdvancedFeaturesBulkActionsCreateMutationBody = BulkActionCreateRequest +export type AssetsAdvancedFeaturesBulkActionsCreateMutationError = ErrorObject | ErrorDetail + +export const useAssetsAdvancedFeaturesBulkActionsCreate = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: BulkActionCreateRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsAdvancedFeaturesBulkActionsCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Retrieve a bulk processing job Returns detailed information about a single bulk processing job, including its @@ -897,83 +847,88 @@ export type assetsAdvancedFeaturesBulkActionsRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsAdvancedFeaturesBulkActionsRetrieveResponseComposite = assetsAdvancedFeaturesBulkActionsRetrieveResponse200 | assetsAdvancedFeaturesBulkActionsRetrieveResponse404; - -export type assetsAdvancedFeaturesBulkActionsRetrieveResponse = assetsAdvancedFeaturesBulkActionsRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsAdvancedFeaturesBulkActionsRetrieveUrl = (uidAsset: string, - actionUid: string,) => { +export type assetsAdvancedFeaturesBulkActionsRetrieveResponseComposite = + | assetsAdvancedFeaturesBulkActionsRetrieveResponse200 + | assetsAdvancedFeaturesBulkActionsRetrieveResponse404 - +export type assetsAdvancedFeaturesBulkActionsRetrieveResponse = + assetsAdvancedFeaturesBulkActionsRetrieveResponseComposite & { + headers: Headers + } +export const getAssetsAdvancedFeaturesBulkActionsRetrieveUrl = (uidAsset: string, actionUid: string) => { return `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/${actionUid}/` } -export const assetsAdvancedFeaturesBulkActionsRetrieve = async (uidAsset: string, - actionUid: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAdvancedFeaturesBulkActionsRetrieveUrl(uidAsset,actionUid), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsAdvancedFeaturesBulkActionsRetrieveQueryKey = (uidAsset: string, - actionUid: string,) => { - return ['api','v2','assets',uidAsset,'advanced-features','bulk-actions',actionUid] as const; - } - - -export const getAssetsAdvancedFeaturesBulkActionsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - actionUid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const assetsAdvancedFeaturesBulkActionsRetrieve = async ( + uidAsset: string, + actionUid: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsAdvancedFeaturesBulkActionsRetrieveUrl(uidAsset, actionUid), + { + ...options, + method: 'GET', + }, + ) +} + +export const getAssetsAdvancedFeaturesBulkActionsRetrieveQueryKey = (uidAsset: string, actionUid: string) => { + return ['api', 'v2', 'assets', uidAsset, 'advanced-features', 'bulk-actions', actionUid] as const +} + +export const getAssetsAdvancedFeaturesBulkActionsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + actionUid: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesBulkActionsRetrieveQueryKey(uidAsset,actionUid); - - + const queryKey = queryOptions?.queryKey ?? getAssetsAdvancedFeaturesBulkActionsRetrieveQueryKey(uidAsset, actionUid) - const queryFn: QueryFunction>> = ({ signal }) => assetsAdvancedFeaturesBulkActionsRetrieve(uidAsset,actionUid, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetsAdvancedFeaturesBulkActionsRetrieve(uidAsset, actionUid, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && actionUid), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && actionUid), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsAdvancedFeaturesBulkActionsRetrieveQueryResult = NonNullable>> +export type AssetsAdvancedFeaturesBulkActionsRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsAdvancedFeaturesBulkActionsRetrieveQueryError = ErrorDetail +export function useAssetsAdvancedFeaturesBulkActionsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + actionUid: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsAdvancedFeaturesBulkActionsRetrieveQueryOptions(uidAsset, actionUid, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsAdvancedFeaturesBulkActionsRetrieve>, TError = ErrorDetail>( - uidAsset: string, - actionUid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsAdvancedFeaturesBulkActionsRetrieveQueryOptions(uidAsset,actionUid,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Update a bulk processing job @@ -1005,77 +960,93 @@ export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponseComposite = assetsAdvancedFeaturesBulkActionsPartialUpdateResponse200 | assetsAdvancedFeaturesBulkActionsPartialUpdateResponse404; - -export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponse = assetsAdvancedFeaturesBulkActionsPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getAssetsAdvancedFeaturesBulkActionsPartialUpdateUrl = (uidAsset: string, - actionUid: string,) => { +export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponseComposite = + | assetsAdvancedFeaturesBulkActionsPartialUpdateResponse200 + | assetsAdvancedFeaturesBulkActionsPartialUpdateResponse404 - +export type assetsAdvancedFeaturesBulkActionsPartialUpdateResponse = + assetsAdvancedFeaturesBulkActionsPartialUpdateResponseComposite & { + headers: Headers + } +export const getAssetsAdvancedFeaturesBulkActionsPartialUpdateUrl = (uidAsset: string, actionUid: string) => { return `/api/v2/assets/${uidAsset}/advanced-features/bulk-actions/${actionUid}/` } -export const assetsAdvancedFeaturesBulkActionsPartialUpdate = async (uidAsset: string, - actionUid: string, - patchedBulkActionPatchRequest: PatchedBulkActionPatchRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAdvancedFeaturesBulkActionsPartialUpdateUrl(uidAsset,actionUid), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedBulkActionPatchRequest,) +export const assetsAdvancedFeaturesBulkActionsPartialUpdate = async ( + uidAsset: string, + actionUid: string, + patchedBulkActionPatchRequest: PatchedBulkActionPatchRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsAdvancedFeaturesBulkActionsPartialUpdateUrl(uidAsset, actionUid), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedBulkActionPatchRequest), + }, + ) +} + +export const getAssetsAdvancedFeaturesBulkActionsPartialUpdateMutationOptions = < + TError = ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; actionUid: string; data: PatchedBulkActionPatchRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; actionUid: string; data: PatchedBulkActionPatchRequest }, + TContext +> => { + const mutationKey = ['assetsAdvancedFeaturesBulkActionsPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; actionUid: string; data: PatchedBulkActionPatchRequest } + > = (props) => { + const { uidAsset, actionUid, data } = props ?? {} + + return assetsAdvancedFeaturesBulkActionsPartialUpdate(uidAsset, actionUid, data, requestOptions) } -);} - - - - -export const getAssetsAdvancedFeaturesBulkActionsPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;actionUid: string;data: PatchedBulkActionPatchRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;actionUid: string;data: PatchedBulkActionPatchRequest}, TContext> => { - -const mutationKey = ['assetsAdvancedFeaturesBulkActionsPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;actionUid: string;data: PatchedBulkActionPatchRequest}> = (props) => { - const {uidAsset,actionUid,data} = props ?? {}; - - return assetsAdvancedFeaturesBulkActionsPartialUpdate(uidAsset,actionUid,data,requestOptions) - } - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationResult = NonNullable>> - export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationBody = PatchedBulkActionPatchRequest - export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationError = ErrorDetail - - export const useAssetsAdvancedFeaturesBulkActionsPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;actionUid: string;data: PatchedBulkActionPatchRequest}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsAdvancedFeaturesBulkActionsPartialUpdateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationBody = PatchedBulkActionPatchRequest +export type AssetsAdvancedFeaturesBulkActionsPartialUpdateMutationError = ErrorDetail + +export const useAssetsAdvancedFeaturesBulkActionsPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; actionUid: string; data: PatchedBulkActionPatchRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsAdvancedFeaturesBulkActionsPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Delete a specific attachment of an Asset * `id` can only be the uid of attachment to be deleted @@ -1095,75 +1066,85 @@ export type assetsAttachmentsDestroyResponse404 = { data: ErrorDetail status: 404 } - -export type assetsAttachmentsDestroyResponseComposite = assetsAttachmentsDestroyResponse204 | assetsAttachmentsDestroyResponse400 | assetsAttachmentsDestroyResponse404; - -export type assetsAttachmentsDestroyResponse = assetsAttachmentsDestroyResponseComposite & { - headers: Headers; -} - -export const getAssetsAttachmentsDestroyUrl = (uidAsset: string, - id: number,) => { +export type assetsAttachmentsDestroyResponseComposite = + | assetsAttachmentsDestroyResponse204 + | assetsAttachmentsDestroyResponse400 + | assetsAttachmentsDestroyResponse404 - +export type assetsAttachmentsDestroyResponse = assetsAttachmentsDestroyResponseComposite & { + headers: Headers +} +export const getAssetsAttachmentsDestroyUrl = (uidAsset: string, id: number) => { return `/api/v2/assets/${uidAsset}/attachments/${id}/` } -export const assetsAttachmentsDestroy = async (uidAsset: string, - id: number, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAttachmentsDestroyUrl(uidAsset,id), - { +export const assetsAttachmentsDestroy = async ( + uidAsset: string, + id: number, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsAttachmentsDestroyUrl(uidAsset, id), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getAssetsAttachmentsDestroyMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: number }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: number }, + TContext +> => { + const mutationKey = ['assetsAttachmentsDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; id: number } + > = (props) => { + const { uidAsset, id } = props ?? {} + + return assetsAttachmentsDestroy(uidAsset, id, requestOptions) } -);} - - - - -export const getAssetsAttachmentsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: number}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;id: number}, TContext> => { - -const mutationKey = ['assetsAttachmentsDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string;id: number}> = (props) => { - const {uidAsset,id} = props ?? {}; - - return assetsAttachmentsDestroy(uidAsset,id,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetsAttachmentsDestroyMutationResult = NonNullable>> - - export type AssetsAttachmentsDestroyMutationError = ErrorObject | ErrorDetail +export type AssetsAttachmentsDestroyMutationResult = NonNullable>> - export const useAssetsAttachmentsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: number}, TContext>, request?: SecondParameter} - ) => { +export type AssetsAttachmentsDestroyMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsAttachmentsDestroyMutationOptions(options); +export const useAssetsAttachmentsDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: number }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsAttachmentsDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Get total audio duration for a list of attachments ```curl @@ -1213,75 +1194,86 @@ export type assetsAttachmentsAudioDurationCreateResponse200 = { data: AssetAttachmentAudioDurationResponse status: 200 } - -export type assetsAttachmentsAudioDurationCreateResponseComposite = assetsAttachmentsAudioDurationCreateResponse200; - -export type assetsAttachmentsAudioDurationCreateResponse = assetsAttachmentsAudioDurationCreateResponseComposite & { - headers: Headers; -} -export const getAssetsAttachmentsAudioDurationCreateUrl = (uidAsset: string,) => { +export type assetsAttachmentsAudioDurationCreateResponseComposite = assetsAttachmentsAudioDurationCreateResponse200 +export type assetsAttachmentsAudioDurationCreateResponse = assetsAttachmentsAudioDurationCreateResponseComposite & { + headers: Headers +} - - +export const getAssetsAttachmentsAudioDurationCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/attachments/audio-duration/` } -export const assetsAttachmentsAudioDurationCreate = async (uidAsset: string, - assetAttachmentAudioDurationRequest: AssetAttachmentAudioDurationRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAttachmentsAudioDurationCreateUrl(uidAsset), - { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - assetAttachmentAudioDurationRequest,) +export const assetsAttachmentsAudioDurationCreate = async ( + uidAsset: string, + assetAttachmentAudioDurationRequest: AssetAttachmentAudioDurationRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsAttachmentsAudioDurationCreateUrl(uidAsset), + { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(assetAttachmentAudioDurationRequest), + }, + ) +} + +export const getAssetsAttachmentsAudioDurationCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: AssetAttachmentAudioDurationRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: AssetAttachmentAudioDurationRequest }, + TContext +> => { + const mutationKey = ['assetsAttachmentsAudioDurationCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: AssetAttachmentAudioDurationRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsAttachmentsAudioDurationCreate(uidAsset, data, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} - -export const getAssetsAttachmentsAudioDurationCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: AssetAttachmentAudioDurationRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: AssetAttachmentAudioDurationRequest}, TContext> => { - -const mutationKey = ['assetsAttachmentsAudioDurationCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: AssetAttachmentAudioDurationRequest}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsAttachmentsAudioDurationCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsAttachmentsAudioDurationCreateMutationResult = NonNullable>> - export type AssetsAttachmentsAudioDurationCreateMutationBody = AssetAttachmentAudioDurationRequest - export type AssetsAttachmentsAudioDurationCreateMutationError = unknown - - export const useAssetsAttachmentsAudioDurationCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: AssetAttachmentAudioDurationRequest}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsAttachmentsAudioDurationCreateMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export type AssetsAttachmentsAudioDurationCreateMutationResult = NonNullable< + Awaited> +> +export type AssetsAttachmentsAudioDurationCreateMutationBody = AssetAttachmentAudioDurationRequest +export type AssetsAttachmentsAudioDurationCreateMutationError = unknown + +export const useAssetsAttachmentsAudioDurationCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: AssetAttachmentAudioDurationRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsAttachmentsAudioDurationCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Delete all attachments from a list of submissions ```curl @@ -1325,75 +1317,87 @@ export type assetsAttachmentsBulkDestroyResponse400 = { export type assetsAttachmentsBulkDestroyResponse404 = { data: ErrorDetail - status: 404 -} - -export type assetsAttachmentsBulkDestroyResponseComposite = assetsAttachmentsBulkDestroyResponse202 | assetsAttachmentsBulkDestroyResponse400 | assetsAttachmentsBulkDestroyResponse404; - -export type assetsAttachmentsBulkDestroyResponse = assetsAttachmentsBulkDestroyResponseComposite & { - headers: Headers; -} - -export const getAssetsAttachmentsBulkDestroyUrl = (uidAsset: string,) => { - - - - - return `/api/v2/assets/${uidAsset}/attachments/bulk/` -} - -export const assetsAttachmentsBulkDestroy = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsAttachmentsBulkDestroyUrl(uidAsset), - { - ...options, - method: 'DELETE' - - - } -);} - - - - -export const getAssetsAttachmentsBulkDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { - -const mutationKey = ['assetsAttachmentsBulkDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - + status: 404 +} - const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { - const {uidAsset} = props ?? {}; +export type assetsAttachmentsBulkDestroyResponseComposite = + | assetsAttachmentsBulkDestroyResponse202 + | assetsAttachmentsBulkDestroyResponse400 + | assetsAttachmentsBulkDestroyResponse404 - return assetsAttachmentsBulkDestroy(uidAsset,requestOptions) - } +export type assetsAttachmentsBulkDestroyResponse = assetsAttachmentsBulkDestroyResponseComposite & { + headers: Headers +} - +export const getAssetsAttachmentsBulkDestroyUrl = (uidAsset: string) => { + return `/api/v2/assets/${uidAsset}/attachments/bulk/` +} +export const assetsAttachmentsBulkDestroy = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsAttachmentsBulkDestroyUrl(uidAsset), { + ...options, + method: 'DELETE', + }) +} + +export const getAssetsAttachmentsBulkDestroyMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext +> => { + const mutationKey = ['assetsAttachmentsBulkDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { uidAsset: string }> = ( + props, + ) => { + const { uidAsset } = props ?? {} + + return assetsAttachmentsBulkDestroy(uidAsset, requestOptions) + } - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetsAttachmentsBulkDestroyMutationResult = NonNullable>> - - export type AssetsAttachmentsBulkDestroyMutationError = ErrorObject | ErrorDetail +export type AssetsAttachmentsBulkDestroyMutationResult = NonNullable< + Awaited> +> - export const useAssetsAttachmentsBulkDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsAttachmentsBulkDestroyMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsAttachmentsBulkDestroyMutationOptions(options); +export const useAssetsAttachmentsBulkDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsAttachmentsBulkDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## List of submissions for a specific asset By default, JSON format is used, but XML and GeoJSON are also available: @@ -1460,90 +1464,86 @@ export type assetsDataListResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataListResponseComposite = assetsDataListResponse200 | assetsDataListResponse404; - + +export type assetsDataListResponseComposite = assetsDataListResponse200 | assetsDataListResponse404 + export type assetsDataListResponse = assetsDataListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsDataListUrl = (uidAsset: string, - params?: AssetsDataListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsDataListUrl = (uidAsset: string, params?: AssetsDataListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/data/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/data/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/data/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/data/` } -export const assetsDataList = async (uidAsset: string, - params?: AssetsDataListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataListUrl(uidAsset,params), - { +export const assetsDataList = async ( + uidAsset: string, + params?: AssetsDataListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataListUrl(uidAsset, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsDataListQueryKey = (uidAsset: string, - params?: AssetsDataListParams,) => { - return ['api','v2','assets',uidAsset,'data', ...(params ? [params]: [])] as const; - } +export const getAssetsDataListQueryKey = (uidAsset: string, params?: AssetsDataListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'data', ...(params ? [params] : [])] as const +} - -export const getAssetsDataListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsDataListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsDataListQueryOptions = >, TError = ErrorDetail>( + uidAsset: string, + params?: AssetsDataListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsDataListQueryKey(uidAsset,params); - - + const queryKey = queryOptions?.queryKey ?? getAssetsDataListQueryKey(uidAsset, params) - const queryFn: QueryFunction>> = ({ signal }) => assetsDataList(uidAsset,params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetsDataList(uidAsset, params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsDataListQueryResult = NonNullable>> export type AssetsDataListQueryError = ErrorDetail - - export function useAssetsDataList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsDataListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + uidAsset: string, + params?: AssetsDataListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDataListQueryOptions(uidAsset, params, options) - const queryOptions = getAssetsDataListQueryOptions(uidAsset,params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Get a specific submission @@ -1590,95 +1590,92 @@ export type assetsDataRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataRetrieveResponseComposite = assetsDataRetrieveResponse200 | assetsDataRetrieveResponse404; - + +export type assetsDataRetrieveResponseComposite = assetsDataRetrieveResponse200 | assetsDataRetrieveResponse404 + export type assetsDataRetrieveResponse = assetsDataRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsDataRetrieveUrl = (uidAsset: string, - id: string, - params?: AssetsDataRetrieveParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsDataRetrieveUrl = (uidAsset: string, id: string, params?: AssetsDataRetrieveParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/data/${id}/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/data/${id}/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/data/${id}/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/data/${id}/` } -export const assetsDataRetrieve = async (uidAsset: string, - id: string, - params?: AssetsDataRetrieveParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataRetrieveUrl(uidAsset,id,params), - { +export const assetsDataRetrieve = async ( + uidAsset: string, + id: string, + params?: AssetsDataRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataRetrieveUrl(uidAsset, id, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsDataRetrieveQueryKey = (uidAsset: string, - id: string, - params?: AssetsDataRetrieveParams,) => { - return ['api','v2','assets',uidAsset,'data',id, ...(params ? [params]: [])] as const; - } +export const getAssetsDataRetrieveQueryKey = (uidAsset: string, id: string, params?: AssetsDataRetrieveParams) => { + return ['api', 'v2', 'assets', uidAsset, 'data', id, ...(params ? [params] : [])] as const +} - -export const getAssetsDataRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - id: string, - params?: AssetsDataRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsDataRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + params?: AssetsDataRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsDataRetrieveQueryKey(uidAsset,id,params); + const queryKey = queryOptions?.queryKey ?? getAssetsDataRetrieveQueryKey(uidAsset, id, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsDataRetrieve(uidAsset, id, params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsDataRetrieve(uidAsset,id,params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsDataRetrieveQueryResult = NonNullable>> export type AssetsDataRetrieveQueryError = ErrorDetail - - export function useAssetsDataRetrieve>, TError = ErrorDetail>( - uidAsset: string, - id: string, - params?: AssetsDataRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsDataRetrieveQueryOptions(uidAsset,id,params,options) + uidAsset: string, + id: string, + params?: AssetsDataRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDataRetrieveQueryOptions(uidAsset, id, params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Deletes current submission @@ -1692,75 +1689,79 @@ export type assetsDataDestroyResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataDestroyResponseComposite = assetsDataDestroyResponse204 | assetsDataDestroyResponse404; - -export type assetsDataDestroyResponse = assetsDataDestroyResponseComposite & { - headers: Headers; -} -export const getAssetsDataDestroyUrl = (uidAsset: string, - id: string,) => { +export type assetsDataDestroyResponseComposite = assetsDataDestroyResponse204 | assetsDataDestroyResponse404 +export type assetsDataDestroyResponse = assetsDataDestroyResponseComposite & { + headers: Headers +} - - +export const getAssetsDataDestroyUrl = (uidAsset: string, id: string) => { return `/api/v2/assets/${uidAsset}/data/${id}/` } -export const assetsDataDestroy = async (uidAsset: string, - id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataDestroyUrl(uidAsset,id), - { +export const assetsDataDestroy = async ( + uidAsset: string, + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataDestroyUrl(uidAsset, id), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getAssetsDataDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string }, + TContext +> => { + const mutationKey = ['assetsDataDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; id: string } + > = (props) => { + const { uidAsset, id } = props ?? {} + + return assetsDataDestroy(uidAsset, id, requestOptions) } -);} - - - - -export const getAssetsDataDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext> => { - -const mutationKey = ['assetsDataDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;id: string}> = (props) => { - const {uidAsset,id} = props ?? {}; - - return assetsDataDestroy(uidAsset,id,requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} - - export type AssetsDataDestroyMutationResult = NonNullable>> - - export type AssetsDataDestroyMutationError = ErrorDetail +export type AssetsDataDestroyMutationResult = NonNullable>> - export const useAssetsDataDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsDataDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsDataDestroyMutationOptions(options); +export const useAssetsDataDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDataDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Duplicate submission Duplicates the data of a submission @@ -1784,77 +1785,84 @@ export type assetsDataDuplicateCreateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataDuplicateCreateResponseComposite = assetsDataDuplicateCreateResponse200 | assetsDataDuplicateCreateResponse404; - -export type assetsDataDuplicateCreateResponse = assetsDataDuplicateCreateResponseComposite & { - headers: Headers; -} - -export const getAssetsDataDuplicateCreateUrl = (uidAsset: string, - id: string,) => { +export type assetsDataDuplicateCreateResponseComposite = + | assetsDataDuplicateCreateResponse200 + | assetsDataDuplicateCreateResponse404 - +export type assetsDataDuplicateCreateResponse = assetsDataDuplicateCreateResponseComposite & { + headers: Headers +} +export const getAssetsDataDuplicateCreateUrl = (uidAsset: string, id: string) => { return `/api/v2/assets/${uidAsset}/data/${id}/duplicate/` } -export const assetsDataDuplicateCreate = async (uidAsset: string, - id: string, - dataBulkDelete: DataBulkDelete, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataDuplicateCreateUrl(uidAsset,id), - { +export const assetsDataDuplicateCreate = async ( + uidAsset: string, + id: string, + dataBulkDelete: DataBulkDelete, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataDuplicateCreateUrl(uidAsset, id), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - dataBulkDelete,) + body: JSON.stringify(dataBulkDelete), + }) +} + +export const getAssetsDataDuplicateCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string; data: DataBulkDelete }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string; data: DataBulkDelete }, + TContext +> => { + const mutationKey = ['assetsDataDuplicateCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; id: string; data: DataBulkDelete } + > = (props) => { + const { uidAsset, id, data } = props ?? {} + + return assetsDataDuplicateCreate(uidAsset, id, data, requestOptions) } -);} - - - - -export const getAssetsDataDuplicateCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string;data: DataBulkDelete}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;id: string;data: DataBulkDelete}, TContext> => { - -const mutationKey = ['assetsDataDuplicateCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {uidAsset: string;id: string;data: DataBulkDelete}> = (props) => { - const {uidAsset,id,data} = props ?? {}; - - return assetsDataDuplicateCreate(uidAsset,id,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsDataDuplicateCreateMutationResult = NonNullable>> - export type AssetsDataDuplicateCreateMutationBody = DataBulkDelete - export type AssetsDataDuplicateCreateMutationError = ErrorDetail - - export const useAssetsDataDuplicateCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string;data: DataBulkDelete}, TContext>, request?: SecondParameter} - ) => { +export type AssetsDataDuplicateCreateMutationResult = NonNullable>> +export type AssetsDataDuplicateCreateMutationBody = DataBulkDelete +export type AssetsDataDuplicateCreateMutationError = ErrorDetail - const mutationOptions = getAssetsDataDuplicateCreateMutationOptions(options); +export const useAssetsDataDuplicateCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string; data: DataBulkDelete }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDataDuplicateCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Get submission url of enketo in edit mode `{id}` can be: @@ -1884,83 +1892,82 @@ export type assetsDataEditRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type assetsDataEditRetrieveResponseComposite = assetsDataEditRetrieveResponse200 | assetsDataEditRetrieveResponse403; - -export type assetsDataEditRetrieveResponse = assetsDataEditRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsDataEditRetrieveUrl = (uidAsset: string, - id: string,) => { +export type assetsDataEditRetrieveResponseComposite = + | assetsDataEditRetrieveResponse200 + | assetsDataEditRetrieveResponse403 - +export type assetsDataEditRetrieveResponse = assetsDataEditRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsDataEditRetrieveUrl = (uidAsset: string, id: string) => { return `/api/v2/assets/${uidAsset}/data/${id}/edit/` } -export const assetsDataEditRetrieve = async (uidAsset: string, - id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataEditRetrieveUrl(uidAsset,id), - { +export const assetsDataEditRetrieve = async ( + uidAsset: string, + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataEditRetrieveUrl(uidAsset, id), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsDataEditRetrieveQueryKey = (uidAsset: string, - id: string,) => { - return ['api','v2','assets',uidAsset,'data',id,'edit'] as const; - } +export const getAssetsDataEditRetrieveQueryKey = (uidAsset: string, id: string) => { + return ['api', 'v2', 'assets', uidAsset, 'data', id, 'edit'] as const +} - -export const getAssetsDataEditRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsDataEditRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsDataEditRetrieveQueryKey(uidAsset,id); - - + const queryKey = queryOptions?.queryKey ?? getAssetsDataEditRetrieveQueryKey(uidAsset, id) - const queryFn: QueryFunction>> = ({ signal }) => assetsDataEditRetrieve(uidAsset,id, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetsDataEditRetrieve(uidAsset, id, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsDataEditRetrieveQueryResult = NonNullable>> export type AssetsDataEditRetrieveQueryError = ErrorDetail +export function useAssetsDataEditRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDataEditRetrieveQueryOptions(uidAsset, id, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsDataEditRetrieve>, TError = ErrorDetail>( - uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsDataEditRetrieveQueryOptions(uidAsset,id,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Get submission url of enketo in edit mode @@ -1991,83 +1998,84 @@ export type assetsDataEnketoEditRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type assetsDataEnketoEditRetrieveResponseComposite = assetsDataEnketoEditRetrieveResponse200 | assetsDataEnketoEditRetrieveResponse403; - -export type assetsDataEnketoEditRetrieveResponse = assetsDataEnketoEditRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsDataEnketoEditRetrieveUrl = (uidAsset: string, - id: string,) => { +export type assetsDataEnketoEditRetrieveResponseComposite = + | assetsDataEnketoEditRetrieveResponse200 + | assetsDataEnketoEditRetrieveResponse403 - +export type assetsDataEnketoEditRetrieveResponse = assetsDataEnketoEditRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsDataEnketoEditRetrieveUrl = (uidAsset: string, id: string) => { return `/api/v2/assets/${uidAsset}/data/${id}/enketo/edit/` } -export const assetsDataEnketoEditRetrieve = async (uidAsset: string, - id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataEnketoEditRetrieveUrl(uidAsset,id), - { +export const assetsDataEnketoEditRetrieve = async ( + uidAsset: string, + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataEnketoEditRetrieveUrl(uidAsset, id), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsDataEnketoEditRetrieveQueryKey = (uidAsset: string, - id: string,) => { - return ['api','v2','assets',uidAsset,'data',id,'enketo','edit'] as const; - } +export const getAssetsDataEnketoEditRetrieveQueryKey = (uidAsset: string, id: string) => { + return ['api', 'v2', 'assets', uidAsset, 'data', id, 'enketo', 'edit'] as const +} - -export const getAssetsDataEnketoEditRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsDataEnketoEditRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoEditRetrieveQueryKey(uidAsset,id); - - + const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoEditRetrieveQueryKey(uidAsset, id) - const queryFn: QueryFunction>> = ({ signal }) => assetsDataEnketoEditRetrieve(uidAsset,id, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetsDataEnketoEditRetrieve(uidAsset, id, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsDataEnketoEditRetrieveQueryResult = NonNullable>> +export type AssetsDataEnketoEditRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsDataEnketoEditRetrieveQueryError = ErrorDetail +export function useAssetsDataEnketoEditRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDataEnketoEditRetrieveQueryOptions(uidAsset, id, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsDataEnketoEditRetrieve>, TError = ErrorDetail>( - uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsDataEnketoEditRetrieveQueryOptions(uidAsset,id,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Get submission url of enketo in edit mode @@ -2098,83 +2106,87 @@ export type assetsDataEnketoRedirectEditRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type assetsDataEnketoRedirectEditRetrieveResponseComposite = assetsDataEnketoRedirectEditRetrieveResponse200 | assetsDataEnketoRedirectEditRetrieveResponse403; - -export type assetsDataEnketoRedirectEditRetrieveResponse = assetsDataEnketoRedirectEditRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsDataEnketoRedirectEditRetrieveUrl = (uidAsset: string, - id: string,) => { +export type assetsDataEnketoRedirectEditRetrieveResponseComposite = + | assetsDataEnketoRedirectEditRetrieveResponse200 + | assetsDataEnketoRedirectEditRetrieveResponse403 +export type assetsDataEnketoRedirectEditRetrieveResponse = assetsDataEnketoRedirectEditRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsDataEnketoRedirectEditRetrieveUrl = (uidAsset: string, id: string) => { return `/api/v2/assets/${uidAsset}/data/${id}/enketo/redirect/edit/` } -export const assetsDataEnketoRedirectEditRetrieve = async (uidAsset: string, - id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataEnketoRedirectEditRetrieveUrl(uidAsset,id), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsDataEnketoRedirectEditRetrieveQueryKey = (uidAsset: string, - id: string,) => { - return ['api','v2','assets',uidAsset,'data',id,'enketo','redirect','edit'] as const; - } - - -export const getAssetsDataEnketoRedirectEditRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const assetsDataEnketoRedirectEditRetrieve = async ( + uidAsset: string, + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsDataEnketoRedirectEditRetrieveUrl(uidAsset, id), + { + ...options, + method: 'GET', + }, + ) +} + +export const getAssetsDataEnketoRedirectEditRetrieveQueryKey = (uidAsset: string, id: string) => { + return ['api', 'v2', 'assets', uidAsset, 'data', id, 'enketo', 'redirect', 'edit'] as const +} + +export const getAssetsDataEnketoRedirectEditRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoRedirectEditRetrieveQueryKey(uidAsset, id) - const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoRedirectEditRetrieveQueryKey(uidAsset,id); + const queryFn: QueryFunction>> = ({ signal }) => + assetsDataEnketoRedirectEditRetrieve(uidAsset, id, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => assetsDataEnketoRedirectEditRetrieve(uidAsset,id, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsDataEnketoRedirectEditRetrieveQueryResult = NonNullable>> +export type AssetsDataEnketoRedirectEditRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsDataEnketoRedirectEditRetrieveQueryError = ErrorDetail +export function useAssetsDataEnketoRedirectEditRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDataEnketoRedirectEditRetrieveQueryOptions(uidAsset, id, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsDataEnketoRedirectEditRetrieve>, TError = ErrorDetail>( - uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsDataEnketoRedirectEditRetrieveQueryOptions(uidAsset,id,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Get submission url of enketo in preview mode @@ -2203,83 +2215,87 @@ export type assetsDataEnketoRedirectViewRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type assetsDataEnketoRedirectViewRetrieveResponseComposite = assetsDataEnketoRedirectViewRetrieveResponse200 | assetsDataEnketoRedirectViewRetrieveResponse403; - -export type assetsDataEnketoRedirectViewRetrieveResponse = assetsDataEnketoRedirectViewRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsDataEnketoRedirectViewRetrieveUrl = (uidAsset: string, - id: string,) => { +export type assetsDataEnketoRedirectViewRetrieveResponseComposite = + | assetsDataEnketoRedirectViewRetrieveResponse200 + | assetsDataEnketoRedirectViewRetrieveResponse403 +export type assetsDataEnketoRedirectViewRetrieveResponse = assetsDataEnketoRedirectViewRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsDataEnketoRedirectViewRetrieveUrl = (uidAsset: string, id: string) => { return `/api/v2/assets/${uidAsset}/data/${id}/enketo/redirect/view/` } -export const assetsDataEnketoRedirectViewRetrieve = async (uidAsset: string, - id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataEnketoRedirectViewRetrieveUrl(uidAsset,id), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsDataEnketoRedirectViewRetrieveQueryKey = (uidAsset: string, - id: string,) => { - return ['api','v2','assets',uidAsset,'data',id,'enketo','redirect','view'] as const; - } - - -export const getAssetsDataEnketoRedirectViewRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const assetsDataEnketoRedirectViewRetrieve = async ( + uidAsset: string, + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsDataEnketoRedirectViewRetrieveUrl(uidAsset, id), + { + ...options, + method: 'GET', + }, + ) +} + +export const getAssetsDataEnketoRedirectViewRetrieveQueryKey = (uidAsset: string, id: string) => { + return ['api', 'v2', 'assets', uidAsset, 'data', id, 'enketo', 'redirect', 'view'] as const +} + +export const getAssetsDataEnketoRedirectViewRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoRedirectViewRetrieveQueryKey(uidAsset,id); - - + const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoRedirectViewRetrieveQueryKey(uidAsset, id) - const queryFn: QueryFunction>> = ({ signal }) => assetsDataEnketoRedirectViewRetrieve(uidAsset,id, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetsDataEnketoRedirectViewRetrieve(uidAsset, id, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsDataEnketoRedirectViewRetrieveQueryResult = NonNullable>> +export type AssetsDataEnketoRedirectViewRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsDataEnketoRedirectViewRetrieveQueryError = ErrorDetail +export function useAssetsDataEnketoRedirectViewRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDataEnketoRedirectViewRetrieveQueryOptions(uidAsset, id, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsDataEnketoRedirectViewRetrieve>, TError = ErrorDetail>( - uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsDataEnketoRedirectViewRetrieveQueryOptions(uidAsset,id,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Get submission url of enketo in preview mode @@ -2308,83 +2324,84 @@ export type assetsDataEnketoViewRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type assetsDataEnketoViewRetrieveResponseComposite = assetsDataEnketoViewRetrieveResponse200 | assetsDataEnketoViewRetrieveResponse403; - -export type assetsDataEnketoViewRetrieveResponse = assetsDataEnketoViewRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsDataEnketoViewRetrieveUrl = (uidAsset: string, - id: string,) => { +export type assetsDataEnketoViewRetrieveResponseComposite = + | assetsDataEnketoViewRetrieveResponse200 + | assetsDataEnketoViewRetrieveResponse403 +export type assetsDataEnketoViewRetrieveResponse = assetsDataEnketoViewRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsDataEnketoViewRetrieveUrl = (uidAsset: string, id: string) => { return `/api/v2/assets/${uidAsset}/data/${id}/enketo/view/` } -export const assetsDataEnketoViewRetrieve = async (uidAsset: string, - id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataEnketoViewRetrieveUrl(uidAsset,id), - { +export const assetsDataEnketoViewRetrieve = async ( + uidAsset: string, + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataEnketoViewRetrieveUrl(uidAsset, id), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsDataEnketoViewRetrieveQueryKey = (uidAsset: string, - id: string,) => { - return ['api','v2','assets',uidAsset,'data',id,'enketo','view'] as const; - } +export const getAssetsDataEnketoViewRetrieveQueryKey = (uidAsset: string, id: string) => { + return ['api', 'v2', 'assets', uidAsset, 'data', id, 'enketo', 'view'] as const +} - -export const getAssetsDataEnketoViewRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsDataEnketoViewRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoViewRetrieveQueryKey(uidAsset,id); + const queryKey = queryOptions?.queryKey ?? getAssetsDataEnketoViewRetrieveQueryKey(uidAsset, id) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsDataEnketoViewRetrieve(uidAsset, id, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsDataEnketoViewRetrieve(uidAsset,id, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsDataEnketoViewRetrieveQueryResult = NonNullable>> +export type AssetsDataEnketoViewRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsDataEnketoViewRetrieveQueryError = ErrorDetail +export function useAssetsDataEnketoViewRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDataEnketoViewRetrieveQueryOptions(uidAsset, id, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsDataEnketoViewRetrieve>, TError = ErrorDetail>( - uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getAssetsDataEnketoViewRetrieveQueryOptions(uidAsset,id,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Get validation statuses Retrieves the validation status of a submission. @@ -2399,173 +2416,193 @@ export type assetsDataValidationStatusRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataValidationStatusRetrieveResponseComposite = assetsDataValidationStatusRetrieveResponse200 | assetsDataValidationStatusRetrieveResponse404; - -export type assetsDataValidationStatusRetrieveResponse = assetsDataValidationStatusRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsDataValidationStatusRetrieveUrl = (uidAsset: string, - id: string,) => { +export type assetsDataValidationStatusRetrieveResponseComposite = + | assetsDataValidationStatusRetrieveResponse200 + | assetsDataValidationStatusRetrieveResponse404 - +export type assetsDataValidationStatusRetrieveResponse = assetsDataValidationStatusRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsDataValidationStatusRetrieveUrl = (uidAsset: string, id: string) => { return `/api/v2/assets/${uidAsset}/data/${id}/validation_status/` } -export const assetsDataValidationStatusRetrieve = async (uidAsset: string, - id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataValidationStatusRetrieveUrl(uidAsset,id), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsDataValidationStatusRetrieveQueryKey = (uidAsset: string, - id: string,) => { - return ['api','v2','assets',uidAsset,'data',id,'validation_status'] as const; - } - - -export const getAssetsDataValidationStatusRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const assetsDataValidationStatusRetrieve = async ( + uidAsset: string, + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsDataValidationStatusRetrieveUrl(uidAsset, id), + { + ...options, + method: 'GET', + }, + ) +} + +export const getAssetsDataValidationStatusRetrieveQueryKey = (uidAsset: string, id: string) => { + return ['api', 'v2', 'assets', uidAsset, 'data', id, 'validation_status'] as const +} + +export const getAssetsDataValidationStatusRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsDataValidationStatusRetrieveQueryKey(uidAsset,id); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsDataValidationStatusRetrieve(uidAsset,id, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetsDataValidationStatusRetrieveQueryKey(uidAsset, id) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsDataValidationStatusRetrieve(uidAsset, id, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && id), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsDataValidationStatusRetrieveQueryResult = NonNullable>> +export type AssetsDataValidationStatusRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsDataValidationStatusRetrieveQueryError = ErrorDetail +export function useAssetsDataValidationStatusRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + id: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDataValidationStatusRetrieveQueryOptions(uidAsset, id, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsDataValidationStatusRetrieve>, TError = ErrorDetail>( - uidAsset: string, - id: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsDataValidationStatusRetrieveQueryOptions(uidAsset,id,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; -} - - - -/** - * ## Update the validation of a submission - -The validation status of the submission can be updated. The `validation_status.uid` should be a `string`, and it must be one of the following values: - -- `validation_status_approved` -- `validation_status_not_approved` -- `validation_status_on_hold` - - */ -export type assetsDataValidationStatusPartialUpdateResponse200 = { - data: DataValidationStatusUpdateResponse - status: 200 -} - -export type assetsDataValidationStatusPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataValidationStatusPartialUpdateResponseComposite = assetsDataValidationStatusPartialUpdateResponse200 | assetsDataValidationStatusPartialUpdateResponse404; - -export type assetsDataValidationStatusPartialUpdateResponse = assetsDataValidationStatusPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getAssetsDataValidationStatusPartialUpdateUrl = (uidAsset: string, - id: string,) => { - + query.queryKey = queryOptions.queryKey - - - return `/api/v2/assets/${uidAsset}/data/${id}/validation_status/` + return query } -export const assetsDataValidationStatusPartialUpdate = async (uidAsset: string, - id: string, - patchedDataValidationStatusUpdatePayload: PatchedDataValidationStatusUpdatePayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataValidationStatusPartialUpdateUrl(uidAsset,id), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedDataValidationStatusUpdatePayload,) - } -);} - - - - -export const getAssetsDataValidationStatusPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string;data: PatchedDataValidationStatusUpdatePayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;id: string;data: PatchedDataValidationStatusUpdatePayload}, TContext> => { - -const mutationKey = ['assetsDataValidationStatusPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - +/** + * ## Update the validation of a submission +The validation status of the submission can be updated. The `validation_status.uid` should be a `string`, and it must be one of the following values: - const mutationFn: MutationFunction>, {uidAsset: string;id: string;data: PatchedDataValidationStatusUpdatePayload}> = (props) => { - const {uidAsset,id,data} = props ?? {}; +- `validation_status_approved` +- `validation_status_not_approved` +- `validation_status_on_hold` - return assetsDataValidationStatusPartialUpdate(uidAsset,id,data,requestOptions) - } + */ +export type assetsDataValidationStatusPartialUpdateResponse200 = { + data: DataValidationStatusUpdateResponse + status: 200 +} - +export type assetsDataValidationStatusPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} +export type assetsDataValidationStatusPartialUpdateResponseComposite = + | assetsDataValidationStatusPartialUpdateResponse200 + | assetsDataValidationStatusPartialUpdateResponse404 - return { mutationFn, ...mutationOptions }} +export type assetsDataValidationStatusPartialUpdateResponse = + assetsDataValidationStatusPartialUpdateResponseComposite & { + headers: Headers + } - export type AssetsDataValidationStatusPartialUpdateMutationResult = NonNullable>> - export type AssetsDataValidationStatusPartialUpdateMutationBody = PatchedDataValidationStatusUpdatePayload - export type AssetsDataValidationStatusPartialUpdateMutationError = ErrorDetail +export const getAssetsDataValidationStatusPartialUpdateUrl = (uidAsset: string, id: string) => { + return `/api/v2/assets/${uidAsset}/data/${id}/validation_status/` +} - export const useAssetsDataValidationStatusPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string;data: PatchedDataValidationStatusUpdatePayload}, TContext>, request?: SecondParameter} - ) => { +export const assetsDataValidationStatusPartialUpdate = async ( + uidAsset: string, + id: string, + patchedDataValidationStatusUpdatePayload: PatchedDataValidationStatusUpdatePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsDataValidationStatusPartialUpdateUrl(uidAsset, id), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedDataValidationStatusUpdatePayload), + }, + ) +} + +export const getAssetsDataValidationStatusPartialUpdateMutationOptions = < + TError = ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string; data: PatchedDataValidationStatusUpdatePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string; data: PatchedDataValidationStatusUpdatePayload }, + TContext +> => { + const mutationKey = ['assetsDataValidationStatusPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; id: string; data: PatchedDataValidationStatusUpdatePayload } + > = (props) => { + const { uidAsset, id, data } = props ?? {} + + return assetsDataValidationStatusPartialUpdate(uidAsset, id, data, requestOptions) + } - const mutationOptions = getAssetsDataValidationStatusPartialUpdateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetsDataValidationStatusPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsDataValidationStatusPartialUpdateMutationBody = PatchedDataValidationStatusUpdatePayload +export type AssetsDataValidationStatusPartialUpdateMutationError = ErrorDetail + +export const useAssetsDataValidationStatusPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string; data: PatchedDataValidationStatusUpdatePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDataValidationStatusPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Delete validation status */ @@ -2578,75 +2615,89 @@ export type assetsDataValidationStatusDestroyResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataValidationStatusDestroyResponseComposite = assetsDataValidationStatusDestroyResponse204 | assetsDataValidationStatusDestroyResponse404; - -export type assetsDataValidationStatusDestroyResponse = assetsDataValidationStatusDestroyResponseComposite & { - headers: Headers; -} - -export const getAssetsDataValidationStatusDestroyUrl = (uidAsset: string, - id: string,) => { +export type assetsDataValidationStatusDestroyResponseComposite = + | assetsDataValidationStatusDestroyResponse204 + | assetsDataValidationStatusDestroyResponse404 - +export type assetsDataValidationStatusDestroyResponse = assetsDataValidationStatusDestroyResponseComposite & { + headers: Headers +} +export const getAssetsDataValidationStatusDestroyUrl = (uidAsset: string, id: string) => { return `/api/v2/assets/${uidAsset}/data/${id}/validation_status/` } -export const assetsDataValidationStatusDestroy = async (uidAsset: string, - id: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataValidationStatusDestroyUrl(uidAsset,id), - { - ...options, - method: 'DELETE' - - +export const assetsDataValidationStatusDestroy = async ( + uidAsset: string, + id: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsDataValidationStatusDestroyUrl(uidAsset, id), + { + ...options, + method: 'DELETE', + }, + ) +} + +export const getAssetsDataValidationStatusDestroyMutationOptions = < + TError = ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string }, + TContext +> => { + const mutationKey = ['assetsDataValidationStatusDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; id: string } + > = (props) => { + const { uidAsset, id } = props ?? {} + + return assetsDataValidationStatusDestroy(uidAsset, id, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} +export type AssetsDataValidationStatusDestroyMutationResult = NonNullable< + Awaited> +> -export const getAssetsDataValidationStatusDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext> => { - -const mutationKey = ['assetsDataValidationStatusDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;id: string}> = (props) => { - const {uidAsset,id} = props ?? {}; - - return assetsDataValidationStatusDestroy(uidAsset,id,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsDataValidationStatusDestroyMutationResult = NonNullable>> - - export type AssetsDataValidationStatusDestroyMutationError = ErrorDetail - - export const useAssetsDataValidationStatusDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;id: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsDataValidationStatusDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsDataValidationStatusDestroyMutationOptions(options); +export const useAssetsDataValidationStatusDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; id: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDataValidationStatusDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retrieve submission supplementary data This endpoint allows you to retrieve supplementary data attached to a submission. @@ -2687,83 +2738,85 @@ export type assetsDataSupplementRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type assetsDataSupplementRetrieveResponseComposite = assetsDataSupplementRetrieveResponse200 | assetsDataSupplementRetrieveResponse400 | assetsDataSupplementRetrieveResponse401; - -export type assetsDataSupplementRetrieveResponse = assetsDataSupplementRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsDataSupplementRetrieveUrl = (uidAsset: string, - rootUuid: string,) => { +export type assetsDataSupplementRetrieveResponseComposite = + | assetsDataSupplementRetrieveResponse200 + | assetsDataSupplementRetrieveResponse400 + | assetsDataSupplementRetrieveResponse401 +export type assetsDataSupplementRetrieveResponse = assetsDataSupplementRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsDataSupplementRetrieveUrl = (uidAsset: string, rootUuid: string) => { return `/api/v2/assets/${uidAsset}/data/${rootUuid}/supplement/` } -export const assetsDataSupplementRetrieve = async (uidAsset: string, - rootUuid: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataSupplementRetrieveUrl(uidAsset,rootUuid), - { +export const assetsDataSupplementRetrieve = async ( + uidAsset: string, + rootUuid: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataSupplementRetrieveUrl(uidAsset, rootUuid), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsDataSupplementRetrieveQueryKey = (uidAsset: string, - rootUuid: string,) => { - return ['api','v2','assets',uidAsset,'data',rootUuid,'supplement'] as const; - } +export const getAssetsDataSupplementRetrieveQueryKey = (uidAsset: string, rootUuid: string) => { + return ['api', 'v2', 'assets', uidAsset, 'data', rootUuid, 'supplement'] as const +} - -export const getAssetsDataSupplementRetrieveQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidAsset: string, - rootUuid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsDataSupplementRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidAsset: string, + rootUuid: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsDataSupplementRetrieveQueryKey(uidAsset,rootUuid); + const queryKey = queryOptions?.queryKey ?? getAssetsDataSupplementRetrieveQueryKey(uidAsset, rootUuid) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsDataSupplementRetrieve(uidAsset, rootUuid, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsDataSupplementRetrieve(uidAsset,rootUuid, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && rootUuid), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && rootUuid), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsDataSupplementRetrieveQueryResult = NonNullable>> +export type AssetsDataSupplementRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsDataSupplementRetrieveQueryError = ErrorObject | ErrorDetail +export function useAssetsDataSupplementRetrieve< + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidAsset: string, + rootUuid: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDataSupplementRetrieveQueryOptions(uidAsset, rootUuid, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsDataSupplementRetrieve>, TError = ErrorObject | ErrorDetail>( - uidAsset: string, - rootUuid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getAssetsDataSupplementRetrieveQueryOptions(uidAsset,rootUuid,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Update submission supplementary data @@ -2799,77 +2852,93 @@ export type assetsDataSupplementPartialUpdateResponse401 = { data: ErrorDetail status: 401 } - -export type assetsDataSupplementPartialUpdateResponseComposite = assetsDataSupplementPartialUpdateResponse200 | assetsDataSupplementPartialUpdateResponse400 | assetsDataSupplementPartialUpdateResponse401; - -export type assetsDataSupplementPartialUpdateResponse = assetsDataSupplementPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getAssetsDataSupplementPartialUpdateUrl = (uidAsset: string, - rootUuid: string,) => { +export type assetsDataSupplementPartialUpdateResponseComposite = + | assetsDataSupplementPartialUpdateResponse200 + | assetsDataSupplementPartialUpdateResponse400 + | assetsDataSupplementPartialUpdateResponse401 - +export type assetsDataSupplementPartialUpdateResponse = assetsDataSupplementPartialUpdateResponseComposite & { + headers: Headers +} +export const getAssetsDataSupplementPartialUpdateUrl = (uidAsset: string, rootUuid: string) => { return `/api/v2/assets/${uidAsset}/data/${rootUuid}/supplement/` } -export const assetsDataSupplementPartialUpdate = async (uidAsset: string, - rootUuid: string, - patchedDataSupplementPayload: PatchedDataSupplementPayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataSupplementPartialUpdateUrl(uidAsset,rootUuid), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedDataSupplementPayload,) +export const assetsDataSupplementPartialUpdate = async ( + uidAsset: string, + rootUuid: string, + patchedDataSupplementPayload: PatchedDataSupplementPayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsDataSupplementPartialUpdateUrl(uidAsset, rootUuid), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedDataSupplementPayload), + }, + ) +} + +export const getAssetsDataSupplementPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; rootUuid: string; data: PatchedDataSupplementPayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; rootUuid: string; data: PatchedDataSupplementPayload }, + TContext +> => { + const mutationKey = ['assetsDataSupplementPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; rootUuid: string; data: PatchedDataSupplementPayload } + > = (props) => { + const { uidAsset, rootUuid, data } = props ?? {} + + return assetsDataSupplementPartialUpdate(uidAsset, rootUuid, data, requestOptions) } -);} - - - -export const getAssetsDataSupplementPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;rootUuid: string;data: PatchedDataSupplementPayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;rootUuid: string;data: PatchedDataSupplementPayload}, TContext> => { - -const mutationKey = ['assetsDataSupplementPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;rootUuid: string;data: PatchedDataSupplementPayload}> = (props) => { - const {uidAsset,rootUuid,data} = props ?? {}; - - return assetsDataSupplementPartialUpdate(uidAsset,rootUuid,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsDataSupplementPartialUpdateMutationResult = NonNullable>> - export type AssetsDataSupplementPartialUpdateMutationBody = PatchedDataSupplementPayload - export type AssetsDataSupplementPartialUpdateMutationError = ErrorObject | ErrorDetail - - export const useAssetsDataSupplementPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;rootUuid: string;data: PatchedDataSupplementPayload}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsDataSupplementPartialUpdateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetsDataSupplementPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsDataSupplementPartialUpdateMutationBody = PatchedDataSupplementPayload +export type AssetsDataSupplementPartialUpdateMutationError = ErrorObject | ErrorDetail + +export const useAssetsDataSupplementPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; rootUuid: string; data: PatchedDataSupplementPayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDataSupplementPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Get an asset's attachment using xpath * `uid_data` can be the primary key of the submission or its `uuid`. @@ -2904,95 +2973,106 @@ export type assetsDataAttachmentsListResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataAttachmentsListResponseComposite = assetsDataAttachmentsListResponse200 | assetsDataAttachmentsListResponse400 | assetsDataAttachmentsListResponse404; - + +export type assetsDataAttachmentsListResponseComposite = + | assetsDataAttachmentsListResponse200 + | assetsDataAttachmentsListResponse400 + | assetsDataAttachmentsListResponse404 + export type assetsDataAttachmentsListResponse = assetsDataAttachmentsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsDataAttachmentsListUrl = (uidAsset: string, - uidData: string, - params: AssetsDataAttachmentsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsDataAttachmentsListUrl = ( + uidAsset: string, + uidData: string, + params: AssetsDataAttachmentsListParams, +) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/` } -export const assetsDataAttachmentsList = async (uidAsset: string, - uidData: string, - params: AssetsDataAttachmentsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataAttachmentsListUrl(uidAsset,uidData,params), - { +export const assetsDataAttachmentsList = async ( + uidAsset: string, + uidData: string, + params: AssetsDataAttachmentsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataAttachmentsListUrl(uidAsset, uidData, params), { ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsDataAttachmentsListQueryKey = (uidAsset: string, - uidData: string, - params: AssetsDataAttachmentsListParams,) => { - return ['api','v2','assets',uidAsset,'data',uidData,'attachments', ...(params ? [params]: [])] as const; - } + method: 'GET', + }) +} - -export const getAssetsDataAttachmentsListQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidAsset: string, - uidData: string, - params: AssetsDataAttachmentsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsDataAttachmentsListQueryKey = ( + uidAsset: string, + uidData: string, + params: AssetsDataAttachmentsListParams, ) => { + return ['api', 'v2', 'assets', uidAsset, 'data', uidData, 'attachments', ...(params ? [params] : [])] as const +} + +export const getAssetsDataAttachmentsListQueryOptions = < + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidAsset: string, + uidData: string, + params: AssetsDataAttachmentsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsDataAttachmentsListQueryKey(uidAsset,uidData,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsDataAttachmentsList(uidAsset,uidData,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getAssetsDataAttachmentsListQueryKey(uidAsset, uidData, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsDataAttachmentsList(uidAsset, uidData, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidAsset && uidData), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidData), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsDataAttachmentsListQueryResult = NonNullable>> export type AssetsDataAttachmentsListQueryError = ErrorObject | ErrorDetail +export function useAssetsDataAttachmentsList< + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidAsset: string, + uidData: string, + params: AssetsDataAttachmentsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsDataAttachmentsListQueryOptions(uidAsset, uidData, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsDataAttachmentsList>, TError = ErrorObject | ErrorDetail>( - uidAsset: string, - uidData: string, - params: AssetsDataAttachmentsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsDataAttachmentsListQueryOptions(uidAsset,uidData,params,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Get an asset's attachment using the ID @@ -3033,100 +3113,111 @@ export type attachmentRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type attachmentRetrieveResponseComposite = attachmentRetrieveResponse200 | attachmentRetrieveResponse400 | attachmentRetrieveResponse404; - + +export type attachmentRetrieveResponseComposite = + | attachmentRetrieveResponse200 + | attachmentRetrieveResponse400 + | attachmentRetrieveResponse404 + export type attachmentRetrieveResponse = attachmentRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getAttachmentRetrieveUrl = (uidAsset: string, - uidData: string, - id: number, - params?: AttachmentRetrieveParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAttachmentRetrieveUrl = ( + uidAsset: string, + uidData: string, + id: number, + params?: AttachmentRetrieveParams, +) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/` } -export const attachmentRetrieve = async (uidAsset: string, - uidData: string, - id: number, - params?: AttachmentRetrieveParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAttachmentRetrieveUrl(uidAsset,uidData,id,params), - { +export const attachmentRetrieve = async ( + uidAsset: string, + uidData: string, + id: number, + params?: AttachmentRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAttachmentRetrieveUrl(uidAsset, uidData, id, params), { ...options, - method: 'GET' - - - } -);} - - - -export const getAttachmentRetrieveQueryKey = (uidAsset: string, - uidData: string, - id: number, - params?: AttachmentRetrieveParams,) => { - return ['api','v2','assets',uidAsset,'data',uidData,'attachments',id, ...(params ? [params]: [])] as const; - } + method: 'GET', + }) +} - -export const getAttachmentRetrieveQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidAsset: string, - uidData: string, - id: number, - params?: AttachmentRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAttachmentRetrieveQueryKey = ( + uidAsset: string, + uidData: string, + id: number, + params?: AttachmentRetrieveParams, ) => { + return ['api', 'v2', 'assets', uidAsset, 'data', uidData, 'attachments', id, ...(params ? [params] : [])] as const +} + +export const getAttachmentRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidAsset: string, + uidData: string, + id: number, + params?: AttachmentRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAttachmentRetrieveQueryKey(uidAsset,uidData,id,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => attachmentRetrieve(uidAsset,uidData,id,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getAttachmentRetrieveQueryKey(uidAsset, uidData, id, params) - + const queryFn: QueryFunction>> = ({ signal }) => + attachmentRetrieve(uidAsset, uidData, id, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidAsset && uidData && id), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidData && id), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AttachmentRetrieveQueryResult = NonNullable>> export type AttachmentRetrieveQueryError = ErrorObject | ErrorDetail +export function useAttachmentRetrieve< + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidAsset: string, + uidData: string, + id: number, + params?: AttachmentRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAttachmentRetrieveQueryOptions(uidAsset, uidData, id, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAttachmentRetrieve>, TError = ErrorObject | ErrorDetail>( - uidAsset: string, - uidData: string, - id: number, - params?: AttachmentRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAttachmentRetrieveQueryOptions(uidAsset,uidData,id,params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Get a specific size of the user's attachment (Only for images) @@ -3156,93 +3247,83 @@ export type attachmentThumbnailResponse404 = { data: ErrorDetail status: 404 } - -export type attachmentThumbnailResponseComposite = attachmentThumbnailResponse200 | attachmentThumbnailResponse404; - -export type attachmentThumbnailResponse = attachmentThumbnailResponseComposite & { - headers: Headers; -} - -export const getAttachmentThumbnailUrl = (uidAsset: string, - uidData: string, - id: number, - suffix: string,) => { +export type attachmentThumbnailResponseComposite = attachmentThumbnailResponse200 | attachmentThumbnailResponse404 - +export type attachmentThumbnailResponse = attachmentThumbnailResponseComposite & { + headers: Headers +} +export const getAttachmentThumbnailUrl = (uidAsset: string, uidData: string, id: number, suffix: string) => { return `/api/v2/assets/${uidAsset}/data/${uidData}/attachments/${id}/${suffix}/` } -export const attachmentThumbnail = async (uidAsset: string, - uidData: string, - id: number, - suffix: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAttachmentThumbnailUrl(uidAsset,uidData,id,suffix), - { +export const attachmentThumbnail = async ( + uidAsset: string, + uidData: string, + id: number, + suffix: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAttachmentThumbnailUrl(uidAsset, uidData, id, suffix), { ...options, - method: 'GET' - - - } -);} - - - -export const getAttachmentThumbnailQueryKey = (uidAsset: string, - uidData: string, - id: number, - suffix: string,) => { - return ['api','v2','assets',uidAsset,'data',uidData,'attachments',id,suffix] as const; - } - - -export const getAttachmentThumbnailQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidData: string, - id: number, - suffix: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + method: 'GET', + }) +} + +export const getAttachmentThumbnailQueryKey = (uidAsset: string, uidData: string, id: number, suffix: string) => { + return ['api', 'v2', 'assets', uidAsset, 'data', uidData, 'attachments', id, suffix] as const +} + +export const getAttachmentThumbnailQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidData: string, + id: number, + suffix: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAttachmentThumbnailQueryKey(uidAsset,uidData,id,suffix); - - + const queryKey = queryOptions?.queryKey ?? getAttachmentThumbnailQueryKey(uidAsset, uidData, id, suffix) - const queryFn: QueryFunction>> = ({ signal }) => attachmentThumbnail(uidAsset,uidData,id,suffix, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + attachmentThumbnail(uidAsset, uidData, id, suffix, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidData && id && suffix), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidData && id && suffix), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AttachmentThumbnailQueryResult = NonNullable>> export type AttachmentThumbnailQueryError = ErrorDetail - - export function useAttachmentThumbnail>, TError = ErrorDetail>( - uidAsset: string, - uidData: string, - id: number, - suffix: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + uidAsset: string, + uidData: string, + id: number, + suffix: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAttachmentThumbnailQueryOptions(uidAsset, uidData, id, suffix, options) - const queryOptions = getAttachmentThumbnailQueryOptions(uidAsset,uidData,id,suffix,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Bulk updating of submissions @@ -3270,75 +3351,85 @@ export type assetsDataBulkPartialUpdateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataBulkPartialUpdateResponseComposite = assetsDataBulkPartialUpdateResponse200 | assetsDataBulkPartialUpdateResponse404; - -export type assetsDataBulkPartialUpdateResponse = assetsDataBulkPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getAssetsDataBulkPartialUpdateUrl = (uidAsset: string,) => { +export type assetsDataBulkPartialUpdateResponseComposite = + | assetsDataBulkPartialUpdateResponse200 + | assetsDataBulkPartialUpdateResponse404 - +export type assetsDataBulkPartialUpdateResponse = assetsDataBulkPartialUpdateResponseComposite & { + headers: Headers +} +export const getAssetsDataBulkPartialUpdateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/data/bulk/` } -export const assetsDataBulkPartialUpdate = async (uidAsset: string, - patchedDataBulkUpdate: PatchedDataBulkUpdate, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataBulkPartialUpdateUrl(uidAsset), - { +export const assetsDataBulkPartialUpdate = async ( + uidAsset: string, + patchedDataBulkUpdate: PatchedDataBulkUpdate, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataBulkPartialUpdateUrl(uidAsset), { ...options, method: 'PATCH', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedDataBulkUpdate,) + body: JSON.stringify(patchedDataBulkUpdate), + }) +} + +export const getAssetsDataBulkPartialUpdateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDataBulkUpdate }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDataBulkUpdate }, + TContext +> => { + const mutationKey = ['assetsDataBulkPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: PatchedDataBulkUpdate } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsDataBulkPartialUpdate(uidAsset, data, requestOptions) } -);} + return { mutationFn, ...mutationOptions } +} - - -export const getAssetsDataBulkPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataBulkUpdate}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataBulkUpdate}, TContext> => { - -const mutationKey = ['assetsDataBulkPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: PatchedDataBulkUpdate}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsDataBulkPartialUpdate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsDataBulkPartialUpdateMutationResult = NonNullable>> - export type AssetsDataBulkPartialUpdateMutationBody = PatchedDataBulkUpdate - export type AssetsDataBulkPartialUpdateMutationError = ErrorDetail - - export const useAssetsDataBulkPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataBulkUpdate}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsDataBulkPartialUpdateMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export type AssetsDataBulkPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsDataBulkPartialUpdateMutationBody = PatchedDataBulkUpdate +export type AssetsDataBulkPartialUpdateMutationError = ErrorDetail + +export const useAssetsDataBulkPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDataBulkUpdate }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDataBulkPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Bulk delete submissions ```curl @@ -3379,73 +3470,72 @@ export type assetsDataBulkDestroyResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataBulkDestroyResponseComposite = assetsDataBulkDestroyResponse200 | assetsDataBulkDestroyResponse404; - -export type assetsDataBulkDestroyResponse = assetsDataBulkDestroyResponseComposite & { - headers: Headers; -} -export const getAssetsDataBulkDestroyUrl = (uidAsset: string,) => { +export type assetsDataBulkDestroyResponseComposite = assetsDataBulkDestroyResponse200 | assetsDataBulkDestroyResponse404 +export type assetsDataBulkDestroyResponse = assetsDataBulkDestroyResponseComposite & { + headers: Headers +} - - +export const getAssetsDataBulkDestroyUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/data/bulk/` } -export const assetsDataBulkDestroy = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataBulkDestroyUrl(uidAsset), - { +export const assetsDataBulkDestroy = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataBulkDestroyUrl(uidAsset), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getAssetsDataBulkDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, { uidAsset: string }, TContext> => { + const mutationKey = ['assetsDataBulkDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { uidAsset: string }> = ( + props, + ) => { + const { uidAsset } = props ?? {} + + return assetsDataBulkDestroy(uidAsset, requestOptions) } -);} - - - - -export const getAssetsDataBulkDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { - -const mutationKey = ['assetsDataBulkDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { - const {uidAsset} = props ?? {}; - - return assetsDataBulkDestroy(uidAsset,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetsDataBulkDestroyMutationResult = NonNullable>> - - export type AssetsDataBulkDestroyMutationError = ErrorDetail +export type AssetsDataBulkDestroyMutationResult = NonNullable>> - export const useAssetsDataBulkDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsDataBulkDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsDataBulkDestroyMutationOptions(options); +export const useAssetsDataBulkDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDataBulkDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Bulk accept NLP results Accepts transcription or translation results for multiple submissions in a @@ -3508,75 +3598,89 @@ export type assetsDataSupplementsBulkCreateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataSupplementsBulkCreateResponseComposite = assetsDataSupplementsBulkCreateResponse200 | assetsDataSupplementsBulkCreateResponse400 | assetsDataSupplementsBulkCreateResponse404; - -export type assetsDataSupplementsBulkCreateResponse = assetsDataSupplementsBulkCreateResponseComposite & { - headers: Headers; -} - -export const getAssetsDataSupplementsBulkCreateUrl = (uidAsset: string,) => { +export type assetsDataSupplementsBulkCreateResponseComposite = + | assetsDataSupplementsBulkCreateResponse200 + | assetsDataSupplementsBulkCreateResponse400 + | assetsDataSupplementsBulkCreateResponse404 - +export type assetsDataSupplementsBulkCreateResponse = assetsDataSupplementsBulkCreateResponseComposite & { + headers: Headers +} +export const getAssetsDataSupplementsBulkCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/data/supplements/bulk/` } -export const assetsDataSupplementsBulkCreate = async (uidAsset: string, - bulkAcceptRequest: BulkAcceptRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataSupplementsBulkCreateUrl(uidAsset), - { +export const assetsDataSupplementsBulkCreate = async ( + uidAsset: string, + bulkAcceptRequest: BulkAcceptRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsDataSupplementsBulkCreateUrl(uidAsset), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - bulkAcceptRequest,) + body: JSON.stringify(bulkAcceptRequest), + }) +} + +export const getAssetsDataSupplementsBulkCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: BulkAcceptRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: BulkAcceptRequest }, + TContext +> => { + const mutationKey = ['assetsDataSupplementsBulkCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: BulkAcceptRequest } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsDataSupplementsBulkCreate(uidAsset, data, requestOptions) } -);} - - + return { mutationFn, ...mutationOptions } +} -export const getAssetsDataSupplementsBulkCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: BulkAcceptRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: BulkAcceptRequest}, TContext> => { - -const mutationKey = ['assetsDataSupplementsBulkCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: BulkAcceptRequest}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsDataSupplementsBulkCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsDataSupplementsBulkCreateMutationResult = NonNullable>> - export type AssetsDataSupplementsBulkCreateMutationBody = BulkAcceptRequest - export type AssetsDataSupplementsBulkCreateMutationError = ErrorObject | ErrorDetail - - export const useAssetsDataSupplementsBulkCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: BulkAcceptRequest}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsDataSupplementsBulkCreateMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export type AssetsDataSupplementsBulkCreateMutationResult = NonNullable< + Awaited> +> +export type AssetsDataSupplementsBulkCreateMutationBody = BulkAcceptRequest +export type AssetsDataSupplementsBulkCreateMutationError = ErrorObject | ErrorDetail + +export const useAssetsDataSupplementsBulkCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: BulkAcceptRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDataSupplementsBulkCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Bulk update submissions status * Where: "submissions_ids" (required) is a list of submission root id on the data @@ -3595,83 +3699,100 @@ Will return the number of submission updated as such: */ export type assetsDataValidationStatusesPartialUpdateResponse200 = { - data: DataStatusesUpdate - status: 200 -} - -export type assetsDataValidationStatusesPartialUpdateResponse404 = { - data: ErrorDetail - status: 404 -} - -export type assetsDataValidationStatusesPartialUpdateResponseComposite = assetsDataValidationStatusesPartialUpdateResponse200 | assetsDataValidationStatusesPartialUpdateResponse404; - -export type assetsDataValidationStatusesPartialUpdateResponse = assetsDataValidationStatusesPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getAssetsDataValidationStatusesPartialUpdateUrl = (uidAsset: string,) => { - - - - - return `/api/v2/assets/${uidAsset}/data/validation_statuses/` -} - -export const assetsDataValidationStatusesPartialUpdate = async (uidAsset: string, - patchedDataValidationStatusesUpdatePayload: PatchedDataValidationStatusesUpdatePayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataValidationStatusesPartialUpdateUrl(uidAsset), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedDataValidationStatusesUpdatePayload,) - } -);} - - - - -export const getAssetsDataValidationStatusesPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataValidationStatusesUpdatePayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataValidationStatusesUpdatePayload}, TContext> => { - -const mutationKey = ['assetsDataValidationStatusesPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: PatchedDataValidationStatusesUpdatePayload}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsDataValidationStatusesPartialUpdate(uidAsset,data,requestOptions) - } + data: DataStatusesUpdate + status: 200 +} - +export type assetsDataValidationStatusesPartialUpdateResponse404 = { + data: ErrorDetail + status: 404 +} +export type assetsDataValidationStatusesPartialUpdateResponseComposite = + | assetsDataValidationStatusesPartialUpdateResponse200 + | assetsDataValidationStatusesPartialUpdateResponse404 - return { mutationFn, ...mutationOptions }} +export type assetsDataValidationStatusesPartialUpdateResponse = + assetsDataValidationStatusesPartialUpdateResponseComposite & { + headers: Headers + } - export type AssetsDataValidationStatusesPartialUpdateMutationResult = NonNullable>> - export type AssetsDataValidationStatusesPartialUpdateMutationBody = PatchedDataValidationStatusesUpdatePayload - export type AssetsDataValidationStatusesPartialUpdateMutationError = ErrorDetail +export const getAssetsDataValidationStatusesPartialUpdateUrl = (uidAsset: string) => { + return `/api/v2/assets/${uidAsset}/data/validation_statuses/` +} - export const useAssetsDataValidationStatusesPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: PatchedDataValidationStatusesUpdatePayload}, TContext>, request?: SecondParameter} - ) => { +export const assetsDataValidationStatusesPartialUpdate = async ( + uidAsset: string, + patchedDataValidationStatusesUpdatePayload: PatchedDataValidationStatusesUpdatePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsDataValidationStatusesPartialUpdateUrl(uidAsset), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedDataValidationStatusesUpdatePayload), + }, + ) +} + +export const getAssetsDataValidationStatusesPartialUpdateMutationOptions = < + TError = ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDataValidationStatusesUpdatePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDataValidationStatusesUpdatePayload }, + TContext +> => { + const mutationKey = ['assetsDataValidationStatusesPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: PatchedDataValidationStatusesUpdatePayload } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsDataValidationStatusesPartialUpdate(uidAsset, data, requestOptions) + } - const mutationOptions = getAssetsDataValidationStatusesPartialUpdateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetsDataValidationStatusesPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsDataValidationStatusesPartialUpdateMutationBody = PatchedDataValidationStatusesUpdatePayload +export type AssetsDataValidationStatusesPartialUpdateMutationError = ErrorDetail + +export const useAssetsDataValidationStatusesPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: PatchedDataValidationStatusesUpdatePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDataValidationStatusesPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Bulk delete submissions status ```curl @@ -3717,73 +3838,88 @@ export type assetsDataValidationStatusesDestroyResponse404 = { data: ErrorDetail status: 404 } - -export type assetsDataValidationStatusesDestroyResponseComposite = assetsDataValidationStatusesDestroyResponse204 | assetsDataValidationStatusesDestroyResponse404; - -export type assetsDataValidationStatusesDestroyResponse = assetsDataValidationStatusesDestroyResponseComposite & { - headers: Headers; -} -export const getAssetsDataValidationStatusesDestroyUrl = (uidAsset: string,) => { +export type assetsDataValidationStatusesDestroyResponseComposite = + | assetsDataValidationStatusesDestroyResponse204 + | assetsDataValidationStatusesDestroyResponse404 +export type assetsDataValidationStatusesDestroyResponse = assetsDataValidationStatusesDestroyResponseComposite & { + headers: Headers +} - - +export const getAssetsDataValidationStatusesDestroyUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/data/validation_statuses/` } -export const assetsDataValidationStatusesDestroy = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsDataValidationStatusesDestroyUrl(uidAsset), - { - ...options, - method: 'DELETE' - - +export const assetsDataValidationStatusesDestroy = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsDataValidationStatusesDestroyUrl(uidAsset), + { + ...options, + method: 'DELETE', + }, + ) +} + +export const getAssetsDataValidationStatusesDestroyMutationOptions = < + TError = ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext +> => { + const mutationKey = ['assetsDataValidationStatusesDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string } + > = (props) => { + const { uidAsset } = props ?? {} + + return assetsDataValidationStatusesDestroy(uidAsset, requestOptions) } -);} - - - - -export const getAssetsDataValidationStatusesDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string}, TContext> => { - -const mutationKey = ['assetsDataValidationStatusesDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string}> = (props) => { - const {uidAsset} = props ?? {}; - - return assetsDataValidationStatusesDestroy(uidAsset,requestOptions) - } - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetsDataValidationStatusesDestroyMutationResult = NonNullable>> - - export type AssetsDataValidationStatusesDestroyMutationError = ErrorDetail +export type AssetsDataValidationStatusesDestroyMutationResult = NonNullable< + Awaited> +> - export const useAssetsDataValidationStatusesDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsDataValidationStatusesDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsDataValidationStatusesDestroyMutationOptions(options); +export const useAssetsDataValidationStatusesDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsDataValidationStatusesDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## List of export settings for a specific asset * _Required permissions: `view_submissions` (View submissions)_ @@ -3798,90 +3934,94 @@ export type assetsExportSettingsListResponse404 = { data: ErrorDetail status: 404 } - -export type assetsExportSettingsListResponseComposite = assetsExportSettingsListResponse200 | assetsExportSettingsListResponse404; - + +export type assetsExportSettingsListResponseComposite = + | assetsExportSettingsListResponse200 + | assetsExportSettingsListResponse404 + export type assetsExportSettingsListResponse = assetsExportSettingsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsExportSettingsListUrl = (uidAsset: string, - params?: AssetsExportSettingsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsExportSettingsListUrl = (uidAsset: string, params?: AssetsExportSettingsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/export-settings/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/export-settings/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/export-settings/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/export-settings/` } -export const assetsExportSettingsList = async (uidAsset: string, - params?: AssetsExportSettingsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsExportSettingsListUrl(uidAsset,params), - { +export const assetsExportSettingsList = async ( + uidAsset: string, + params?: AssetsExportSettingsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsExportSettingsListUrl(uidAsset, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsExportSettingsListQueryKey = (uidAsset: string, - params?: AssetsExportSettingsListParams,) => { - return ['api','v2','assets',uidAsset,'export-settings', ...(params ? [params]: [])] as const; - } +export const getAssetsExportSettingsListQueryKey = (uidAsset: string, params?: AssetsExportSettingsListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'export-settings', ...(params ? [params] : [])] as const +} - -export const getAssetsExportSettingsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsExportSettingsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsExportSettingsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsExportSettingsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsExportSettingsListQueryKey(uidAsset,params); + const queryKey = queryOptions?.queryKey ?? getAssetsExportSettingsListQueryKey(uidAsset, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsExportSettingsList(uidAsset, params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsExportSettingsList(uidAsset,params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsExportSettingsListQueryResult = NonNullable>> export type AssetsExportSettingsListQueryError = ErrorDetail +export function useAssetsExportSettingsList< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsExportSettingsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsExportSettingsListQueryOptions(uidAsset, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsExportSettingsList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsExportSettingsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsExportSettingsListQueryOptions(uidAsset,params,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Create an export setting for an asset @@ -3939,75 +4079,89 @@ export type assetsExportSettingsCreateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsExportSettingsCreateResponseComposite = assetsExportSettingsCreateResponse201 | assetsExportSettingsCreateResponse400 | assetsExportSettingsCreateResponse404; - -export type assetsExportSettingsCreateResponse = assetsExportSettingsCreateResponseComposite & { - headers: Headers; -} -export const getAssetsExportSettingsCreateUrl = (uidAsset: string,) => { +export type assetsExportSettingsCreateResponseComposite = + | assetsExportSettingsCreateResponse201 + | assetsExportSettingsCreateResponse400 + | assetsExportSettingsCreateResponse404 +export type assetsExportSettingsCreateResponse = assetsExportSettingsCreateResponseComposite & { + headers: Headers +} - - +export const getAssetsExportSettingsCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/export-settings/` } -export const assetsExportSettingsCreate = async (uidAsset: string, - exportSettingCreatePayload: ExportSettingCreatePayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsExportSettingsCreateUrl(uidAsset), - { +export const assetsExportSettingsCreate = async ( + uidAsset: string, + exportSettingCreatePayload: ExportSettingCreatePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsExportSettingsCreateUrl(uidAsset), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - exportSettingCreatePayload,) + body: JSON.stringify(exportSettingCreatePayload), + }) +} + +export const getAssetsExportSettingsCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: ExportSettingCreatePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: ExportSettingCreatePayload }, + TContext +> => { + const mutationKey = ['assetsExportSettingsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: ExportSettingCreatePayload } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsExportSettingsCreate(uidAsset, data, requestOptions) } -);} - - - -export const getAssetsExportSettingsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: ExportSettingCreatePayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: ExportSettingCreatePayload}, TContext> => { - -const mutationKey = ['assetsExportSettingsCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: ExportSettingCreatePayload}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsExportSettingsCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsExportSettingsCreateMutationResult = NonNullable>> - export type AssetsExportSettingsCreateMutationBody = ExportSettingCreatePayload - export type AssetsExportSettingsCreateMutationError = ErrorObject | ErrorDetail - - export const useAssetsExportSettingsCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: ExportSettingCreatePayload}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsExportSettingsCreateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetsExportSettingsCreateMutationResult = NonNullable< + Awaited> +> +export type AssetsExportSettingsCreateMutationBody = ExportSettingCreatePayload +export type AssetsExportSettingsCreateMutationError = ErrorObject | ErrorDetail + +export const useAssetsExportSettingsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: ExportSettingCreatePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsExportSettingsCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Retrieve a specific export setting * _Required permissions: `view_submissions` (View submissions)_ @@ -4022,83 +4176,87 @@ export type assetsExportSettingsRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsExportSettingsRetrieveResponseComposite = assetsExportSettingsRetrieveResponse200 | assetsExportSettingsRetrieveResponse404; - -export type assetsExportSettingsRetrieveResponse = assetsExportSettingsRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsExportSettingsRetrieveUrl = (uidAsset: string, - uidExportSetting: string,) => { +export type assetsExportSettingsRetrieveResponseComposite = + | assetsExportSettingsRetrieveResponse200 + | assetsExportSettingsRetrieveResponse404 - +export type assetsExportSettingsRetrieveResponse = assetsExportSettingsRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsExportSettingsRetrieveUrl = (uidAsset: string, uidExportSetting: string) => { return `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/` } -export const assetsExportSettingsRetrieve = async (uidAsset: string, - uidExportSetting: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsExportSettingsRetrieveUrl(uidAsset,uidExportSetting), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsExportSettingsRetrieveQueryKey = (uidAsset: string, - uidExportSetting: string,) => { - return ['api','v2','assets',uidAsset,'export-settings',uidExportSetting] as const; - } - - -export const getAssetsExportSettingsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidExportSetting: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const assetsExportSettingsRetrieve = async ( + uidAsset: string, + uidExportSetting: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsExportSettingsRetrieveUrl(uidAsset, uidExportSetting), + { + ...options, + method: 'GET', + }, + ) +} + +export const getAssetsExportSettingsRetrieveQueryKey = (uidAsset: string, uidExportSetting: string) => { + return ['api', 'v2', 'assets', uidAsset, 'export-settings', uidExportSetting] as const +} + +export const getAssetsExportSettingsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidExportSetting: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsExportSettingsRetrieveQueryKey(uidAsset,uidExportSetting); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsExportSettingsRetrieve(uidAsset,uidExportSetting, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetsExportSettingsRetrieveQueryKey(uidAsset, uidExportSetting) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsExportSettingsRetrieve(uidAsset, uidExportSetting, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidExportSetting), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidExportSetting), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsExportSettingsRetrieveQueryResult = NonNullable>> +export type AssetsExportSettingsRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsExportSettingsRetrieveQueryError = ErrorDetail +export function useAssetsExportSettingsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidExportSetting: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsExportSettingsRetrieveQueryOptions(uidAsset, uidExportSetting, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsExportSettingsRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidExportSetting: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsExportSettingsRetrieveQueryOptions(uidAsset,uidExportSetting,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Update the current export setting @@ -4119,77 +4277,93 @@ export type assetsExportSettingsPartialUpdateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsExportSettingsPartialUpdateResponseComposite = assetsExportSettingsPartialUpdateResponse200 | assetsExportSettingsPartialUpdateResponse400 | assetsExportSettingsPartialUpdateResponse404; - -export type assetsExportSettingsPartialUpdateResponse = assetsExportSettingsPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getAssetsExportSettingsPartialUpdateUrl = (uidAsset: string, - uidExportSetting: string,) => { +export type assetsExportSettingsPartialUpdateResponseComposite = + | assetsExportSettingsPartialUpdateResponse200 + | assetsExportSettingsPartialUpdateResponse400 + | assetsExportSettingsPartialUpdateResponse404 - +export type assetsExportSettingsPartialUpdateResponse = assetsExportSettingsPartialUpdateResponseComposite & { + headers: Headers +} +export const getAssetsExportSettingsPartialUpdateUrl = (uidAsset: string, uidExportSetting: string) => { return `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/` } -export const assetsExportSettingsPartialUpdate = async (uidAsset: string, - uidExportSetting: string, - patchedExportSettingUpdatePayload: PatchedExportSettingUpdatePayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsExportSettingsPartialUpdateUrl(uidAsset,uidExportSetting), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedExportSettingUpdatePayload,) +export const assetsExportSettingsPartialUpdate = async ( + uidAsset: string, + uidExportSetting: string, + patchedExportSettingUpdatePayload: PatchedExportSettingUpdatePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsExportSettingsPartialUpdateUrl(uidAsset, uidExportSetting), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedExportSettingUpdatePayload), + }, + ) +} + +export const getAssetsExportSettingsPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidExportSetting: string; data: PatchedExportSettingUpdatePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidExportSetting: string; data: PatchedExportSettingUpdatePayload }, + TContext +> => { + const mutationKey = ['assetsExportSettingsPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidExportSetting: string; data: PatchedExportSettingUpdatePayload } + > = (props) => { + const { uidAsset, uidExportSetting, data } = props ?? {} + + return assetsExportSettingsPartialUpdate(uidAsset, uidExportSetting, data, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} - -export const getAssetsExportSettingsPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string;data: PatchedExportSettingUpdatePayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string;data: PatchedExportSettingUpdatePayload}, TContext> => { - -const mutationKey = ['assetsExportSettingsPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidExportSetting: string;data: PatchedExportSettingUpdatePayload}> = (props) => { - const {uidAsset,uidExportSetting,data} = props ?? {}; - - return assetsExportSettingsPartialUpdate(uidAsset,uidExportSetting,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsExportSettingsPartialUpdateMutationResult = NonNullable>> - export type AssetsExportSettingsPartialUpdateMutationBody = PatchedExportSettingUpdatePayload - export type AssetsExportSettingsPartialUpdateMutationError = ErrorObject | ErrorDetail - - export const useAssetsExportSettingsPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string;data: PatchedExportSettingUpdatePayload}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsExportSettingsPartialUpdateMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export type AssetsExportSettingsPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsExportSettingsPartialUpdateMutationBody = PatchedExportSettingUpdatePayload +export type AssetsExportSettingsPartialUpdateMutationError = ErrorObject | ErrorDetail + +export const useAssetsExportSettingsPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidExportSetting: string; data: PatchedExportSettingUpdatePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsExportSettingsPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Delete current export setting * _Required permissions: `manage_asset` (Manage project)_ @@ -4205,75 +4379,86 @@ export type assetsExportSettingsDestroyResponse404 = { data: ErrorDetail status: 404 } - -export type assetsExportSettingsDestroyResponseComposite = assetsExportSettingsDestroyResponse204 | assetsExportSettingsDestroyResponse404; - -export type assetsExportSettingsDestroyResponse = assetsExportSettingsDestroyResponseComposite & { - headers: Headers; -} - -export const getAssetsExportSettingsDestroyUrl = (uidAsset: string, - uidExportSetting: string,) => { +export type assetsExportSettingsDestroyResponseComposite = + | assetsExportSettingsDestroyResponse204 + | assetsExportSettingsDestroyResponse404 - +export type assetsExportSettingsDestroyResponse = assetsExportSettingsDestroyResponseComposite & { + headers: Headers +} +export const getAssetsExportSettingsDestroyUrl = (uidAsset: string, uidExportSetting: string) => { return `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/` } -export const assetsExportSettingsDestroy = async (uidAsset: string, - uidExportSetting: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsExportSettingsDestroyUrl(uidAsset,uidExportSetting), - { - ...options, - method: 'DELETE' - - +export const assetsExportSettingsDestroy = async ( + uidAsset: string, + uidExportSetting: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsExportSettingsDestroyUrl(uidAsset, uidExportSetting), + { + ...options, + method: 'DELETE', + }, + ) +} + +export const getAssetsExportSettingsDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidExportSetting: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidExportSetting: string }, + TContext +> => { + const mutationKey = ['assetsExportSettingsDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidExportSetting: string } + > = (props) => { + const { uidAsset, uidExportSetting } = props ?? {} + + return assetsExportSettingsDestroy(uidAsset, uidExportSetting, requestOptions) } -);} - - - - -export const getAssetsExportSettingsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string}, TContext> => { - -const mutationKey = ['assetsExportSettingsDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidExportSetting: string}> = (props) => { - const {uidAsset,uidExportSetting} = props ?? {}; - - return assetsExportSettingsDestroy(uidAsset,uidExportSetting,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetsExportSettingsDestroyMutationResult = NonNullable>> - - export type AssetsExportSettingsDestroyMutationError = ErrorDetail +export type AssetsExportSettingsDestroyMutationResult = NonNullable< + Awaited> +> - export const useAssetsExportSettingsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExportSetting: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsExportSettingsDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsExportSettingsDestroyMutationOptions(options); +export const useAssetsExportSettingsDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidExportSetting: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsExportSettingsDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Synchronously export data To retrieve data synchronously in CSV and XLSX format according to a @@ -4297,95 +4482,121 @@ export type assetsExportSettingsDataRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsExportSettingsDataRetrieveResponseComposite = assetsExportSettingsDataRetrieveResponse200 | assetsExportSettingsDataRetrieveResponse400 | assetsExportSettingsDataRetrieveResponse404; - + +export type assetsExportSettingsDataRetrieveResponseComposite = + | assetsExportSettingsDataRetrieveResponse200 + | assetsExportSettingsDataRetrieveResponse400 + | assetsExportSettingsDataRetrieveResponse404 + export type assetsExportSettingsDataRetrieveResponse = assetsExportSettingsDataRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsExportSettingsDataRetrieveUrl = (uidAsset: string, - uidExportSetting: string, - params: AssetsExportSettingsDataRetrieveParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsExportSettingsDataRetrieveUrl = ( + uidAsset: string, + uidExportSetting: string, + params: AssetsExportSettingsDataRetrieveParams, +) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); - - const stringifiedParams = normalizedParams.toString(); - - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/data/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/data/` -} - -export const assetsExportSettingsDataRetrieve = async (uidAsset: string, - uidExportSetting: string, - params: AssetsExportSettingsDataRetrieveParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsExportSettingsDataRetrieveUrl(uidAsset,uidExportSetting,params), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsExportSettingsDataRetrieveQueryKey = (uidAsset: string, - uidExportSetting: string, - params: AssetsExportSettingsDataRetrieveParams,) => { - return ['api','v2','assets',uidAsset,'export-settings',uidExportSetting,'data', ...(params ? [params]: [])] as const; - } - - -export const getAssetsExportSettingsDataRetrieveQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidAsset: string, - uidExportSetting: string, - params: AssetsExportSettingsDataRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} + }) + + const stringifiedParams = normalizedParams.toString() + + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/data/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/export-settings/${uidExportSetting}/data/` +} + +export const assetsExportSettingsDataRetrieve = async ( + uidAsset: string, + uidExportSetting: string, + params: AssetsExportSettingsDataRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsExportSettingsDataRetrieveUrl(uidAsset, uidExportSetting, params), + { + ...options, + method: 'GET', + }, + ) +} + +export const getAssetsExportSettingsDataRetrieveQueryKey = ( + uidAsset: string, + uidExportSetting: string, + params: AssetsExportSettingsDataRetrieveParams, ) => { + return [ + 'api', + 'v2', + 'assets', + uidAsset, + 'export-settings', + uidExportSetting, + 'data', + ...(params ? [params] : []), + ] as const +} + +export const getAssetsExportSettingsDataRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidAsset: string, + uidExportSetting: string, + params: AssetsExportSettingsDataRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsExportSettingsDataRetrieveQueryKey(uidAsset,uidExportSetting,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsExportSettingsDataRetrieve(uidAsset,uidExportSetting,params, { signal, ...requestOptions }); - - + const queryKey = + queryOptions?.queryKey ?? getAssetsExportSettingsDataRetrieveQueryKey(uidAsset, uidExportSetting, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsExportSettingsDataRetrieve(uidAsset, uidExportSetting, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidAsset && uidExportSetting), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidExportSetting), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsExportSettingsDataRetrieveQueryResult = NonNullable>> +export type AssetsExportSettingsDataRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsExportSettingsDataRetrieveQueryError = ErrorObject | ErrorDetail +export function useAssetsExportSettingsDataRetrieve< + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidAsset: string, + uidExportSetting: string, + params: AssetsExportSettingsDataRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsExportSettingsDataRetrieveQueryOptions(uidAsset, uidExportSetting, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsExportSettingsDataRetrieve>, TError = ErrorObject | ErrorDetail>( - uidAsset: string, - uidExportSetting: string, - params: AssetsExportSettingsDataRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsExportSettingsDataRetrieveQueryOptions(uidAsset,uidExportSetting,params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## List of export tasks endpoints @@ -4411,90 +4622,89 @@ export type assetsExportsListResponse403 = { data: ErrorDetail status: 403 } - -export type assetsExportsListResponseComposite = assetsExportsListResponse200 | assetsExportsListResponse403; - + +export type assetsExportsListResponseComposite = assetsExportsListResponse200 | assetsExportsListResponse403 + export type assetsExportsListResponse = assetsExportsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsExportsListUrl = (uidAsset: string, - params?: AssetsExportsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsExportsListUrl = (uidAsset: string, params?: AssetsExportsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/exports/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/exports/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/exports/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/exports/` } -export const assetsExportsList = async (uidAsset: string, - params?: AssetsExportsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsExportsListUrl(uidAsset,params), - { +export const assetsExportsList = async ( + uidAsset: string, + params?: AssetsExportsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsExportsListUrl(uidAsset, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsExportsListQueryKey = (uidAsset: string, - params?: AssetsExportsListParams,) => { - return ['api','v2','assets',uidAsset,'exports', ...(params ? [params]: [])] as const; - } +export const getAssetsExportsListQueryKey = (uidAsset: string, params?: AssetsExportsListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'exports', ...(params ? [params] : [])] as const +} - -export const getAssetsExportsListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsExportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsExportsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsExportsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsExportsListQueryKey(uidAsset,params); + const queryKey = queryOptions?.queryKey ?? getAssetsExportsListQueryKey(uidAsset, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsExportsList(uidAsset, params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsExportsList(uidAsset,params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsExportsListQueryResult = NonNullable>> export type AssetsExportsListQueryError = ErrorDetail - - export function useAssetsExportsList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsExportsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsExportsListQueryOptions(uidAsset,params,options) + uidAsset: string, + params?: AssetsExportsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsExportsListQueryOptions(uidAsset, params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Creates an export task @@ -4544,75 +4754,87 @@ export type assetsExportsCreateResponse403 = { data: ErrorDetail status: 403 } - -export type assetsExportsCreateResponseComposite = assetsExportsCreateResponse201 | assetsExportsCreateResponse400 | assetsExportsCreateResponse403; - -export type assetsExportsCreateResponse = assetsExportsCreateResponseComposite & { - headers: Headers; -} -export const getAssetsExportsCreateUrl = (uidAsset: string,) => { +export type assetsExportsCreateResponseComposite = + | assetsExportsCreateResponse201 + | assetsExportsCreateResponse400 + | assetsExportsCreateResponse403 +export type assetsExportsCreateResponse = assetsExportsCreateResponseComposite & { + headers: Headers +} - - +export const getAssetsExportsCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/exports/` } -export const assetsExportsCreate = async (uidAsset: string, - exportCreatePayload: ExportCreatePayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsExportsCreateUrl(uidAsset), - { +export const assetsExportsCreate = async ( + uidAsset: string, + exportCreatePayload: ExportCreatePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsExportsCreateUrl(uidAsset), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - exportCreatePayload,) + body: JSON.stringify(exportCreatePayload), + }) +} + +export const getAssetsExportsCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: ExportCreatePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: ExportCreatePayload }, + TContext +> => { + const mutationKey = ['assetsExportsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: ExportCreatePayload } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsExportsCreate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsExportsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: ExportCreatePayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: ExportCreatePayload}, TContext> => { - -const mutationKey = ['assetsExportsCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: ExportCreatePayload}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsExportsCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsExportsCreateMutationResult = NonNullable>> - export type AssetsExportsCreateMutationBody = ExportCreatePayload - export type AssetsExportsCreateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsExportsCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: ExportCreatePayload}, TContext>, request?: SecondParameter} - ) => { +export type AssetsExportsCreateMutationResult = NonNullable>> +export type AssetsExportsCreateMutationBody = ExportCreatePayload +export type AssetsExportsCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsExportsCreateMutationOptions(options); +export const useAssetsExportsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: ExportCreatePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsExportsCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retrieves current export task */ @@ -4625,83 +4847,80 @@ export type assetsExportsRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type assetsExportsRetrieveResponseComposite = assetsExportsRetrieveResponse200 | assetsExportsRetrieveResponse403; - -export type assetsExportsRetrieveResponse = assetsExportsRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsExportsRetrieveUrl = (uidAsset: string, - uidExport: string,) => { +export type assetsExportsRetrieveResponseComposite = assetsExportsRetrieveResponse200 | assetsExportsRetrieveResponse403 +export type assetsExportsRetrieveResponse = assetsExportsRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsExportsRetrieveUrl = (uidAsset: string, uidExport: string) => { return `/api/v2/assets/${uidAsset}/exports/${uidExport}/` } -export const assetsExportsRetrieve = async (uidAsset: string, - uidExport: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsExportsRetrieveUrl(uidAsset,uidExport), - { +export const assetsExportsRetrieve = async ( + uidAsset: string, + uidExport: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsExportsRetrieveUrl(uidAsset, uidExport), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsExportsRetrieveQueryKey = (uidAsset: string, - uidExport: string,) => { - return ['api','v2','assets',uidAsset,'exports',uidExport] as const; - } +export const getAssetsExportsRetrieveQueryKey = (uidAsset: string, uidExport: string) => { + return ['api', 'v2', 'assets', uidAsset, 'exports', uidExport] as const +} - -export const getAssetsExportsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidExport: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsExportsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidExport: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsExportsRetrieveQueryKey(uidAsset,uidExport); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsExportsRetrieve(uidAsset,uidExport, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetsExportsRetrieveQueryKey(uidAsset, uidExport) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsExportsRetrieve(uidAsset, uidExport, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidExport), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidExport), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsExportsRetrieveQueryResult = NonNullable>> export type AssetsExportsRetrieveQueryError = ErrorDetail +export function useAssetsExportsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidExport: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsExportsRetrieveQueryOptions(uidAsset, uidExport, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsExportsRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidExport: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsExportsRetrieveQueryOptions(uidAsset,uidExport,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Deletes current export task @@ -4715,75 +4934,79 @@ export type assetsExportsDestroyResponse403 = { data: ErrorDetail status: 403 } - -export type assetsExportsDestroyResponseComposite = assetsExportsDestroyResponse204 | assetsExportsDestroyResponse403; - -export type assetsExportsDestroyResponse = assetsExportsDestroyResponseComposite & { - headers: Headers; -} -export const getAssetsExportsDestroyUrl = (uidAsset: string, - uidExport: string,) => { +export type assetsExportsDestroyResponseComposite = assetsExportsDestroyResponse204 | assetsExportsDestroyResponse403 +export type assetsExportsDestroyResponse = assetsExportsDestroyResponseComposite & { + headers: Headers +} - - +export const getAssetsExportsDestroyUrl = (uidAsset: string, uidExport: string) => { return `/api/v2/assets/${uidAsset}/exports/${uidExport}/` } -export const assetsExportsDestroy = async (uidAsset: string, - uidExport: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsExportsDestroyUrl(uidAsset,uidExport), - { +export const assetsExportsDestroy = async ( + uidAsset: string, + uidExport: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsExportsDestroyUrl(uidAsset, uidExport), { ...options, - method: 'DELETE' - - - } -);} - - - - -export const getAssetsExportsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExport: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidExport: string}, TContext> => { - -const mutationKey = ['assetsExportsDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidExport: string}> = (props) => { - const {uidAsset,uidExport} = props ?? {}; - - return assetsExportsDestroy(uidAsset,uidExport,requestOptions) - } - - - + method: 'DELETE', + }) +} + +export const getAssetsExportsDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidExport: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidExport: string }, + TContext +> => { + const mutationKey = ['assetsExportsDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidExport: string } + > = (props) => { + const { uidAsset, uidExport } = props ?? {} + + return assetsExportsDestroy(uidAsset, uidExport, requestOptions) + } - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type AssetsExportsDestroyMutationResult = NonNullable>> - - export type AssetsExportsDestroyMutationError = ErrorDetail +export type AssetsExportsDestroyMutationResult = NonNullable>> - export const useAssetsExportsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidExport: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsExportsDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsExportsDestroyMutationOptions(options); +export const useAssetsExportsDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidExport: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsExportsDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retrieve current asset files Results can be narrowed down with a filter by type: @@ -4801,90 +5024,89 @@ export type assetsFilesListResponse404 = { data: ErrorDetail status: 404 } - -export type assetsFilesListResponseComposite = assetsFilesListResponse200 | assetsFilesListResponse404; - + +export type assetsFilesListResponseComposite = assetsFilesListResponse200 | assetsFilesListResponse404 + export type assetsFilesListResponse = assetsFilesListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsFilesListUrl = (uidAsset: string, - params?: AssetsFilesListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsFilesListUrl = (uidAsset: string, params?: AssetsFilesListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/files/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/files/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/files/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/files/` } -export const assetsFilesList = async (uidAsset: string, - params?: AssetsFilesListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsFilesListUrl(uidAsset,params), - { +export const assetsFilesList = async ( + uidAsset: string, + params?: AssetsFilesListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsFilesListUrl(uidAsset, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsFilesListQueryKey = (uidAsset: string, - params?: AssetsFilesListParams,) => { - return ['api','v2','assets',uidAsset,'files', ...(params ? [params]: [])] as const; - } +export const getAssetsFilesListQueryKey = (uidAsset: string, params?: AssetsFilesListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'files', ...(params ? [params] : [])] as const +} - -export const getAssetsFilesListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsFilesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsFilesListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsFilesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsFilesListQueryKey(uidAsset,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsFilesList(uidAsset,params, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetsFilesListQueryKey(uidAsset, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsFilesList(uidAsset, params, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsFilesListQueryResult = NonNullable>> export type AssetsFilesListQueryError = ErrorDetail - - export function useAssetsFilesList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsFilesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsFilesListQueryOptions(uidAsset,params,options) + uidAsset: string, + params?: AssetsFilesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsFilesListQueryOptions(uidAsset, params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Create a new file on current asset @@ -4927,75 +5149,84 @@ export type assetsFilesCreateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsFilesCreateResponseComposite = assetsFilesCreateResponse201 | assetsFilesCreateResponse400 | assetsFilesCreateResponse404; - -export type assetsFilesCreateResponse = assetsFilesCreateResponseComposite & { - headers: Headers; -} -export const getAssetsFilesCreateUrl = (uidAsset: string,) => { +export type assetsFilesCreateResponseComposite = + | assetsFilesCreateResponse201 + | assetsFilesCreateResponse400 + | assetsFilesCreateResponse404 +export type assetsFilesCreateResponse = assetsFilesCreateResponseComposite & { + headers: Headers +} - - +export const getAssetsFilesCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/files/` } -export const assetsFilesCreate = async (uidAsset: string, - createFilePayload: CreateFilePayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsFilesCreateUrl(uidAsset), - { +export const assetsFilesCreate = async ( + uidAsset: string, + createFilePayload: CreateFilePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsFilesCreateUrl(uidAsset), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - createFilePayload,) + body: JSON.stringify(createFilePayload), + }) +} + +export const getAssetsFilesCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: CreateFilePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: CreateFilePayload }, + TContext +> => { + const mutationKey = ['assetsFilesCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: CreateFilePayload } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsFilesCreate(uidAsset, data, requestOptions) } -);} - - - - -export const getAssetsFilesCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: CreateFilePayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: CreateFilePayload}, TContext> => { - -const mutationKey = ['assetsFilesCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: CreateFilePayload}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsFilesCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsFilesCreateMutationResult = NonNullable>> - export type AssetsFilesCreateMutationBody = CreateFilePayload - export type AssetsFilesCreateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useAssetsFilesCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: CreateFilePayload}, TContext>, request?: SecondParameter} - ) => { +export type AssetsFilesCreateMutationResult = NonNullable>> +export type AssetsFilesCreateMutationBody = CreateFilePayload +export type AssetsFilesCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getAssetsFilesCreateMutationOptions(options); +export const useAssetsFilesCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: CreateFilePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsFilesCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retrieve a file from current asset */ @@ -5008,83 +5239,77 @@ export type assetsFilesRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsFilesRetrieveResponseComposite = assetsFilesRetrieveResponse200 | assetsFilesRetrieveResponse404; - -export type assetsFilesRetrieveResponse = assetsFilesRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsFilesRetrieveUrl = (uidAsset: string, - uidFile: string,) => { +export type assetsFilesRetrieveResponseComposite = assetsFilesRetrieveResponse200 | assetsFilesRetrieveResponse404 +export type assetsFilesRetrieveResponse = assetsFilesRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsFilesRetrieveUrl = (uidAsset: string, uidFile: string) => { return `/api/v2/assets/${uidAsset}/files/${uidFile}/` } -export const assetsFilesRetrieve = async (uidAsset: string, - uidFile: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsFilesRetrieveUrl(uidAsset,uidFile), - { +export const assetsFilesRetrieve = async ( + uidAsset: string, + uidFile: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsFilesRetrieveUrl(uidAsset, uidFile), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsFilesRetrieveQueryKey = (uidAsset: string, - uidFile: string,) => { - return ['api','v2','assets',uidAsset,'files',uidFile] as const; - } +export const getAssetsFilesRetrieveQueryKey = (uidAsset: string, uidFile: string) => { + return ['api', 'v2', 'assets', uidAsset, 'files', uidFile] as const +} - -export const getAssetsFilesRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidFile: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsFilesRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidFile: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsFilesRetrieveQueryKey(uidAsset,uidFile); + const queryKey = queryOptions?.queryKey ?? getAssetsFilesRetrieveQueryKey(uidAsset, uidFile) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsFilesRetrieve(uidAsset, uidFile, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsFilesRetrieve(uidAsset,uidFile, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidFile), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidFile), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsFilesRetrieveQueryResult = NonNullable>> export type AssetsFilesRetrieveQueryError = ErrorDetail - - export function useAssetsFilesRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidFile: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsFilesRetrieveQueryOptions(uidAsset,uidFile,options) + uidAsset: string, + uidFile: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsFilesRetrieveQueryOptions(uidAsset, uidFile, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Delete a file from current asset @@ -5098,75 +5323,79 @@ export type assetsFilesDestroyResponse404 = { data: ErrorDetail status: 404 } - -export type assetsFilesDestroyResponseComposite = assetsFilesDestroyResponse204 | assetsFilesDestroyResponse404; - -export type assetsFilesDestroyResponse = assetsFilesDestroyResponseComposite & { - headers: Headers; -} -export const getAssetsFilesDestroyUrl = (uidAsset: string, - uidFile: string,) => { +export type assetsFilesDestroyResponseComposite = assetsFilesDestroyResponse204 | assetsFilesDestroyResponse404 +export type assetsFilesDestroyResponse = assetsFilesDestroyResponseComposite & { + headers: Headers +} - - +export const getAssetsFilesDestroyUrl = (uidAsset: string, uidFile: string) => { return `/api/v2/assets/${uidAsset}/files/${uidFile}/` } -export const assetsFilesDestroy = async (uidAsset: string, - uidFile: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsFilesDestroyUrl(uidAsset,uidFile), - { +export const assetsFilesDestroy = async ( + uidAsset: string, + uidFile: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsFilesDestroyUrl(uidAsset, uidFile), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getAssetsFilesDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidFile: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidFile: string }, + TContext +> => { + const mutationKey = ['assetsFilesDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidFile: string } + > = (props) => { + const { uidAsset, uidFile } = props ?? {} + + return assetsFilesDestroy(uidAsset, uidFile, requestOptions) } -);} - - - - -export const getAssetsFilesDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidFile: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidFile: string}, TContext> => { - -const mutationKey = ['assetsFilesDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidFile: string}> = (props) => { - const {uidAsset,uidFile} = props ?? {}; - - return assetsFilesDestroy(uidAsset,uidFile,requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} - - export type AssetsFilesDestroyMutationResult = NonNullable>> - - export type AssetsFilesDestroyMutationError = ErrorDetail +export type AssetsFilesDestroyMutationResult = NonNullable>> - export const useAssetsFilesDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidFile: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsFilesDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsFilesDestroyMutationOptions(options); +export const useAssetsFilesDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidFile: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsFilesDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Download the asset file */ @@ -5179,83 +5408,82 @@ export type assetsFilesContentRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsFilesContentRetrieveResponseComposite = assetsFilesContentRetrieveResponse200 | assetsFilesContentRetrieveResponse404; - -export type assetsFilesContentRetrieveResponse = assetsFilesContentRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsFilesContentRetrieveUrl = (uidAsset: string, - uidFile: string,) => { +export type assetsFilesContentRetrieveResponseComposite = + | assetsFilesContentRetrieveResponse200 + | assetsFilesContentRetrieveResponse404 - +export type assetsFilesContentRetrieveResponse = assetsFilesContentRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsFilesContentRetrieveUrl = (uidAsset: string, uidFile: string) => { return `/api/v2/assets/${uidAsset}/files/${uidFile}/content/` } -export const assetsFilesContentRetrieve = async (uidAsset: string, - uidFile: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsFilesContentRetrieveUrl(uidAsset,uidFile), - { +export const assetsFilesContentRetrieve = async ( + uidAsset: string, + uidFile: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsFilesContentRetrieveUrl(uidAsset, uidFile), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsFilesContentRetrieveQueryKey = (uidAsset: string, - uidFile: string,) => { - return ['api','v2','assets',uidAsset,'files',uidFile,'content'] as const; - } +export const getAssetsFilesContentRetrieveQueryKey = (uidAsset: string, uidFile: string) => { + return ['api', 'v2', 'assets', uidAsset, 'files', uidFile, 'content'] as const +} - -export const getAssetsFilesContentRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidFile: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsFilesContentRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidFile: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getAssetsFilesContentRetrieveQueryKey(uidAsset, uidFile) - const queryKey = queryOptions?.queryKey ?? getAssetsFilesContentRetrieveQueryKey(uidAsset,uidFile); + const queryFn: QueryFunction>> = ({ signal }) => + assetsFilesContentRetrieve(uidAsset, uidFile, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => assetsFilesContentRetrieve(uidAsset,uidFile, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidFile), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidFile), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsFilesContentRetrieveQueryResult = NonNullable>> export type AssetsFilesContentRetrieveQueryError = ErrorDetail +export function useAssetsFilesContentRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidFile: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsFilesContentRetrieveQueryOptions(uidAsset, uidFile, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsFilesContentRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidFile: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getAssetsFilesContentRetrieveQueryOptions(uidAsset,uidFile,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## List paired project endpoints @@ -5273,90 +5501,89 @@ export type assetsPairedDataListResponse404 = { data: ErrorDetail status: 404 } - -export type assetsPairedDataListResponseComposite = assetsPairedDataListResponse200 | assetsPairedDataListResponse404; - + +export type assetsPairedDataListResponseComposite = assetsPairedDataListResponse200 | assetsPairedDataListResponse404 + export type assetsPairedDataListResponse = assetsPairedDataListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetsPairedDataListUrl = (uidAsset: string, - params?: AssetsPairedDataListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetsPairedDataListUrl = (uidAsset: string, params?: AssetsPairedDataListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/assets/${uidAsset}/paired-data/?${stringifiedParams}` : `/api/v2/assets/${uidAsset}/paired-data/` + return stringifiedParams.length > 0 + ? `/api/v2/assets/${uidAsset}/paired-data/?${stringifiedParams}` + : `/api/v2/assets/${uidAsset}/paired-data/` } -export const assetsPairedDataList = async (uidAsset: string, - params?: AssetsPairedDataListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPairedDataListUrl(uidAsset,params), - { +export const assetsPairedDataList = async ( + uidAsset: string, + params?: AssetsPairedDataListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsPairedDataListUrl(uidAsset, params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsPairedDataListQueryKey = (uidAsset: string, - params?: AssetsPairedDataListParams,) => { - return ['api','v2','assets',uidAsset,'paired-data', ...(params ? [params]: [])] as const; - } +export const getAssetsPairedDataListQueryKey = (uidAsset: string, params?: AssetsPairedDataListParams) => { + return ['api', 'v2', 'assets', uidAsset, 'paired-data', ...(params ? [params] : [])] as const +} - -export const getAssetsPairedDataListQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - params?: AssetsPairedDataListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsPairedDataListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + params?: AssetsPairedDataListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataListQueryKey(uidAsset,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsPairedDataList(uidAsset,params, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataListQueryKey(uidAsset, params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsPairedDataList(uidAsset, params, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsPairedDataListQueryResult = NonNullable>> export type AssetsPairedDataListQueryError = ErrorDetail - - export function useAssetsPairedDataList>, TError = ErrorDetail>( - uidAsset: string, - params?: AssetsPairedDataListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsPairedDataListQueryOptions(uidAsset,params,options) + uidAsset: string, + params?: AssetsPairedDataListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsPairedDataListQueryOptions(uidAsset, params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Create a connection between two projects @@ -5381,75 +5608,87 @@ export type assetsPairedDataCreateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsPairedDataCreateResponseComposite = assetsPairedDataCreateResponse201 | assetsPairedDataCreateResponse400 | assetsPairedDataCreateResponse404; - -export type assetsPairedDataCreateResponse = assetsPairedDataCreateResponseComposite & { - headers: Headers; -} -export const getAssetsPairedDataCreateUrl = (uidAsset: string,) => { +export type assetsPairedDataCreateResponseComposite = + | assetsPairedDataCreateResponse201 + | assetsPairedDataCreateResponse400 + | assetsPairedDataCreateResponse404 +export type assetsPairedDataCreateResponse = assetsPairedDataCreateResponseComposite & { + headers: Headers +} - - +export const getAssetsPairedDataCreateUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/paired-data/` } -export const assetsPairedDataCreate = async (uidAsset: string, - pairedData: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPairedDataCreateUrl(uidAsset), - { +export const assetsPairedDataCreate = async ( + uidAsset: string, + pairedData: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsPairedDataCreateUrl(uidAsset), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - pairedData,) + body: JSON.stringify(pairedData), + }) +} + +export const getAssetsPairedDataCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: NonReadonly }, + TContext +> => { + const mutationKey = ['assetsPairedDataCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; data: NonReadonly } + > = (props) => { + const { uidAsset, data } = props ?? {} + + return assetsPairedDataCreate(uidAsset, data, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} +export type AssetsPairedDataCreateMutationResult = NonNullable>> +export type AssetsPairedDataCreateMutationBody = NonReadonly +export type AssetsPairedDataCreateMutationError = ErrorObject | ErrorDetail -export const getAssetsPairedDataCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext> => { - -const mutationKey = ['assetsPairedDataCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;data: NonReadonly}> = (props) => { - const {uidAsset,data} = props ?? {}; - - return assetsPairedDataCreate(uidAsset,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsPairedDataCreateMutationResult = NonNullable>> - export type AssetsPairedDataCreateMutationBody = NonReadonly - export type AssetsPairedDataCreateMutationError = ErrorObject | ErrorDetail - - export const useAssetsPairedDataCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsPairedDataCreateMutationOptions(options); +export const useAssetsPairedDataCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsPairedDataCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retrieve a connection between two projects */ @@ -5462,83 +5701,82 @@ export type assetsPairedDataRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsPairedDataRetrieveResponseComposite = assetsPairedDataRetrieveResponse200 | assetsPairedDataRetrieveResponse404; - -export type assetsPairedDataRetrieveResponse = assetsPairedDataRetrieveResponseComposite & { - headers: Headers; -} -export const getAssetsPairedDataRetrieveUrl = (uidAsset: string, - uidPairedData: string,) => { +export type assetsPairedDataRetrieveResponseComposite = + | assetsPairedDataRetrieveResponse200 + | assetsPairedDataRetrieveResponse404 +export type assetsPairedDataRetrieveResponse = assetsPairedDataRetrieveResponseComposite & { + headers: Headers +} - - +export const getAssetsPairedDataRetrieveUrl = (uidAsset: string, uidPairedData: string) => { return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/` } -export const assetsPairedDataRetrieve = async (uidAsset: string, - uidPairedData: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPairedDataRetrieveUrl(uidAsset,uidPairedData), - { +export const assetsPairedDataRetrieve = async ( + uidAsset: string, + uidPairedData: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsPairedDataRetrieveUrl(uidAsset, uidPairedData), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsPairedDataRetrieveQueryKey = (uidAsset: string, - uidPairedData: string,) => { - return ['api','v2','assets',uidAsset,'paired-data',uidPairedData] as const; - } +export const getAssetsPairedDataRetrieveQueryKey = (uidAsset: string, uidPairedData: string) => { + return ['api', 'v2', 'assets', uidAsset, 'paired-data', uidPairedData] as const +} - -export const getAssetsPairedDataRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidPairedData: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsPairedDataRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidPairedData: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataRetrieveQueryKey(uidAsset,uidPairedData); + const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataRetrieveQueryKey(uidAsset, uidPairedData) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsPairedDataRetrieve(uidAsset, uidPairedData, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => assetsPairedDataRetrieve(uidAsset,uidPairedData, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidPairedData), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidPairedData), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsPairedDataRetrieveQueryResult = NonNullable>> export type AssetsPairedDataRetrieveQueryError = ErrorDetail +export function useAssetsPairedDataRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidPairedData: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsPairedDataRetrieveQueryOptions(uidAsset, uidPairedData, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsPairedDataRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidPairedData: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsPairedDataRetrieveQueryOptions(uidAsset,uidPairedData,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Update a connection between two projects @@ -5559,77 +5797,93 @@ export type assetsPairedDataPartialUpdateResponse404 = { data: ErrorDetail status: 404 } - -export type assetsPairedDataPartialUpdateResponseComposite = assetsPairedDataPartialUpdateResponse200 | assetsPairedDataPartialUpdateResponse400 | assetsPairedDataPartialUpdateResponse404; - -export type assetsPairedDataPartialUpdateResponse = assetsPairedDataPartialUpdateResponseComposite & { - headers: Headers; -} -export const getAssetsPairedDataPartialUpdateUrl = (uidAsset: string, - uidPairedData: string,) => { +export type assetsPairedDataPartialUpdateResponseComposite = + | assetsPairedDataPartialUpdateResponse200 + | assetsPairedDataPartialUpdateResponse400 + | assetsPairedDataPartialUpdateResponse404 +export type assetsPairedDataPartialUpdateResponse = assetsPairedDataPartialUpdateResponseComposite & { + headers: Headers +} - - +export const getAssetsPairedDataPartialUpdateUrl = (uidAsset: string, uidPairedData: string) => { return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/` } -export const assetsPairedDataPartialUpdate = async (uidAsset: string, - uidPairedData: string, - patchedPairedDataPatchPayload: PatchedPairedDataPatchPayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPairedDataPartialUpdateUrl(uidAsset,uidPairedData), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedPairedDataPatchPayload,) +export const assetsPairedDataPartialUpdate = async ( + uidAsset: string, + uidPairedData: string, + patchedPairedDataPatchPayload: PatchedPairedDataPatchPayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsPairedDataPartialUpdateUrl(uidAsset, uidPairedData), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedPairedDataPatchPayload), + }, + ) +} + +export const getAssetsPairedDataPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidPairedData: string; data: PatchedPairedDataPatchPayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidPairedData: string; data: PatchedPairedDataPatchPayload }, + TContext +> => { + const mutationKey = ['assetsPairedDataPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidPairedData: string; data: PatchedPairedDataPatchPayload } + > = (props) => { + const { uidAsset, uidPairedData, data } = props ?? {} + + return assetsPairedDataPartialUpdate(uidAsset, uidPairedData, data, requestOptions) } -);} - - - - -export const getAssetsPairedDataPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string;data: PatchedPairedDataPatchPayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string;data: PatchedPairedDataPatchPayload}, TContext> => { -const mutationKey = ['assetsPairedDataPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidPairedData: string;data: PatchedPairedDataPatchPayload}> = (props) => { - const {uidAsset,uidPairedData,data} = props ?? {}; - - return assetsPairedDataPartialUpdate(uidAsset,uidPairedData,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type AssetsPairedDataPartialUpdateMutationResult = NonNullable>> - export type AssetsPairedDataPartialUpdateMutationBody = PatchedPairedDataPatchPayload - export type AssetsPairedDataPartialUpdateMutationError = ErrorObject | ErrorDetail - - export const useAssetsPairedDataPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string;data: PatchedPairedDataPatchPayload}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getAssetsPairedDataPartialUpdateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type AssetsPairedDataPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type AssetsPairedDataPartialUpdateMutationBody = PatchedPairedDataPatchPayload +export type AssetsPairedDataPartialUpdateMutationError = ErrorObject | ErrorDetail + +export const useAssetsPairedDataPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidPairedData: string; data: PatchedPairedDataPatchPayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsPairedDataPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Remove a connection between two projects */ @@ -5642,75 +5896,81 @@ export type assetsPairedDataDestroyResponse404 = { data: ErrorDetail status: 404 } - -export type assetsPairedDataDestroyResponseComposite = assetsPairedDataDestroyResponse204 | assetsPairedDataDestroyResponse404; - -export type assetsPairedDataDestroyResponse = assetsPairedDataDestroyResponseComposite & { - headers: Headers; -} -export const getAssetsPairedDataDestroyUrl = (uidAsset: string, - uidPairedData: string,) => { +export type assetsPairedDataDestroyResponseComposite = + | assetsPairedDataDestroyResponse204 + | assetsPairedDataDestroyResponse404 +export type assetsPairedDataDestroyResponse = assetsPairedDataDestroyResponseComposite & { + headers: Headers +} - - +export const getAssetsPairedDataDestroyUrl = (uidAsset: string, uidPairedData: string) => { return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/` } -export const assetsPairedDataDestroy = async (uidAsset: string, - uidPairedData: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPairedDataDestroyUrl(uidAsset,uidPairedData), - { +export const assetsPairedDataDestroy = async ( + uidAsset: string, + uidPairedData: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsPairedDataDestroyUrl(uidAsset, uidPairedData), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getAssetsPairedDataDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidPairedData: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidPairedData: string }, + TContext +> => { + const mutationKey = ['assetsPairedDataDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidAsset: string; uidPairedData: string } + > = (props) => { + const { uidAsset, uidPairedData } = props ?? {} + + return assetsPairedDataDestroy(uidAsset, uidPairedData, requestOptions) } -);} - - - - -export const getAssetsPairedDataDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string}, TContext> => { - -const mutationKey = ['assetsPairedDataDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidAsset: string;uidPairedData: string}> = (props) => { - const {uidAsset,uidPairedData} = props ?? {}; - - return assetsPairedDataDestroy(uidAsset,uidPairedData,requestOptions) - } - - + return { mutationFn, ...mutationOptions } +} - return { mutationFn, ...mutationOptions }} - - export type AssetsPairedDataDestroyMutationResult = NonNullable>> - - export type AssetsPairedDataDestroyMutationError = ErrorDetail +export type AssetsPairedDataDestroyMutationResult = NonNullable>> - export const useAssetsPairedDataDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidAsset: string;uidPairedData: string}, TContext>, request?: SecondParameter} - ) => { +export type AssetsPairedDataDestroyMutationError = ErrorDetail - const mutationOptions = getAssetsPairedDataDestroyMutationOptions(options); +export const useAssetsPairedDataDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidAsset: string; uidPairedData: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getAssetsPairedDataDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Return an XML which contains data submitted to paired asset Creates the endpoints @@ -5727,83 +5987,87 @@ export type assetsPairedDataExternalRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsPairedDataExternalRetrieveResponseComposite = assetsPairedDataExternalRetrieveResponse200 | assetsPairedDataExternalRetrieveResponse404; - -export type assetsPairedDataExternalRetrieveResponse = assetsPairedDataExternalRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsPairedDataExternalRetrieveUrl = (uidAsset: string, - uidPairedData: string,) => { +export type assetsPairedDataExternalRetrieveResponseComposite = + | assetsPairedDataExternalRetrieveResponse200 + | assetsPairedDataExternalRetrieveResponse404 - +export type assetsPairedDataExternalRetrieveResponse = assetsPairedDataExternalRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsPairedDataExternalRetrieveUrl = (uidAsset: string, uidPairedData: string) => { return `/api/v2/assets/${uidAsset}/paired-data/${uidPairedData}/external/` } -export const assetsPairedDataExternalRetrieve = async (uidAsset: string, - uidPairedData: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsPairedDataExternalRetrieveUrl(uidAsset,uidPairedData), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getAssetsPairedDataExternalRetrieveQueryKey = (uidAsset: string, - uidPairedData: string,) => { - return ['api','v2','assets',uidAsset,'paired-data',uidPairedData,'external'] as const; - } - - -export const getAssetsPairedDataExternalRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, - uidPairedData: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const assetsPairedDataExternalRetrieve = async ( + uidAsset: string, + uidPairedData: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getAssetsPairedDataExternalRetrieveUrl(uidAsset, uidPairedData), + { + ...options, + method: 'GET', + }, + ) +} + +export const getAssetsPairedDataExternalRetrieveQueryKey = (uidAsset: string, uidPairedData: string) => { + return ['api', 'v2', 'assets', uidAsset, 'paired-data', uidPairedData, 'external'] as const +} + +export const getAssetsPairedDataExternalRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidPairedData: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataExternalRetrieveQueryKey(uidAsset,uidPairedData); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetsPairedDataExternalRetrieve(uidAsset,uidPairedData, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetsPairedDataExternalRetrieveQueryKey(uidAsset, uidPairedData) - + const queryFn: QueryFunction>> = ({ signal }) => + assetsPairedDataExternalRetrieve(uidAsset, uidPairedData, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidAsset && uidPairedData), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidAsset && uidPairedData), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type AssetsPairedDataExternalRetrieveQueryResult = NonNullable>> +export type AssetsPairedDataExternalRetrieveQueryResult = NonNullable< + Awaited> +> export type AssetsPairedDataExternalRetrieveQueryError = ErrorDetail +export function useAssetsPairedDataExternalRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + uidPairedData: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsPairedDataExternalRetrieveQueryOptions(uidAsset, uidPairedData, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsPairedDataExternalRetrieve>, TError = ErrorDetail>( - uidAsset: string, - uidPairedData: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsPairedDataExternalRetrieveQueryOptions(uidAsset,uidPairedData,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Report of a user's asset @@ -5821,75 +6085,73 @@ export type assetsReportsRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type assetsReportsRetrieveResponseComposite = assetsReportsRetrieveResponse200 | assetsReportsRetrieveResponse404; - -export type assetsReportsRetrieveResponse = assetsReportsRetrieveResponseComposite & { - headers: Headers; -} - -export const getAssetsReportsRetrieveUrl = (uidAsset: string,) => { +export type assetsReportsRetrieveResponseComposite = assetsReportsRetrieveResponse200 | assetsReportsRetrieveResponse404 - +export type assetsReportsRetrieveResponse = assetsReportsRetrieveResponseComposite & { + headers: Headers +} +export const getAssetsReportsRetrieveUrl = (uidAsset: string) => { return `/api/v2/assets/${uidAsset}/reports/` } -export const assetsReportsRetrieve = async (uidAsset: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetsReportsRetrieveUrl(uidAsset), - { +export const assetsReportsRetrieve = async ( + uidAsset: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetsReportsRetrieveUrl(uidAsset), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetsReportsRetrieveQueryKey = (uidAsset: string,) => { - return ['api','v2','assets',uidAsset,'reports'] as const; - } +export const getAssetsReportsRetrieveQueryKey = (uidAsset: string) => { + return ['api', 'v2', 'assets', uidAsset, 'reports'] as const +} - -export const getAssetsReportsRetrieveQueryOptions = >, TError = ErrorDetail>(uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetsReportsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetsReportsRetrieveQueryKey(uidAsset); - - + const queryKey = queryOptions?.queryKey ?? getAssetsReportsRetrieveQueryKey(uidAsset) - const queryFn: QueryFunction>> = ({ signal }) => assetsReportsRetrieve(uidAsset, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + assetsReportsRetrieve(uidAsset, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidAsset), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidAsset, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetsReportsRetrieveQueryResult = NonNullable>> export type AssetsReportsRetrieveQueryError = ErrorDetail +export function useAssetsReportsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidAsset: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetsReportsRetrieveQueryOptions(uidAsset, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useAssetsReportsRetrieve>, TError = ErrorDetail>( - uidAsset: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetsReportsRetrieveQueryOptions(uidAsset,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - - diff --git a/jsapp/js/api/react-query/survey-data/msw.ts b/jsapp/js/api/react-query/survey-data/msw.ts index 0b12355e22..081c1eb882 100644 --- a/jsapp/js/api/react-query/survey-data/msw.ts +++ b/jsapp/js/api/react-query/survey-data/msw.ts @@ -9,959 +9,2956 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; +import { http, HttpResponse } from 'msw' -import { - ActionEnum -} from '../../models/actionEnum'; +import { ActionEnum } from '../../models/actionEnum' -import { - ActionIdEnum -} from '../../models/actionIdEnum'; +import { ActionIdEnum } from '../../models/actionIdEnum' -import type { - AdvancedFeatureCreateResponse -} from '../../models/advancedFeatureCreateResponse'; +import type { AdvancedFeatureCreateResponse } from '../../models/advancedFeatureCreateResponse' -import type { - AdvancedFeatureResponse -} from '../../models/advancedFeatureResponse'; +import type { AdvancedFeatureResponse } from '../../models/advancedFeatureResponse' -import type { - AssetAttachmentAudioDurationResponse -} from '../../models/assetAttachmentAudioDurationResponse'; +import type { AssetAttachmentAudioDurationResponse } from '../../models/assetAttachmentAudioDurationResponse' -import type { - BulkAcceptResponse -} from '../../models/bulkAcceptResponse'; +import type { BulkAcceptResponse } from '../../models/bulkAcceptResponse' -import type { - BulkActionCreateResponse -} from '../../models/bulkActionCreateResponse'; +import type { BulkActionCreateResponse } from '../../models/bulkActionCreateResponse' -import type { - BulkActionListResponse -} from '../../models/bulkActionListResponse'; +import type { BulkActionListResponse } from '../../models/bulkActionListResponse' -import type { - BulkActionResponse -} from '../../models/bulkActionResponse'; +import type { BulkActionResponse } from '../../models/bulkActionResponse' -import { - BulkActionResponseStatusEnum -} from '../../models/bulkActionResponseStatusEnum'; +import { BulkActionResponseStatusEnum } from '../../models/bulkActionResponseStatusEnum' -import { - BulkActionSubmissionStatusResponseStatusEnum -} from '../../models/bulkActionSubmissionStatusResponseStatusEnum'; +import { BulkActionSubmissionStatusResponseStatusEnum } from '../../models/bulkActionSubmissionStatusResponseStatusEnum' -import type { - DataBulkUpdateResponse -} from '../../models/dataBulkUpdateResponse'; +import type { DataBulkUpdateResponse } from '../../models/dataBulkUpdateResponse' -import type { - DataResponse -} from '../../models/dataResponse'; +import type { DataResponse } from '../../models/dataResponse' -import type { - DataStatusesUpdate -} from '../../models/dataStatusesUpdate'; +import type { DataStatusesUpdate } from '../../models/dataStatusesUpdate' -import type { - DataSupplementAutomaticQualDataIntegerResponse -} from '../../models/dataSupplementAutomaticQualDataIntegerResponse'; +import type { DataSupplementAutomaticQualDataIntegerResponse } from '../../models/dataSupplementAutomaticQualDataIntegerResponse' -import type { - DataSupplementAutomaticQualDataSelectMultipleResponse -} from '../../models/dataSupplementAutomaticQualDataSelectMultipleResponse'; +import type { DataSupplementAutomaticQualDataSelectMultipleResponse } from '../../models/dataSupplementAutomaticQualDataSelectMultipleResponse' -import type { - DataSupplementAutomaticQualDataSelectOneResponse -} from '../../models/dataSupplementAutomaticQualDataSelectOneResponse'; +import type { DataSupplementAutomaticQualDataSelectOneResponse } from '../../models/dataSupplementAutomaticQualDataSelectOneResponse' -import type { - DataSupplementAutomaticQualDataTextResponse -} from '../../models/dataSupplementAutomaticQualDataTextResponse'; +import type { DataSupplementAutomaticQualDataTextResponse } from '../../models/dataSupplementAutomaticQualDataTextResponse' -import type { - DataSupplementManualQualDataInteger -} from '../../models/dataSupplementManualQualDataInteger'; +import type { DataSupplementManualQualDataInteger } from '../../models/dataSupplementManualQualDataInteger' -import type { - DataSupplementManualQualDataSelectMultiple -} from '../../models/dataSupplementManualQualDataSelectMultiple'; +import type { DataSupplementManualQualDataSelectMultiple } from '../../models/dataSupplementManualQualDataSelectMultiple' -import type { - DataSupplementManualQualDataSelectOne -} from '../../models/dataSupplementManualQualDataSelectOne'; +import type { DataSupplementManualQualDataSelectOne } from '../../models/dataSupplementManualQualDataSelectOne' -import type { - DataSupplementManualQualDataTags -} from '../../models/dataSupplementManualQualDataTags'; +import type { DataSupplementManualQualDataTags } from '../../models/dataSupplementManualQualDataTags' -import type { - DataSupplementManualQualDataText -} from '../../models/dataSupplementManualQualDataText'; +import type { DataSupplementManualQualDataText } from '../../models/dataSupplementManualQualDataText' -import type { - DataSupplementResponse -} from '../../models/dataSupplementResponse'; +import type { DataSupplementResponse } from '../../models/dataSupplementResponse' -import type { - DataValidationStatus -} from '../../models/dataValidationStatus'; +import type { DataValidationStatus } from '../../models/dataValidationStatus' -import { - DataValidationStatusLabelEnum -} from '../../models/dataValidationStatusLabelEnum'; +import { DataValidationStatusLabelEnum } from '../../models/dataValidationStatusLabelEnum' -import { - DataValidationStatusUidEnum -} from '../../models/dataValidationStatusUidEnum'; +import { DataValidationStatusUidEnum } from '../../models/dataValidationStatusUidEnum' -import type { - DataValidationStatusUpdateResponse -} from '../../models/dataValidationStatusUpdateResponse'; +import type { DataValidationStatusUpdateResponse } from '../../models/dataValidationStatusUpdateResponse' -import type { - EnketoEditResponse -} from '../../models/enketoEditResponse'; +import type { EnketoEditResponse } from '../../models/enketoEditResponse' -import type { - EnketoViewResponse -} from '../../models/enketoViewResponse'; +import type { EnketoViewResponse } from '../../models/enketoViewResponse' -import type { - ExportResponse -} from '../../models/exportResponse'; +import type { ExportResponse } from '../../models/exportResponse' -import type { - ExportSettingResponse -} from '../../models/exportSettingResponse'; +import type { ExportSettingResponse } from '../../models/exportSettingResponse' -import type { - ExternalResponse -} from '../../models/externalResponse'; +import type { ExternalResponse } from '../../models/externalResponse' -import type { - FilesResponse -} from '../../models/filesResponse'; +import type { FilesResponse } from '../../models/filesResponse' -import type { - PaginatedDataResponseList -} from '../../models/paginatedDataResponseList'; +import type { PaginatedDataResponseList } from '../../models/paginatedDataResponseList' -import type { - PaginatedExportResponseList -} from '../../models/paginatedExportResponseList'; +import type { PaginatedExportResponseList } from '../../models/paginatedExportResponseList' -import type { - PaginatedExportSettingResponseList -} from '../../models/paginatedExportSettingResponseList'; +import type { PaginatedExportSettingResponseList } from '../../models/paginatedExportSettingResponseList' -import type { - PaginatedFilesResponseList -} from '../../models/paginatedFilesResponseList'; +import type { PaginatedFilesResponseList } from '../../models/paginatedFilesResponseList' -import type { - PaginatedPairedDataResponseList -} from '../../models/paginatedPairedDataResponseList'; +import type { PaginatedPairedDataResponseList } from '../../models/paginatedPairedDataResponseList' -import type { - PairedDataResponse -} from '../../models/pairedDataResponse'; +import type { PairedDataResponse } from '../../models/pairedDataResponse' -import { - QualSelectQuestionParamsTypeEnum -} from '../../models/qualSelectQuestionParamsTypeEnum'; +import { QualSelectQuestionParamsTypeEnum } from '../../models/qualSelectQuestionParamsTypeEnum' -import { - QualSimpleQuestionParamsTypeEnum -} from '../../models/qualSimpleQuestionParamsTypeEnum'; +import { QualSimpleQuestionParamsTypeEnum } from '../../models/qualSimpleQuestionParamsTypeEnum' -import type { - ReportResponse -} from '../../models/reportResponse'; +import type { ReportResponse } from '../../models/reportResponse' -import type { - SupplementalDataContentAutomaticComplete -} from '../../models/supplementalDataContentAutomaticComplete'; +import type { SupplementalDataContentAutomaticComplete } from '../../models/supplementalDataContentAutomaticComplete' -import type { - SupplementalDataContentAutomaticDeleted -} from '../../models/supplementalDataContentAutomaticDeleted'; +import type { SupplementalDataContentAutomaticDeleted } from '../../models/supplementalDataContentAutomaticDeleted' -import type { - SupplementalDataContentAutomaticFailed -} from '../../models/supplementalDataContentAutomaticFailed'; +import type { SupplementalDataContentAutomaticFailed } from '../../models/supplementalDataContentAutomaticFailed' -import type { - SupplementalDataContentAutomaticInProgress -} from '../../models/supplementalDataContentAutomaticInProgress'; +import type { SupplementalDataContentAutomaticInProgress } from '../../models/supplementalDataContentAutomaticInProgress' - -export const getApiV2AssetsAdvancedFeaturesListResponseMock = (): AdvancedFeatureResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.helpers.arrayElement(Object.values(ActionEnum)), params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{language: faker.string.alpha({length: {min: 10, max: 20}})},faker.helpers.arrayElement([{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.uuid(), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])})), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},]),{uuid: faker.string.uuid()},]))), uid: faker.string.alpha({length: {min: 10, max: 20}})}))) - -export const getApiV2AssetsAdvancedFeaturesCreateResponseMock = (overrideResponse: Partial< AdvancedFeatureCreateResponse > = {}): AdvancedFeatureCreateResponse => ({question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.helpers.arrayElement(Object.values(ActionEnum)), params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{language: faker.string.alpha({length: {min: 10, max: 20}})},faker.helpers.arrayElement([{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, hint: faker.helpers.arrayElement([{}, undefined])},{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.uuid(), hint: faker.helpers.arrayElement([{}, undefined])})), hint: faker.helpers.arrayElement([{}, undefined])},]),{uuid: faker.string.uuid()},]))), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsAdvancedFeaturesRetrieveResponseMock = (overrideResponse: Partial< AdvancedFeatureResponse > = {}): AdvancedFeatureResponse => ({question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.helpers.arrayElement(Object.values(ActionEnum)), params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{language: faker.string.alpha({length: {min: 10, max: 20}})},faker.helpers.arrayElement([{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.uuid(), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])})), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},]),{uuid: faker.string.uuid()},]))), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock = (overrideResponse: Partial< AdvancedFeatureResponse > = {}): AdvancedFeatureResponse => ({question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), action: faker.helpers.arrayElement(Object.values(ActionEnum)), params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([{language: faker.string.alpha({length: {min: 10, max: 20}})},faker.helpers.arrayElement([{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},{uuid: faker.string.uuid(), type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.uuid(), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])})), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), hint: faker.helpers.arrayElement([{}, undefined])},]),{uuid: faker.string.uuid()},]))), uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock = (overrideResponse: Partial< BulkActionListResponse > = {}): BulkActionListResponse => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), params: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, progress: faker.number.int({min: 0, max: 100, multipleOf: undefined}), created_by: {username: faker.string.alpha({length: {min: 10, max: 20}})}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, cancelled_by: faker.helpers.arrayElement([{...{username: faker.string.alpha({length: {min: 10, max: 20}})},}, undefined])})), ...overrideResponse}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock = (overrideResponse: Partial< BulkActionCreateResponse > = {}): BulkActionCreateResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), params: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, progress: faker.number.int({min: 0, max: 100, multipleOf: undefined}), created_by: {username: faker.string.alpha({length: {min: 10, max: 20}})}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, cancelled_by: faker.helpers.arrayElement([{...{username: faker.string.alpha({length: {min: 10, max: 20}})},}, undefined]), skipped_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock = (overrideResponse: Partial< BulkActionResponse > = {}): BulkActionResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), params: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, progress: faker.number.int({min: 0, max: 100, multipleOf: undefined}), created_by: {username: faker.string.alpha({length: {min: 10, max: 20}})}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, cancelled_by: faker.helpers.arrayElement([{...{username: faker.string.alpha({length: {min: 10, max: 20}})},}, undefined]), ...overrideResponse}) - -export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock = (overrideResponse: Partial< BulkActionResponse > = {}): BulkActionResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), error: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), params: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, progress: faker.number.int({min: 0, max: 100, multipleOf: undefined}), created_by: {username: faker.string.alpha({length: {min: 10, max: 20}})}, date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, cancelled_by: faker.helpers.arrayElement([{...{username: faker.string.alpha({length: {min: 10, max: 20}})},}, undefined]), ...overrideResponse}) - -export const getApiV2AssetsAttachmentsAudioDurationCreateResponseMock = (overrideResponse: Partial< AssetAttachmentAudioDurationResponse > = {}): AssetAttachmentAudioDurationResponse => ({attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), seconds: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null])})), total: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), ...overrideResponse}) - -export const getApiV2AssetsDataListResponseDataValidationStatusMock = (overrideResponse: Partial = {}): DataValidationStatus => ({...{timestamp: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), by_whom: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum))}, ...overrideResponse}); - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticInProgress => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'in_progress'}, ...overrideResponse}); - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticFailed => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticComplete => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'complete', value: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); - -export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticDeleted => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'deleted', value: null}, ...overrideResponse}); - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataInteger => ({...{value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataText => ({...{value: faker.string.alpha({length: {min: 10, max: 20}}), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectOne => ({...{value: faker.string.uuid(), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectMultiple => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataTags => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataIntegerResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataTextResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.alpha({length: {min: 10, max: 20}}), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectOneResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectMultipleResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataListResponseMock = (overrideResponse: Partial< PaginatedDataResponseList > = {}): PaginatedDataResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), __version__: faker.string.alpha({length: {min: 10, max: 20}}), 'meta/instanceID': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/rootUuid': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), _xform_id_string: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.alpha({length: {min: 10, max: 20}}), _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({download_url: faker.internet.url(), download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), mimetype: faker.string.alpha({length: {min: 10, max: 20}}), media_file_basename: faker.string.alpha({length: {min: 10, max: 20}}), filename: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}}), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])})), _status: faker.string.alpha({length: {min: 10, max: 20}}), _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}),null,]))), _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, _validation_status: faker.helpers.arrayElement([{...getApiV2AssetsDataListResponseDataValidationStatusMock()},]), _submitted_by: faker.string.alpha({length: {min: 10, max: 20}}), _supplementalDetails: faker.helpers.arrayElement([faker.helpers.arrayElement([{ - [faker.string.alphanumeric(5)]: {manual_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))}} - },{ - [faker.string.alphanumeric(5)]: {manual_translation: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))} - }} - },{ - [faker.string.alphanumeric(5)]: {automatic_google_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _data: faker.helpers.arrayElement([{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock()},])}))}} - },{ - [faker.string.alphanumeric(5)]: {automatic_google_translation: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: faker.helpers.arrayElement([{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock()},])}))} - }} - },{ - [faker.string.alphanumeric(5)]: {manual_qual: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock()},{...getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock()},{...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock()},{...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock()},{...getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} - }} - },{ - [faker.string.alphanumeric(5)]: {automatic_bedrock_qual: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock()},{...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock()},{...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock()},{...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), _dependency: faker.helpers.arrayElement([{_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, undefined]), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} - }} - },]), undefined])})), ...overrideResponse}) - -export const getApiV2AssetsDataRetrieveResponseDataValidationStatusMock = (overrideResponse: Partial = {}): DataValidationStatus => ({...{timestamp: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), by_whom: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum))}, ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticInProgress => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'in_progress'}, ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticFailed => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticComplete => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'complete', value: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticDeleted => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'deleted', value: null}, ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataInteger => ({...{value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataText => ({...{value: faker.string.alpha({length: {min: 10, max: 20}}), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectOne => ({...{value: faker.string.uuid(), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectMultiple => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataTags => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataIntegerResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataTextResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.alpha({length: {min: 10, max: 20}}), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectOneResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectMultipleResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataRetrieveResponseMock = (overrideResponse: Partial< DataResponse > = {}): DataResponse => ({_id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), __version__: faker.string.alpha({length: {min: 10, max: 20}}), 'meta/instanceID': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/rootUuid': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), _xform_id_string: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.alpha({length: {min: 10, max: 20}}), _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({download_url: faker.internet.url(), download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), mimetype: faker.string.alpha({length: {min: 10, max: 20}}), media_file_basename: faker.string.alpha({length: {min: 10, max: 20}}), filename: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}}), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])})), _status: faker.string.alpha({length: {min: 10, max: 20}}), _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}),null,]))), _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, _validation_status: faker.helpers.arrayElement([{...getApiV2AssetsDataRetrieveResponseDataValidationStatusMock()},]), _submitted_by: faker.string.alpha({length: {min: 10, max: 20}}), _supplementalDetails: faker.helpers.arrayElement([faker.helpers.arrayElement([{ - [faker.string.alphanumeric(5)]: {manual_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))}} - },{ - [faker.string.alphanumeric(5)]: {manual_translation: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))} - }} - },{ - [faker.string.alphanumeric(5)]: {automatic_google_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _data: faker.helpers.arrayElement([{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock()},])}))}} - },{ - [faker.string.alphanumeric(5)]: {automatic_google_translation: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: faker.helpers.arrayElement([{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock()},])}))} - }} - },{ - [faker.string.alphanumeric(5)]: {manual_qual: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} - }} - },{ - [faker.string.alphanumeric(5)]: {automatic_bedrock_qual: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock()},{...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), _dependency: faker.helpers.arrayElement([{_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, undefined]), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} - }} - },]), undefined]), ...overrideResponse}) - -export const getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock = (overrideResponse: Partial = {}): DataValidationStatus => ({...{timestamp: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), by_whom: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum))}, ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticInProgress => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'in_progress'}, ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticFailed => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticComplete => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'complete', value: faker.string.alpha({length: {min: 10, max: 20}})}, ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock = (overrideResponse: Partial = {}): SupplementalDataContentAutomaticDeleted => ({...{language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status: 'deleted', value: null}, ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataInteger => ({...{value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataText => ({...{value: faker.string.alpha({length: {min: 10, max: 20}}), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectOne => ({...{value: faker.string.uuid(), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataSelectMultiple => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock = (overrideResponse: Partial = {}): DataSupplementManualQualDataTags => ({...{value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), uuid: faker.string.uuid()}, ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataIntegerResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), null]), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataTextResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.alpha({length: {min: 10, max: 20}}), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectOneResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = (overrideResponse: Omit, 'status'> = {}): DataSupplementAutomaticQualDataSelectMultipleResponse => ({...faker.helpers.arrayElement([{uuid: faker.string.uuid(), value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.uuid())), status: 'complete'},{uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({length: {min: 10, max: 20}})},]), ...overrideResponse}); - -export const getApiV2AssetsDataDuplicateCreateResponseMock = (overrideResponse: Partial< DataResponse > = {}): DataResponse => ({_id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), __version__: faker.string.alpha({length: {min: 10, max: 20}}), 'meta/instanceID': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/rootUuid': faker.string.alpha({length: {min: 10, max: 20}}), 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), _xform_id_string: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.alpha({length: {min: 10, max: 20}}), _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({download_url: faker.internet.url(), download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), mimetype: faker.string.alpha({length: {min: 10, max: 20}}), media_file_basename: faker.string.alpha({length: {min: 10, max: 20}}), filename: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}}), question_xpath: faker.string.alpha({length: {min: 10, max: 20}}), is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])})), _status: faker.string.alpha({length: {min: 10, max: 20}}), _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}),null,]))), _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, _validation_status: faker.helpers.arrayElement([{...getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock()},]), _submitted_by: faker.string.alpha({length: {min: 10, max: 20}}), _supplementalDetails: faker.helpers.arrayElement([faker.helpers.arrayElement([{ - [faker.string.alphanumeric(5)]: {manual_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))}} - },{ - [faker.string.alphanumeric(5)]: {manual_translation: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: {language: faker.string.alpha({length: {min: 10, max: 20}}), locale: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])}}))} - }} - },{ - [faker.string.alphanumeric(5)]: {automatic_google_transcription: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _data: faker.helpers.arrayElement([{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock()},])}))}} - },{ - [faker.string.alphanumeric(5)]: {automatic_google_translation: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _uuid: faker.string.uuid(), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dependency: {_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, _data: faker.helpers.arrayElement([{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock()},{...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock()},])}))} - }} - },{ - [faker.string.alphanumeric(5)]: {manual_qual: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} - }} - },{ - [faker.string.alphanumeric(5)]: {automatic_bedrock_qual: { - [faker.string.alphanumeric(5)]: {_dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({_data: faker.helpers.arrayElement([{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock()},{...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock()},]), _dateAccepted: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, _dateVerified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), _uuid: faker.string.uuid(), _dependency: faker.helpers.arrayElement([{_actionId: faker.string.alpha({length: {min: 10, max: 20}}), _uuid: faker.string.uuid()}, undefined]), verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}))} - }} - },]), undefined]), ...overrideResponse}) - -export const getApiV2AssetsDataEditRetrieveResponseMock = (overrideResponse: Partial< EnketoEditResponse > = {}): EnketoEditResponse => ({url: faker.internet.url(), version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsDataEnketoEditRetrieveResponseMock = (overrideResponse: Partial< EnketoEditResponse > = {}): EnketoEditResponse => ({url: faker.internet.url(), version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock = (overrideResponse: Partial< EnketoEditResponse > = {}): EnketoEditResponse => ({url: faker.internet.url(), version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock = (overrideResponse: Partial< EnketoViewResponse > = {}): EnketoViewResponse => ({url: faker.internet.url(), version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsDataEnketoViewRetrieveResponseMock = (overrideResponse: Partial< EnketoViewResponse > = {}): EnketoViewResponse => ({url: faker.internet.url(), version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsDataValidationStatusRetrieveResponseMock = (overrideResponse: Partial< DataValidationStatusUpdateResponse > = {}): DataValidationStatusUpdateResponse => ({timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, uid: faker.string.alpha({length: {min: 10, max: 20}}), by_whom: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsDataValidationStatusPartialUpdateResponseMock = (overrideResponse: Partial< DataValidationStatusUpdateResponse > = {}): DataValidationStatusUpdateResponse => ({timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, uid: faker.string.alpha({length: {min: 10, max: 20}}), by_whom: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsDataSupplementRetrieveResponseMock = (overrideResponse: Partial< DataSupplementResponse > = {}): DataSupplementResponse => ({_version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsDataSupplementPartialUpdateResponseMock = (overrideResponse: Partial< DataSupplementResponse > = {}): DataSupplementResponse => ({_version: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsDataBulkPartialUpdateResponseMock = (overrideResponse: Partial< DataBulkUpdateResponse > = {}): DataBulkUpdateResponse => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), successes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), failures: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), status_code: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), message: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), ...overrideResponse}) - -export const getApiV2AssetsDataSupplementsBulkCreateResponseMock = (overrideResponse: Partial< BulkAcceptResponse > = {}): BulkAcceptResponse => ({accepted_count: faker.number.int({min: 0, max: undefined, multipleOf: undefined}), ...overrideResponse}) - -export const getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock = (overrideResponse: Partial< DataStatusesUpdate > = {}): DataStatusesUpdate => ({detail: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2AssetsExportSettingsListResponseMock = (overrideResponse: Partial< PaginatedExportSettingResponseList > = {}): PaginatedExportSettingResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), data_url_csv: faker.internet.url(), data_url_xlsx: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}})), ...overrideResponse}) - -export const getApiV2AssetsExportSettingsCreateResponseMock = (overrideResponse: Partial< ExportSettingResponse > = {}): ExportSettingResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), data_url_csv: faker.internet.url(), data_url_xlsx: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, ...overrideResponse}) - -export const getApiV2AssetsExportSettingsRetrieveResponseMock = (overrideResponse: Partial< ExportSettingResponse > = {}): ExportSettingResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), data_url_csv: faker.internet.url(), data_url_xlsx: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, ...overrideResponse}) - -export const getApiV2AssetsExportSettingsPartialUpdateResponseMock = (overrideResponse: Partial< ExportSettingResponse > = {}): ExportSettingResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), data_url_csv: faker.internet.url(), data_url_xlsx: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, ...overrideResponse}) - -export const getApiV2AssetsExportsListResponseMock = (overrideResponse: Partial< PaginatedExportResponseList > = {}): PaginatedExportResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), message: {}, uid: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, result: faker.internet.url(), data: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), source: faker.helpers.arrayElement([faker.internet.url(), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), processing_time_seconds: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}})), ...overrideResponse}) - -export const getApiV2AssetsExportsCreateResponseMock = (overrideResponse: Partial< ExportResponse > = {}): ExportResponse => ({url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), message: {}, uid: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, result: faker.internet.url(), data: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), source: faker.helpers.arrayElement([faker.internet.url(), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), processing_time_seconds: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, ...overrideResponse}) - -export const getApiV2AssetsExportsRetrieveResponseMock = (overrideResponse: Partial< ExportResponse > = {}): ExportResponse => ({url: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), message: {}, uid: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, result: faker.internet.url(), data: {lang: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), source: faker.helpers.arrayElement([faker.internet.url(), undefined]), group_sep: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), multiple_select: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), processing_time_seconds: faker.helpers.arrayElement([faker.number.float({min: undefined, max: undefined, fractionDigits: 2}), undefined]), fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, ...overrideResponse}) - -export const getApiV2AssetsFilesListResponseMock = (overrideResponse: Partial< PaginatedFilesResponseList > = {}): PaginatedFilesResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), asset: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), file_type: faker.string.alpha({length: {min: 10, max: 20}}), description: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, content: faker.internet.url(), metadata: {hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), mimetype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}})), ...overrideResponse}) - -export const getApiV2AssetsFilesCreateResponseMock = (overrideResponse: Partial< FilesResponse > = {}): FilesResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), asset: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), file_type: faker.string.alpha({length: {min: 10, max: 20}}), description: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, content: faker.internet.url(), metadata: {hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), mimetype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, ...overrideResponse}) - -export const getApiV2AssetsFilesRetrieveResponseMock = (overrideResponse: Partial< FilesResponse > = {}): FilesResponse => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), asset: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), file_type: faker.string.alpha({length: {min: 10, max: 20}}), description: faker.string.alpha({length: {min: 10, max: 20}}), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, content: faker.internet.url(), metadata: {hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), mimetype: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, ...overrideResponse}) - -export const getApiV2AssetsPairedDataListResponseMock = (overrideResponse: Partial< PaginatedPairedDataResponseList > = {}): PaginatedPairedDataResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({source: faker.internet.url(), source__name: faker.string.alpha({length: {min: 10, max: 20}}), fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), filename: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url()})), ...overrideResponse}) - -export const getApiV2AssetsPairedDataCreateResponseMock = (overrideResponse: Partial< PairedDataResponse > = {}): PairedDataResponse => ({source: faker.internet.url(), source__name: faker.string.alpha({length: {min: 10, max: 20}}), fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), filename: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) - -export const getApiV2AssetsPairedDataRetrieveResponseMock = (overrideResponse: Partial< PairedDataResponse > = {}): PairedDataResponse => ({source: faker.internet.url(), source__name: faker.string.alpha({length: {min: 10, max: 20}}), fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), filename: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) - -export const getApiV2AssetsPairedDataPartialUpdateResponseMock = (overrideResponse: Partial< PairedDataResponse > = {}): PairedDataResponse => ({source: faker.internet.url(), source__name: faker.string.alpha({length: {min: 10, max: 20}}), fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), filename: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), ...overrideResponse}) - -export const getApiV2AssetsPairedDataExternalRetrieveResponseMock = (overrideResponse: Partial< ExternalResponse > = {}): ExternalResponse => ({root: {data: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), field_value_1: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), field_value_2: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined])}, ...overrideResponse}) - -export const getApiV2AssetsReportsRetrieveResponseMock = (overrideResponse: Partial< ReportResponse > = {}): ReportResponse => ({url: faker.internet.url(), count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), list: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), row: faker.helpers.arrayElement([{type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), data: faker.helpers.arrayElement([{total_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), not_provided: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), provided: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), show_graph: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), kuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([{}, undefined])})), ...overrideResponse}) - - -export const getApiV2AssetsAdvancedFeaturesListMockHandler = (overrideResponse?: AdvancedFeatureResponse[] | ((info: Parameters[1]>[0]) => Promise | AdvancedFeatureResponse[])) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsAdvancedFeaturesListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsAdvancedFeaturesListResponseMock = (): AdvancedFeatureResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2AssetsAdvancedFeaturesCreateResponseMock = ( + overrideResponse: Partial = {}, +): AdvancedFeatureCreateResponse => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AdvancedFeatureResponse => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): AdvancedFeatureResponse => ({ + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + action: faker.helpers.arrayElement(Object.values(ActionEnum)), + params: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([ + { language: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSimpleQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + { + uuid: faker.string.uuid(), + type: faker.helpers.arrayElement(Object.values(QualSelectQuestionParamsTypeEnum)), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + choices: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.uuid(), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + })), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + hint: faker.helpers.arrayElement([{}, undefined]), + }, + ]), + { uuid: faker.string.uuid() }, + ]), + ), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionListResponse => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + previous: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionCreateResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + skipped_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): BulkActionResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionResponseStatusEnum)), + action_id: faker.helpers.arrayElement(Object.values(ActionIdEnum)), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + submission_uuids: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + submission_statuses: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(BulkActionSubmissionStatusResponseStatusEnum)), + error: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + params: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + progress: faker.number.int({ min: 0, max: 100, multipleOf: undefined }), + created_by: { username: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + cancelled_by: faker.helpers.arrayElement([ + { ...{ username: faker.string.alpha({ length: { min: 10, max: 20 } }) } }, + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsAttachmentsAudioDurationCreateResponseMock = ( + overrideResponse: Partial = {}, +): AssetAttachmentAudioDurationResponse => ({ + attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + seconds: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + })), + total: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataValidationStatusMock = ( + overrideResponse: Partial = {}, +): DataValidationStatus => ({ + ...{ + timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticInProgress => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'in_progress', + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticFailed => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'failed', + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticComplete => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'complete', + value: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticDeleted => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'deleted', + value: null, + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataInteger => ({ + ...{ + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataText => ({ + ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectOne => ({ + ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectMultiple => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataTags => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataIntegerResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataTextResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectOneResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedDataResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + download_url: faker.internet.url(), + download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), + media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + _status: faker.string.alpha({ length: { min: 10, max: 20 } }), + _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), + ), + _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + _validation_status: faker.helpers.arrayElement([{ ...getApiV2AssetsDataListResponseDataValidationStatusMock() }]), + _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), + _supplementalDetails: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + { + [faker.string.alphanumeric(5)]: { + manual_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataListResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataIntegerMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataTextMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectOneMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataSelectMultipleMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementManualQualDataTagsMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataTextResponseMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectOneResponseMock() }, + { ...getApiV2AssetsDataListResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + _dependency: faker.helpers.arrayElement([ + { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, + undefined, + ]), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + ]), + undefined, + ]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataValidationStatusMock = ( + overrideResponse: Partial = {}, +): DataValidationStatus => ({ + ...{ + timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticInProgress => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'in_progress', + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticFailed => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'failed', + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticComplete => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'complete', + value: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticDeleted => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'deleted', + value: null, + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataInteger => ({ + ...{ + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataText => ({ + ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectOne => ({ + ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectMultiple => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataTags => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataIntegerResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataTextResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectOneResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataRetrieveResponseMock = (overrideResponse: Partial = {}): DataResponse => ({ + _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + download_url: faker.internet.url(), + download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), + media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + _status: faker.string.alpha({ length: { min: 10, max: 20 } }), + _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), + ), + _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + _validation_status: faker.helpers.arrayElement([{ ...getApiV2AssetsDataRetrieveResponseDataValidationStatusMock() }]), + _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), + _supplementalDetails: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + { + [faker.string.alphanumeric(5)]: { + manual_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataRetrieveResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataIntegerMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTextMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectOneMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataSelectMultipleMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementManualQualDataTagsMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataTextResponseMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectOneResponseMock() }, + { ...getApiV2AssetsDataRetrieveResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + _dependency: faker.helpers.arrayElement([ + { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, + undefined, + ]), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + ]), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock = ( + overrideResponse: Partial = {}, +): DataValidationStatus => ({ + ...{ + timestamp: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + uid: faker.helpers.arrayElement(Object.values(DataValidationStatusUidEnum)), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement(Object.values(DataValidationStatusLabelEnum)), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticInProgress => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'in_progress', + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticFailed => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'failed', + error: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticComplete => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'complete', + value: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock = ( + overrideResponse: Partial = {}, +): SupplementalDataContentAutomaticDeleted => ({ + ...{ + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status: 'deleted', + value: null, + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataInteger => ({ + ...{ + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataText => ({ + ...{ value: faker.string.alpha({ length: { min: 10, max: 20 } }), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectOne => ({ + ...{ value: faker.string.uuid(), uuid: faker.string.uuid() }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataSelectMultiple => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock = ( + overrideResponse: Partial = {}, +): DataSupplementManualQualDataTags => ({ + ...{ + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + uuid: faker.string.uuid(), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataIntegerResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + null, + ]), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataTextResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.alpha({ length: { min: 10, max: 20 } }), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectOneResponse => ({ + ...faker.helpers.arrayElement([ + { uuid: faker.string.uuid(), value: faker.string.uuid(), status: 'complete' }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock = ( + overrideResponse: Omit, 'status'> = {}, +): DataSupplementAutomaticQualDataSelectMultipleResponse => ({ + ...faker.helpers.arrayElement([ + { + uuid: faker.string.uuid(), + value: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + status: 'complete', + }, + { uuid: faker.string.uuid(), status: 'failed', error: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataDuplicateCreateResponseMock = ( + overrideResponse: Partial = {}, +): DataResponse => ({ + _id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + 'formhub/uuid': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + __version__: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/instanceID': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/rootUuid': faker.string.alpha({ length: { min: 10, max: 20 } }), + 'meta/deprecatedID': faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + _xform_id_string: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + _attachments: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + download_url: faker.internet.url(), + download_large_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_medium_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + download_small_url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + mimetype: faker.string.alpha({ length: { min: 10, max: 20 } }), + media_file_basename: faker.string.alpha({ length: { min: 10, max: 20 } }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + question_xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + _status: faker.string.alpha({ length: { min: 10, max: 20 } }), + _geolocation: Array.from({ length: faker.number.int({ min: 2, max: 2 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), null]), + ), + _submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + _validation_status: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseDataValidationStatusMock() }, + ]), + _submitted_by: faker.string.alpha({ length: { min: 10, max: 20 } }), + _supplementalDetails: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + { + [faker.string.alphanumeric(5)]: { + manual_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: { + language: faker.string.alpha({ length: { min: 10, max: 20 } }), + locale: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + }, + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_transcription: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_google_translation: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _uuid: faker.string.uuid(), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dependency: { + _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), + _uuid: faker.string.uuid(), + }, + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticInProgressMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticFailedMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticCompleteMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseSupplementalDataContentAutomaticDeletedMock() }, + ]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + manual_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataIntegerMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTextMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectOneMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataSelectMultipleMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementManualQualDataTagsMock() }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + { + [faker.string.alphanumeric(5)]: { + automatic_bedrock_qual: { + [faker.string.alphanumeric(5)]: { + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateModified: `${faker.date.past().toISOString().split('.')[0]}Z`, + _versions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + _data: faker.helpers.arrayElement([ + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataIntegerResponseMock() }, + { ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataTextResponseMock() }, + { + ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectOneResponseMock(), + }, + { + ...getApiV2AssetsDataDuplicateCreateResponseDataSupplementAutomaticQualDataSelectMultipleResponseMock(), + }, + ]), + _dateAccepted: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _dateCreated: `${faker.date.past().toISOString().split('.')[0]}Z`, + _dateVerified: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + _uuid: faker.string.uuid(), + _dependency: faker.helpers.arrayElement([ + { _actionId: faker.string.alpha({ length: { min: 10, max: 20 } }), _uuid: faker.string.uuid() }, + undefined, + ]), + verified: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + })), + }, + }, + }, + }, + ]), + undefined, + ]), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEditRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoEditResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoEditRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoEditResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoEditResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoViewResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataEnketoViewRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): EnketoViewResponse => ({ + url: faker.internet.url(), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataValidationStatusRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): DataValidationStatusUpdateResponse => ({ + timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataValidationStatusPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataValidationStatusUpdateResponse => ({ + timestamp: `${faker.date.past().toISOString().split('.')[0]}Z`, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + by_whom: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataSupplementRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AssetsDataSupplementPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AssetsDataBulkPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataBulkUpdateResponse => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + successes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + failures: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + status_code: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + message: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsDataSupplementsBulkCreateResponseMock = ( + overrideResponse: Partial = {}, +): BulkAcceptResponse => ({ + accepted_count: faker.number.int({ min: 0, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): DataStatusesUpdate => ({ detail: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) + +export const getApiV2AssetsExportSettingsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedExportSettingResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsExportSettingsCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportSettingResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportSettingsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExportSettingResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportSettingsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): ExportSettingResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + data_url_csv: faker.internet.url(), + data_url_xlsx: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + xls_types_as_text: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedExportResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + message: {}, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + result: faker.internet.url(), + data: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source: faker.helpers.arrayElement([faker.internet.url(), undefined]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + processing_time_seconds: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsExportsCreateResponseMock = ( + overrideResponse: Partial = {}, +): ExportResponse => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + message: {}, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + result: faker.internet.url(), + data: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source: faker.helpers.arrayElement([faker.internet.url(), undefined]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + processing_time_seconds: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsExportsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExportResponse => ({ + url: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + message: {}, + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_submission_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + result: faker.internet.url(), + data: { + lang: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + source: faker.helpers.arrayElement([faker.internet.url(), undefined]), + group_sep: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + multiple_select: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + include_media_url: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + hierarchy_in_labels: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + processing_time_seconds: faker.helpers.arrayElement([ + faker.number.float({ min: undefined, max: undefined, fractionDigits: 2 }), + undefined, + ]), + fields_from_all_versions: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsFilesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedFilesResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + asset: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + description: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: faker.internet.url(), + metadata: { + hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2AssetsFilesCreateResponseMock = ( + overrideResponse: Partial = {}, +): FilesResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + asset: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + description: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: faker.internet.url(), + metadata: { + hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsFilesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): FilesResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + asset: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + file_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + description: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + content: faker.internet.url(), + metadata: { + hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + mimetype: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedPairedDataResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataCreateResponseMock = ( + overrideResponse: Partial = {}, +): PairedDataResponse => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PairedDataResponse => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): PairedDataResponse => ({ + source: faker.internet.url(), + source__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2AssetsPairedDataExternalRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ExternalResponse => ({ + root: { + data: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + field_value_1: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + field_value_2: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getApiV2AssetsReportsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ReportResponse => ({ + url: faker.internet.url(), + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + list: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + row: faker.helpers.arrayElement([ + { type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]) }, + undefined, + ]), + data: faker.helpers.arrayElement([ + { + total_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + not_provided: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + provided: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + show_graph: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + undefined, + ]), + kuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([{}, undefined]), + })), + ...overrideResponse, +}) + +export const getApiV2AssetsAdvancedFeaturesListMockHandler = ( + overrideResponse?: + | AdvancedFeatureResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureResponse[]), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsAdvancedFeaturesCreateMockHandler = (overrideResponse?: AdvancedFeatureCreateResponse | ((info: Parameters[1]>[0]) => Promise | AdvancedFeatureCreateResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsAdvancedFeaturesCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsAdvancedFeaturesCreateMockHandler = ( + overrideResponse?: + | AdvancedFeatureCreateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureCreateResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsAdvancedFeaturesRetrieveMockHandler = (overrideResponse?: AdvancedFeatureResponse | ((info: Parameters[1]>[0]) => Promise | AdvancedFeatureResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsAdvancedFeaturesRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsAdvancedFeaturesRetrieveMockHandler = ( + overrideResponse?: + | AdvancedFeatureResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler = (overrideResponse?: AdvancedFeatureResponse | ((info: Parameters[1]>[0]) => Promise | AdvancedFeatureResponse)) => { - return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler = ( + overrideResponse?: + | AdvancedFeatureResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AdvancedFeatureResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler = (overrideResponse?: BulkActionListResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionListResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler = ( + overrideResponse?: + | BulkActionListResponse + | (( + info: Parameters[1]>[0], + ) => Promise | BulkActionListResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler = (overrideResponse?: BulkActionCreateResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionCreateResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler = ( + overrideResponse?: + | BulkActionCreateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | BulkActionCreateResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler = (overrideResponse?: BulkActionResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler = ( + overrideResponse?: + | BulkActionResponse + | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = (overrideResponse?: BulkActionResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse)) => { - return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = ( + overrideResponse?: + | BulkActionResponse + | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsAttachmentsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/attachments/:id/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsAttachmentsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/attachments/:id/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = (overrideResponse?: AssetAttachmentAudioDurationResponse | ((info: Parameters[1]>[0]) => Promise | AssetAttachmentAudioDurationResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsAttachmentsAudioDurationCreateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = ( + overrideResponse?: + | AssetAttachmentAudioDurationResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AssetAttachmentAudioDurationResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsAttachmentsAudioDurationCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsAttachmentsBulkDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 202, - - }) +export const getApiV2AssetsAttachmentsBulkDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 202 }) }) } -export const getApiV2AssetsDataListMockHandler = (overrideResponse?: PaginatedDataResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedDataResponseList)) => { - return http.get('*/api/v2/assets/:uidAsset/data/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataListMockHandler = ( + overrideResponse?: + | PaginatedDataResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedDataResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataRetrieveMockHandler = (overrideResponse?: DataResponse | ((info: Parameters[1]>[0]) => Promise | DataResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataRetrieveMockHandler = ( + overrideResponse?: + | DataResponse + | ((info: Parameters[1]>[0]) => Promise | DataResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/data/:id/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsDataDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsDataDuplicateCreateMockHandler = (overrideResponse?: DataResponse | ((info: Parameters[1]>[0]) => Promise | DataResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataDuplicateCreateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataDuplicateCreateMockHandler = ( + overrideResponse?: + | DataResponse + | ((info: Parameters[1]>[0]) => Promise | DataResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataDuplicateCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataEditRetrieveMockHandler = (overrideResponse?: EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/edit/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataEditRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataEditRetrieveMockHandler = ( + overrideResponse?: + | EnketoEditResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/edit/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEditRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataEnketoEditRetrieveMockHandler = (overrideResponse?: EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataEnketoEditRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataEnketoEditRetrieveMockHandler = ( + overrideResponse?: + | EnketoEditResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoEditRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler = (overrideResponse?: EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler = ( + overrideResponse?: + | EnketoEditResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoRedirectEditRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler = (overrideResponse?: EnketoViewResponse | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler = ( + overrideResponse?: + | EnketoViewResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoRedirectViewRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataEnketoViewRetrieveMockHandler = (overrideResponse?: EnketoViewResponse | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataEnketoViewRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataEnketoViewRetrieveMockHandler = ( + overrideResponse?: + | EnketoViewResponse + | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataEnketoViewRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataValidationStatusRetrieveMockHandler = (overrideResponse?: DataValidationStatusUpdateResponse | ((info: Parameters[1]>[0]) => Promise | DataValidationStatusUpdateResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataValidationStatusRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataValidationStatusRetrieveMockHandler = ( + overrideResponse?: + | DataValidationStatusUpdateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataValidationStatusUpdateResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataValidationStatusRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = (overrideResponse?: DataValidationStatusUpdateResponse | ((info: Parameters[1]>[0]) => Promise | DataValidationStatusUpdateResponse)) => { - return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataValidationStatusPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = ( + overrideResponse?: + | DataValidationStatusUpdateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataValidationStatusUpdateResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataValidationStatusPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataValidationStatusDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsDataValidationStatusDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsDataSupplementRetrieveMockHandler = (overrideResponse?: DataSupplementResponse | ((info: Parameters[1]>[0]) => Promise | DataSupplementResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataSupplementRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataSupplementRetrieveMockHandler = ( + overrideResponse?: + | DataSupplementResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataSupplementResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataSupplementRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = (overrideResponse?: DataSupplementResponse | ((info: Parameters[1]>[0]) => Promise | DataSupplementResponse)) => { - return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataSupplementPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = ( + overrideResponse?: + | DataSupplementResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataSupplementResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataSupplementPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataAttachmentsListMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AssetsDataAttachmentsListMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getAttachmentRetrieveMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getAttachmentRetrieveMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getAttachmentThumbnailMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getAttachmentThumbnailMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AssetsDataBulkPartialUpdateMockHandler = (overrideResponse?: DataBulkUpdateResponse | ((info: Parameters[1]>[0]) => Promise | DataBulkUpdateResponse)) => { - return http.patch('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataBulkPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataBulkPartialUpdateMockHandler = ( + overrideResponse?: + | DataBulkUpdateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | DataBulkUpdateResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataBulkPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataBulkDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AssetsDataBulkDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AssetsDataSupplementsBulkCreateMockHandler = (overrideResponse?: BulkAcceptResponse | ((info: Parameters[1]>[0]) => Promise | BulkAcceptResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataSupplementsBulkCreateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataSupplementsBulkCreateMockHandler = ( + overrideResponse?: + | BulkAcceptResponse + | ((info: Parameters[1]>[0]) => Promise | BulkAcceptResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataSupplementsBulkCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = (overrideResponse?: DataStatusesUpdate | ((info: Parameters[1]>[0]) => Promise | DataStatusesUpdate)) => { - return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = ( + overrideResponse?: + | DataStatusesUpdate + | ((info: Parameters[1]>[0]) => Promise | DataStatusesUpdate), +) => { + return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsDataValidationStatusesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsDataValidationStatusesDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsDataValidationStatusesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsExportSettingsListMockHandler = (overrideResponse?: PaginatedExportSettingResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedExportSettingResponseList)) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsExportSettingsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsExportSettingsListMockHandler = ( + overrideResponse?: + | PaginatedExportSettingResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedExportSettingResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsExportSettingsCreateMockHandler = (overrideResponse?: ExportSettingResponse | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/export-settings/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsExportSettingsCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsExportSettingsCreateMockHandler = ( + overrideResponse?: + | ExportSettingResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ExportSettingResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsExportSettingsRetrieveMockHandler = (overrideResponse?: ExportSettingResponse | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsExportSettingsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsExportSettingsRetrieveMockHandler = ( + overrideResponse?: + | ExportSettingResponse + | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = (overrideResponse?: ExportSettingResponse | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse)) => { - return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsExportSettingsPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = ( + overrideResponse?: + | ExportSettingResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ExportSettingResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportSettingsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsExportSettingsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsExportSettingsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsExportSettingsDataRetrieveMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AssetsExportSettingsDataRetrieveMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AssetsExportsListMockHandler = (overrideResponse?: PaginatedExportResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedExportResponseList)) => { - return http.get('*/api/v2/assets/:uidAsset/exports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsExportsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsExportsListMockHandler = ( + overrideResponse?: + | PaginatedExportResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedExportResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/exports/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsExportsCreateMockHandler = (overrideResponse?: ExportResponse | ((info: Parameters[1]>[0]) => Promise | ExportResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/exports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsExportsCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsExportsCreateMockHandler = ( + overrideResponse?: + | ExportResponse + | ((info: Parameters[1]>[0]) => Promise | ExportResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/exports/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsExportsRetrieveMockHandler = (overrideResponse?: ExportResponse | ((info: Parameters[1]>[0]) => Promise | ExportResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsExportsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsExportsRetrieveMockHandler = ( + overrideResponse?: + | ExportResponse + | ((info: Parameters[1]>[0]) => Promise | ExportResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsExportsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsExportsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsExportsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsFilesListMockHandler = (overrideResponse?: PaginatedFilesResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedFilesResponseList)) => { - return http.get('*/api/v2/assets/:uidAsset/files/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsFilesListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsFilesListMockHandler = ( + overrideResponse?: + | PaginatedFilesResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedFilesResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/files/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsFilesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsFilesCreateMockHandler = (overrideResponse?: FilesResponse | ((info: Parameters[1]>[0]) => Promise | FilesResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/files/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsFilesCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsFilesCreateMockHandler = ( + overrideResponse?: + | FilesResponse + | ((info: Parameters[1]>[0]) => Promise | FilesResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/files/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsFilesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsFilesRetrieveMockHandler = (overrideResponse?: FilesResponse | ((info: Parameters[1]>[0]) => Promise | FilesResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsFilesRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsFilesRetrieveMockHandler = ( + overrideResponse?: + | FilesResponse + | ((info: Parameters[1]>[0]) => Promise | FilesResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsFilesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsFilesDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsFilesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsFilesContentRetrieveMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 200, - - }) +export const getApiV2AssetsFilesContentRetrieveMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 200 }) }) } -export const getApiV2AssetsPairedDataListMockHandler = (overrideResponse?: PaginatedPairedDataResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedPairedDataResponseList)) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPairedDataListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsPairedDataListMockHandler = ( + overrideResponse?: + | PaginatedPairedDataResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedPairedDataResponseList), +) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsPairedDataCreateMockHandler = (overrideResponse?: PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse)) => { - return http.post('*/api/v2/assets/:uidAsset/paired-data/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPairedDataCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsPairedDataCreateMockHandler = ( + overrideResponse?: + | PairedDataResponse + | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), +) => { + return http.post('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsPairedDataRetrieveMockHandler = (overrideResponse?: PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPairedDataRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsPairedDataRetrieveMockHandler = ( + overrideResponse?: + | PairedDataResponse + | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsPairedDataPartialUpdateMockHandler = (overrideResponse?: PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse)) => { - return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPairedDataPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsPairedDataPartialUpdateMockHandler = ( + overrideResponse?: + | PairedDataResponse + | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), +) => { + return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsPairedDataDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2AssetsPairedDataDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = (overrideResponse?: ExternalResponse | ((info: Parameters[1]>[0]) => Promise | ExternalResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsPairedDataExternalRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = ( + overrideResponse?: + | ExternalResponse + | ((info: Parameters[1]>[0]) => Promise | ExternalResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsPairedDataExternalRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2AssetsReportsRetrieveMockHandler = (overrideResponse?: ReportResponse | ((info: Parameters[1]>[0]) => Promise | ReportResponse)) => { - return http.get('*/api/v2/assets/:uidAsset/reports/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetsReportsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2AssetsReportsRetrieveMockHandler = ( + overrideResponse?: + | ReportResponse + | ((info: Parameters[1]>[0]) => Promise | ReportResponse), +) => { + return http.get('*/api/v2/assets/:uidAsset/reports/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsReportsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } export const getSurveyDataMock = () => [ @@ -1019,5 +3016,5 @@ export const getSurveyDataMock = () => [ getApiV2AssetsPairedDataPartialUpdateMockHandler(), getApiV2AssetsPairedDataDestroyMockHandler(), getApiV2AssetsPairedDataExternalRetrieveMockHandler(), - getApiV2AssetsReportsRetrieveMockHandler() + getApiV2AssetsReportsRetrieveMockHandler(), ] diff --git a/jsapp/js/api/react-query/user-team-organization-usage/index.ts b/jsapp/js/api/react-query/user-team-organization-usage/index.ts index 260ecdf21c..f30710d6c3 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage/index.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage/index.ts @@ -9,244 +9,132 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - useMutation, - useQuery -} from '@tanstack/react-query'; +import { useMutation, useQuery } from '@tanstack/react-query' import type { MutationFunction, QueryFunction, QueryKey, UseMutationOptions, UseQueryOptions, - UseQueryResult -} from '@tanstack/react-query'; + UseQueryResult, +} from '@tanstack/react-query' -import type { - AssetListCount -} from '../../models/assetListCount'; +import type { AssetListCount } from '../../models/assetListCount' -import type { - AssetUsageListParams -} from '../../models/assetUsageListParams'; +import type { AssetUsageListParams } from '../../models/assetUsageListParams' -import type { - EmailAddress -} from '../../models/emailAddress'; +import type { EmailAddress } from '../../models/emailAddress' -import type { - EmailRequestPayload -} from '../../models/emailRequestPayload'; +import type { EmailRequestPayload } from '../../models/emailRequestPayload' -import type { - ErrorDetail -} from '../../models/errorDetail'; +import type { ErrorDetail } from '../../models/errorDetail' -import type { - ErrorObject -} from '../../models/errorObject'; +import type { ErrorObject } from '../../models/errorObject' -import type { - InviteCreatePayload -} from '../../models/inviteCreatePayload'; +import type { InviteCreatePayload } from '../../models/inviteCreatePayload' -import type { - InviteCreateResponse -} from '../../models/inviteCreateResponse'; +import type { InviteCreateResponse } from '../../models/inviteCreateResponse' -import type { - InviteResponse -} from '../../models/inviteResponse'; +import type { InviteResponse } from '../../models/inviteResponse' -import type { - MeEmailsListParams -} from '../../models/meEmailsListParams'; +import type { MeEmailsListParams } from '../../models/meEmailsListParams' -import type { - MeListResponse -} from '../../models/meListResponse'; +import type { MeListResponse } from '../../models/meListResponse' -import type { - MeSocialAccountsListParams -} from '../../models/meSocialAccountsListParams'; +import type { MeSocialAccountsListParams } from '../../models/meSocialAccountsListParams' -import type { - MemberListResponse -} from '../../models/memberListResponse'; +import type { MemberListResponse } from '../../models/memberListResponse' -import type { - OrganizationResponse -} from '../../models/organizationResponse'; +import type { OrganizationResponse } from '../../models/organizationResponse' -import type { - OrganizationServiceUsageResponse -} from '../../models/organizationServiceUsageResponse'; +import type { OrganizationServiceUsageResponse } from '../../models/organizationServiceUsageResponse' -import type { - OrganizationsAssetUsageListParams -} from '../../models/organizationsAssetUsageListParams'; +import type { OrganizationsAssetUsageListParams } from '../../models/organizationsAssetUsageListParams' -import type { - OrganizationsAssetsMinimalListRetrieveParams -} from '../../models/organizationsAssetsMinimalListRetrieveParams'; +import type { OrganizationsAssetsMinimalListRetrieveParams } from '../../models/organizationsAssetsMinimalListRetrieveParams' -import type { - OrganizationsInvitesListParams -} from '../../models/organizationsInvitesListParams'; +import type { OrganizationsInvitesListParams } from '../../models/organizationsInvitesListParams' -import type { - OrganizationsListParams -} from '../../models/organizationsListParams'; +import type { OrganizationsListParams } from '../../models/organizationsListParams' -import type { - OrganizationsMembersListParams -} from '../../models/organizationsMembersListParams'; +import type { OrganizationsMembersListParams } from '../../models/organizationsMembersListParams' -import type { - PaginatedAssetList -} from '../../models/paginatedAssetList'; +import type { PaginatedAssetList } from '../../models/paginatedAssetList' -import type { - PaginatedAssetMinimalListList -} from '../../models/paginatedAssetMinimalListList'; +import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' -import type { - PaginatedAssetUsageResponseList -} from '../../models/paginatedAssetUsageResponseList'; +import type { PaginatedAssetUsageResponseList } from '../../models/paginatedAssetUsageResponseList' -import type { - PaginatedCustomAssetUsageList -} from '../../models/paginatedCustomAssetUsageList'; +import type { PaginatedCustomAssetUsageList } from '../../models/paginatedCustomAssetUsageList' -import type { - PaginatedEmailAddressList -} from '../../models/paginatedEmailAddressList'; +import type { PaginatedEmailAddressList } from '../../models/paginatedEmailAddressList' -import type { - PaginatedInviteResponseList -} from '../../models/paginatedInviteResponseList'; +import type { PaginatedInviteResponseList } from '../../models/paginatedInviteResponseList' -import type { - PaginatedMemberListResponseList -} from '../../models/paginatedMemberListResponseList'; +import type { PaginatedMemberListResponseList } from '../../models/paginatedMemberListResponseList' -import type { - PaginatedOrganizationResponseList -} from '../../models/paginatedOrganizationResponseList'; +import type { PaginatedOrganizationResponseList } from '../../models/paginatedOrganizationResponseList' -import type { - PaginatedProjectViewAssetResponseList -} from '../../models/paginatedProjectViewAssetResponseList'; +import type { PaginatedProjectViewAssetResponseList } from '../../models/paginatedProjectViewAssetResponseList' -import type { - PaginatedProjectViewListResponseList -} from '../../models/paginatedProjectViewListResponseList'; +import type { PaginatedProjectViewListResponseList } from '../../models/paginatedProjectViewListResponseList' -import type { - PaginatedProjectViewUserResponseList -} from '../../models/paginatedProjectViewUserResponseList'; +import type { PaginatedProjectViewUserResponseList } from '../../models/paginatedProjectViewUserResponseList' -import type { - PaginatedSocialAccountList -} from '../../models/paginatedSocialAccountList'; +import type { PaginatedSocialAccountList } from '../../models/paginatedSocialAccountList' -import type { - PaginatedUserListResponseList -} from '../../models/paginatedUserListResponseList'; +import type { PaginatedUserListResponseList } from '../../models/paginatedUserListResponseList' -import type { - PatchedCurrentUser -} from '../../models/patchedCurrentUser'; +import type { PatchedCurrentUser } from '../../models/patchedCurrentUser' -import type { - PatchedInvitePatchPayload -} from '../../models/patchedInvitePatchPayload'; +import type { PatchedInvitePatchPayload } from '../../models/patchedInvitePatchPayload' -import type { - PatchedMemberPatchRequest -} from '../../models/patchedMemberPatchRequest'; +import type { PatchedMemberPatchRequest } from '../../models/patchedMemberPatchRequest' -import type { - PatchedOrganizationPatchPayload -} from '../../models/patchedOrganizationPatchPayload'; +import type { PatchedOrganizationPatchPayload } from '../../models/patchedOrganizationPatchPayload' -import type { - ProjectViewExportCreateResponse -} from '../../models/projectViewExportCreateResponse'; +import type { ProjectViewExportCreateResponse } from '../../models/projectViewExportCreateResponse' -import type { - ProjectViewExportResponse -} from '../../models/projectViewExportResponse'; +import type { ProjectViewExportResponse } from '../../models/projectViewExportResponse' -import type { - ProjectViewListResponse -} from '../../models/projectViewListResponse'; +import type { ProjectViewListResponse } from '../../models/projectViewListResponse' -import type { - ProjectViewsAssetsMinimalListRetrieveParams -} from '../../models/projectViewsAssetsMinimalListRetrieveParams'; +import type { ProjectViewsAssetsMinimalListRetrieveParams } from '../../models/projectViewsAssetsMinimalListRetrieveParams' -import type { - ProjectViewsAssetsRetrieveParams -} from '../../models/projectViewsAssetsRetrieveParams'; +import type { ProjectViewsAssetsRetrieveParams } from '../../models/projectViewsAssetsRetrieveParams' -import type { - ProjectViewsListParams -} from '../../models/projectViewsListParams'; +import type { ProjectViewsListParams } from '../../models/projectViewsListParams' -import type { - ProjectViewsUsersRetrieveParams -} from '../../models/projectViewsUsersRetrieveParams'; +import type { ProjectViewsUsersRetrieveParams } from '../../models/projectViewsUsersRetrieveParams' -import type { - ServiceUsageResponse -} from '../../models/serviceUsageResponse'; +import type { ServiceUsageResponse } from '../../models/serviceUsageResponse' -import type { - SocialAccount -} from '../../models/socialAccount'; +import type { SocialAccount } from '../../models/socialAccount' -import type { - UserRetrieveResponse -} from '../../models/userRetrieveResponse'; +import type { UserRetrieveResponse } from '../../models/userRetrieveResponse' -import type { - UsersListParams -} from '../../models/usersListParams'; +import type { UsersListParams } from '../../models/usersListParams' -import { fetchWithAuth } from '../../orval.mutator'; +import { fetchWithAuth } from '../../orval.mutator' // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497 -type IfEquals = (() => T extends X ? 1 : 2) extends < -T, ->() => T extends Y ? 1 : 2 -? A -: B; +type IfEquals = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? A : B type WritableKeys = { -[P in keyof T]-?: IfEquals< - { [Q in P]: T[P] }, - { -readonly [Q in P]: T[P] }, - P ->; -}[keyof T]; + [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P> +}[keyof T] -type UnionToIntersection = - (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never; -type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never; - -type Writable = Pick>; -type NonReadonly = [T] extends [UnionToIntersection] ? { - [P in keyof Writable]: T[P] extends object - ? NonReadonly> - : T[P]; -} : DistributeReadOnlyOverUnions; - - - -type SecondParameter unknown> = Parameters[1]; +type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never +type DistributeReadOnlyOverUnions = T extends any ? NonReadonly : never +type Writable = Pick> +type NonReadonly = [T] extends [UnionToIntersection] + ? { + [P in keyof Writable]: T[P] extends object ? NonReadonly> : T[P] + } + : DistributeReadOnlyOverUnions +type SecondParameter unknown> = Parameters[1] /** * ## Get user's asset usage @@ -261,85 +149,81 @@ export type assetUsageListResponse401 = { data: ErrorDetail status: 401 } - -export type assetUsageListResponseComposite = assetUsageListResponse200 | assetUsageListResponse401; - + +export type assetUsageListResponseComposite = assetUsageListResponse200 | assetUsageListResponse401 + export type assetUsageListResponse = assetUsageListResponseComposite & { - headers: Headers; + headers: Headers } -export const getAssetUsageListUrl = (params?: AssetUsageListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getAssetUsageListUrl = (params?: AssetUsageListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/asset_usage/?${stringifiedParams}` : `/api/v2/asset_usage/` } -export const assetUsageList = async (params?: AssetUsageListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getAssetUsageListUrl(params), - { +export const assetUsageList = async ( + params?: AssetUsageListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getAssetUsageListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getAssetUsageListQueryKey = (params?: AssetUsageListParams,) => { - return ['api','v2','asset_usage', ...(params ? [params]: [])] as const; - } +export const getAssetUsageListQueryKey = (params?: AssetUsageListParams) => { + return ['api', 'v2', 'asset_usage', ...(params ? [params] : [])] as const +} - -export const getAssetUsageListQueryOptions = >, TError = ErrorDetail>(params?: AssetUsageListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getAssetUsageListQueryOptions = >, TError = ErrorDetail>( + params?: AssetUsageListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getAssetUsageListQueryKey(params); - - - - const queryFn: QueryFunction>> = ({ signal }) => assetUsageList(params, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getAssetUsageListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + assetUsageList(params, { signal, ...requestOptions }) - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type AssetUsageListQueryResult = NonNullable>> export type AssetUsageListQueryError = ErrorDetail - - export function useAssetUsageList>, TError = ErrorDetail>( - params?: AssetUsageListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getAssetUsageListQueryOptions(params,options) + params?: AssetUsageListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getAssetUsageListQueryOptions(params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## List user's organizations @@ -353,85 +237,84 @@ export type organizationsListResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsListResponseComposite = organizationsListResponse200 | organizationsListResponse404; - + +export type organizationsListResponseComposite = organizationsListResponse200 | organizationsListResponse404 + export type organizationsListResponse = organizationsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getOrganizationsListUrl = (params?: OrganizationsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getOrganizationsListUrl = (params?: OrganizationsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/organizations/?${stringifiedParams}` : `/api/v2/organizations/` } -export const organizationsList = async (params?: OrganizationsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsListUrl(params), - { +export const organizationsList = async ( + params?: OrganizationsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getOrganizationsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getOrganizationsListQueryKey = (params?: OrganizationsListParams,) => { - return ['api','v2','organizations', ...(params ? [params]: [])] as const; - } +export const getOrganizationsListQueryKey = (params?: OrganizationsListParams) => { + return ['api', 'v2', 'organizations', ...(params ? [params] : [])] as const +} - -export const getOrganizationsListQueryOptions = >, TError = ErrorDetail>(params?: OrganizationsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getOrganizationsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: OrganizationsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsListQueryKey(params); - - + const queryKey = queryOptions?.queryKey ?? getOrganizationsListQueryKey(params) - const queryFn: QueryFunction>> = ({ signal }) => organizationsList(params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + organizationsList(params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type OrganizationsListQueryResult = NonNullable>> export type OrganizationsListQueryError = ErrorDetail - - export function useOrganizationsList>, TError = ErrorDetail>( - params?: OrganizationsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + params?: OrganizationsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsListQueryOptions(params, options) - const queryOptions = getOrganizationsListQueryOptions(params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Retrieve organization's details @@ -445,78 +328,77 @@ export type organizationsRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsRetrieveResponseComposite = organizationsRetrieveResponse200 | organizationsRetrieveResponse404; - -export type organizationsRetrieveResponse = organizationsRetrieveResponseComposite & { - headers: Headers; -} - -export const getOrganizationsRetrieveUrl = (uidOrganization: string,) => { +export type organizationsRetrieveResponseComposite = organizationsRetrieveResponse200 | organizationsRetrieveResponse404 - +export type organizationsRetrieveResponse = organizationsRetrieveResponseComposite & { + headers: Headers +} +export const getOrganizationsRetrieveUrl = (uidOrganization: string) => { return `/api/v2/organizations/${uidOrganization}/` } -export const organizationsRetrieve = async (uidOrganization: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsRetrieveUrl(uidOrganization), - { +export const organizationsRetrieve = async ( + uidOrganization: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getOrganizationsRetrieveUrl(uidOrganization), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getOrganizationsRetrieveQueryKey = (uidOrganization: string,) => { - return ['api','v2','organizations',uidOrganization] as const; - } +export const getOrganizationsRetrieveQueryKey = (uidOrganization: string) => { + return ['api', 'v2', 'organizations', uidOrganization] as const +} - -export const getOrganizationsRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getOrganizationsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsRetrieveQueryKey(uidOrganization); - - + const queryKey = queryOptions?.queryKey ?? getOrganizationsRetrieveQueryKey(uidOrganization) - const queryFn: QueryFunction>> = ({ signal }) => organizationsRetrieve(uidOrganization, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + organizationsRetrieve(uidOrganization, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type OrganizationsRetrieveQueryResult = NonNullable>> export type OrganizationsRetrieveQueryError = ErrorDetail +export function useOrganizationsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsRetrieveQueryOptions(uidOrganization, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useOrganizationsRetrieve>, TError = ErrorDetail>( - uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getOrganizationsRetrieveQueryOptions(uidOrganization,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Update organization's details @@ -535,75 +417,89 @@ export type organizationsPartialUpdateResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsPartialUpdateResponseComposite = organizationsPartialUpdateResponse200 | organizationsPartialUpdateResponse400 | organizationsPartialUpdateResponse404; - -export type organizationsPartialUpdateResponse = organizationsPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getOrganizationsPartialUpdateUrl = (uidOrganization: string,) => { +export type organizationsPartialUpdateResponseComposite = + | organizationsPartialUpdateResponse200 + | organizationsPartialUpdateResponse400 + | organizationsPartialUpdateResponse404 - +export type organizationsPartialUpdateResponse = organizationsPartialUpdateResponseComposite & { + headers: Headers +} +export const getOrganizationsPartialUpdateUrl = (uidOrganization: string) => { return `/api/v2/organizations/${uidOrganization}/` } -export const organizationsPartialUpdate = async (uidOrganization: string, - patchedOrganizationPatchPayload: PatchedOrganizationPatchPayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsPartialUpdateUrl(uidOrganization), - { +export const organizationsPartialUpdate = async ( + uidOrganization: string, + patchedOrganizationPatchPayload: PatchedOrganizationPatchPayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getOrganizationsPartialUpdateUrl(uidOrganization), { ...options, method: 'PATCH', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedOrganizationPatchPayload,) + body: JSON.stringify(patchedOrganizationPatchPayload), + }) +} + +export const getOrganizationsPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; data: PatchedOrganizationPatchPayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; data: PatchedOrganizationPatchPayload }, + TContext +> => { + const mutationKey = ['organizationsPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidOrganization: string; data: PatchedOrganizationPatchPayload } + > = (props) => { + const { uidOrganization, data } = props ?? {} + + return organizationsPartialUpdate(uidOrganization, data, requestOptions) } -);} + return { mutationFn, ...mutationOptions } +} - - -export const getOrganizationsPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;data: PatchedOrganizationPatchPayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidOrganization: string;data: PatchedOrganizationPatchPayload}, TContext> => { - -const mutationKey = ['organizationsPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidOrganization: string;data: PatchedOrganizationPatchPayload}> = (props) => { - const {uidOrganization,data} = props ?? {}; - - return organizationsPartialUpdate(uidOrganization,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type OrganizationsPartialUpdateMutationResult = NonNullable>> - export type OrganizationsPartialUpdateMutationBody = PatchedOrganizationPatchPayload - export type OrganizationsPartialUpdateMutationError = ErrorObject | ErrorDetail - - export const useOrganizationsPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;data: PatchedOrganizationPatchPayload}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getOrganizationsPartialUpdateMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export type OrganizationsPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type OrganizationsPartialUpdateMutationBody = PatchedOrganizationPatchPayload +export type OrganizationsPartialUpdateMutationError = ErrorObject | ErrorDetail + +export const useOrganizationsPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; data: PatchedOrganizationPatchPayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getOrganizationsPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Retrieve organization asset usage tracker Tracks the total usage of each asset for the user in the given organization @@ -618,90 +514,105 @@ export type organizationsAssetUsageListResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsAssetUsageListResponseComposite = organizationsAssetUsageListResponse200 | organizationsAssetUsageListResponse404; - + +export type organizationsAssetUsageListResponseComposite = + | organizationsAssetUsageListResponse200 + | organizationsAssetUsageListResponse404 + export type organizationsAssetUsageListResponse = organizationsAssetUsageListResponseComposite & { - headers: Headers; + headers: Headers } -export const getOrganizationsAssetUsageListUrl = (uidOrganization: string, - params?: OrganizationsAssetUsageListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getOrganizationsAssetUsageListUrl = ( + uidOrganization: string, + params?: OrganizationsAssetUsageListParams, +) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/organizations/${uidOrganization}/asset_usage/?${stringifiedParams}` : `/api/v2/organizations/${uidOrganization}/asset_usage/` + return stringifiedParams.length > 0 + ? `/api/v2/organizations/${uidOrganization}/asset_usage/?${stringifiedParams}` + : `/api/v2/organizations/${uidOrganization}/asset_usage/` } -export const organizationsAssetUsageList = async (uidOrganization: string, - params?: OrganizationsAssetUsageListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsAssetUsageListUrl(uidOrganization,params), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getOrganizationsAssetUsageListQueryKey = (uidOrganization: string, - params?: OrganizationsAssetUsageListParams,) => { - return ['api','v2','organizations',uidOrganization,'asset_usage', ...(params ? [params]: [])] as const; - } +export const organizationsAssetUsageList = async ( + uidOrganization: string, + params?: OrganizationsAssetUsageListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getOrganizationsAssetUsageListUrl(uidOrganization, params), + { + ...options, + method: 'GET', + }, + ) +} - -export const getOrganizationsAssetUsageListQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, - params?: OrganizationsAssetUsageListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getOrganizationsAssetUsageListQueryKey = ( + uidOrganization: string, + params?: OrganizationsAssetUsageListParams, ) => { + return ['api', 'v2', 'organizations', uidOrganization, 'asset_usage', ...(params ? [params] : [])] as const +} + +export const getOrganizationsAssetUsageListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + params?: OrganizationsAssetUsageListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetUsageListQueryKey(uidOrganization,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => organizationsAssetUsageList(uidOrganization,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetUsageListQueryKey(uidOrganization, params) - + const queryFn: QueryFunction>> = ({ signal }) => + organizationsAssetUsageList(uidOrganization, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type OrganizationsAssetUsageListQueryResult = NonNullable>> +export type OrganizationsAssetUsageListQueryResult = NonNullable< + Awaited> +> export type OrganizationsAssetUsageListQueryError = ErrorDetail +export function useOrganizationsAssetUsageList< + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + params?: OrganizationsAssetUsageListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsAssetUsageListQueryOptions(uidOrganization, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useOrganizationsAssetUsageList>, TError = ErrorDetail>( - uidOrganization: string, - params?: OrganizationsAssetUsageListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getOrganizationsAssetUsageListQueryOptions(uidOrganization,params,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Retrieve Organization Assets @@ -724,78 +635,81 @@ export type organizationsAssetsRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsAssetsRetrieveResponseComposite = organizationsAssetsRetrieveResponse200 | organizationsAssetsRetrieveResponse404; - -export type organizationsAssetsRetrieveResponse = organizationsAssetsRetrieveResponseComposite & { - headers: Headers; -} -export const getOrganizationsAssetsRetrieveUrl = (uidOrganization: string,) => { +export type organizationsAssetsRetrieveResponseComposite = + | organizationsAssetsRetrieveResponse200 + | organizationsAssetsRetrieveResponse404 +export type organizationsAssetsRetrieveResponse = organizationsAssetsRetrieveResponseComposite & { + headers: Headers +} - - +export const getOrganizationsAssetsRetrieveUrl = (uidOrganization: string) => { return `/api/v2/organizations/${uidOrganization}/assets/` } -export const organizationsAssetsRetrieve = async (uidOrganization: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsAssetsRetrieveUrl(uidOrganization), - { +export const organizationsAssetsRetrieve = async ( + uidOrganization: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getOrganizationsAssetsRetrieveUrl(uidOrganization), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getOrganizationsAssetsRetrieveQueryKey = (uidOrganization: string,) => { - return ['api','v2','organizations',uidOrganization,'assets'] as const; - } +export const getOrganizationsAssetsRetrieveQueryKey = (uidOrganization: string) => { + return ['api', 'v2', 'organizations', uidOrganization, 'assets'] as const +} - -export const getOrganizationsAssetsRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getOrganizationsAssetsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsRetrieveQueryKey(uidOrganization); + const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsRetrieveQueryKey(uidOrganization) - + const queryFn: QueryFunction>> = ({ signal }) => + organizationsAssetsRetrieve(uidOrganization, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => organizationsAssetsRetrieve(uidOrganization, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type OrganizationsAssetsRetrieveQueryResult = NonNullable>> +export type OrganizationsAssetsRetrieveQueryResult = NonNullable< + Awaited> +> export type OrganizationsAssetsRetrieveQueryError = ErrorDetail +export function useOrganizationsAssetsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsAssetsRetrieveQueryOptions(uidOrganization, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useOrganizationsAssetsRetrieve>, TError = ErrorDetail>( - uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getOrganizationsAssetsRetrieveQueryOptions(uidOrganization,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Return counts of deployed, archived, and draft assets owned by the organization @@ -809,78 +723,84 @@ export type organizationsAssetsCountsRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsAssetsCountsRetrieveResponseComposite = organizationsAssetsCountsRetrieveResponse200 | organizationsAssetsCountsRetrieveResponse404; - -export type organizationsAssetsCountsRetrieveResponse = organizationsAssetsCountsRetrieveResponseComposite & { - headers: Headers; -} - -export const getOrganizationsAssetsCountsRetrieveUrl = (uidOrganization: string,) => { +export type organizationsAssetsCountsRetrieveResponseComposite = + | organizationsAssetsCountsRetrieveResponse200 + | organizationsAssetsCountsRetrieveResponse404 - +export type organizationsAssetsCountsRetrieveResponse = organizationsAssetsCountsRetrieveResponseComposite & { + headers: Headers +} +export const getOrganizationsAssetsCountsRetrieveUrl = (uidOrganization: string) => { return `/api/v2/organizations/${uidOrganization}/assets/counts/` } -export const organizationsAssetsCountsRetrieve = async (uidOrganization: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsAssetsCountsRetrieveUrl(uidOrganization), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getOrganizationsAssetsCountsRetrieveQueryKey = (uidOrganization: string,) => { - return ['api','v2','organizations',uidOrganization,'assets','counts'] as const; - } - - -export const getOrganizationsAssetsCountsRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const organizationsAssetsCountsRetrieve = async ( + uidOrganization: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getOrganizationsAssetsCountsRetrieveUrl(uidOrganization), + { + ...options, + method: 'GET', + }, + ) +} + +export const getOrganizationsAssetsCountsRetrieveQueryKey = (uidOrganization: string) => { + return ['api', 'v2', 'organizations', uidOrganization, 'assets', 'counts'] as const +} + +export const getOrganizationsAssetsCountsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsCountsRetrieveQueryKey(uidOrganization); - - - - const queryFn: QueryFunction>> = ({ signal }) => organizationsAssetsCountsRetrieve(uidOrganization, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsCountsRetrieveQueryKey(uidOrganization) - + const queryFn: QueryFunction>> = ({ signal }) => + organizationsAssetsCountsRetrieve(uidOrganization, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type OrganizationsAssetsCountsRetrieveQueryResult = NonNullable>> +export type OrganizationsAssetsCountsRetrieveQueryResult = NonNullable< + Awaited> +> export type OrganizationsAssetsCountsRetrieveQueryError = ErrorDetail +export function useOrganizationsAssetsCountsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsAssetsCountsRetrieveQueryOptions(uidOrganization, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useOrganizationsAssetsCountsRetrieve>, TError = ErrorDetail>( - uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getOrganizationsAssetsCountsRetrieveQueryOptions(uidOrganization,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Return a minimal listing of assets in an organization @@ -900,90 +820,105 @@ export type organizationsAssetsMinimalListRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsAssetsMinimalListRetrieveResponseComposite = organizationsAssetsMinimalListRetrieveResponse200 | organizationsAssetsMinimalListRetrieveResponse404; - + +export type organizationsAssetsMinimalListRetrieveResponseComposite = + | organizationsAssetsMinimalListRetrieveResponse200 + | organizationsAssetsMinimalListRetrieveResponse404 + export type organizationsAssetsMinimalListRetrieveResponse = organizationsAssetsMinimalListRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getOrganizationsAssetsMinimalListRetrieveUrl = (uidOrganization: string, - params?: OrganizationsAssetsMinimalListRetrieveParams,) => { - const normalizedParams = new URLSearchParams(); +export const getOrganizationsAssetsMinimalListRetrieveUrl = ( + uidOrganization: string, + params?: OrganizationsAssetsMinimalListRetrieveParams, +) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/organizations/${uidOrganization}/assets/minimal-list/?${stringifiedParams}` : `/api/v2/organizations/${uidOrganization}/assets/minimal-list/` + return stringifiedParams.length > 0 + ? `/api/v2/organizations/${uidOrganization}/assets/minimal-list/?${stringifiedParams}` + : `/api/v2/organizations/${uidOrganization}/assets/minimal-list/` } -export const organizationsAssetsMinimalListRetrieve = async (uidOrganization: string, - params?: OrganizationsAssetsMinimalListRetrieveParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsAssetsMinimalListRetrieveUrl(uidOrganization,params), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getOrganizationsAssetsMinimalListRetrieveQueryKey = (uidOrganization: string, - params?: OrganizationsAssetsMinimalListRetrieveParams,) => { - return ['api','v2','organizations',uidOrganization,'assets','minimal-list', ...(params ? [params]: [])] as const; - } +export const organizationsAssetsMinimalListRetrieve = async ( + uidOrganization: string, + params?: OrganizationsAssetsMinimalListRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getOrganizationsAssetsMinimalListRetrieveUrl(uidOrganization, params), + { + ...options, + method: 'GET', + }, + ) +} - -export const getOrganizationsAssetsMinimalListRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, - params?: OrganizationsAssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getOrganizationsAssetsMinimalListRetrieveQueryKey = ( + uidOrganization: string, + params?: OrganizationsAssetsMinimalListRetrieveParams, ) => { + return ['api', 'v2', 'organizations', uidOrganization, 'assets', 'minimal-list', ...(params ? [params] : [])] as const +} + +export const getOrganizationsAssetsMinimalListRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + params?: OrganizationsAssetsMinimalListRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsMinimalListRetrieveQueryKey(uidOrganization,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => organizationsAssetsMinimalListRetrieve(uidOrganization,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getOrganizationsAssetsMinimalListRetrieveQueryKey(uidOrganization, params) - + const queryFn: QueryFunction>> = ({ signal }) => + organizationsAssetsMinimalListRetrieve(uidOrganization, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type OrganizationsAssetsMinimalListRetrieveQueryResult = NonNullable>> +export type OrganizationsAssetsMinimalListRetrieveQueryResult = NonNullable< + Awaited> +> export type OrganizationsAssetsMinimalListRetrieveQueryError = ErrorDetail +export function useOrganizationsAssetsMinimalListRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + params?: OrganizationsAssetsMinimalListRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsAssetsMinimalListRetrieveQueryOptions(uidOrganization, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useOrganizationsAssetsMinimalListRetrieve>, TError = ErrorDetail>( - uidOrganization: string, - params?: OrganizationsAssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getOrganizationsAssetsMinimalListRetrieveQueryOptions(uidOrganization,params,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## List organization invites @@ -997,90 +932,97 @@ export type organizationsInvitesListResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsInvitesListResponseComposite = organizationsInvitesListResponse200 | organizationsInvitesListResponse404; - + +export type organizationsInvitesListResponseComposite = + | organizationsInvitesListResponse200 + | organizationsInvitesListResponse404 + export type organizationsInvitesListResponse = organizationsInvitesListResponseComposite & { - headers: Headers; + headers: Headers } -export const getOrganizationsInvitesListUrl = (uidOrganization: string, - params?: OrganizationsInvitesListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getOrganizationsInvitesListUrl = (uidOrganization: string, params?: OrganizationsInvitesListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/organizations/${uidOrganization}/invites/?${stringifiedParams}` : `/api/v2/organizations/${uidOrganization}/invites/` + return stringifiedParams.length > 0 + ? `/api/v2/organizations/${uidOrganization}/invites/?${stringifiedParams}` + : `/api/v2/organizations/${uidOrganization}/invites/` } -export const organizationsInvitesList = async (uidOrganization: string, - params?: OrganizationsInvitesListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsInvitesListUrl(uidOrganization,params), - { +export const organizationsInvitesList = async ( + uidOrganization: string, + params?: OrganizationsInvitesListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getOrganizationsInvitesListUrl(uidOrganization, params), { ...options, - method: 'GET' - - - } -);} - - - -export const getOrganizationsInvitesListQueryKey = (uidOrganization: string, - params?: OrganizationsInvitesListParams,) => { - return ['api','v2','organizations',uidOrganization,'invites', ...(params ? [params]: [])] as const; - } + method: 'GET', + }) +} - -export const getOrganizationsInvitesListQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, - params?: OrganizationsInvitesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getOrganizationsInvitesListQueryKey = ( + uidOrganization: string, + params?: OrganizationsInvitesListParams, ) => { + return ['api', 'v2', 'organizations', uidOrganization, 'invites', ...(params ? [params] : [])] as const +} + +export const getOrganizationsInvitesListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + params?: OrganizationsInvitesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsInvitesListQueryKey(uidOrganization,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => organizationsInvitesList(uidOrganization,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getOrganizationsInvitesListQueryKey(uidOrganization, params) - + const queryFn: QueryFunction>> = ({ signal }) => + organizationsInvitesList(uidOrganization, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type OrganizationsInvitesListQueryResult = NonNullable>> export type OrganizationsInvitesListQueryError = ErrorDetail +export function useOrganizationsInvitesList< + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + params?: OrganizationsInvitesListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsInvitesListQueryOptions(uidOrganization, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useOrganizationsInvitesList>, TError = ErrorDetail>( - uidOrganization: string, - params?: OrganizationsInvitesListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getOrganizationsInvitesListQueryOptions(uidOrganization,params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Create Organization Invite @@ -1103,164 +1045,182 @@ export type organizationsInvitesCreateResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsInvitesCreateResponseComposite = organizationsInvitesCreateResponse201 | organizationsInvitesCreateResponse400 | organizationsInvitesCreateResponse404; - -export type organizationsInvitesCreateResponse = organizationsInvitesCreateResponseComposite & { - headers: Headers; -} -export const getOrganizationsInvitesCreateUrl = (uidOrganization: string,) => { +export type organizationsInvitesCreateResponseComposite = + | organizationsInvitesCreateResponse201 + | organizationsInvitesCreateResponse400 + | organizationsInvitesCreateResponse404 +export type organizationsInvitesCreateResponse = organizationsInvitesCreateResponseComposite & { + headers: Headers +} - - +export const getOrganizationsInvitesCreateUrl = (uidOrganization: string) => { return `/api/v2/organizations/${uidOrganization}/invites/` } -export const organizationsInvitesCreate = async (uidOrganization: string, - inviteCreatePayload: InviteCreatePayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsInvitesCreateUrl(uidOrganization), - { +export const organizationsInvitesCreate = async ( + uidOrganization: string, + inviteCreatePayload: InviteCreatePayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getOrganizationsInvitesCreateUrl(uidOrganization), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - inviteCreatePayload,) + body: JSON.stringify(inviteCreatePayload), + }) +} + +export const getOrganizationsInvitesCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; data: InviteCreatePayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; data: InviteCreatePayload }, + TContext +> => { + const mutationKey = ['organizationsInvitesCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidOrganization: string; data: InviteCreatePayload } + > = (props) => { + const { uidOrganization, data } = props ?? {} + + return organizationsInvitesCreate(uidOrganization, data, requestOptions) } -);} - + return { mutationFn, ...mutationOptions } +} +export type OrganizationsInvitesCreateMutationResult = NonNullable< + Awaited> +> +export type OrganizationsInvitesCreateMutationBody = InviteCreatePayload +export type OrganizationsInvitesCreateMutationError = ErrorObject | ErrorDetail + +export const useOrganizationsInvitesCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; data: InviteCreatePayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getOrganizationsInvitesCreateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** + * ## Retrieve organization invite -export const getOrganizationsInvitesCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;data: InviteCreatePayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidOrganization: string;data: InviteCreatePayload}, TContext> => { + */ +export type organizationsInvitesRetrieveResponse200 = { + data: InviteResponse + status: 200 +} -const mutationKey = ['organizationsInvitesCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; +export type organizationsInvitesRetrieveResponse404 = { + data: ErrorDetail + status: 404 +} - +export type organizationsInvitesRetrieveResponseComposite = + | organizationsInvitesRetrieveResponse200 + | organizationsInvitesRetrieveResponse404 +export type organizationsInvitesRetrieveResponse = organizationsInvitesRetrieveResponseComposite & { + headers: Headers +} - const mutationFn: MutationFunction>, {uidOrganization: string;data: InviteCreatePayload}> = (props) => { - const {uidOrganization,data} = props ?? {}; - - return organizationsInvitesCreate(uidOrganization,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type OrganizationsInvitesCreateMutationResult = NonNullable>> - export type OrganizationsInvitesCreateMutationBody = InviteCreatePayload - export type OrganizationsInvitesCreateMutationError = ErrorObject | ErrorDetail - - export const useOrganizationsInvitesCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;data: InviteCreatePayload}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getOrganizationsInvitesCreateMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** - * ## Retrieve organization invite - - */ -export type organizationsInvitesRetrieveResponse200 = { - data: InviteResponse - status: 200 -} - -export type organizationsInvitesRetrieveResponse404 = { - data: ErrorDetail - status: 404 -} - -export type organizationsInvitesRetrieveResponseComposite = organizationsInvitesRetrieveResponse200 | organizationsInvitesRetrieveResponse404; - -export type organizationsInvitesRetrieveResponse = organizationsInvitesRetrieveResponseComposite & { - headers: Headers; -} - -export const getOrganizationsInvitesRetrieveUrl = (uidOrganization: string, - guid: string,) => { - - - - +export const getOrganizationsInvitesRetrieveUrl = (uidOrganization: string, guid: string) => { return `/api/v2/organizations/${uidOrganization}/invites/${guid}/` } -export const organizationsInvitesRetrieve = async (uidOrganization: string, - guid: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsInvitesRetrieveUrl(uidOrganization,guid), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getOrganizationsInvitesRetrieveQueryKey = (uidOrganization: string, - guid: string,) => { - return ['api','v2','organizations',uidOrganization,'invites',guid] as const; - } - - -export const getOrganizationsInvitesRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, - guid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const organizationsInvitesRetrieve = async ( + uidOrganization: string, + guid: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getOrganizationsInvitesRetrieveUrl(uidOrganization, guid), + { + ...options, + method: 'GET', + }, + ) +} + +export const getOrganizationsInvitesRetrieveQueryKey = (uidOrganization: string, guid: string) => { + return ['api', 'v2', 'organizations', uidOrganization, 'invites', guid] as const +} + +export const getOrganizationsInvitesRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + guid: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsInvitesRetrieveQueryKey(uidOrganization,guid); + const queryKey = queryOptions?.queryKey ?? getOrganizationsInvitesRetrieveQueryKey(uidOrganization, guid) - + const queryFn: QueryFunction>> = ({ signal }) => + organizationsInvitesRetrieve(uidOrganization, guid, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => organizationsInvitesRetrieve(uidOrganization,guid, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(uidOrganization && guid), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidOrganization && guid), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type OrganizationsInvitesRetrieveQueryResult = NonNullable>> +export type OrganizationsInvitesRetrieveQueryResult = NonNullable< + Awaited> +> export type OrganizationsInvitesRetrieveQueryError = ErrorDetail +export function useOrganizationsInvitesRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + guid: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsInvitesRetrieveQueryOptions(uidOrganization, guid, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useOrganizationsInvitesRetrieve>, TError = ErrorDetail>( - uidOrganization: string, - guid: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getOrganizationsInvitesRetrieveQueryOptions(uidOrganization,guid,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Update Organization Invite @@ -1283,77 +1243,93 @@ export type organizationsInvitesPartialUpdateResponse403 = { data: ErrorDetail status: 403 } - -export type organizationsInvitesPartialUpdateResponseComposite = organizationsInvitesPartialUpdateResponse200 | organizationsInvitesPartialUpdateResponse400 | organizationsInvitesPartialUpdateResponse403; - -export type organizationsInvitesPartialUpdateResponse = organizationsInvitesPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getOrganizationsInvitesPartialUpdateUrl = (uidOrganization: string, - guid: string,) => { +export type organizationsInvitesPartialUpdateResponseComposite = + | organizationsInvitesPartialUpdateResponse200 + | organizationsInvitesPartialUpdateResponse400 + | organizationsInvitesPartialUpdateResponse403 - +export type organizationsInvitesPartialUpdateResponse = organizationsInvitesPartialUpdateResponseComposite & { + headers: Headers +} +export const getOrganizationsInvitesPartialUpdateUrl = (uidOrganization: string, guid: string) => { return `/api/v2/organizations/${uidOrganization}/invites/${guid}/` } -export const organizationsInvitesPartialUpdate = async (uidOrganization: string, - guid: string, - patchedInvitePatchPayload: PatchedInvitePatchPayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsInvitesPartialUpdateUrl(uidOrganization,guid), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedInvitePatchPayload,) +export const organizationsInvitesPartialUpdate = async ( + uidOrganization: string, + guid: string, + patchedInvitePatchPayload: PatchedInvitePatchPayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getOrganizationsInvitesPartialUpdateUrl(uidOrganization, guid), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedInvitePatchPayload), + }, + ) +} + +export const getOrganizationsInvitesPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; guid: string; data: PatchedInvitePatchPayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; guid: string; data: PatchedInvitePatchPayload }, + TContext +> => { + const mutationKey = ['organizationsInvitesPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidOrganization: string; guid: string; data: PatchedInvitePatchPayload } + > = (props) => { + const { uidOrganization, guid, data } = props ?? {} + + return organizationsInvitesPartialUpdate(uidOrganization, guid, data, requestOptions) } -);} - - - - -export const getOrganizationsInvitesPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;guid: string;data: PatchedInvitePatchPayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidOrganization: string;guid: string;data: PatchedInvitePatchPayload}, TContext> => { - -const mutationKey = ['organizationsInvitesPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidOrganization: string;guid: string;data: PatchedInvitePatchPayload}> = (props) => { - const {uidOrganization,guid,data} = props ?? {}; - return organizationsInvitesPartialUpdate(uidOrganization,guid,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type OrganizationsInvitesPartialUpdateMutationResult = NonNullable>> - export type OrganizationsInvitesPartialUpdateMutationBody = PatchedInvitePatchPayload - export type OrganizationsInvitesPartialUpdateMutationError = ErrorObject | ErrorDetail - - export const useOrganizationsInvitesPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;guid: string;data: PatchedInvitePatchPayload}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getOrganizationsInvitesPartialUpdateMutationOptions(options); + return { mutationFn, ...mutationOptions } +} - return useMutation(mutationOptions ); - } - /** +export type OrganizationsInvitesPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type OrganizationsInvitesPartialUpdateMutationBody = PatchedInvitePatchPayload +export type OrganizationsInvitesPartialUpdateMutationError = ErrorObject | ErrorDetail + +export const useOrganizationsInvitesPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; guid: string; data: PatchedInvitePatchPayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getOrganizationsInvitesPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Delete Organization Invite * Organization owner or admin can delete an organization invite. @@ -1368,75 +1344,83 @@ export type organizationsInvitesDestroyResponse403 = { data: ErrorDetail status: 403 } - -export type organizationsInvitesDestroyResponseComposite = organizationsInvitesDestroyResponse204 | organizationsInvitesDestroyResponse403; - -export type organizationsInvitesDestroyResponse = organizationsInvitesDestroyResponseComposite & { - headers: Headers; -} -export const getOrganizationsInvitesDestroyUrl = (uidOrganization: string, - guid: string,) => { +export type organizationsInvitesDestroyResponseComposite = + | organizationsInvitesDestroyResponse204 + | organizationsInvitesDestroyResponse403 +export type organizationsInvitesDestroyResponse = organizationsInvitesDestroyResponseComposite & { + headers: Headers +} - - +export const getOrganizationsInvitesDestroyUrl = (uidOrganization: string, guid: string) => { return `/api/v2/organizations/${uidOrganization}/invites/${guid}/` } -export const organizationsInvitesDestroy = async (uidOrganization: string, - guid: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsInvitesDestroyUrl(uidOrganization,guid), - { +export const organizationsInvitesDestroy = async ( + uidOrganization: string, + guid: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getOrganizationsInvitesDestroyUrl(uidOrganization, guid), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getOrganizationsInvitesDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; guid: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; guid: string }, + TContext +> => { + const mutationKey = ['organizationsInvitesDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidOrganization: string; guid: string } + > = (props) => { + const { uidOrganization, guid } = props ?? {} + + return organizationsInvitesDestroy(uidOrganization, guid, requestOptions) } -);} - - - - -export const getOrganizationsInvitesDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;guid: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidOrganization: string;guid: string}, TContext> => { -const mutationKey = ['organizationsInvitesDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidOrganization: string;guid: string}> = (props) => { - const {uidOrganization,guid} = props ?? {}; - - return organizationsInvitesDestroy(uidOrganization,guid,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type OrganizationsInvitesDestroyMutationResult = NonNullable>> - - export type OrganizationsInvitesDestroyMutationError = ErrorDetail +export type OrganizationsInvitesDestroyMutationResult = NonNullable< + Awaited> +> - export const useOrganizationsInvitesDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;guid: string}, TContext>, request?: SecondParameter} - ) => { +export type OrganizationsInvitesDestroyMutationError = ErrorDetail - const mutationOptions = getOrganizationsInvitesDestroyMutationOptions(options); +export const useOrganizationsInvitesDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; guid: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getOrganizationsInvitesDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## List Members Retrieves all members in the specified organization. @@ -1451,90 +1435,97 @@ export type organizationsMembersListResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsMembersListResponseComposite = organizationsMembersListResponse200 | organizationsMembersListResponse404; - + +export type organizationsMembersListResponseComposite = + | organizationsMembersListResponse200 + | organizationsMembersListResponse404 + export type organizationsMembersListResponse = organizationsMembersListResponseComposite & { - headers: Headers; + headers: Headers } -export const getOrganizationsMembersListUrl = (uidOrganization: string, - params?: OrganizationsMembersListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getOrganizationsMembersListUrl = (uidOrganization: string, params?: OrganizationsMembersListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/organizations/${uidOrganization}/members/?${stringifiedParams}` : `/api/v2/organizations/${uidOrganization}/members/` + return stringifiedParams.length > 0 + ? `/api/v2/organizations/${uidOrganization}/members/?${stringifiedParams}` + : `/api/v2/organizations/${uidOrganization}/members/` } -export const organizationsMembersList = async (uidOrganization: string, - params?: OrganizationsMembersListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsMembersListUrl(uidOrganization,params), - { +export const organizationsMembersList = async ( + uidOrganization: string, + params?: OrganizationsMembersListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getOrganizationsMembersListUrl(uidOrganization, params), { ...options, - method: 'GET' - - - } -);} - - - -export const getOrganizationsMembersListQueryKey = (uidOrganization: string, - params?: OrganizationsMembersListParams,) => { - return ['api','v2','organizations',uidOrganization,'members', ...(params ? [params]: [])] as const; - } + method: 'GET', + }) +} - -export const getOrganizationsMembersListQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, - params?: OrganizationsMembersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getOrganizationsMembersListQueryKey = ( + uidOrganization: string, + params?: OrganizationsMembersListParams, ) => { + return ['api', 'v2', 'organizations', uidOrganization, 'members', ...(params ? [params] : [])] as const +} + +export const getOrganizationsMembersListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + params?: OrganizationsMembersListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsMembersListQueryKey(uidOrganization,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => organizationsMembersList(uidOrganization,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getOrganizationsMembersListQueryKey(uidOrganization, params) - + const queryFn: QueryFunction>> = ({ signal }) => + organizationsMembersList(uidOrganization, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type OrganizationsMembersListQueryResult = NonNullable>> export type OrganizationsMembersListQueryError = ErrorDetail +export function useOrganizationsMembersList< + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + params?: OrganizationsMembersListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsMembersListQueryOptions(uidOrganization, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useOrganizationsMembersList>, TError = ErrorDetail>( - uidOrganization: string, - params?: OrganizationsMembersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getOrganizationsMembersListQueryOptions(uidOrganization,params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Retrieve Member Details @@ -1550,83 +1541,87 @@ export type organizationsMembersRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsMembersRetrieveResponseComposite = organizationsMembersRetrieveResponse200 | organizationsMembersRetrieveResponse404; - -export type organizationsMembersRetrieveResponse = organizationsMembersRetrieveResponseComposite & { - headers: Headers; -} - -export const getOrganizationsMembersRetrieveUrl = (uidOrganization: string, - username: string,) => { +export type organizationsMembersRetrieveResponseComposite = + | organizationsMembersRetrieveResponse200 + | organizationsMembersRetrieveResponse404 - +export type organizationsMembersRetrieveResponse = organizationsMembersRetrieveResponseComposite & { + headers: Headers +} +export const getOrganizationsMembersRetrieveUrl = (uidOrganization: string, username: string) => { return `/api/v2/organizations/${uidOrganization}/members/${username}/` } -export const organizationsMembersRetrieve = async (uidOrganization: string, - username: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsMembersRetrieveUrl(uidOrganization,username), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getOrganizationsMembersRetrieveQueryKey = (uidOrganization: string, - username: string,) => { - return ['api','v2','organizations',uidOrganization,'members',username] as const; - } - - -export const getOrganizationsMembersRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, - username: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const organizationsMembersRetrieve = async ( + uidOrganization: string, + username: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getOrganizationsMembersRetrieveUrl(uidOrganization, username), + { + ...options, + method: 'GET', + }, + ) +} + +export const getOrganizationsMembersRetrieveQueryKey = (uidOrganization: string, username: string) => { + return ['api', 'v2', 'organizations', uidOrganization, 'members', username] as const +} + +export const getOrganizationsMembersRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + username: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsMembersRetrieveQueryKey(uidOrganization,username); - - - - const queryFn: QueryFunction>> = ({ signal }) => organizationsMembersRetrieve(uidOrganization,username, { signal, ...requestOptions }); + const queryKey = queryOptions?.queryKey ?? getOrganizationsMembersRetrieveQueryKey(uidOrganization, username) - + const queryFn: QueryFunction>> = ({ signal }) => + organizationsMembersRetrieve(uidOrganization, username, { signal, ...requestOptions }) - - - return { queryKey, queryFn, enabled: !!(uidOrganization && username), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidOrganization && username), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type OrganizationsMembersRetrieveQueryResult = NonNullable>> +export type OrganizationsMembersRetrieveQueryResult = NonNullable< + Awaited> +> export type OrganizationsMembersRetrieveQueryError = ErrorDetail +export function useOrganizationsMembersRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + username: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsMembersRetrieveQueryOptions(uidOrganization, username, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useOrganizationsMembersRetrieve>, TError = ErrorDetail>( - uidOrganization: string, - username: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getOrganizationsMembersRetrieveQueryOptions(uidOrganization,username,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Update Member Role @@ -1651,77 +1646,93 @@ export type organizationsMembersPartialUpdateResponse403 = { data: ErrorDetail status: 403 } - -export type organizationsMembersPartialUpdateResponseComposite = organizationsMembersPartialUpdateResponse200 | organizationsMembersPartialUpdateResponse400 | organizationsMembersPartialUpdateResponse403; - -export type organizationsMembersPartialUpdateResponse = organizationsMembersPartialUpdateResponseComposite & { - headers: Headers; -} - -export const getOrganizationsMembersPartialUpdateUrl = (uidOrganization: string, - username: string,) => { +export type organizationsMembersPartialUpdateResponseComposite = + | organizationsMembersPartialUpdateResponse200 + | organizationsMembersPartialUpdateResponse400 + | organizationsMembersPartialUpdateResponse403 - +export type organizationsMembersPartialUpdateResponse = organizationsMembersPartialUpdateResponseComposite & { + headers: Headers +} +export const getOrganizationsMembersPartialUpdateUrl = (uidOrganization: string, username: string) => { return `/api/v2/organizations/${uidOrganization}/members/${username}/` } -export const organizationsMembersPartialUpdate = async (uidOrganization: string, - username: string, - patchedMemberPatchRequest: PatchedMemberPatchRequest, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsMembersPartialUpdateUrl(uidOrganization,username), - { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedMemberPatchRequest,) +export const organizationsMembersPartialUpdate = async ( + uidOrganization: string, + username: string, + patchedMemberPatchRequest: PatchedMemberPatchRequest, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getOrganizationsMembersPartialUpdateUrl(uidOrganization, username), + { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(patchedMemberPatchRequest), + }, + ) +} + +export const getOrganizationsMembersPartialUpdateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; username: string; data: PatchedMemberPatchRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; username: string; data: PatchedMemberPatchRequest }, + TContext +> => { + const mutationKey = ['organizationsMembersPartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidOrganization: string; username: string; data: PatchedMemberPatchRequest } + > = (props) => { + const { uidOrganization, username, data } = props ?? {} + + return organizationsMembersPartialUpdate(uidOrganization, username, data, requestOptions) } -);} + return { mutationFn, ...mutationOptions } +} - - -export const getOrganizationsMembersPartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;username: string;data: PatchedMemberPatchRequest}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidOrganization: string;username: string;data: PatchedMemberPatchRequest}, TContext> => { - -const mutationKey = ['organizationsMembersPartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidOrganization: string;username: string;data: PatchedMemberPatchRequest}> = (props) => { - const {uidOrganization,username,data} = props ?? {}; - - return organizationsMembersPartialUpdate(uidOrganization,username,data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type OrganizationsMembersPartialUpdateMutationResult = NonNullable>> - export type OrganizationsMembersPartialUpdateMutationBody = PatchedMemberPatchRequest - export type OrganizationsMembersPartialUpdateMutationError = ErrorObject | ErrorDetail - - export const useOrganizationsMembersPartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;username: string;data: PatchedMemberPatchRequest}, TContext>, request?: SecondParameter} - ) => { - - const mutationOptions = getOrganizationsMembersPartialUpdateMutationOptions(options); - - return useMutation(mutationOptions ); - } - /** +export type OrganizationsMembersPartialUpdateMutationResult = NonNullable< + Awaited> +> +export type OrganizationsMembersPartialUpdateMutationBody = PatchedMemberPatchRequest +export type OrganizationsMembersPartialUpdateMutationError = ErrorObject | ErrorDetail + +export const useOrganizationsMembersPartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; username: string; data: PatchedMemberPatchRequest }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getOrganizationsMembersPartialUpdateMutationOptions(options) + + return useMutation(mutationOptions) +} +/** * ## Remove Member Delete an organization member. @@ -1736,75 +1747,86 @@ export type organizationsMembersDestroyResponse403 = { data: ErrorDetail status: 403 } - -export type organizationsMembersDestroyResponseComposite = organizationsMembersDestroyResponse204 | organizationsMembersDestroyResponse403; - -export type organizationsMembersDestroyResponse = organizationsMembersDestroyResponseComposite & { - headers: Headers; -} - -export const getOrganizationsMembersDestroyUrl = (uidOrganization: string, - username: string,) => { +export type organizationsMembersDestroyResponseComposite = + | organizationsMembersDestroyResponse204 + | organizationsMembersDestroyResponse403 - +export type organizationsMembersDestroyResponse = organizationsMembersDestroyResponseComposite & { + headers: Headers +} +export const getOrganizationsMembersDestroyUrl = (uidOrganization: string, username: string) => { return `/api/v2/organizations/${uidOrganization}/members/${username}/` } -export const organizationsMembersDestroy = async (uidOrganization: string, - username: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsMembersDestroyUrl(uidOrganization,username), - { - ...options, - method: 'DELETE' - - +export const organizationsMembersDestroy = async ( + uidOrganization: string, + username: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getOrganizationsMembersDestroyUrl(uidOrganization, username), + { + ...options, + method: 'DELETE', + }, + ) +} + +export const getOrganizationsMembersDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; username: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; username: string }, + TContext +> => { + const mutationKey = ['organizationsMembersDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidOrganization: string; username: string } + > = (props) => { + const { uidOrganization, username } = props ?? {} + + return organizationsMembersDestroy(uidOrganization, username, requestOptions) } -);} - - - - -export const getOrganizationsMembersDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;username: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidOrganization: string;username: string}, TContext> => { - -const mutationKey = ['organizationsMembersDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, {uidOrganization: string;username: string}> = (props) => { - const {uidOrganization,username} = props ?? {}; - - return organizationsMembersDestroy(uidOrganization,username,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type OrganizationsMembersDestroyMutationResult = NonNullable>> - - export type OrganizationsMembersDestroyMutationError = ErrorDetail +export type OrganizationsMembersDestroyMutationResult = NonNullable< + Awaited> +> - export const useOrganizationsMembersDestroy = (options?: { mutation?:UseMutationOptions>, TError,{uidOrganization: string;username: string}, TContext>, request?: SecondParameter} - ) => { +export type OrganizationsMembersDestroyMutationError = ErrorDetail - const mutationOptions = getOrganizationsMembersDestroyMutationOptions(options); +export const useOrganizationsMembersDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidOrganization: string; username: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getOrganizationsMembersDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Organization Usage Tracker - Tracks the total usage of different services for each account in an organization @@ -1825,78 +1847,84 @@ export type organizationsServiceUsageRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type organizationsServiceUsageRetrieveResponseComposite = organizationsServiceUsageRetrieveResponse200 | organizationsServiceUsageRetrieveResponse404; - -export type organizationsServiceUsageRetrieveResponse = organizationsServiceUsageRetrieveResponseComposite & { - headers: Headers; -} -export const getOrganizationsServiceUsageRetrieveUrl = (uidOrganization: string,) => { +export type organizationsServiceUsageRetrieveResponseComposite = + | organizationsServiceUsageRetrieveResponse200 + | organizationsServiceUsageRetrieveResponse404 +export type organizationsServiceUsageRetrieveResponse = organizationsServiceUsageRetrieveResponseComposite & { + headers: Headers +} - - +export const getOrganizationsServiceUsageRetrieveUrl = (uidOrganization: string) => { return `/api/v2/organizations/${uidOrganization}/service_usage/` } -export const organizationsServiceUsageRetrieve = async (uidOrganization: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getOrganizationsServiceUsageRetrieveUrl(uidOrganization), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getOrganizationsServiceUsageRetrieveQueryKey = (uidOrganization: string,) => { - return ['api','v2','organizations',uidOrganization,'service_usage'] as const; - } - - -export const getOrganizationsServiceUsageRetrieveQueryOptions = >, TError = ErrorDetail>(uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const organizationsServiceUsageRetrieve = async ( + uidOrganization: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getOrganizationsServiceUsageRetrieveUrl(uidOrganization), + { + ...options, + method: 'GET', + }, + ) +} + +export const getOrganizationsServiceUsageRetrieveQueryKey = (uidOrganization: string) => { + return ['api', 'v2', 'organizations', uidOrganization, 'service_usage'] as const +} + +export const getOrganizationsServiceUsageRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getOrganizationsServiceUsageRetrieveQueryKey(uidOrganization); - - + const queryKey = queryOptions?.queryKey ?? getOrganizationsServiceUsageRetrieveQueryKey(uidOrganization) - const queryFn: QueryFunction>> = ({ signal }) => organizationsServiceUsageRetrieve(uidOrganization, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + organizationsServiceUsageRetrieve(uidOrganization, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, enabled: !!(uidOrganization), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidOrganization, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type OrganizationsServiceUsageRetrieveQueryResult = NonNullable>> +export type OrganizationsServiceUsageRetrieveQueryResult = NonNullable< + Awaited> +> export type OrganizationsServiceUsageRetrieveQueryError = ErrorDetail +export function useOrganizationsServiceUsageRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidOrganization: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getOrganizationsServiceUsageRetrieveQueryOptions(uidOrganization, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useOrganizationsServiceUsageRetrieve>, TError = ErrorDetail>( - uidOrganization: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getOrganizationsServiceUsageRetrieveQueryOptions(uidOrganization,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## List project views for current user @@ -1910,85 +1938,84 @@ export type projectViewsListResponse403 = { data: ErrorDetail status: 403 } - -export type projectViewsListResponseComposite = projectViewsListResponse200 | projectViewsListResponse403; - + +export type projectViewsListResponseComposite = projectViewsListResponse200 | projectViewsListResponse403 + export type projectViewsListResponse = projectViewsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getProjectViewsListUrl = (params?: ProjectViewsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getProjectViewsListUrl = (params?: ProjectViewsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/project-views/?${stringifiedParams}` : `/api/v2/project-views/` } -export const projectViewsList = async (params?: ProjectViewsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectViewsListUrl(params), - { +export const projectViewsList = async ( + params?: ProjectViewsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectViewsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getProjectViewsListQueryKey = (params?: ProjectViewsListParams,) => { - return ['api','v2','project-views', ...(params ? [params]: [])] as const; - } +export const getProjectViewsListQueryKey = (params?: ProjectViewsListParams) => { + return ['api', 'v2', 'project-views', ...(params ? [params] : [])] as const +} - -export const getProjectViewsListQueryOptions = >, TError = ErrorDetail>(params?: ProjectViewsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getProjectViewsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: ProjectViewsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectViewsListQueryKey(params); - - - - const queryFn: QueryFunction>> = ({ signal }) => projectViewsList(params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getProjectViewsListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + projectViewsList(params, { signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ProjectViewsListQueryResult = NonNullable>> export type ProjectViewsListQueryError = ErrorDetail - - export function useProjectViewsList>, TError = ErrorDetail>( - params?: ProjectViewsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getProjectViewsListQueryOptions(params,options) + params?: ProjectViewsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectViewsListQueryOptions(params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Retrieve project view of a shared project to current user @@ -2002,78 +2029,74 @@ export type projectViewsRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type projectViewsRetrieveResponseComposite = projectViewsRetrieveResponse200 | projectViewsRetrieveResponse403; - -export type projectViewsRetrieveResponse = projectViewsRetrieveResponseComposite & { - headers: Headers; -} - -export const getProjectViewsRetrieveUrl = (uidProjectView: string,) => { +export type projectViewsRetrieveResponseComposite = projectViewsRetrieveResponse200 | projectViewsRetrieveResponse403 - +export type projectViewsRetrieveResponse = projectViewsRetrieveResponseComposite & { + headers: Headers +} +export const getProjectViewsRetrieveUrl = (uidProjectView: string) => { return `/api/v2/project-views/${uidProjectView}/` } -export const projectViewsRetrieve = async (uidProjectView: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectViewsRetrieveUrl(uidProjectView), - { +export const projectViewsRetrieve = async ( + uidProjectView: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectViewsRetrieveUrl(uidProjectView), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getProjectViewsRetrieveQueryKey = (uidProjectView: string,) => { - return ['api','v2','project-views',uidProjectView] as const; - } +export const getProjectViewsRetrieveQueryKey = (uidProjectView: string) => { + return ['api', 'v2', 'project-views', uidProjectView] as const +} - -export const getProjectViewsRetrieveQueryOptions = >, TError = ErrorDetail>(uidProjectView: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getProjectViewsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidProjectView: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectViewsRetrieveQueryKey(uidProjectView); - - - - const queryFn: QueryFunction>> = ({ signal }) => projectViewsRetrieve(uidProjectView, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getProjectViewsRetrieveQueryKey(uidProjectView) - + const queryFn: QueryFunction>> = ({ signal }) => + projectViewsRetrieve(uidProjectView, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidProjectView), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidProjectView, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ProjectViewsRetrieveQueryResult = NonNullable>> export type ProjectViewsRetrieveQueryError = ErrorDetail - - export function useProjectViewsRetrieve>, TError = ErrorDetail>( - uidProjectView: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getProjectViewsRetrieveQueryOptions(uidProjectView,options) + uidProjectView: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectViewsRetrieveQueryOptions(uidProjectView, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Retrieve an export for the requested object @@ -2095,83 +2118,83 @@ export type projectViewsExportRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type projectViewsExportRetrieveResponseComposite = projectViewsExportRetrieveResponse200 | projectViewsExportRetrieveResponse400 | projectViewsExportRetrieveResponse401; - -export type projectViewsExportRetrieveResponse = projectViewsExportRetrieveResponseComposite & { - headers: Headers; -} - -export const getProjectViewsExportRetrieveUrl = (uidProjectView: string, - objType: string,) => { +export type projectViewsExportRetrieveResponseComposite = + | projectViewsExportRetrieveResponse200 + | projectViewsExportRetrieveResponse400 + | projectViewsExportRetrieveResponse401 - +export type projectViewsExportRetrieveResponse = projectViewsExportRetrieveResponseComposite & { + headers: Headers +} +export const getProjectViewsExportRetrieveUrl = (uidProjectView: string, objType: string) => { return `/api/v2/project-views/${uidProjectView}/${objType}/export/` } -export const projectViewsExportRetrieve = async (uidProjectView: string, - objType: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectViewsExportRetrieveUrl(uidProjectView,objType), - { +export const projectViewsExportRetrieve = async ( + uidProjectView: string, + objType: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectViewsExportRetrieveUrl(uidProjectView, objType), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getProjectViewsExportRetrieveQueryKey = (uidProjectView: string, - objType: string,) => { - return ['api','v2','project-views',uidProjectView,objType,'export'] as const; - } +export const getProjectViewsExportRetrieveQueryKey = (uidProjectView: string, objType: string) => { + return ['api', 'v2', 'project-views', uidProjectView, objType, 'export'] as const +} - -export const getProjectViewsExportRetrieveQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidProjectView: string, - objType: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getProjectViewsExportRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidProjectView: string, + objType: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectViewsExportRetrieveQueryKey(uidProjectView,objType); - - - - const queryFn: QueryFunction>> = ({ signal }) => projectViewsExportRetrieve(uidProjectView,objType, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getProjectViewsExportRetrieveQueryKey(uidProjectView, objType) - + const queryFn: QueryFunction>> = ({ signal }) => + projectViewsExportRetrieve(uidProjectView, objType, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidProjectView && objType), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(uidProjectView && objType), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ProjectViewsExportRetrieveQueryResult = NonNullable>> export type ProjectViewsExportRetrieveQueryError = ErrorObject | ErrorDetail +export function useProjectViewsExportRetrieve< + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidProjectView: string, + objType: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectViewsExportRetrieveQueryOptions(uidProjectView, objType, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useProjectViewsExportRetrieve>, TError = ErrorObject | ErrorDetail>( - uidProjectView: string, - objType: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getProjectViewsExportRetrieveQueryOptions(uidProjectView,objType,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Create an export for the requested object @@ -2192,75 +2215,85 @@ export type projectViewsExportCreateResponse401 = { data: ErrorDetail status: 401 } - -export type projectViewsExportCreateResponseComposite = projectViewsExportCreateResponse200 | projectViewsExportCreateResponse400 | projectViewsExportCreateResponse401; - -export type projectViewsExportCreateResponse = projectViewsExportCreateResponseComposite & { - headers: Headers; -} - -export const getProjectViewsExportCreateUrl = (uidProjectView: string, - objType: string,) => { +export type projectViewsExportCreateResponseComposite = + | projectViewsExportCreateResponse200 + | projectViewsExportCreateResponse400 + | projectViewsExportCreateResponse401 - +export type projectViewsExportCreateResponse = projectViewsExportCreateResponseComposite & { + headers: Headers +} +export const getProjectViewsExportCreateUrl = (uidProjectView: string, objType: string) => { return `/api/v2/project-views/${uidProjectView}/${objType}/export/` } -export const projectViewsExportCreate = async (uidProjectView: string, - objType: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectViewsExportCreateUrl(uidProjectView,objType), - { +export const projectViewsExportCreate = async ( + uidProjectView: string, + objType: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectViewsExportCreateUrl(uidProjectView, objType), { ...options, - method: 'POST' - - + method: 'POST', + }) +} + +export const getProjectViewsExportCreateMutationOptions = < + TError = ErrorObject | ErrorDetail, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidProjectView: string; objType: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { uidProjectView: string; objType: string }, + TContext +> => { + const mutationKey = ['projectViewsExportCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { uidProjectView: string; objType: string } + > = (props) => { + const { uidProjectView, objType } = props ?? {} + + return projectViewsExportCreate(uidProjectView, objType, requestOptions) } -);} - - - - -export const getProjectViewsExportCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{uidProjectView: string;objType: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{uidProjectView: string;objType: string}, TContext> => { -const mutationKey = ['projectViewsExportCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {uidProjectView: string;objType: string}> = (props) => { - const {uidProjectView,objType} = props ?? {}; - - return projectViewsExportCreate(uidProjectView,objType,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type ProjectViewsExportCreateMutationResult = NonNullable>> - - export type ProjectViewsExportCreateMutationError = ErrorObject | ErrorDetail +export type ProjectViewsExportCreateMutationResult = NonNullable>> - export const useProjectViewsExportCreate = (options?: { mutation?:UseMutationOptions>, TError,{uidProjectView: string;objType: string}, TContext>, request?: SecondParameter} - ) => { +export type ProjectViewsExportCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getProjectViewsExportCreateMutationOptions(options); +export const useProjectViewsExportCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { uidProjectView: string; objType: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getProjectViewsExportCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Retrieve assets available in project view */ @@ -2278,90 +2311,98 @@ export type projectViewsAssetsRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type projectViewsAssetsRetrieveResponseComposite = projectViewsAssetsRetrieveResponse200 | projectViewsAssetsRetrieveResponse400 | projectViewsAssetsRetrieveResponse401; - + +export type projectViewsAssetsRetrieveResponseComposite = + | projectViewsAssetsRetrieveResponse200 + | projectViewsAssetsRetrieveResponse400 + | projectViewsAssetsRetrieveResponse401 + export type projectViewsAssetsRetrieveResponse = projectViewsAssetsRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getProjectViewsAssetsRetrieveUrl = (uidProjectView: string, - params?: ProjectViewsAssetsRetrieveParams,) => { - const normalizedParams = new URLSearchParams(); +export const getProjectViewsAssetsRetrieveUrl = (uidProjectView: string, params?: ProjectViewsAssetsRetrieveParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/project-views/${uidProjectView}/assets/?${stringifiedParams}` : `/api/v2/project-views/${uidProjectView}/assets/` + return stringifiedParams.length > 0 + ? `/api/v2/project-views/${uidProjectView}/assets/?${stringifiedParams}` + : `/api/v2/project-views/${uidProjectView}/assets/` } -export const projectViewsAssetsRetrieve = async (uidProjectView: string, - params?: ProjectViewsAssetsRetrieveParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectViewsAssetsRetrieveUrl(uidProjectView,params), - { +export const projectViewsAssetsRetrieve = async ( + uidProjectView: string, + params?: ProjectViewsAssetsRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectViewsAssetsRetrieveUrl(uidProjectView, params), { ...options, - method: 'GET' - - - } -);} - - - -export const getProjectViewsAssetsRetrieveQueryKey = (uidProjectView: string, - params?: ProjectViewsAssetsRetrieveParams,) => { - return ['api','v2','project-views',uidProjectView,'assets', ...(params ? [params]: [])] as const; - } + method: 'GET', + }) +} - -export const getProjectViewsAssetsRetrieveQueryOptions = >, TError = ErrorObject | ErrorDetail>(uidProjectView: string, - params?: ProjectViewsAssetsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getProjectViewsAssetsRetrieveQueryKey = ( + uidProjectView: string, + params?: ProjectViewsAssetsRetrieveParams, ) => { + return ['api', 'v2', 'project-views', uidProjectView, 'assets', ...(params ? [params] : [])] as const +} + +export const getProjectViewsAssetsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidProjectView: string, + params?: ProjectViewsAssetsRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsRetrieveQueryKey(uidProjectView,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => projectViewsAssetsRetrieve(uidProjectView,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsRetrieveQueryKey(uidProjectView, params) - + const queryFn: QueryFunction>> = ({ signal }) => + projectViewsAssetsRetrieve(uidProjectView, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidProjectView), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidProjectView, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ProjectViewsAssetsRetrieveQueryResult = NonNullable>> export type ProjectViewsAssetsRetrieveQueryError = ErrorObject | ErrorDetail +export function useProjectViewsAssetsRetrieve< + TData = Awaited>, + TError = ErrorObject | ErrorDetail, +>( + uidProjectView: string, + params?: ProjectViewsAssetsRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectViewsAssetsRetrieveQueryOptions(uidProjectView, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useProjectViewsAssetsRetrieve>, TError = ErrorObject | ErrorDetail>( - uidProjectView: string, - params?: ProjectViewsAssetsRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getProjectViewsAssetsRetrieveQueryOptions(uidProjectView,params,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Return counts of deployed, archived, and draft assets in the project view @@ -2375,78 +2416,84 @@ export type projectViewsAssetsCountsRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type projectViewsAssetsCountsRetrieveResponseComposite = projectViewsAssetsCountsRetrieveResponse200 | projectViewsAssetsCountsRetrieveResponse404; - -export type projectViewsAssetsCountsRetrieveResponse = projectViewsAssetsCountsRetrieveResponseComposite & { - headers: Headers; -} - -export const getProjectViewsAssetsCountsRetrieveUrl = (uidProjectView: string,) => { +export type projectViewsAssetsCountsRetrieveResponseComposite = + | projectViewsAssetsCountsRetrieveResponse200 + | projectViewsAssetsCountsRetrieveResponse404 - +export type projectViewsAssetsCountsRetrieveResponse = projectViewsAssetsCountsRetrieveResponseComposite & { + headers: Headers +} +export const getProjectViewsAssetsCountsRetrieveUrl = (uidProjectView: string) => { return `/api/v2/project-views/${uidProjectView}/assets/counts/` } -export const projectViewsAssetsCountsRetrieve = async (uidProjectView: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectViewsAssetsCountsRetrieveUrl(uidProjectView), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getProjectViewsAssetsCountsRetrieveQueryKey = (uidProjectView: string,) => { - return ['api','v2','project-views',uidProjectView,'assets','counts'] as const; - } - - -export const getProjectViewsAssetsCountsRetrieveQueryOptions = >, TError = ErrorDetail>(uidProjectView: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const projectViewsAssetsCountsRetrieve = async ( + uidProjectView: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getProjectViewsAssetsCountsRetrieveUrl(uidProjectView), + { + ...options, + method: 'GET', + }, + ) +} + +export const getProjectViewsAssetsCountsRetrieveQueryKey = (uidProjectView: string) => { + return ['api', 'v2', 'project-views', uidProjectView, 'assets', 'counts'] as const +} + +export const getProjectViewsAssetsCountsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidProjectView: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsCountsRetrieveQueryKey(uidProjectView); - - - - const queryFn: QueryFunction>> = ({ signal }) => projectViewsAssetsCountsRetrieve(uidProjectView, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsCountsRetrieveQueryKey(uidProjectView) - + const queryFn: QueryFunction>> = ({ signal }) => + projectViewsAssetsCountsRetrieve(uidProjectView, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidProjectView), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidProjectView, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type ProjectViewsAssetsCountsRetrieveQueryResult = NonNullable>> -export type ProjectViewsAssetsCountsRetrieveQueryError = ErrorDetail - - - -export function useProjectViewsAssetsCountsRetrieve>, TError = ErrorDetail>( - uidProjectView: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { +export type ProjectViewsAssetsCountsRetrieveQueryResult = NonNullable< + Awaited> +> +export type ProjectViewsAssetsCountsRetrieveQueryError = ErrorDetail - const queryOptions = getProjectViewsAssetsCountsRetrieveQueryOptions(uidProjectView,options) +export function useProjectViewsAssetsCountsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidProjectView: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectViewsAssetsCountsRetrieveQueryOptions(uidProjectView, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Return a minimal listing of assets in a project view @@ -2466,90 +2513,105 @@ export type projectViewsAssetsMinimalListRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type projectViewsAssetsMinimalListRetrieveResponseComposite = projectViewsAssetsMinimalListRetrieveResponse200 | projectViewsAssetsMinimalListRetrieveResponse404; - + +export type projectViewsAssetsMinimalListRetrieveResponseComposite = + | projectViewsAssetsMinimalListRetrieveResponse200 + | projectViewsAssetsMinimalListRetrieveResponse404 + export type projectViewsAssetsMinimalListRetrieveResponse = projectViewsAssetsMinimalListRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getProjectViewsAssetsMinimalListRetrieveUrl = (uidProjectView: string, - params?: ProjectViewsAssetsMinimalListRetrieveParams,) => { - const normalizedParams = new URLSearchParams(); +export const getProjectViewsAssetsMinimalListRetrieveUrl = ( + uidProjectView: string, + params?: ProjectViewsAssetsMinimalListRetrieveParams, +) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/project-views/${uidProjectView}/assets/minimal-list/?${stringifiedParams}` : `/api/v2/project-views/${uidProjectView}/assets/minimal-list/` + return stringifiedParams.length > 0 + ? `/api/v2/project-views/${uidProjectView}/assets/minimal-list/?${stringifiedParams}` + : `/api/v2/project-views/${uidProjectView}/assets/minimal-list/` } -export const projectViewsAssetsMinimalListRetrieve = async (uidProjectView: string, - params?: ProjectViewsAssetsMinimalListRetrieveParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectViewsAssetsMinimalListRetrieveUrl(uidProjectView,params), - { - ...options, - method: 'GET' - - - } -);} - - - -export const getProjectViewsAssetsMinimalListRetrieveQueryKey = (uidProjectView: string, - params?: ProjectViewsAssetsMinimalListRetrieveParams,) => { - return ['api','v2','project-views',uidProjectView,'assets','minimal-list', ...(params ? [params]: [])] as const; - } +export const projectViewsAssetsMinimalListRetrieve = async ( + uidProjectView: string, + params?: ProjectViewsAssetsMinimalListRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth( + getProjectViewsAssetsMinimalListRetrieveUrl(uidProjectView, params), + { + ...options, + method: 'GET', + }, + ) +} - -export const getProjectViewsAssetsMinimalListRetrieveQueryOptions = >, TError = ErrorDetail>(uidProjectView: string, - params?: ProjectViewsAssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getProjectViewsAssetsMinimalListRetrieveQueryKey = ( + uidProjectView: string, + params?: ProjectViewsAssetsMinimalListRetrieveParams, ) => { + return ['api', 'v2', 'project-views', uidProjectView, 'assets', 'minimal-list', ...(params ? [params] : [])] as const +} + +export const getProjectViewsAssetsMinimalListRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidProjectView: string, + params?: ProjectViewsAssetsMinimalListRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsMinimalListRetrieveQueryKey(uidProjectView,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => projectViewsAssetsMinimalListRetrieve(uidProjectView,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getProjectViewsAssetsMinimalListRetrieveQueryKey(uidProjectView, params) - + const queryFn: QueryFunction>> = ({ signal }) => + projectViewsAssetsMinimalListRetrieve(uidProjectView, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidProjectView), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidProjectView, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } -export type ProjectViewsAssetsMinimalListRetrieveQueryResult = NonNullable>> +export type ProjectViewsAssetsMinimalListRetrieveQueryResult = NonNullable< + Awaited> +> export type ProjectViewsAssetsMinimalListRetrieveQueryError = ErrorDetail +export function useProjectViewsAssetsMinimalListRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidProjectView: string, + params?: ProjectViewsAssetsMinimalListRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectViewsAssetsMinimalListRetrieveQueryOptions(uidProjectView, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useProjectViewsAssetsMinimalListRetrieve>, TError = ErrorDetail>( - uidProjectView: string, - params?: ProjectViewsAssetsMinimalListRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getProjectViewsAssetsMinimalListRetrieveQueryOptions(uidProjectView,params,options) + query.queryKey = queryOptions.queryKey - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Retrieve users available in project view @@ -2563,90 +2625,97 @@ export type projectViewsUsersRetrieveResponse403 = { data: ErrorDetail status: 403 } - -export type projectViewsUsersRetrieveResponseComposite = projectViewsUsersRetrieveResponse200 | projectViewsUsersRetrieveResponse403; - + +export type projectViewsUsersRetrieveResponseComposite = + | projectViewsUsersRetrieveResponse200 + | projectViewsUsersRetrieveResponse403 + export type projectViewsUsersRetrieveResponse = projectViewsUsersRetrieveResponseComposite & { - headers: Headers; + headers: Headers } -export const getProjectViewsUsersRetrieveUrl = (uidProjectView: string, - params?: ProjectViewsUsersRetrieveParams,) => { - const normalizedParams = new URLSearchParams(); +export const getProjectViewsUsersRetrieveUrl = (uidProjectView: string, params?: ProjectViewsUsersRetrieveParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() - return stringifiedParams.length > 0 ? `/api/v2/project-views/${uidProjectView}/users/?${stringifiedParams}` : `/api/v2/project-views/${uidProjectView}/users/` + return stringifiedParams.length > 0 + ? `/api/v2/project-views/${uidProjectView}/users/?${stringifiedParams}` + : `/api/v2/project-views/${uidProjectView}/users/` } -export const projectViewsUsersRetrieve = async (uidProjectView: string, - params?: ProjectViewsUsersRetrieveParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getProjectViewsUsersRetrieveUrl(uidProjectView,params), - { +export const projectViewsUsersRetrieve = async ( + uidProjectView: string, + params?: ProjectViewsUsersRetrieveParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getProjectViewsUsersRetrieveUrl(uidProjectView, params), { ...options, - method: 'GET' - - - } -);} - - - -export const getProjectViewsUsersRetrieveQueryKey = (uidProjectView: string, - params?: ProjectViewsUsersRetrieveParams,) => { - return ['api','v2','project-views',uidProjectView,'users', ...(params ? [params]: [])] as const; - } + method: 'GET', + }) +} - -export const getProjectViewsUsersRetrieveQueryOptions = >, TError = ErrorDetail>(uidProjectView: string, - params?: ProjectViewsUsersRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getProjectViewsUsersRetrieveQueryKey = ( + uidProjectView: string, + params?: ProjectViewsUsersRetrieveParams, ) => { + return ['api', 'v2', 'project-views', uidProjectView, 'users', ...(params ? [params] : [])] as const +} + +export const getProjectViewsUsersRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + uidProjectView: string, + params?: ProjectViewsUsersRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getProjectViewsUsersRetrieveQueryKey(uidProjectView,params); - - - - const queryFn: QueryFunction>> = ({ signal }) => projectViewsUsersRetrieve(uidProjectView,params, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getProjectViewsUsersRetrieveQueryKey(uidProjectView, params) - + const queryFn: QueryFunction>> = ({ signal }) => + projectViewsUsersRetrieve(uidProjectView, params, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(uidProjectView), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!uidProjectView, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ProjectViewsUsersRetrieveQueryResult = NonNullable>> export type ProjectViewsUsersRetrieveQueryError = ErrorDetail +export function useProjectViewsUsersRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + uidProjectView: string, + params?: ProjectViewsUsersRetrieveParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getProjectViewsUsersRetrieveQueryOptions(uidProjectView, params, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useProjectViewsUsersRetrieve>, TError = ErrorDetail>( - uidProjectView: string, - params?: ProjectViewsUsersRetrieveParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getProjectViewsUsersRetrieveQueryOptions(uidProjectView,params,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ⚠️ Deprecated ## Track Service Usage @@ -2667,78 +2736,68 @@ export type serviceUsageListResponse401 = { data: ErrorDetail status: 401 } - -export type serviceUsageListResponseComposite = serviceUsageListResponse200 | serviceUsageListResponse401; - + +export type serviceUsageListResponseComposite = serviceUsageListResponse200 | serviceUsageListResponse401 + export type serviceUsageListResponse = serviceUsageListResponseComposite & { - headers: Headers; + headers: Headers } export const getServiceUsageListUrl = () => { - - - - return `/api/v2/service_usage/` } -export const serviceUsageList = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getServiceUsageListUrl(), - { +export const serviceUsageList = async (options?: RequestInit): Promise => { + return fetchWithAuth(getServiceUsageListUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getServiceUsageListQueryKey = () => { - return ['api','v2','service_usage'] as const; - } - - -export const getServiceUsageListQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getServiceUsageListQueryKey(); - - + return ['api', 'v2', 'service_usage'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => serviceUsageList({ signal, ...requestOptions }); +export const getServiceUsageListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getServiceUsageListQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + serviceUsageList({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type ServiceUsageListQueryResult = NonNullable>> export type ServiceUsageListQueryError = ErrorDetail - - -export function useServiceUsageList>, TError = ErrorDetail>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useServiceUsageList< + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getServiceUsageListQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## List users @@ -2765,85 +2824,78 @@ export type usersListResponse403 = { data: ErrorDetail status: 403 } - -export type usersListResponseComposite = usersListResponse200 | usersListResponse403; - + +export type usersListResponseComposite = usersListResponse200 | usersListResponse403 + export type usersListResponse = usersListResponseComposite & { - headers: Headers; + headers: Headers } -export const getUsersListUrl = (params?: UsersListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getUsersListUrl = (params?: UsersListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/api/v2/users/?${stringifiedParams}` : `/api/v2/users/` } export const usersList = async (params?: UsersListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getUsersListUrl(params), - { + return fetchWithAuth(getUsersListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getUsersListQueryKey = (params?: UsersListParams,) => { - return ['api','v2','users', ...(params ? [params]: [])] as const; - } +export const getUsersListQueryKey = (params?: UsersListParams) => { + return ['api', 'v2', 'users', ...(params ? [params] : [])] as const +} - -export const getUsersListQueryOptions = >, TError = ErrorDetail>(params?: UsersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getUsersListQueryOptions = >, TError = ErrorDetail>( + params?: UsersListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getUsersListQueryKey(params); + const queryKey = queryOptions?.queryKey ?? getUsersListQueryKey(params) - + const queryFn: QueryFunction>> = ({ signal }) => + usersList(params, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => usersList(params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type UsersListQueryResult = NonNullable>> export type UsersListQueryError = ErrorDetail - - export function useUsersList>, TError = ErrorDetail>( - params?: UsersListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getUsersListQueryOptions(params,options) + params?: UsersListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getUsersListQueryOptions(params, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Retrieve a user @@ -2859,78 +2911,68 @@ export type usersRetrieveResponse404 = { data: ErrorDetail status: 404 } - -export type usersRetrieveResponseComposite = usersRetrieveResponse200 | usersRetrieveResponse404; - -export type usersRetrieveResponse = usersRetrieveResponseComposite & { - headers: Headers; -} -export const getUsersRetrieveUrl = (username: string,) => { +export type usersRetrieveResponseComposite = usersRetrieveResponse200 | usersRetrieveResponse404 +export type usersRetrieveResponse = usersRetrieveResponseComposite & { + headers: Headers +} - - +export const getUsersRetrieveUrl = (username: string) => { return `/api/v2/users/${username}/` } export const usersRetrieve = async (username: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getUsersRetrieveUrl(username), - { + return fetchWithAuth(getUsersRetrieveUrl(username), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getUsersRetrieveQueryKey = (username: string,) => { - return ['api','v2','users',username] as const; - } +export const getUsersRetrieveQueryKey = (username: string) => { + return ['api', 'v2', 'users', username] as const +} - -export const getUsersRetrieveQueryOptions = >, TError = ErrorDetail>(username: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getUsersRetrieveQueryOptions = >, TError = ErrorDetail>( + username: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getUsersRetrieveQueryKey(username); + const queryKey = queryOptions?.queryKey ?? getUsersRetrieveQueryKey(username) - + const queryFn: QueryFunction>> = ({ signal }) => + usersRetrieve(username, { signal, ...requestOptions }) - const queryFn: QueryFunction>> = ({ signal }) => usersRetrieve(username, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, enabled: !!(username), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!username, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type UsersRetrieveQueryResult = NonNullable>> export type UsersRetrieveQueryError = ErrorDetail - - export function useUsersRetrieve>, TError = ErrorDetail>( - username: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - - const queryOptions = getUsersRetrieveQueryOptions(username,options) + username: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getUsersRetrieveQueryOptions(username, options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Retrieve current user profile @@ -2944,78 +2986,65 @@ export type meRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type meRetrieveResponseComposite = meRetrieveResponse200 | meRetrieveResponse401; - + +export type meRetrieveResponseComposite = meRetrieveResponse200 | meRetrieveResponse401 + export type meRetrieveResponse = meRetrieveResponseComposite & { - headers: Headers; + headers: Headers } export const getMeRetrieveUrl = () => { - - - - return `/me/` } -export const meRetrieve = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getMeRetrieveUrl(), - { +export const meRetrieve = async (options?: RequestInit): Promise => { + return fetchWithAuth(getMeRetrieveUrl(), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} export const getMeRetrieveQueryKey = () => { - return ['me'] as const; - } - - -export const getMeRetrieveQueryOptions = >, TError = ErrorDetail>( options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getMeRetrieveQueryKey(); - - + return ['me'] as const +} - const queryFn: QueryFunction>> = ({ signal }) => meRetrieve({ signal, ...requestOptions }); +export const getMeRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} - + const queryKey = queryOptions?.queryKey ?? getMeRetrieveQueryKey() - + const queryFn: QueryFunction>> = ({ signal }) => + meRetrieve({ signal, ...requestOptions }) - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type MeRetrieveQueryResult = NonNullable>> export type MeRetrieveQueryError = ErrorDetail - - -export function useMeRetrieve>, TError = ErrorDetail>( - options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { - +export function useMeRetrieve>, TError = ErrorDetail>(options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter +}): UseQueryResult & { queryKey: QueryKey } { const queryOptions = getMeRetrieveQueryOptions(options) - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - query.queryKey = queryOptions.queryKey ; + query.queryKey = queryOptions.queryKey - return query; + return query } - - /** * ## Update current user infos @@ -3034,74 +3063,83 @@ export type mePartialUpdateResponse401 = { data: ErrorDetail status: 401 } - -export type mePartialUpdateResponseComposite = mePartialUpdateResponse200 | mePartialUpdateResponse400 | mePartialUpdateResponse401; - + +export type mePartialUpdateResponseComposite = + | mePartialUpdateResponse200 + | mePartialUpdateResponse400 + | mePartialUpdateResponse401 + export type mePartialUpdateResponse = mePartialUpdateResponseComposite & { - headers: Headers; + headers: Headers } export const getMePartialUpdateUrl = () => { - - - - return `/me/` } -export const mePartialUpdate = async (patchedCurrentUser: NonReadonly, options?: RequestInit): Promise => { - - return fetchWithAuth(getMePartialUpdateUrl(), - { +export const mePartialUpdate = async ( + patchedCurrentUser: NonReadonly, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getMePartialUpdateUrl(), { ...options, method: 'PATCH', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - patchedCurrentUser,) + body: JSON.stringify(patchedCurrentUser), + }) +} + +export const getMePartialUpdateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext +> => { + const mutationKey = ['mePartialUpdate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: NonReadonly } + > = (props) => { + const { data } = props ?? {} + + return mePartialUpdate(data, requestOptions) } -);} - - + return { mutationFn, ...mutationOptions } +} -export const getMePartialUpdateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: NonReadonly}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: NonReadonly}, TContext> => { - -const mutationKey = ['mePartialUpdate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: NonReadonly}> = (props) => { - const {data} = props ?? {}; - - return mePartialUpdate(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type MePartialUpdateMutationResult = NonNullable>> - export type MePartialUpdateMutationBody = NonReadonly - export type MePartialUpdateMutationError = ErrorObject | ErrorDetail - - export const useMePartialUpdate = (options?: { mutation?:UseMutationOptions>, TError,{data: NonReadonly}, TContext>, request?: SecondParameter} - ) => { +export type MePartialUpdateMutationResult = NonNullable>> +export type MePartialUpdateMutationBody = NonReadonly +export type MePartialUpdateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getMePartialUpdateMutationOptions(options); +export const useMePartialUpdate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: NonReadonly }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getMePartialUpdateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## Delete current user > Payload Example: @@ -3128,73 +3166,55 @@ export type meDestroyResponse401 = { data: ErrorDetail status: 401 } - -export type meDestroyResponseComposite = meDestroyResponse204 | meDestroyResponse400 | meDestroyResponse401; - + +export type meDestroyResponseComposite = meDestroyResponse204 | meDestroyResponse400 | meDestroyResponse401 + export type meDestroyResponse = meDestroyResponseComposite & { - headers: Headers; + headers: Headers } export const getMeDestroyUrl = () => { - - - - return `/me/` } -export const meDestroy = async ( options?: RequestInit): Promise => { - - return fetchWithAuth(getMeDestroyUrl(), - { +export const meDestroy = async (options?: RequestInit): Promise => { + return fetchWithAuth(getMeDestroyUrl(), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getMeDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['meDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return meDestroy(requestOptions) } -);} - - - - -export const getMeDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,void, TContext> => { - -const mutationKey = ['meDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - const mutationFn: MutationFunction>, void> = () => { - - - return meDestroy(requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} + return { mutationFn, ...mutationOptions } +} - export type MeDestroyMutationResult = NonNullable>> - - export type MeDestroyMutationError = ErrorObject | ErrorDetail +export type MeDestroyMutationResult = NonNullable>> - export const useMeDestroy = (options?: { mutation?:UseMutationOptions>, TError,void, TContext>, request?: SecondParameter} - ) => { +export type MeDestroyMutationError = ErrorObject | ErrorDetail - const mutationOptions = getMeDestroyMutationOptions(options); +export const useMeDestroy = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}) => { + const mutationOptions = getMeDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## View current user's email */ @@ -3207,85 +3227,81 @@ export type meEmailsListResponse401 = { data: ErrorDetail status: 401 } - -export type meEmailsListResponseComposite = meEmailsListResponse200 | meEmailsListResponse401; - + +export type meEmailsListResponseComposite = meEmailsListResponse200 | meEmailsListResponse401 + export type meEmailsListResponse = meEmailsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getMeEmailsListUrl = (params?: MeEmailsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getMeEmailsListUrl = (params?: MeEmailsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/me/emails/?${stringifiedParams}` : `/me/emails/` } -export const meEmailsList = async (params?: MeEmailsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getMeEmailsListUrl(params), - { +export const meEmailsList = async ( + params?: MeEmailsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getMeEmailsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getMeEmailsListQueryKey = (params?: MeEmailsListParams,) => { - return ['me','emails', ...(params ? [params]: [])] as const; - } +export const getMeEmailsListQueryKey = (params?: MeEmailsListParams) => { + return ['me', 'emails', ...(params ? [params] : [])] as const +} - -export const getMeEmailsListQueryOptions = >, TError = ErrorDetail>(params?: MeEmailsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getMeEmailsListQueryOptions = >, TError = ErrorDetail>( + params?: MeEmailsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getMeEmailsListQueryKey(params); - - + const queryKey = queryOptions?.queryKey ?? getMeEmailsListQueryKey(params) - const queryFn: QueryFunction>> = ({ signal }) => meEmailsList(params, { signal, ...requestOptions }); + const queryFn: QueryFunction>> = ({ signal }) => + meEmailsList(params, { signal, ...requestOptions }) - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type MeEmailsListQueryResult = NonNullable>> export type MeEmailsListQueryError = ErrorDetail - - export function useMeEmailsList>, TError = ErrorDetail>( - params?: MeEmailsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + params?: MeEmailsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getMeEmailsListQueryOptions(params, options) - const queryOptions = getMeEmailsListQueryOptions(params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Set a new email @@ -3307,74 +3323,77 @@ export type meEmailsCreateResponse401 = { data: ErrorDetail status: 401 } - -export type meEmailsCreateResponseComposite = meEmailsCreateResponse201 | meEmailsCreateResponse400 | meEmailsCreateResponse401; - + +export type meEmailsCreateResponseComposite = + | meEmailsCreateResponse201 + | meEmailsCreateResponse400 + | meEmailsCreateResponse401 + export type meEmailsCreateResponse = meEmailsCreateResponseComposite & { - headers: Headers; + headers: Headers } export const getMeEmailsCreateUrl = () => { - - - - return `/me/emails/` } -export const meEmailsCreate = async (emailRequestPayload: EmailRequestPayload, options?: RequestInit): Promise => { - - return fetchWithAuth(getMeEmailsCreateUrl(), - { +export const meEmailsCreate = async ( + emailRequestPayload: EmailRequestPayload, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getMeEmailsCreateUrl(), { ...options, method: 'POST', headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify( - emailRequestPayload,) + body: JSON.stringify(emailRequestPayload), + }) +} + +export const getMeEmailsCreateMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailRequestPayload }, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, { data: EmailRequestPayload }, TContext> => { + const mutationKey = ['meEmailsCreate'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: EmailRequestPayload }> = ( + props, + ) => { + const { data } = props ?? {} + + return meEmailsCreate(data, requestOptions) } -);} - - - - -export const getMeEmailsCreateMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailRequestPayload}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{data: EmailRequestPayload}, TContext> => { - -const mutationKey = ['meEmailsCreate']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {data: EmailRequestPayload}> = (props) => { - const {data} = props ?? {}; - return meEmailsCreate(data,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type MeEmailsCreateMutationResult = NonNullable>> - export type MeEmailsCreateMutationBody = EmailRequestPayload - export type MeEmailsCreateMutationError = ErrorObject | ErrorDetail + return { mutationFn, ...mutationOptions } +} - export const useMeEmailsCreate = (options?: { mutation?:UseMutationOptions>, TError,{data: EmailRequestPayload}, TContext>, request?: SecondParameter} - ) => { +export type MeEmailsCreateMutationResult = NonNullable>> +export type MeEmailsCreateMutationBody = EmailRequestPayload +export type MeEmailsCreateMutationError = ErrorObject | ErrorDetail - const mutationOptions = getMeEmailsCreateMutationOptions(options); +export const useMeEmailsCreate = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: EmailRequestPayload }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getMeEmailsCreateMutationOptions(options) - return useMutation(mutationOptions ); - } - /** + return useMutation(mutationOptions) +} +/** * ## List user's social accounts */ @@ -3387,85 +3406,84 @@ export type meSocialAccountsListResponse401 = { data: ErrorDetail status: 401 } - -export type meSocialAccountsListResponseComposite = meSocialAccountsListResponse200 | meSocialAccountsListResponse401; - + +export type meSocialAccountsListResponseComposite = meSocialAccountsListResponse200 | meSocialAccountsListResponse401 + export type meSocialAccountsListResponse = meSocialAccountsListResponseComposite & { - headers: Headers; + headers: Headers } -export const getMeSocialAccountsListUrl = (params?: MeSocialAccountsListParams,) => { - const normalizedParams = new URLSearchParams(); +export const getMeSocialAccountsListUrl = (params?: MeSocialAccountsListParams) => { + const normalizedParams = new URLSearchParams() Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : value.toString()) } - }); + }) - const stringifiedParams = normalizedParams.toString(); + const stringifiedParams = normalizedParams.toString() return stringifiedParams.length > 0 ? `/me/social-accounts/?${stringifiedParams}` : `/me/social-accounts/` } -export const meSocialAccountsList = async (params?: MeSocialAccountsListParams, options?: RequestInit): Promise => { - - return fetchWithAuth(getMeSocialAccountsListUrl(params), - { +export const meSocialAccountsList = async ( + params?: MeSocialAccountsListParams, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getMeSocialAccountsListUrl(params), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getMeSocialAccountsListQueryKey = (params?: MeSocialAccountsListParams,) => { - return ['me','social-accounts', ...(params ? [params]: [])] as const; - } +export const getMeSocialAccountsListQueryKey = (params?: MeSocialAccountsListParams) => { + return ['me', 'social-accounts', ...(params ? [params] : [])] as const +} - -export const getMeSocialAccountsListQueryOptions = >, TError = ErrorDetail>(params?: MeSocialAccountsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getMeSocialAccountsListQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + params?: MeSocialAccountsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; + const queryKey = queryOptions?.queryKey ?? getMeSocialAccountsListQueryKey(params) - const queryKey = queryOptions?.queryKey ?? getMeSocialAccountsListQueryKey(params); + const queryFn: QueryFunction>> = ({ signal }) => + meSocialAccountsList(params, { signal, ...requestOptions }) - - - const queryFn: QueryFunction>> = ({ signal }) => meSocialAccountsList(params, { signal, ...requestOptions }); - - - - - - return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type MeSocialAccountsListQueryResult = NonNullable>> export type MeSocialAccountsListQueryError = ErrorDetail - - export function useMeSocialAccountsList>, TError = ErrorDetail>( - params?: MeSocialAccountsListParams, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + params?: MeSocialAccountsListParams, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getMeSocialAccountsListQueryOptions(params, options) - const queryOptions = getMeSocialAccountsListQueryOptions(params,options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Retrieve a social account provider @@ -3479,83 +3497,82 @@ export type meSocialAccountsRetrieveResponse401 = { data: ErrorDetail status: 401 } - -export type meSocialAccountsRetrieveResponseComposite = meSocialAccountsRetrieveResponse200 | meSocialAccountsRetrieveResponse401; - -export type meSocialAccountsRetrieveResponse = meSocialAccountsRetrieveResponseComposite & { - headers: Headers; -} - -export const getMeSocialAccountsRetrieveUrl = (provider: string, - uidSocialAccount: string,) => { +export type meSocialAccountsRetrieveResponseComposite = + | meSocialAccountsRetrieveResponse200 + | meSocialAccountsRetrieveResponse401 - +export type meSocialAccountsRetrieveResponse = meSocialAccountsRetrieveResponseComposite & { + headers: Headers +} +export const getMeSocialAccountsRetrieveUrl = (provider: string, uidSocialAccount: string) => { return `/me/social-accounts/${provider}/${uidSocialAccount}/` } -export const meSocialAccountsRetrieve = async (provider: string, - uidSocialAccount: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getMeSocialAccountsRetrieveUrl(provider,uidSocialAccount), - { +export const meSocialAccountsRetrieve = async ( + provider: string, + uidSocialAccount: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getMeSocialAccountsRetrieveUrl(provider, uidSocialAccount), { ...options, - method: 'GET' - - - } -);} - - + method: 'GET', + }) +} -export const getMeSocialAccountsRetrieveQueryKey = (provider: string, - uidSocialAccount: string,) => { - return ['me','social-accounts',provider,uidSocialAccount] as const; - } +export const getMeSocialAccountsRetrieveQueryKey = (provider: string, uidSocialAccount: string) => { + return ['me', 'social-accounts', provider, uidSocialAccount] as const +} - -export const getMeSocialAccountsRetrieveQueryOptions = >, TError = ErrorDetail>(provider: string, - uidSocialAccount: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} +export const getMeSocialAccountsRetrieveQueryOptions = < + TData = Awaited>, + TError = ErrorDetail, +>( + provider: string, + uidSocialAccount: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, ) => { + const { query: queryOptions, request: requestOptions } = options ?? {} -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getMeSocialAccountsRetrieveQueryKey(provider,uidSocialAccount); - - - - const queryFn: QueryFunction>> = ({ signal }) => meSocialAccountsRetrieve(provider,uidSocialAccount, { signal, ...requestOptions }); - - + const queryKey = queryOptions?.queryKey ?? getMeSocialAccountsRetrieveQueryKey(provider, uidSocialAccount) - + const queryFn: QueryFunction>> = ({ signal }) => + meSocialAccountsRetrieve(provider, uidSocialAccount, { signal, ...requestOptions }) - return { queryKey, queryFn, enabled: !!(provider && uidSocialAccount), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(provider && uidSocialAccount), ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } } export type MeSocialAccountsRetrieveQueryResult = NonNullable>> export type MeSocialAccountsRetrieveQueryError = ErrorDetail +export function useMeSocialAccountsRetrieve< + TData = Awaited>, + TError = ErrorDetail, +>( + provider: string, + uidSocialAccount: string, + options?: { + query?: UseQueryOptions>, TError, TData> + request?: SecondParameter + }, +): UseQueryResult & { queryKey: QueryKey } { + const queryOptions = getMeSocialAccountsRetrieveQueryOptions(provider, uidSocialAccount, options) + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey } -export function useMeSocialAccountsRetrieve>, TError = ErrorDetail>( - provider: string, - uidSocialAccount: string, options?: { query?:UseQueryOptions>, TError, TData>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } { + query.queryKey = queryOptions.queryKey - const queryOptions = getMeSocialAccountsRetrieveQueryOptions(provider,uidSocialAccount,options) - - const query = useQuery(queryOptions ) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; - - return query; + return query } - - /** * ## Delete a social account provider @@ -3569,72 +3586,77 @@ export type meSocialAccountsDestroyResponse401 = { data: ErrorDetail status: 401 } - -export type meSocialAccountsDestroyResponseComposite = meSocialAccountsDestroyResponse204 | meSocialAccountsDestroyResponse401; - -export type meSocialAccountsDestroyResponse = meSocialAccountsDestroyResponseComposite & { - headers: Headers; -} - -export const getMeSocialAccountsDestroyUrl = (provider: string, - uidSocialAccount: string,) => { +export type meSocialAccountsDestroyResponseComposite = + | meSocialAccountsDestroyResponse204 + | meSocialAccountsDestroyResponse401 - +export type meSocialAccountsDestroyResponse = meSocialAccountsDestroyResponseComposite & { + headers: Headers +} +export const getMeSocialAccountsDestroyUrl = (provider: string, uidSocialAccount: string) => { return `/me/social-accounts/${provider}/${uidSocialAccount}/` } -export const meSocialAccountsDestroy = async (provider: string, - uidSocialAccount: string, options?: RequestInit): Promise => { - - return fetchWithAuth(getMeSocialAccountsDestroyUrl(provider,uidSocialAccount), - { +export const meSocialAccountsDestroy = async ( + provider: string, + uidSocialAccount: string, + options?: RequestInit, +): Promise => { + return fetchWithAuth(getMeSocialAccountsDestroyUrl(provider, uidSocialAccount), { ...options, - method: 'DELETE' - - + method: 'DELETE', + }) +} + +export const getMeSocialAccountsDestroyMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { provider: string; uidSocialAccount: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { provider: string; uidSocialAccount: string }, + TContext +> => { + const mutationKey = ['meSocialAccountsDestroy'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { provider: string; uidSocialAccount: string } + > = (props) => { + const { provider, uidSocialAccount } = props ?? {} + + return meSocialAccountsDestroy(provider, uidSocialAccount, requestOptions) } -);} - - - - -export const getMeSocialAccountsDestroyMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{provider: string;uidSocialAccount: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{provider: string;uidSocialAccount: string}, TContext> => { - -const mutationKey = ['meSocialAccountsDestroy']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - + return { mutationFn, ...mutationOptions } +} - const mutationFn: MutationFunction>, {provider: string;uidSocialAccount: string}> = (props) => { - const {provider,uidSocialAccount} = props ?? {}; - - return meSocialAccountsDestroy(provider,uidSocialAccount,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type MeSocialAccountsDestroyMutationResult = NonNullable>> - - export type MeSocialAccountsDestroyMutationError = ErrorDetail +export type MeSocialAccountsDestroyMutationResult = NonNullable>> - export const useMeSocialAccountsDestroy = (options?: { mutation?:UseMutationOptions>, TError,{provider: string;uidSocialAccount: string}, TContext>, request?: SecondParameter} - ) => { +export type MeSocialAccountsDestroyMutationError = ErrorDetail - const mutationOptions = getMeSocialAccountsDestroyMutationOptions(options); +export const useMeSocialAccountsDestroy = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { provider: string; uidSocialAccount: string }, + TContext + > + request?: SecondParameter +}) => { + const mutationOptions = getMeSocialAccountsDestroyMutationOptions(options) - return useMutation(mutationOptions ); - } - \ No newline at end of file + return useMutation(mutationOptions) +} diff --git a/jsapp/js/api/react-query/user-team-organization-usage/msw.ts b/jsapp/js/api/react-query/user-team-organization-usage/msw.ts index cfe585d0f3..1acb66798f 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage/msw.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage/msw.ts @@ -9,594 +9,2241 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ -import { - faker -} from '@faker-js/faker'; +import { faker } from '@faker-js/faker' -import { HttpResponse, - http } from 'msw'; +import { http, HttpResponse } from 'msw' -import { - AssetDeploymentStatusEnum -} from '../../models/assetDeploymentStatusEnum'; +import { AssetDeploymentStatusEnum } from '../../models/assetDeploymentStatusEnum' -import type { - AssetListCount -} from '../../models/assetListCount'; +import type { AssetListCount } from '../../models/assetListCount' -import { - AssetTypeEnum -} from '../../models/assetTypeEnum'; +import { AssetTypeEnum } from '../../models/assetTypeEnum' -import { - CustomAssetUsageDeploymentStatusEnum -} from '../../models/customAssetUsageDeploymentStatusEnum'; +import { CustomAssetUsageDeploymentStatusEnum } from '../../models/customAssetUsageDeploymentStatusEnum' -import type { - EmailAddress -} from '../../models/emailAddress'; +import type { EmailAddress } from '../../models/emailAddress' -import type { - InviteCreateResponse -} from '../../models/inviteCreateResponse'; +import type { InviteCreateResponse } from '../../models/inviteCreateResponse' -import type { - InviteResponse -} from '../../models/inviteResponse'; +import type { InviteResponse } from '../../models/inviteResponse' -import { - InviteStatusChoicesEnum -} from '../../models/inviteStatusChoicesEnum'; +import { InviteStatusChoicesEnum } from '../../models/inviteStatusChoicesEnum' -import { - InviteeRoleEnum -} from '../../models/inviteeRoleEnum'; +import { InviteeRoleEnum } from '../../models/inviteeRoleEnum' -import type { - MeListResponse -} from '../../models/meListResponse'; +import type { MeListResponse } from '../../models/meListResponse' -import type { - MemberListResponse -} from '../../models/memberListResponse'; +import type { MemberListResponse } from '../../models/memberListResponse' -import { - MemberRoleEnum -} from '../../models/memberRoleEnum'; +import { MemberRoleEnum } from '../../models/memberRoleEnum' -import type { - OrganizationResponse -} from '../../models/organizationResponse'; +import type { OrganizationResponse } from '../../models/organizationResponse' -import type { - OrganizationServiceUsageResponse -} from '../../models/organizationServiceUsageResponse'; +import type { OrganizationServiceUsageResponse } from '../../models/organizationServiceUsageResponse' -import { - OrganizationTypeEnum -} from '../../models/organizationTypeEnum'; +import { OrganizationTypeEnum } from '../../models/organizationTypeEnum' -import type { - PaginatedAssetList -} from '../../models/paginatedAssetList'; +import type { PaginatedAssetList } from '../../models/paginatedAssetList' -import type { - PaginatedAssetMinimalListList -} from '../../models/paginatedAssetMinimalListList'; +import type { PaginatedAssetMinimalListList } from '../../models/paginatedAssetMinimalListList' -import type { - PaginatedAssetUsageResponseList -} from '../../models/paginatedAssetUsageResponseList'; +import type { PaginatedAssetUsageResponseList } from '../../models/paginatedAssetUsageResponseList' -import type { - PaginatedCustomAssetUsageList -} from '../../models/paginatedCustomAssetUsageList'; +import type { PaginatedCustomAssetUsageList } from '../../models/paginatedCustomAssetUsageList' -import type { - PaginatedEmailAddressList -} from '../../models/paginatedEmailAddressList'; +import type { PaginatedEmailAddressList } from '../../models/paginatedEmailAddressList' -import type { - PaginatedInviteResponseList -} from '../../models/paginatedInviteResponseList'; +import type { PaginatedInviteResponseList } from '../../models/paginatedInviteResponseList' -import type { - PaginatedMemberListResponseList -} from '../../models/paginatedMemberListResponseList'; +import type { PaginatedMemberListResponseList } from '../../models/paginatedMemberListResponseList' -import type { - PaginatedOrganizationResponseList -} from '../../models/paginatedOrganizationResponseList'; +import type { PaginatedOrganizationResponseList } from '../../models/paginatedOrganizationResponseList' -import type { - PaginatedProjectViewAssetResponseList -} from '../../models/paginatedProjectViewAssetResponseList'; +import type { PaginatedProjectViewAssetResponseList } from '../../models/paginatedProjectViewAssetResponseList' -import type { - PaginatedProjectViewListResponseList -} from '../../models/paginatedProjectViewListResponseList'; +import type { PaginatedProjectViewListResponseList } from '../../models/paginatedProjectViewListResponseList' -import type { - PaginatedProjectViewUserResponseList -} from '../../models/paginatedProjectViewUserResponseList'; +import type { PaginatedProjectViewUserResponseList } from '../../models/paginatedProjectViewUserResponseList' -import type { - PaginatedSocialAccountList -} from '../../models/paginatedSocialAccountList'; +import type { PaginatedSocialAccountList } from '../../models/paginatedSocialAccountList' -import type { - PaginatedUserListResponseList -} from '../../models/paginatedUserListResponseList'; +import type { PaginatedUserListResponseList } from '../../models/paginatedUserListResponseList' -import type { - ProjectViewExportCreateResponse -} from '../../models/projectViewExportCreateResponse'; +import type { ProjectViewExportCreateResponse } from '../../models/projectViewExportCreateResponse' -import type { - ProjectViewExportResponse -} from '../../models/projectViewExportResponse'; +import type { ProjectViewExportResponse } from '../../models/projectViewExportResponse' + +import type { ProjectViewListResponse } from '../../models/projectViewListResponse' -import type { - ProjectViewListResponse -} from '../../models/projectViewListResponse'; - -import type { - ServiceUsageBalanceData -} from '../../models/serviceUsageBalanceData'; - -import type { - ServiceUsageResponse -} from '../../models/serviceUsageResponse'; - -import type { - SocialAccount -} from '../../models/socialAccount'; - -import type { - UserRetrieveResponse -} from '../../models/userRetrieveResponse'; - - -export const getApiV2AssetUsageListResponseMock = (overrideResponse: Partial< PaginatedAssetUsageResponseList > = {}): PaginatedAssetUsageResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({asset: faker.internet.url(), asset__name: faker.string.alpha({length: {min: 10, max: 20}}), nlp_usage_current_period: {total_nlp_asr_seconds: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_mt_characters: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_llm_requests: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, nlp_usage_all_time: {total_nlp_asr_seconds: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_mt_characters: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_llm_requests: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, storage_bytes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), submission_count_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), submission_count_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})})), ...overrideResponse}) - -export const getApiV2OrganizationsListResponseMock = (overrideResponse: Partial< PaginatedOrganizationResponseList > = {}): PaginatedOrganizationResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 200}}), website: faker.string.alpha({length: {min: 10, max: 255}}), organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, is_owner: faker.datatype.boolean(), is_mmo: faker.datatype.boolean(), request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), members: faker.internet.url(), assets: faker.internet.url(), service_usage: faker.internet.url(), asset_usage: faker.internet.url()})), ...overrideResponse}) - -export const getApiV2OrganizationsRetrieveResponseMock = (overrideResponse: Partial< OrganizationResponse > = {}): OrganizationResponse => ({id: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 200}}), website: faker.string.alpha({length: {min: 10, max: 255}}), organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, is_owner: faker.datatype.boolean(), is_mmo: faker.datatype.boolean(), request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), members: faker.internet.url(), assets: faker.internet.url(), service_usage: faker.internet.url(), asset_usage: faker.internet.url(), ...overrideResponse}) - -export const getApiV2OrganizationsPartialUpdateResponseMock = (overrideResponse: Partial< OrganizationResponse > = {}): OrganizationResponse => ({id: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), name: faker.string.alpha({length: {min: 10, max: 200}}), website: faker.string.alpha({length: {min: 10, max: 255}}), organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, is_owner: faker.datatype.boolean(), is_mmo: faker.datatype.boolean(), request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), members: faker.internet.url(), assets: faker.internet.url(), service_usage: faker.internet.url(), asset_usage: faker.internet.url(), ...overrideResponse}) - -export const getApiV2OrganizationsAssetUsageListResponseMock = (overrideResponse: Partial< PaginatedCustomAssetUsageList > = {}): PaginatedCustomAssetUsageList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({asset: faker.internet.url(), asset__name: faker.string.alpha({length: {min: 10, max: 20}}), nlp_usage_current_period: {...{total_nlp_asr_seconds: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_llm_requests: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_mt_characters: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},}, nlp_usage_all_time: {...{total_nlp_asr_seconds: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_llm_requests: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_nlp_mt_characters: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})},}, storage_bytes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), submission_count_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), submission_count_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment_status: faker.helpers.arrayElement(Object.values(CustomAssetUsageDeploymentStatusEnum))})), ...overrideResponse}) - -export const getApiV2OrganizationsAssetsRetrieveResponseMock = (overrideResponse: Partial< PaginatedAssetList > = {}): PaginatedAssetList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([{sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), organization: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined])}, undefined]), asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), asset: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), user__username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), file_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), date_created: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), content: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), metadata: faker.helpers.arrayElement([{}, undefined])})), summary: {geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), labels: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), columns: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), row_count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), name_quality: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), bad: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), good: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), total: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), firsts: faker.helpers.arrayElement([{ok: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), bad: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), index: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}, undefined]), default_translation: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), naming_conflicts: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_deployed: faker.helpers.arrayElement([faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), undefined]), version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version__content_hash: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), version_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), has_deployment: faker.datatype.boolean(), deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployed_versions: {count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), previous: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.internet.url(), content_hash: faker.string.alpha({length: {min: 10, max: 20}}), date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`}))}, deployment__links: {}, deployment__active: faker.datatype.boolean(), deployment__data_download_links: {csv_legacy: faker.string.alpha({length: {min: 10, max: 20}}), csv: faker.string.alpha({length: {min: 10, max: 20}}), geojson: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), kml_legacy: faker.string.alpha({length: {min: 10, max: 20}}), spss_labels: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), xls_legacy: faker.string.alpha({length: {min: 10, max: 20}}), xls: faker.string.alpha({length: {min: 10, max: 20}}), zip_legacy: faker.string.alpha({length: {min: 10, max: 20}})}, deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment__last_submission_time: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), deployment__encrypted: faker.datatype.boolean(), deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), report_styles: faker.helpers.arrayElement([{default: faker.helpers.arrayElement([{groupDataBy: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), report_colors: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translationIndex: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), graphWidth: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, undefined]), specified: faker.helpers.arrayElement([{}, undefined]), kuid_names: faker.helpers.arrayElement([{}, undefined])}, undefined]), report_custom: faker.helpers.arrayElement([{}, undefined]), advanced_features: faker.helpers.arrayElement([{transcript: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), translation: faker.helpers.arrayElement([{values: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), languages: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined]), qual: faker.helpers.arrayElement([{qual_survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({type: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined]), xpath: faker.string.alpha({length: {min: 10, max: 20}}), scope: faker.string.alpha({length: {min: 10, max: 20}}), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}, uuid: faker.string.alpha({length: {min: 10, max: 20}}), options: faker.helpers.arrayElement([{deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined])}, undefined])})), undefined])})), undefined])}, undefined]), _version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_styles: faker.helpers.arrayElement([{colorSet: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), querylimit: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), map_custom: faker.helpers.arrayElement([{}, undefined]), content: faker.helpers.arrayElement([{schema: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), survey: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$kuid: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.string.alpha({length: {min: 10, max: 20}}), $xpath: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), calculation: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), hint: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), appearance: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), parameters: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--matrix_list': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-constraint-message': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--rank-items': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--score-choices': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), tags: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), select_from_list_name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'body::accept': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({$autovalue: faker.string.alpha({length: {min: 10, max: 20}}), $kuid: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), list_name: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), 'media::image': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), $autoname: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), settings: faker.helpers.arrayElement([{name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), version: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), id_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), style: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), form_id: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), title: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), 'kobo--locking-profile': faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), default_language: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined])}, undefined]), translated: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), translations: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]))), undefined]), translations_0: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), undefined]), 'kobo--locking-profiles': faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - [faker.string.alphanumeric(5)]: {} - })), undefined])}, undefined]), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}})})), analysis_form_json: {additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), source: faker.string.alpha({length: {min: 10, max: 20}}), type: faker.helpers.arrayElement(['transcript','translation','qualVerification','qualSource','qualInteger','qualTags','qualText','qualNote','qualAutoKeywordCount','qualSelectMultiple','qualSelectOne'] as const), name: faker.string.alpha({length: {min: 10, max: 20}}), dtpath: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), choices: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uuid: faker.string.alpha({length: {min: 10, max: 20}}), labels: {_default: faker.string.alpha({length: {min: 10, max: 20}})}})), undefined])}))}, xform_link: faker.internet.url(), hooks_link: faker.internet.url(), tag_string: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.string.alpha({length: {min: 10, max: 20}}), kind: faker.string.alpha({length: {min: 10, max: 20}}), xls_link: faker.internet.url(), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 255}}), undefined]), assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},])})), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.string.alpha({length: {min: 10, max: 20}}), user: faker.string.alpha({length: {min: 10, max: 20}}), permission: faker.string.alpha({length: {min: 10, max: 20}}), partial_permissions: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), undefined])})), undefined]), label: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),{default: faker.string.alpha({length: {min: 10, max: 20}}), view_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), change_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), delete_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), validate_submissions: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])},]), undefined])})), effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({codename: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), exports: faker.internet.url(), export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 20}}), url: faker.string.alpha({length: {min: 10, max: 20}}), data_url_csv: faker.string.alpha({length: {min: 10, max: 20}}), data_url_xlsx: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, export_settings: { - [faker.string.alphanumeric(5)]: {} - }})), data: faker.internet.url(), children: {count: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), status: faker.string.alpha({length: {min: 10, max: 20}}), access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { - [faker.string.alphanumeric(5)]: {} - }, owner_label: faker.string.alpha({length: {min: 10, max: 20}}), last_modified_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null]), created_by: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), null])})), ...overrideResponse}) - -export const getApiV2OrganizationsAssetsCountsRetrieveResponseMock = (overrideResponse: Partial< AssetListCount > = {}): AssetListCount => ({deployed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), archived_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), draft_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), ...overrideResponse}) - -export const getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock = (overrideResponse: Partial< PaginatedAssetMinimalListList > = {}): PaginatedAssetMinimalListList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 22}}), name: faker.string.alpha({length: {min: 10, max: 20}}), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum))})), ...overrideResponse}) - -export const getApiV2OrganizationsInvitesListResponseMock = (overrideResponse: Partial< PaginatedInviteResponseList > = {}): PaginatedInviteResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) - -export const getApiV2OrganizationsInvitesCreateResponseMock = (): InviteCreateResponse => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), invited_by: faker.internet.url(), status: faker.string.alpha({length: {min: 10, max: 20}}), invitee_role: faker.helpers.arrayElement(['admin','member'] as const), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}})}))) - -export const getApiV2OrganizationsInvitesRetrieveResponseMock = (overrideResponse: Partial< InviteResponse > = {}): InviteResponse => ({invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2OrganizationsInvitesPartialUpdateResponseMock = (overrideResponse: Partial< InviteResponse > = {}): InviteResponse => ({invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getApiV2OrganizationsMembersListResponseMock = (overrideResponse: Partial< PaginatedMemberListResponseList > = {}): PaginatedMemberListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), url: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), user__email: faker.internet.email(), user__extra_details__name: faker.string.alpha({length: {min: 10, max: 20}}), user__has_mfa_enabled: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, user__is_active: faker.datatype.boolean(), invite: {...{invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}})},}})), ...overrideResponse}) - -export const getApiV2OrganizationsMembersRetrieveResponseMock = (overrideResponse: Partial< MemberListResponse > = {}): MemberListResponse => ({role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), url: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), user__email: faker.internet.email(), user__extra_details__name: faker.string.alpha({length: {min: 10, max: 20}}), user__has_mfa_enabled: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, user__is_active: faker.datatype.boolean(), invite: {...{invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}})},}, ...overrideResponse}) - -export const getApiV2OrganizationsMembersPartialUpdateResponseMock = (overrideResponse: Partial< MemberListResponse > = {}): MemberListResponse => ({role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), url: faker.internet.url(), user: faker.internet.url(), user__username: faker.string.alpha({length: {min: 10, max: 20}}), user__email: faker.internet.email(), user__extra_details__name: faker.string.alpha({length: {min: 10, max: 20}}), user__has_mfa_enabled: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, user__is_active: faker.datatype.boolean(), invite: {...{invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), url: faker.internet.url(), invited_by: faker.internet.url(), organization_name: faker.string.alpha({length: {min: 10, max: 20}}), created: `${faker.date.past().toISOString().split('.')[0]}Z`, modified: `${faker.date.past().toISOString().split('.')[0]}Z`, invitee: faker.string.alpha({length: {min: 10, max: 20}})},}, ...overrideResponse}) - -export const getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock = (overrideResponse: Partial = {}): ServiceUsageBalanceData => ({...{effective_limit: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_value: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_percent: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), exceeded: faker.datatype.boolean()}, ...overrideResponse}); - -export const getApiV2OrganizationsServiceUsageRetrieveResponseMock = (overrideResponse: Partial< OrganizationServiceUsageResponse > = {}): OrganizationServiceUsageResponse => ({total_nlp_usage: {asr_seconds_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), asr_seconds_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, total_storage_bytes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_submission_count: {all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, balances: {submission: faker.helpers.arrayElement([{...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock()},null,]), storage_bytes: faker.helpers.arrayElement([{...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock()},null,]), asr_seconds: faker.helpers.arrayElement([{...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock()},null,]), mt_characters: faker.helpers.arrayElement([{...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock()},null,]), llm_requests: faker.helpers.arrayElement([{...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock()},null,])}, current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, ...overrideResponse}) - -export const getApiV2ProjectViewsListResponseMock = (overrideResponse: Partial< PaginatedProjectViewListResponseList > = {}): PaginatedProjectViewListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 32}}), name: faker.internet.url(), url: faker.internet.url(), assets: faker.internet.url(), assets_export: faker.internet.url(), users: faker.internet.url(), users_export: faker.internet.url(), countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}})))})), ...overrideResponse}) - -export const getApiV2ProjectViewsRetrieveResponseMock = (overrideResponse: Partial< ProjectViewListResponse > = {}): ProjectViewListResponse => ({uid: faker.string.alpha({length: {min: 10, max: 32}}), name: faker.internet.url(), url: faker.internet.url(), assets: faker.internet.url(), assets_export: faker.internet.url(), users: faker.internet.url(), users_export: faker.internet.url(), countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), ...overrideResponse}) - -export const getApiV2ProjectViewsExportRetrieveResponseMock = (overrideResponse: Partial< ProjectViewExportResponse > = {}): ProjectViewExportResponse => ({status: faker.string.alpha({length: {min: 10, max: 32}}), result: faker.internet.url(), ...overrideResponse}) - -export const getApiV2ProjectViewsExportCreateResponseMock = (overrideResponse: Partial< ProjectViewExportCreateResponse > = {}): ProjectViewExportCreateResponse => ({status: faker.string.alpha({length: {min: 10, max: 32}}), ...overrideResponse}) - -export const getApiV2ProjectViewsAssetsRetrieveResponseMock = (overrideResponse: Partial< PaginatedProjectViewAssetResponseList > = {}): PaginatedProjectViewAssetResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({url: faker.internet.url(), date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, owner: faker.internet.url(), owner__username: faker.string.alpha({length: {min: 10, max: 20}}), owner__email: faker.internet.email(), owner__name: faker.string.alpha({length: {min: 10, max: 20}}), owner__organization: faker.string.alpha({length: {min: 10, max: 20}}), uid: faker.string.alpha({length: {min: 10, max: 20}}), name: faker.string.alpha({length: {min: 10, max: 20}}), settings: {sector: faker.helpers.arrayElement([{label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, undefined]), country: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({label: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), value: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), collects_pii: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country_codes: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), operational_purpose: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), has_deployment: faker.datatype.boolean(), deployment__active: faker.datatype.boolean(), deployment__submission_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), deployment_status: faker.string.alpha({length: {min: 10, max: 20}}), asset_type: faker.string.alpha({length: {min: 10, max: 20}}), downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({format: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), url: faker.helpers.arrayElement([faker.internet.url(), undefined])})), owner_label: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) - -export const getApiV2ProjectViewsAssetsCountsRetrieveResponseMock = (overrideResponse: Partial< AssetListCount > = {}): AssetListCount => ({deployed_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), archived_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), draft_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), ...overrideResponse}) - -export const getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock = (overrideResponse: Partial< PaginatedAssetMinimalListList > = {}): PaginatedAssetMinimalListList => ({next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({uid: faker.string.alpha({length: {min: 10, max: 22}}), name: faker.string.alpha({length: {min: 10, max: 20}}), deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum))})), ...overrideResponse}) - -export const getApiV2ProjectViewsUsersRetrieveResponseMock = (overrideResponse: Partial< PaginatedProjectViewUserResponseList > = {}): PaginatedProjectViewUserResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), username: faker.string.alpha({length: {min: 10, max: 20}}), is_superuser: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, is_active: faker.datatype.boolean(), email: faker.internet.email(), asset_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), metadata: {city: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), sector: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_ui_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_website: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_view_settings: faker.helpers.arrayElement([{my_project_view_name: faker.helpers.arrayElement([{order: faker.helpers.arrayElement([{}, undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}})), ...overrideResponse}) - -export const getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock = (overrideResponse: Partial = {}): ServiceUsageBalanceData => ({...{effective_limit: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_value: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), balance_percent: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), exceeded: faker.datatype.boolean()}, ...overrideResponse}); - -export const getApiV2ServiceUsageListResponseMock = (): ServiceUsageResponse[] => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({total_nlp_usage: {asr_seconds_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_current_period: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), asr_seconds_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), llm_requests_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), mt_characters_all_time: faker.number.int({min: undefined, max: undefined, multipleOf: undefined})}, total_storage_bytes: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), total_submission_count: {all_time: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined]), current_period: faker.helpers.arrayElement([faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), undefined])}, balances: {submission: faker.helpers.arrayElement([{...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock()},null,]), storage_bytes: faker.helpers.arrayElement([{...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock()},null,]), asr_seconds: faker.helpers.arrayElement([{...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock()},null,]), mt_characters: faker.helpers.arrayElement([{...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock()},null,]), llm_requests: faker.helpers.arrayElement([{...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock()},null,])}, current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`}))) - -export const getApiV2UsersListResponseMock = (overrideResponse: Partial< PaginatedUserListResponseList > = {}): PaginatedUserListResponseList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), username: faker.string.alpha({length: {min: 10, max: 20}}), is_superuser: faker.datatype.boolean(), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, is_active: faker.datatype.boolean(), email: faker.internet.email(), asset_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), metadata: {name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), sector: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_ui_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_website: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_views_settings: faker.helpers.arrayElement([{kobo_my_project: faker.helpers.arrayElement([{order: faker.helpers.arrayElement([{}, undefined]), fields: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined]), filters: faker.helpers.arrayElement([Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => (faker.string.alpha({length: {min: 10, max: 20}}))), undefined])}, undefined])}, undefined])}})), ...overrideResponse}) - -export const getApiV2UsersRetrieveResponseMock = (overrideResponse: Partial< UserRetrieveResponse > = {}): UserRetrieveResponse => ({url: faker.internet.url(), username: faker.string.alpha({length: {min: 10, max: 20}}), date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, public_collection_subscribers_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), public_collections_count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), ...overrideResponse}) - -export const getMeRetrieveResponseMock = (overrideResponse: Partial< MeListResponse > = {}): MeListResponse => ({username: faker.string.alpha({length: {min: 10, max: 20}}), first_name: faker.string.alpha({length: {min: 10, max: 20}}), last_name: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.internet.email(), server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, projects_url: faker.internet.url(), gravatar: faker.internet.url(), last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), extra_details: {bio: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), city: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), sector: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), twitter: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), linkedin: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), instagram: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_ui_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_website: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_views_settings: faker.helpers.arrayElement([{}, undefined]), require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), newsletter_subscription: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, git_rev: faker.helpers.arrayElement([faker.datatype.boolean(),{short: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), long: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), branch: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), tag: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined])},]), social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({provider: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), email: faker.helpers.arrayElement([faker.internet.email(), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), validated_password: faker.datatype.boolean(), accepted_tos: faker.datatype.boolean(), organization: {url: faker.helpers.arrayElement([faker.internet.url(), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, extra_details__uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getMePartialUpdateResponseMock = (overrideResponse: Partial< MeListResponse > = {}): MeListResponse => ({username: faker.string.alpha({length: {min: 10, max: 20}}), first_name: faker.string.alpha({length: {min: 10, max: 20}}), last_name: faker.string.alpha({length: {min: 10, max: 20}}), email: faker.internet.email(), server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, projects_url: faker.internet.url(), gravatar: faker.internet.url(), last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), extra_details: {bio: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), city: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), sector: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), country: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), twitter: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), linkedin: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), instagram: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_ui_language: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_type: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), organization_website: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), project_views_settings: faker.helpers.arrayElement([{}, undefined]), require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), newsletter_subscription: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, git_rev: faker.helpers.arrayElement([faker.datatype.boolean(),{short: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), long: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), branch: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined]), tag: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}),faker.datatype.boolean(),]), undefined])},]), social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({provider: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), email: faker.helpers.arrayElement([faker.internet.email(), undefined]), username: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])})), validated_password: faker.datatype.boolean(), accepted_tos: faker.datatype.boolean(), organization: {url: faker.helpers.arrayElement([faker.internet.url(), undefined]), name: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined]), uid: faker.helpers.arrayElement([faker.string.alpha({length: {min: 10, max: 20}}), undefined])}, extra_details__uid: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - -export const getMeEmailsListResponseMock = (overrideResponse: Partial< PaginatedEmailAddressList > = {}): PaginatedEmailAddressList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean()})), ...overrideResponse}) - -export const getMeEmailsCreateResponseMock = (overrideResponse: Partial< EmailAddress > = {}): EmailAddress => ({email: faker.string.alpha({length: {min: 10, max: 20}}), primary: faker.datatype.boolean(), verified: faker.datatype.boolean(), ...overrideResponse}) - -export const getMeSocialAccountsListResponseMock = (overrideResponse: Partial< PaginatedSocialAccountList > = {}): PaginatedSocialAccountList => ({count: faker.number.int({min: undefined, max: undefined, multipleOf: undefined}), next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({provider: faker.string.alpha({length: {min: 10, max: 200}}), uid: faker.string.alpha({length: {min: 10, max: 191}}), last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, email: faker.internet.email(), username: faker.string.alpha({length: {min: 10, max: 20}})})), ...overrideResponse}) - -export const getMeSocialAccountsRetrieveResponseMock = (overrideResponse: Partial< SocialAccount > = {}): SocialAccount => ({provider: faker.string.alpha({length: {min: 10, max: 200}}), uid: faker.string.alpha({length: {min: 10, max: 191}}), last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, email: faker.internet.email(), username: faker.string.alpha({length: {min: 10, max: 20}}), ...overrideResponse}) - - -export const getApiV2AssetUsageListMockHandler = (overrideResponse?: PaginatedAssetUsageResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetUsageResponseList)) => { - return http.get('*/api/v2/asset_usage/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2AssetUsageListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +import type { ServiceUsageBalanceData } from '../../models/serviceUsageBalanceData' + +import type { ServiceUsageResponse } from '../../models/serviceUsageResponse' + +import type { SocialAccount } from '../../models/socialAccount' + +import type { UserRetrieveResponse } from '../../models/userRetrieveResponse' + +export const getApiV2AssetUsageListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetUsageResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + asset: faker.internet.url(), + asset__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + nlp_usage_current_period: { + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + nlp_usage_all_time: { + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedOrganizationResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + website: faker.string.alpha({ length: { min: 10, max: 255 } }), + organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_owner: faker.datatype.boolean(), + is_mmo: faker.datatype.boolean(), + request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + members: faker.internet.url(), + assets: faker.internet.url(), + service_usage: faker.internet.url(), + asset_usage: faker.internet.url(), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OrganizationResponse => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + website: faker.string.alpha({ length: { min: 10, max: 255 } }), + organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_owner: faker.datatype.boolean(), + is_mmo: faker.datatype.boolean(), + request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + members: faker.internet.url(), + assets: faker.internet.url(), + service_usage: faker.internet.url(), + asset_usage: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2OrganizationsPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): OrganizationResponse => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + name: faker.string.alpha({ length: { min: 10, max: 200 } }), + website: faker.string.alpha({ length: { min: 10, max: 255 } }), + organization_type: faker.helpers.arrayElement(Object.values(OrganizationTypeEnum)), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_owner: faker.datatype.boolean(), + is_mmo: faker.datatype.boolean(), + request_user_role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + members: faker.internet.url(), + assets: faker.internet.url(), + service_usage: faker.internet.url(), + asset_usage: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetUsageListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedCustomAssetUsageList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + asset: faker.internet.url(), + asset__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + nlp_usage_current_period: { + ...{ + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + nlp_usage_all_time: { + ...{ + total_nlp_asr_seconds: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_llm_requests: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_nlp_mt_characters: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + }, + storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + submission_count_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment_status: faker.helpers.arrayElement(Object.values(CustomAssetUsageDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + settings: faker.helpers.arrayElement([ + { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + organization: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + }, + undefined, + ]), + asset_type: faker.helpers.arrayElement(Object.values(AssetTypeEnum)), + files: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + asset: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + user__username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + file_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + date_created: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + content: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + metadata: faker.helpers.arrayElement([{}, undefined]), + })), + summary: { + geo: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + labels: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + columns: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + lock_all: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + lock_any: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + row_count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + name_quality: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + bad: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + good: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + total: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + firsts: faker.helpers.arrayElement([ + { + ok: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + bad: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + index: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + default_translation: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + naming_conflicts: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + date_created: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_modified: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_deployed: faker.helpers.arrayElement([ + faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + undefined, + ]), + version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version__content_hash: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + version_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + has_deployment: faker.datatype.boolean(), + deployed_version_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployed_versions: { + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + previous: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.internet.url(), + content_hash: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + })), + }, + deployment__links: {}, + deployment__active: faker.datatype.boolean(), + deployment__data_download_links: { + csv_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + geojson: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + kml_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + spss_labels: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + xls_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls: faker.string.alpha({ length: { min: 10, max: 20 } }), + zip_legacy: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment__last_submission_time: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + null, + ]), + deployment__encrypted: faker.datatype.boolean(), + deployment__uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + report_styles: faker.helpers.arrayElement([ + { + default: faker.helpers.arrayElement([ + { + groupDataBy: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + report_colors: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translationIndex: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + graphWidth: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + undefined, + ]), + specified: faker.helpers.arrayElement([{}, undefined]), + kuid_names: faker.helpers.arrayElement([{}, undefined]), + }, + undefined, + ]), + report_custom: faker.helpers.arrayElement([{}, undefined]), + advanced_features: faker.helpers.arrayElement([ + { + transcript: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + translation: faker.helpers.arrayElement([ + { + values: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + languages: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + qual: faker.helpers.arrayElement([ + { + qual_survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + xpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + scope: faker.string.alpha({ length: { min: 10, max: 20 } }), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + options: faker.helpers.arrayElement([ + { deleted: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]) }, + undefined, + ]), + })), + undefined, + ]), + })), + undefined, + ]), + }, + undefined, + ]), + _version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_styles: faker.helpers.arrayElement([ + { + colorSet: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + querylimit: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + selectedQuestion: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + map_custom: faker.helpers.arrayElement([{}, undefined]), + content: faker.helpers.arrayElement([ + { + schema: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + survey: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.string.alpha({ length: { min: 10, max: 20 } }), + $xpath: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + calculation: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + hint: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + required: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + appearance: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + parameters: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--matrix_list': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-constraint-message': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--rank-items': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--score-choices': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + tags: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + select_from_list_name: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + 'body::accept': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + })), + undefined, + ]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + $autovalue: faker.string.alpha({ length: { min: 10, max: 20 } }), + $kuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + list_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + 'media::image': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + $autoname: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + settings: faker.helpers.arrayElement([ + { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + version: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + id_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + style: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + form_id: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + title: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + 'kobo--lock_all': faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + 'kobo--locking-profile': faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + default_language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + undefined, + ]), + translated: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + translations: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + ), + undefined, + ]), + translations_0: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + 'kobo--locking-profiles': faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + [faker.string.alphanumeric(5)]: {}, + })), + undefined, + ]), + }, + undefined, + ]), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + embeds: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + analysis_form_json: { + additional_fields: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + source: faker.string.alpha({ length: { min: 10, max: 20 } }), + type: faker.helpers.arrayElement([ + 'transcript', + 'translation', + 'qualVerification', + 'qualSource', + 'qualInteger', + 'qualTags', + 'qualText', + 'qualNote', + 'qualAutoKeywordCount', + 'qualSelectMultiple', + 'qualSelectOne', + ] as const), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + dtpath: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + choices: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uuid: faker.string.alpha({ length: { min: 10, max: 20 } }), + labels: { _default: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + })), + undefined, + ]), + })), + }, + xform_link: faker.internet.url(), + hooks_link: faker.internet.url(), + tag_string: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + xls_link: faker.internet.url(), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 255 } }), undefined]), + assignable_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + label: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + })), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + user: faker.string.alpha({ length: { min: 10, max: 20 } }), + permission: faker.string.alpha({ length: { min: 10, max: 20 } }), + partial_permissions: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({})), + undefined, + ]), + })), + undefined, + ]), + label: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + { + default: faker.string.alpha({ length: { min: 10, max: 20 } }), + view_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + change_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + delete_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + validate_submissions: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + ]), + undefined, + ]), + })), + effective_permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + codename: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + exports: faker.internet.url(), + export_settings: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + url: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_csv: faker.string.alpha({ length: { min: 10, max: 20 } }), + data_url_xlsx: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + export_settings: { + [faker.string.alphanumeric(5)]: {}, + }, + })), + data: faker.internet.url(), + children: { + count: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + data_sharing: faker.helpers.arrayElement([{}, undefined]), + paired_data: faker.internet.url(), + project_ownership: { + [faker.string.alphanumeric(5)]: {}, + }, + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_modified_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + created_by: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetsCountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetListCount => ({ + deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetMinimalListList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 22 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsInvitesListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedInviteResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsInvitesCreateResponseMock = (): InviteCreateResponse => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + invited_by: faker.internet.url(), + status: faker.string.alpha({ length: { min: 10, max: 20 } }), + invitee_role: faker.helpers.arrayElement(['admin', 'member'] as const), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + })) + +export const getApiV2OrganizationsInvitesRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): InviteResponse => ({ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2OrganizationsInvitesPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): InviteResponse => ({ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2OrganizationsMembersListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedMemberListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + url: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__email: faker.internet.email(), + user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__has_mfa_enabled: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + user__is_active: faker.datatype.boolean(), + invite: { + ...{ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + })), + ...overrideResponse, +}) + +export const getApiV2OrganizationsMembersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): MemberListResponse => ({ + role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + url: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__email: faker.internet.email(), + user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__has_mfa_enabled: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + user__is_active: faker.datatype.boolean(), + invite: { + ...{ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2OrganizationsMembersPartialUpdateResponseMock = ( + overrideResponse: Partial = {}, +): MemberListResponse => ({ + role: faker.helpers.arrayElement(Object.values(MemberRoleEnum)), + url: faker.internet.url(), + user: faker.internet.url(), + user__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__email: faker.internet.email(), + user__extra_details__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + user__has_mfa_enabled: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + user__is_active: faker.datatype.boolean(), + invite: { + ...{ + invitee_role: faker.helpers.arrayElement(Object.values(InviteeRoleEnum)), + status: faker.helpers.arrayElement(Object.values(InviteStatusChoicesEnum)), + url: faker.internet.url(), + invited_by: faker.internet.url(), + organization_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + created: `${faker.date.past().toISOString().split('.')[0]}Z`, + modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + invitee: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + }, + ...overrideResponse, +}) + +export const getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock = ( + overrideResponse: Partial = {}, +): ServiceUsageBalanceData => ({ + ...{ + effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + exceeded: faker.datatype.boolean(), + }, + ...overrideResponse, +}) + +export const getApiV2OrganizationsServiceUsageRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): OrganizationServiceUsageResponse => ({ + total_nlp_usage: { + asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_submission_count: { + all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + balances: { + submission: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + storage_bytes: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + asr_seconds: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + mt_characters: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + llm_requests: faker.helpers.arrayElement([ + { ...getApiV2OrganizationsServiceUsageRetrieveResponseServiceUsageBalanceDataMock() }, + null, + ]), + }, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + ...overrideResponse, +}) + +export const getApiV2ProjectViewsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectViewListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 32 } }), + name: faker.internet.url(), + url: faker.internet.url(), + assets: faker.internet.url(), + assets_export: faker.internet.url(), + users: faker.internet.url(), + users_export: faker.internet.url(), + countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ProjectViewListResponse => ({ + uid: faker.string.alpha({ length: { min: 10, max: 32 } }), + name: faker.internet.url(), + url: faker.internet.url(), + assets: faker.internet.url(), + assets_export: faker.internet.url(), + users: faker.internet.url(), + users_export: faker.internet.url(), + countries: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + permissions: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + assigned_users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsExportRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): ProjectViewExportResponse => ({ + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + result: faker.internet.url(), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsExportCreateResponseMock = ( + overrideResponse: Partial = {}, +): ProjectViewExportCreateResponse => ({ + status: faker.string.alpha({ length: { min: 10, max: 32 } }), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsAssetsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectViewAssetResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + url: faker.internet.url(), + date_created: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_modified: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_deployed: `${faker.date.past().toISOString().split('.')[0]}Z`, + owner: faker.internet.url(), + owner__username: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner__email: faker.internet.email(), + owner__name: faker.string.alpha({ length: { min: 10, max: 20 } }), + owner__organization: faker.string.alpha({ length: { min: 10, max: 20 } }), + uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + settings: { + sector: faker.helpers.arrayElement([ + { + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + undefined, + ]), + country: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + undefined, + ]), + description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + collects_pii: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country_codes: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + operational_purpose: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + has_deployment: faker.datatype.boolean(), + deployment__active: faker.datatype.boolean(), + deployment__submission_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + deployment_status: faker.string.alpha({ length: { min: 10, max: 20 } }), + asset_type: faker.string.alpha({ length: { min: 10, max: 20 } }), + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + format: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + })), + owner_label: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsAssetsCountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): AssetListCount => ({ + deployed_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + archived_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + draft_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedAssetMinimalListList => ({ + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + uid: faker.string.alpha({ length: { min: 10, max: 22 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + deployment_status: faker.helpers.arrayElement(Object.values(AssetDeploymentStatusEnum)), + })), + ...overrideResponse, +}) + +export const getApiV2ProjectViewsUsersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedProjectViewUserResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_superuser: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_active: faker.datatype.boolean(), + email: faker.internet.email(), + asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + metadata: { + city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + project_view_settings: faker.helpers.arrayElement([ + { + my_project_view_name: faker.helpers.arrayElement([ + { + order: faker.helpers.arrayElement([{}, undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock = ( + overrideResponse: Partial = {}, +): ServiceUsageBalanceData => ({ + ...{ + effective_limit: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_value: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + balance_percent: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + exceeded: faker.datatype.boolean(), + }, + ...overrideResponse, +}) + +export const getApiV2ServiceUsageListResponseMock = (): ServiceUsageResponse[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + total_nlp_usage: { + asr_seconds_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_current_period: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + asr_seconds_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + llm_requests_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + mt_characters_all_time: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + }, + total_storage_bytes: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + total_submission_count: { + all_time: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + current_period: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + undefined, + ]), + }, + balances: { + submission: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + storage_bytes: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + asr_seconds: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + mt_characters: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + llm_requests: faker.helpers.arrayElement([ + { ...getApiV2ServiceUsageListResponseServiceUsageBalanceDataMock() }, + null, + ]), + }, + current_period_start: `${faker.date.past().toISOString().split('.')[0]}Z`, + current_period_end: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_updated: `${faker.date.past().toISOString().split('.')[0]}Z`, + })) + +export const getApiV2UsersListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedUserListResponseList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + is_superuser: faker.datatype.boolean(), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + is_active: faker.datatype.boolean(), + email: faker.internet.email(), + asset_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + metadata: { + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + project_views_settings: faker.helpers.arrayElement([ + { + kobo_my_project: faker.helpers.arrayElement([ + { + order: faker.helpers.arrayElement([{}, undefined]), + fields: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + filters: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + }, + })), + ...overrideResponse, +}) + +export const getApiV2UsersRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): UserRetrieveResponse => ({ + url: faker.internet.url(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + public_collection_subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + public_collections_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + ...overrideResponse, +}) + +export const getMeRetrieveResponseMock = (overrideResponse: Partial = {}): MeListResponse => ({ + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.internet.email(), + server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + projects_url: faker.internet.url(), + gravatar: faker.internet.url(), + last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + extra_details: { + bio: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + twitter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + linkedin: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + instagram: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_views_settings: faker.helpers.arrayElement([{}, undefined]), + require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + newsletter_subscription: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + git_rev: faker.helpers.arrayElement([ + faker.datatype.boolean(), + { + short: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + long: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + branch: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + tag: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + }, + ]), + social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + email: faker.helpers.arrayElement([faker.internet.email(), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + validated_password: faker.datatype.boolean(), + accepted_tos: faker.datatype.boolean(), + organization: { + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + extra_details__uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getMePartialUpdateResponseMock = (overrideResponse: Partial = {}): MeListResponse => ({ + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + first_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + last_name: faker.string.alpha({ length: { min: 10, max: 20 } }), + email: faker.internet.email(), + server_time: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + projects_url: faker.internet.url(), + gravatar: faker.internet.url(), + last_login: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, null]), + extra_details: { + bio: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + city: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + sector: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + country: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + twitter: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + linkedin: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + instagram: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_ui_language: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_type: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + organization_website: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + project_views_settings: faker.helpers.arrayElement([{}, undefined]), + require_auth: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + newsletter_subscription: faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + undefined, + ]), + }, + git_rev: faker.helpers.arrayElement([ + faker.datatype.boolean(), + { + short: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + long: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + branch: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + tag: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), faker.datatype.boolean()]), + undefined, + ]), + }, + ]), + social_accounts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + last_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + date_joined: faker.helpers.arrayElement([`${faker.date.past().toISOString().split('.')[0]}Z`, undefined]), + email: faker.helpers.arrayElement([faker.internet.email(), undefined]), + username: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + })), + validated_password: faker.datatype.boolean(), + accepted_tos: faker.datatype.boolean(), + organization: { + url: faker.helpers.arrayElement([faker.internet.url(), undefined]), + name: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + uid: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), + }, + extra_details__uid: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getMeEmailsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedEmailAddressList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + })), + ...overrideResponse, +}) + +export const getMeEmailsCreateResponseMock = (overrideResponse: Partial = {}): EmailAddress => ({ + email: faker.string.alpha({ length: { min: 10, max: 20 } }), + primary: faker.datatype.boolean(), + verified: faker.datatype.boolean(), + ...overrideResponse, +}) + +export const getMeSocialAccountsListResponseMock = ( + overrideResponse: Partial = {}, +): PaginatedSocialAccountList => ({ + count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), + next: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + previous: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), + results: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + provider: faker.string.alpha({ length: { min: 10, max: 200 } }), + uid: faker.string.alpha({ length: { min: 10, max: 191 } }), + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + email: faker.internet.email(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + })), + ...overrideResponse, +}) + +export const getMeSocialAccountsRetrieveResponseMock = ( + overrideResponse: Partial = {}, +): SocialAccount => ({ + provider: faker.string.alpha({ length: { min: 10, max: 200 } }), + uid: faker.string.alpha({ length: { min: 10, max: 191 } }), + last_login: `${faker.date.past().toISOString().split('.')[0]}Z`, + date_joined: `${faker.date.past().toISOString().split('.')[0]}Z`, + email: faker.internet.email(), + username: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getApiV2AssetUsageListMockHandler = ( + overrideResponse?: + | PaginatedAssetUsageResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetUsageResponseList), +) => { + return http.get('*/api/v2/asset_usage/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetUsageListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsListMockHandler = (overrideResponse?: PaginatedOrganizationResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedOrganizationResponseList)) => { - return http.get('*/api/v2/organizations/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsListMockHandler = ( + overrideResponse?: + | PaginatedOrganizationResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedOrganizationResponseList), +) => { + return http.get('*/api/v2/organizations/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsRetrieveMockHandler = (overrideResponse?: OrganizationResponse | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse)) => { - return http.get('*/api/v2/organizations/:uidOrganization/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsRetrieveMockHandler = ( + overrideResponse?: + | OrganizationResponse + | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsPartialUpdateMockHandler = (overrideResponse?: OrganizationResponse | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse)) => { - return http.patch('*/api/v2/organizations/:uidOrganization/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsPartialUpdateMockHandler = ( + overrideResponse?: + | OrganizationResponse + | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), +) => { + return http.patch('*/api/v2/organizations/:uidOrganization/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsAssetUsageListMockHandler = (overrideResponse?: PaginatedCustomAssetUsageList | ((info: Parameters[1]>[0]) => Promise | PaginatedCustomAssetUsageList)) => { - return http.get('*/api/v2/organizations/:uidOrganization/asset_usage/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsAssetUsageListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsAssetUsageListMockHandler = ( + overrideResponse?: + | PaginatedCustomAssetUsageList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedCustomAssetUsageList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/asset_usage/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetUsageListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsAssetsRetrieveMockHandler = (overrideResponse?: PaginatedAssetList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList)) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsAssetsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsAssetsRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetList + | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsAssetsCountsRetrieveMockHandler = (overrideResponse?: AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount)) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/counts/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsAssetsCountsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsAssetsCountsRetrieveMockHandler = ( + overrideResponse?: + | AssetListCount + | ((info: Parameters[1]>[0]) => Promise | AssetListCount), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/counts/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetsCountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler = (overrideResponse?: PaginatedAssetMinimalListList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetMinimalListList)) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetMinimalListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetMinimalListList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsAssetsMinimalListRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsInvitesListMockHandler = (overrideResponse?: PaginatedInviteResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedInviteResponseList)) => { - return http.get('*/api/v2/organizations/:uidOrganization/invites/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsInvitesListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsInvitesListMockHandler = ( + overrideResponse?: + | PaginatedInviteResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedInviteResponseList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsInvitesCreateMockHandler = (overrideResponse?: InviteCreateResponse | ((info: Parameters[1]>[0]) => Promise | InviteCreateResponse)) => { - return http.post('*/api/v2/organizations/:uidOrganization/invites/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsInvitesCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsInvitesCreateMockHandler = ( + overrideResponse?: + | InviteCreateResponse + | ((info: Parameters[1]>[0]) => Promise | InviteCreateResponse), +) => { + return http.post('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsInvitesRetrieveMockHandler = (overrideResponse?: InviteResponse | ((info: Parameters[1]>[0]) => Promise | InviteResponse)) => { - return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsInvitesRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsInvitesRetrieveMockHandler = ( + overrideResponse?: + | InviteResponse + | ((info: Parameters[1]>[0]) => Promise | InviteResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = (overrideResponse?: InviteResponse | ((info: Parameters[1]>[0]) => Promise | InviteResponse)) => { - return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsInvitesPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = ( + overrideResponse?: + | InviteResponse + | ((info: Parameters[1]>[0]) => Promise | InviteResponse), +) => { + return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsInvitesPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsInvitesDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2OrganizationsInvitesDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2OrganizationsMembersListMockHandler = (overrideResponse?: PaginatedMemberListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedMemberListResponseList)) => { - return http.get('*/api/v2/organizations/:uidOrganization/members/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsMembersListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsMembersListMockHandler = ( + overrideResponse?: + | PaginatedMemberListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedMemberListResponseList), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/members/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsMembersListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsMembersRetrieveMockHandler = (overrideResponse?: MemberListResponse | ((info: Parameters[1]>[0]) => Promise | MemberListResponse)) => { - return http.get('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsMembersRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsMembersRetrieveMockHandler = ( + overrideResponse?: + | MemberListResponse + | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsMembersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsMembersPartialUpdateMockHandler = (overrideResponse?: MemberListResponse | ((info: Parameters[1]>[0]) => Promise | MemberListResponse)) => { - return http.patch('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsMembersPartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsMembersPartialUpdateMockHandler = ( + overrideResponse?: + | MemberListResponse + | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), +) => { + return http.patch('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsMembersPartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2OrganizationsMembersDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getApiV2OrganizationsMembersDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getApiV2OrganizationsServiceUsageRetrieveMockHandler = (overrideResponse?: OrganizationServiceUsageResponse | ((info: Parameters[1]>[0]) => Promise | OrganizationServiceUsageResponse)) => { - return http.get('*/api/v2/organizations/:uidOrganization/service_usage/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2OrganizationsServiceUsageRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2OrganizationsServiceUsageRetrieveMockHandler = ( + overrideResponse?: + | OrganizationServiceUsageResponse + | (( + info: Parameters[1]>[0], + ) => Promise | OrganizationServiceUsageResponse), +) => { + return http.get('*/api/v2/organizations/:uidOrganization/service_usage/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2OrganizationsServiceUsageRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectViewsListMockHandler = (overrideResponse?: PaginatedProjectViewListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedProjectViewListResponseList)) => { - return http.get('*/api/v2/project-views/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectViewsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectViewsListMockHandler = ( + overrideResponse?: + | PaginatedProjectViewListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectViewListResponseList), +) => { + return http.get('*/api/v2/project-views/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectViewsRetrieveMockHandler = (overrideResponse?: ProjectViewListResponse | ((info: Parameters[1]>[0]) => Promise | ProjectViewListResponse)) => { - return http.get('*/api/v2/project-views/:uidProjectView/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectViewsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectViewsRetrieveMockHandler = ( + overrideResponse?: + | ProjectViewListResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectViewListResponse), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectViewsExportRetrieveMockHandler = (overrideResponse?: ProjectViewExportResponse | ((info: Parameters[1]>[0]) => Promise | ProjectViewExportResponse)) => { - return http.get('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectViewsExportRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectViewsExportRetrieveMockHandler = ( + overrideResponse?: + | ProjectViewExportResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectViewExportResponse), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsExportRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectViewsExportCreateMockHandler = (overrideResponse?: ProjectViewExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ProjectViewExportCreateResponse)) => { - return http.post('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectViewsExportCreateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectViewsExportCreateMockHandler = ( + overrideResponse?: + | ProjectViewExportCreateResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectViewExportCreateResponse), +) => { + return http.post('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsExportCreateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectViewsAssetsRetrieveMockHandler = (overrideResponse?: PaginatedProjectViewAssetResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedProjectViewAssetResponseList)) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectViewsAssetsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectViewsAssetsRetrieveMockHandler = ( + overrideResponse?: + | PaginatedProjectViewAssetResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectViewAssetResponseList), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsAssetsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectViewsAssetsCountsRetrieveMockHandler = (overrideResponse?: AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount)) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/counts/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectViewsAssetsCountsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectViewsAssetsCountsRetrieveMockHandler = ( + overrideResponse?: + | AssetListCount + | ((info: Parameters[1]>[0]) => Promise | AssetListCount), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/counts/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsAssetsCountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler = (overrideResponse?: PaginatedAssetMinimalListList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetMinimalListList)) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler = ( + overrideResponse?: + | PaginatedAssetMinimalListList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedAssetMinimalListList), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsAssetsMinimalListRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ProjectViewsUsersRetrieveMockHandler = (overrideResponse?: PaginatedProjectViewUserResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedProjectViewUserResponseList)) => { - return http.get('*/api/v2/project-views/:uidProjectView/users/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ProjectViewsUsersRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ProjectViewsUsersRetrieveMockHandler = ( + overrideResponse?: + | PaginatedProjectViewUserResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedProjectViewUserResponseList), +) => { + return http.get('*/api/v2/project-views/:uidProjectView/users/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ProjectViewsUsersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2ServiceUsageListMockHandler = (overrideResponse?: ServiceUsageResponse[] | ((info: Parameters[1]>[0]) => Promise | ServiceUsageResponse[])) => { - return http.get('*/api/v2/service_usage/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2ServiceUsageListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2ServiceUsageListMockHandler = ( + overrideResponse?: + | ServiceUsageResponse[] + | (( + info: Parameters[1]>[0], + ) => Promise | ServiceUsageResponse[]), +) => { + return http.get('*/api/v2/service_usage/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2ServiceUsageListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2UsersListMockHandler = (overrideResponse?: PaginatedUserListResponseList | ((info: Parameters[1]>[0]) => Promise | PaginatedUserListResponseList)) => { - return http.get('*/api/v2/users/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2UsersListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2UsersListMockHandler = ( + overrideResponse?: + | PaginatedUserListResponseList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedUserListResponseList), +) => { + return http.get('*/api/v2/users/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2UsersListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getApiV2UsersRetrieveMockHandler = (overrideResponse?: UserRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | UserRetrieveResponse)) => { - return http.get('*/api/v2/users/:username/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getApiV2UsersRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getApiV2UsersRetrieveMockHandler = ( + overrideResponse?: + | UserRetrieveResponse + | ((info: Parameters[1]>[0]) => Promise | UserRetrieveResponse), +) => { + return http.get('*/api/v2/users/:username/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2UsersRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getMeRetrieveMockHandler = (overrideResponse?: MeListResponse | ((info: Parameters[1]>[0]) => Promise | MeListResponse)) => { - return http.get('*/me/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getMeRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getMeRetrieveMockHandler = ( + overrideResponse?: + | MeListResponse + | ((info: Parameters[1]>[0]) => Promise | MeListResponse), +) => { + return http.get('*/me/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getMePartialUpdateMockHandler = (overrideResponse?: MeListResponse | ((info: Parameters[1]>[0]) => Promise | MeListResponse)) => { - return http.patch('*/me/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getMePartialUpdateResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getMePartialUpdateMockHandler = ( + overrideResponse?: + | MeListResponse + | ((info: Parameters[1]>[0]) => Promise | MeListResponse), +) => { + return http.patch('*/me/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMePartialUpdateResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getMeDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/me/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getMeDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/me/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } -export const getMeEmailsListMockHandler = (overrideResponse?: PaginatedEmailAddressList | ((info: Parameters[1]>[0]) => Promise | PaginatedEmailAddressList)) => { - return http.get('*/me/emails/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getMeEmailsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getMeEmailsListMockHandler = ( + overrideResponse?: + | PaginatedEmailAddressList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedEmailAddressList), +) => { + return http.get('*/me/emails/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeEmailsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getMeEmailsCreateMockHandler = (overrideResponse?: EmailAddress | ((info: Parameters[1]>[0]) => Promise | EmailAddress)) => { - return http.post('*/me/emails/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getMeEmailsCreateResponseMock()), - { status: 201, - headers: { 'Content-Type': 'application/json' } - }) +export const getMeEmailsCreateMockHandler = ( + overrideResponse?: + | EmailAddress + | ((info: Parameters[1]>[0]) => Promise | EmailAddress), +) => { + return http.post('*/me/emails/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeEmailsCreateResponseMock(), + ), + { status: 201, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getMeSocialAccountsListMockHandler = (overrideResponse?: PaginatedSocialAccountList | ((info: Parameters[1]>[0]) => Promise | PaginatedSocialAccountList)) => { - return http.get('*/me/social-accounts/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getMeSocialAccountsListResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getMeSocialAccountsListMockHandler = ( + overrideResponse?: + | PaginatedSocialAccountList + | (( + info: Parameters[1]>[0], + ) => Promise | PaginatedSocialAccountList), +) => { + return http.get('*/me/social-accounts/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeSocialAccountsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getMeSocialAccountsRetrieveMockHandler = (overrideResponse?: SocialAccount | ((info: Parameters[1]>[0]) => Promise | SocialAccount)) => { - return http.get('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => {return new HttpResponse(JSON.stringify(overrideResponse !== undefined - ? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse) - : getMeSocialAccountsRetrieveResponseMock()), - { status: 200, - headers: { 'Content-Type': 'application/json' } - }) +export const getMeSocialAccountsRetrieveMockHandler = ( + overrideResponse?: + | SocialAccount + | ((info: Parameters[1]>[0]) => Promise | SocialAccount), +) => { + return http.get('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getMeSocialAccountsRetrieveResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) }) } -export const getMeSocialAccountsDestroyMockHandler = (overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void)) => { - return http.delete('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => {if (typeof overrideResponse === 'function') {await overrideResponse(info); } - return new HttpResponse(null, - { status: 204, - - }) +export const getMeSocialAccountsDestroyMockHandler = ( + overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), +) => { + return http.delete('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + return new HttpResponse(null, { status: 204 }) }) } export const getUserTeamOrganizationUsageMock = () => [ @@ -636,5 +2283,5 @@ export const getUserTeamOrganizationUsageMock = () => [ getMeEmailsCreateMockHandler(), getMeSocialAccountsListMockHandler(), getMeSocialAccountsRetrieveMockHandler(), - getMeSocialAccountsDestroyMockHandler() + getMeSocialAccountsDestroyMockHandler(), ] diff --git a/orval.config.js b/orval.config.js index 1ad616db73..37fe45a232 100644 --- a/orval.config.js +++ b/orval.config.js @@ -19,7 +19,9 @@ module.exports = { // With mode: 'tags-split', mocks are generated separately from runtime code mock: true, indexFiles: false, - biome: true, + // Disable built-in biome, as it is running before `afterAllFilesWrite` + // scripts - we run it manually after post-processing + biome: false, // baseUrl: 'https://api.example.com', // prepend https://api.example.com to all api calls urlEncodeParameters: true, @@ -50,12 +52,14 @@ module.exports = { // Also fix TypeScript errors in MSW mock factories for types with index signatures. // Make trailing slashes optional in MSW handlers to match both /path and /path/ // Rename files to index.ts/msw.ts pattern for clean imports + // Run Biome last to format and organize imports after all modifications afterAllFilesWrite: [ 'node scripts/orval-rename-to-index.js', 'node scripts/orval-fix-referenced-additional-properties.js', 'node scripts/orval-fix-mock-factory-type-assertions.js', 'node scripts/orval-make-trailing-slash-optional.js', 'node scripts/orval-remove-mock-delays.js', + 'npx biome check --write --unsafe jsapp/js/api/react-query jsapp/js/api/models', ], }, }, From a2aeea9d1359133ae405719497b62a352485edf1 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 18:37:04 +0200 Subject: [PATCH 77/86] fix tests --- jsapp/js/api/react-query/survey-data/msw.ts | 6 ++++-- .../components/submissions/useDataTableBulkActions.tests.ts | 6 +++--- scripts/orval-fix-mock-factory-type-assertions.js | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/jsapp/js/api/react-query/survey-data/msw.ts b/jsapp/js/api/react-query/survey-data/msw.ts index 081c1eb882..5a558c1404 100644 --- a/jsapp/js/api/react-query/survey-data/msw.ts +++ b/jsapp/js/api/react-query/survey-data/msw.ts @@ -1567,11 +1567,13 @@ export const getApiV2AssetsDataValidationStatusPartialUpdateResponseMock = ( export const getApiV2AssetsDataSupplementRetrieveResponseMock = ( overrideResponse: Partial = {}, -): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) +): DataSupplementResponse => + ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) as DataSupplementResponse export const getApiV2AssetsDataSupplementPartialUpdateResponseMock = ( overrideResponse: Partial = {}, -): DataSupplementResponse => ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) +): DataSupplementResponse => + ({ _version: faker.string.alpha({ length: { min: 10, max: 20 } }), ...overrideResponse }) as DataSupplementResponse export const getApiV2AssetsDataBulkPartialUpdateResponseMock = ( overrideResponse: Partial = {}, diff --git a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts index af67bd9a5b..5cb932362f 100644 --- a/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts +++ b/jsapp/js/components/submissions/useDataTableBulkActions.tests.ts @@ -3,10 +3,10 @@ import { ActionIdEnum } from '#/api/models/actionIdEnum' import type { BulkActionResponse } from '#/api/models/bulkActionResponse' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' import { - getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock, getAssetsAdvancedFeaturesBulkActionsListQueryKey, useAssetsAdvancedFeaturesBulkActionsList, -} from '#/api/react-query/survey-data/msw' +} from '#/api/react-query/survey-data' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data/msw' import { useFeatureFlag } from '#/featureFlags' import { useSession } from '#/stores/useSession' import { getBulkActionsPollingIntervalMs, useDataTableBulkActions } from './useDataTableBulkActions' @@ -112,7 +112,7 @@ describe('useDataTableBulkActions', () => { beforeEach(() => { jest.resetAllMocks() getBulkActionsListQueryKeyMock.mockImplementation( - (uidAsset: string, params) => + (uidAsset: string, params?: unknown) => ['api', 'v2', 'assets', uidAsset, 'advanced-features', 'bulk-actions', ...(params ? [params] : [])] as const, ) envStore.data.asr_mt_features_enabled = true diff --git a/scripts/orval-fix-mock-factory-type-assertions.js b/scripts/orval-fix-mock-factory-type-assertions.js index 54392aa819..3aab9be041 100644 --- a/scripts/orval-fix-mock-factory-type-assertions.js +++ b/scripts/orval-fix-mock-factory-type-assertions.js @@ -27,11 +27,11 @@ const REACT_QUERY_DIR = path.join(ROOT, 'jsapp/js/api/react-query') const TYPE_FILES = { 'dataSupplementResponse.ts': { typeName: 'DataSupplementResponse', - factoryFile: 'survey-data.ts', + factoryFile: 'survey-data/msw.ts', }, 'patchedDataSupplementPayload.ts': { typeName: 'PatchedDataSupplementPayload', - factoryFile: 'survey-data.ts', + factoryFile: 'survey-data/msw.ts', }, } From 9e85079460caefdaa8072048f69e6b521863c3ea Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 18:43:21 +0200 Subject: [PATCH 78/86] fix tests (more) --- jsapp/js/assetUtils.tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsapp/js/assetUtils.tests.js b/jsapp/js/assetUtils.tests.js index 3c459d2082..3aa17f9b2f 100644 --- a/jsapp/js/assetUtils.tests.js +++ b/jsapp/js/assetUtils.tests.js @@ -24,7 +24,7 @@ jest.mock('#/api/react-query/user-team-organization-usage', () => ({ })) import { MemberRoleEnum } from '#/api/models/memberRoleEnum' -import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content' +import { getApiV2AssetsRetrieveResponseMock } from '#/api/react-query/manage-projects-and-library-content/msw' import { DeleteBlockerReason, getSurveyFlatPaths, userCanDeleteAssets } from '#/assetUtils' import { surveyWithAllPossibleGroups, surveyWithGroups } from '#/assetUtils.mocks' From d63d251820ea2e4b2c8095fdccf4485f22866b22 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 18:59:07 +0200 Subject: [PATCH 79/86] cr fix --- kpi/schema_extensions/v2/assets/extensions.py | 8 +++++--- kpi/schema_extensions/v2/generic/schema.py | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/kpi/schema_extensions/v2/assets/extensions.py b/kpi/schema_extensions/v2/assets/extensions.py index 4eab9603ce..f70ccde8a7 100644 --- a/kpi/schema_extensions/v2/assets/extensions.py +++ b/kpi/schema_extensions/v2/assets/extensions.py @@ -632,15 +632,17 @@ def map_serializer_field(self, auto_schema, direction): } ) - # Nullable LabelValuePair for optional fields + # Orval-compatible nullable object: type: ['object', 'null'] AND nullable: True nullable_label_value_pair_schema = { **label_value_pair_schema, + 'type': ['object', 'null'], 'nullable': True, } - # Country is an array of LabelValuePair objects, nullable + # Orval-compatible nullable array: type: ['array', 'null'] AND nullable: True nullable_label_value_pair_array_schema = { - **build_array_type(schema=label_value_pair_schema), + 'type': ['array', 'null'], + 'items': label_value_pair_schema, 'nullable': True, } diff --git a/kpi/schema_extensions/v2/generic/schema.py b/kpi/schema_extensions/v2/generic/schema.py index 7640e51ecc..4f1d19b331 100644 --- a/kpi/schema_extensions/v2/generic/schema.py +++ b/kpi/schema_extensions/v2/generic/schema.py @@ -73,7 +73,8 @@ GENERIC_STRING_SCHEMA = build_basic_type(OpenApiTypes.STR) -NULLABLE_STRING_SCHEMA = {**build_basic_type(OpenApiTypes.STR), 'nullable': True} +# Orval requires both type: ['string', 'null'] AND nullable: True +NULLABLE_STRING_SCHEMA = {'type': ['string', 'null'], 'nullable': True} GENERIC_INT_SCHEMA = build_basic_type(OpenApiTypes.INT) @@ -83,8 +84,10 @@ GENERIC_DATETIME_SCHEMA = build_basic_type(OpenApiTypes.DATETIME) +# Orval requires both type: ['array', 'null'] AND nullable: True for nullable arrays NULLABLE_ARRAY_SCHEMA = { - **build_array_type(schema=build_basic_type(OpenApiTypes.STR)), + 'type': ['array', 'null'], + 'items': {'type': 'string'}, 'nullable': True, } From ffe103405e79b0b085f9ecee5b2ddf02c5e17945 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 18:59:50 +0200 Subject: [PATCH 80/86] regenerate orval --- jsapp/js/api/models/asset.ts | 3 +- jsapp/js/api/models/assetAccessTypes.ts | 16 ++ jsapp/js/api/models/assetContent.ts | 6 +- .../js/api/models/assetContentChoicesItem.ts | 3 +- .../assetContentChoicesItemLabelItem.ts | 16 ++ jsapp/js/api/models/assetContentSettings.ts | 3 +- .../assetContentSettingsDefaultLanguage.ts | 16 ++ jsapp/js/api/models/assetContentSurveyItem.ts | 6 +- .../models/assetContentSurveyItemHintItem.ts | 16 ++ .../models/assetContentSurveyItemLabelItem.ts | 16 ++ .../api/models/assetContentTranslations0.ts | 16 ++ .../models/assetContentTranslationsItem.ts | 16 ++ jsapp/js/api/models/assetDeployedVersions.ts | 6 +- .../api/models/assetDeployedVersionsNext.ts | 16 ++ .../models/assetDeployedVersionsPrevious.ts | 16 ++ jsapp/js/api/models/assetSettings.ts | 7 +- .../js/api/models/assetSettingsCollectsPii.ts | 6 +- .../models/assetSettingsCollectsPiiAnyOf.ts | 19 ++ jsapp/js/api/models/assetSettingsCountry.ts | 17 ++ ...em.ts => assetSettingsCountryAnyOfItem.ts} | 2 +- .../models/assetSettingsOperationalPurpose.ts | 6 +- .../assetSettingsOperationalPurposeAnyOf.ts | 19 ++ .../api/models/assetSettingsOrganization.ts | 16 ++ jsapp/js/api/models/assetSettingsSector.ts | 6 +- .../js/api/models/assetSettingsSectorAnyOf.ts | 19 ++ jsapp/js/api/models/assetSummary.ts | 3 +- .../models/assetSummaryDefaultTranslation.ts | 16 ++ .../msw.ts | 252 +++--------------- .../user-team-organization-usage/msw.ts | 36 +-- static/openapi/schema_v2.json | 75 ++++-- static/openapi/schema_v2.yaml | 60 +++-- 31 files changed, 426 insertions(+), 304 deletions(-) create mode 100644 jsapp/js/api/models/assetAccessTypes.ts create mode 100644 jsapp/js/api/models/assetContentChoicesItemLabelItem.ts create mode 100644 jsapp/js/api/models/assetContentSettingsDefaultLanguage.ts create mode 100644 jsapp/js/api/models/assetContentSurveyItemHintItem.ts create mode 100644 jsapp/js/api/models/assetContentSurveyItemLabelItem.ts create mode 100644 jsapp/js/api/models/assetContentTranslations0.ts create mode 100644 jsapp/js/api/models/assetContentTranslationsItem.ts create mode 100644 jsapp/js/api/models/assetDeployedVersionsNext.ts create mode 100644 jsapp/js/api/models/assetDeployedVersionsPrevious.ts create mode 100644 jsapp/js/api/models/assetSettingsCollectsPiiAnyOf.ts create mode 100644 jsapp/js/api/models/assetSettingsCountry.ts rename jsapp/js/api/models/{assetSettingsCountryItem.ts => assetSettingsCountryAnyOfItem.ts} (94%) create mode 100644 jsapp/js/api/models/assetSettingsOperationalPurposeAnyOf.ts create mode 100644 jsapp/js/api/models/assetSettingsOrganization.ts create mode 100644 jsapp/js/api/models/assetSettingsSectorAnyOf.ts create mode 100644 jsapp/js/api/models/assetSummaryDefaultTranslation.ts diff --git a/jsapp/js/api/models/asset.ts b/jsapp/js/api/models/asset.ts index ac63c864ca..4abf6d9b5b 100644 --- a/jsapp/js/api/models/asset.ts +++ b/jsapp/js/api/models/asset.ts @@ -1,3 +1,4 @@ +import type { AssetAccessTypes } from './assetAccessTypes' import type { AssetAdvancedFeatures } from './assetAdvancedFeatures' import type { AssetAnalysisFormJson } from './assetAnalysisFormJson' import type { AssetAssignablePermissionsItem } from './assetAssignablePermissionsItem' @@ -95,7 +96,7 @@ export interface Asset { readonly subscribers_count: number readonly status: string /** @nullable */ - readonly access_types: readonly string[] | null + readonly access_types: AssetAccessTypes data_sharing?: AssetDataSharing readonly paired_data: string /** @nullable */ diff --git a/jsapp/js/api/models/assetAccessTypes.ts b/jsapp/js/api/models/assetAccessTypes.ts new file mode 100644 index 0000000000..34b3823507 --- /dev/null +++ b/jsapp/js/api/models/assetAccessTypes.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetAccessTypes = readonly string[] | null | null | null diff --git a/jsapp/js/api/models/assetContent.ts b/jsapp/js/api/models/assetContent.ts index 38c5ab31a0..f78fb4e2d1 100644 --- a/jsapp/js/api/models/assetContent.ts +++ b/jsapp/js/api/models/assetContent.ts @@ -13,6 +13,8 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ import type { AssetContentSurveyItem } from './assetContentSurveyItem' +import type { AssetContentTranslations0 } from './assetContentTranslations0' +import type { AssetContentTranslationsItem } from './assetContentTranslationsItem' export type AssetContent = { schema?: string @@ -20,8 +22,8 @@ export type AssetContent = { choices?: AssetContentChoicesItem[] settings?: AssetContentSettings translated?: string[] - translations?: (string | null)[] + translations?: AssetContentTranslationsItem[] /** @nullable */ - translations_0?: string | null + translations_0?: AssetContentTranslations0 'kobo--locking-profiles'?: AssetContentKoboLockingProfilesItem[] } diff --git a/jsapp/js/api/models/assetContentChoicesItem.ts b/jsapp/js/api/models/assetContentChoicesItem.ts index 3b4391daed..3130a5a358 100644 --- a/jsapp/js/api/models/assetContentChoicesItem.ts +++ b/jsapp/js/api/models/assetContentChoicesItem.ts @@ -9,11 +9,12 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetContentChoicesItemLabelItem } from './assetContentChoicesItemLabelItem' export type AssetContentChoicesItem = { $autovalue: string $kuid: string - label?: (string | null)[] + label?: AssetContentChoicesItemLabelItem[] list_name: string name: string 'media::image'?: string[] diff --git a/jsapp/js/api/models/assetContentChoicesItemLabelItem.ts b/jsapp/js/api/models/assetContentChoicesItemLabelItem.ts new file mode 100644 index 0000000000..015ac4c6a4 --- /dev/null +++ b/jsapp/js/api/models/assetContentChoicesItemLabelItem.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetContentChoicesItemLabelItem = string | null | null | null diff --git a/jsapp/js/api/models/assetContentSettings.ts b/jsapp/js/api/models/assetContentSettings.ts index e74f82c285..962ee49463 100644 --- a/jsapp/js/api/models/assetContentSettings.ts +++ b/jsapp/js/api/models/assetContentSettings.ts @@ -9,6 +9,7 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetContentSettingsDefaultLanguage } from './assetContentSettingsDefaultLanguage' export type AssetContentSettings = { name?: string @@ -20,5 +21,5 @@ export type AssetContentSettings = { 'kobo--lock_all'?: boolean 'kobo--locking-profile'?: string /** @nullable */ - default_language?: string | null + default_language?: AssetContentSettingsDefaultLanguage } diff --git a/jsapp/js/api/models/assetContentSettingsDefaultLanguage.ts b/jsapp/js/api/models/assetContentSettingsDefaultLanguage.ts new file mode 100644 index 0000000000..20d6ed7d56 --- /dev/null +++ b/jsapp/js/api/models/assetContentSettingsDefaultLanguage.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetContentSettingsDefaultLanguage = string | null | null | null diff --git a/jsapp/js/api/models/assetContentSurveyItem.ts b/jsapp/js/api/models/assetContentSurveyItem.ts index 5088771223..73fc1119a7 100644 --- a/jsapp/js/api/models/assetContentSurveyItem.ts +++ b/jsapp/js/api/models/assetContentSurveyItem.ts @@ -1,3 +1,4 @@ +import type { AssetContentSurveyItemHintItem } from './assetContentSurveyItemHintItem' /** * Generated by orval v7.10.0 🍺 * Do not edit manually. @@ -9,6 +10,7 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetContentSurveyItemLabelItem } from './assetContentSurveyItemLabelItem' export type AssetContentSurveyItem = { $kuid: string @@ -16,8 +18,8 @@ export type AssetContentSurveyItem = { $xpath?: string $autoname?: string calculation?: string - label?: (string | null)[] - hint?: (string | null)[] + label?: AssetContentSurveyItemLabelItem[] + hint?: AssetContentSurveyItemHintItem[] name?: string required?: boolean appearance?: string diff --git a/jsapp/js/api/models/assetContentSurveyItemHintItem.ts b/jsapp/js/api/models/assetContentSurveyItemHintItem.ts new file mode 100644 index 0000000000..8c30359718 --- /dev/null +++ b/jsapp/js/api/models/assetContentSurveyItemHintItem.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetContentSurveyItemHintItem = string | null | null | null diff --git a/jsapp/js/api/models/assetContentSurveyItemLabelItem.ts b/jsapp/js/api/models/assetContentSurveyItemLabelItem.ts new file mode 100644 index 0000000000..dc26779d53 --- /dev/null +++ b/jsapp/js/api/models/assetContentSurveyItemLabelItem.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetContentSurveyItemLabelItem = string | null | null | null diff --git a/jsapp/js/api/models/assetContentTranslations0.ts b/jsapp/js/api/models/assetContentTranslations0.ts new file mode 100644 index 0000000000..028fc28057 --- /dev/null +++ b/jsapp/js/api/models/assetContentTranslations0.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetContentTranslations0 = string | null | null | null diff --git a/jsapp/js/api/models/assetContentTranslationsItem.ts b/jsapp/js/api/models/assetContentTranslationsItem.ts new file mode 100644 index 0000000000..9541097171 --- /dev/null +++ b/jsapp/js/api/models/assetContentTranslationsItem.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetContentTranslationsItem = string | null | null | null diff --git a/jsapp/js/api/models/assetDeployedVersions.ts b/jsapp/js/api/models/assetDeployedVersions.ts index dc04b9e2be..3ce235a854 100644 --- a/jsapp/js/api/models/assetDeployedVersions.ts +++ b/jsapp/js/api/models/assetDeployedVersions.ts @@ -9,13 +9,15 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetDeployedVersionsNext } from './assetDeployedVersionsNext' +import type { AssetDeployedVersionsPrevious } from './assetDeployedVersionsPrevious' import type { AssetDeployedVersionsResultsItem } from './assetDeployedVersionsResultsItem' export type AssetDeployedVersions = { readonly count: number /** @nullable */ - readonly next: string | null + readonly next: AssetDeployedVersionsNext /** @nullable */ - readonly previous: string | null + readonly previous: AssetDeployedVersionsPrevious readonly results: AssetDeployedVersionsResultsItem[] } diff --git a/jsapp/js/api/models/assetDeployedVersionsNext.ts b/jsapp/js/api/models/assetDeployedVersionsNext.ts new file mode 100644 index 0000000000..ff579c1200 --- /dev/null +++ b/jsapp/js/api/models/assetDeployedVersionsNext.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetDeployedVersionsNext = string | null | null | null diff --git a/jsapp/js/api/models/assetDeployedVersionsPrevious.ts b/jsapp/js/api/models/assetDeployedVersionsPrevious.ts new file mode 100644 index 0000000000..a56d174732 --- /dev/null +++ b/jsapp/js/api/models/assetDeployedVersionsPrevious.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetDeployedVersionsPrevious = string | null | null | null diff --git a/jsapp/js/api/models/assetSettings.ts b/jsapp/js/api/models/assetSettings.ts index 7c7068d4c6..51368c40e1 100644 --- a/jsapp/js/api/models/assetSettings.ts +++ b/jsapp/js/api/models/assetSettings.ts @@ -1,6 +1,7 @@ import type { AssetSettingsCollectsPii } from './assetSettingsCollectsPii' -import type { AssetSettingsCountryItem } from './assetSettingsCountryItem' +import type { AssetSettingsCountry } from './assetSettingsCountry' import type { AssetSettingsOperationalPurpose } from './assetSettingsOperationalPurpose' +import type { AssetSettingsOrganization } from './assetSettingsOrganization' /** * Generated by orval v7.10.0 🍺 * Do not edit manually. @@ -18,12 +19,12 @@ export type AssetSettings = { /** @nullable */ sector?: AssetSettingsSector /** @nullable */ - country?: AssetSettingsCountryItem[] | null + country?: AssetSettingsCountry description?: string /** @nullable */ collects_pii?: AssetSettingsCollectsPii /** @nullable */ - organization?: string | null + organization?: AssetSettingsOrganization country_codes?: string[] /** @nullable */ operational_purpose?: AssetSettingsOperationalPurpose diff --git a/jsapp/js/api/models/assetSettingsCollectsPii.ts b/jsapp/js/api/models/assetSettingsCollectsPii.ts index 482aecfb4b..5e712e58f9 100644 --- a/jsapp/js/api/models/assetSettingsCollectsPii.ts +++ b/jsapp/js/api/models/assetSettingsCollectsPii.ts @@ -9,11 +9,9 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetSettingsCollectsPiiAnyOf } from './assetSettingsCollectsPiiAnyOf' /** * @nullable */ -export type AssetSettingsCollectsPii = { - label?: string - value?: string -} | null +export type AssetSettingsCollectsPii = AssetSettingsCollectsPiiAnyOf | null | null diff --git a/jsapp/js/api/models/assetSettingsCollectsPiiAnyOf.ts b/jsapp/js/api/models/assetSettingsCollectsPiiAnyOf.ts new file mode 100644 index 0000000000..3ce713fed6 --- /dev/null +++ b/jsapp/js/api/models/assetSettingsCollectsPiiAnyOf.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetSettingsCollectsPiiAnyOf = { + label?: string + value?: string +} | null diff --git a/jsapp/js/api/models/assetSettingsCountry.ts b/jsapp/js/api/models/assetSettingsCountry.ts new file mode 100644 index 0000000000..4eb8ab5f12 --- /dev/null +++ b/jsapp/js/api/models/assetSettingsCountry.ts @@ -0,0 +1,17 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ +import type { AssetSettingsCountryAnyOfItem } from './assetSettingsCountryAnyOfItem' + +/** + * @nullable + */ +export type AssetSettingsCountry = AssetSettingsCountryAnyOfItem[] | null | null | null diff --git a/jsapp/js/api/models/assetSettingsCountryItem.ts b/jsapp/js/api/models/assetSettingsCountryAnyOfItem.ts similarity index 94% rename from jsapp/js/api/models/assetSettingsCountryItem.ts rename to jsapp/js/api/models/assetSettingsCountryAnyOfItem.ts index 591ef50963..8ef3145fe6 100644 --- a/jsapp/js/api/models/assetSettingsCountryItem.ts +++ b/jsapp/js/api/models/assetSettingsCountryAnyOfItem.ts @@ -10,7 +10,7 @@ The endpoints are grouped by area of intended use. Each category contains relate * OpenAPI spec version: 2.0.0 (api_v2) */ -export type AssetSettingsCountryItem = { +export type AssetSettingsCountryAnyOfItem = { label?: string value?: string } diff --git a/jsapp/js/api/models/assetSettingsOperationalPurpose.ts b/jsapp/js/api/models/assetSettingsOperationalPurpose.ts index 974f538247..20d4652b68 100644 --- a/jsapp/js/api/models/assetSettingsOperationalPurpose.ts +++ b/jsapp/js/api/models/assetSettingsOperationalPurpose.ts @@ -9,11 +9,9 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetSettingsOperationalPurposeAnyOf } from './assetSettingsOperationalPurposeAnyOf' /** * @nullable */ -export type AssetSettingsOperationalPurpose = { - label?: string - value?: string -} | null +export type AssetSettingsOperationalPurpose = AssetSettingsOperationalPurposeAnyOf | null | null diff --git a/jsapp/js/api/models/assetSettingsOperationalPurposeAnyOf.ts b/jsapp/js/api/models/assetSettingsOperationalPurposeAnyOf.ts new file mode 100644 index 0000000000..1c5738ad12 --- /dev/null +++ b/jsapp/js/api/models/assetSettingsOperationalPurposeAnyOf.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetSettingsOperationalPurposeAnyOf = { + label?: string + value?: string +} | null diff --git a/jsapp/js/api/models/assetSettingsOrganization.ts b/jsapp/js/api/models/assetSettingsOrganization.ts new file mode 100644 index 0000000000..61aa994758 --- /dev/null +++ b/jsapp/js/api/models/assetSettingsOrganization.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetSettingsOrganization = string | null | null | null diff --git a/jsapp/js/api/models/assetSettingsSector.ts b/jsapp/js/api/models/assetSettingsSector.ts index 291272e66b..ad55f751f3 100644 --- a/jsapp/js/api/models/assetSettingsSector.ts +++ b/jsapp/js/api/models/assetSettingsSector.ts @@ -9,11 +9,9 @@ The endpoints are grouped by area of intended use. Each category contains relate **General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". * OpenAPI spec version: 2.0.0 (api_v2) */ +import type { AssetSettingsSectorAnyOf } from './assetSettingsSectorAnyOf' /** * @nullable */ -export type AssetSettingsSector = { - label?: string - value?: string -} | null +export type AssetSettingsSector = AssetSettingsSectorAnyOf | null | null diff --git a/jsapp/js/api/models/assetSettingsSectorAnyOf.ts b/jsapp/js/api/models/assetSettingsSectorAnyOf.ts new file mode 100644 index 0000000000..5fd48282ad --- /dev/null +++ b/jsapp/js/api/models/assetSettingsSectorAnyOf.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetSettingsSectorAnyOf = { + label?: string + value?: string +} | null diff --git a/jsapp/js/api/models/assetSummary.ts b/jsapp/js/api/models/assetSummary.ts index 7ce5d8b03d..a14b200ab6 100644 --- a/jsapp/js/api/models/assetSummary.ts +++ b/jsapp/js/api/models/assetSummary.ts @@ -1,3 +1,4 @@ +import type { AssetSummaryDefaultTranslation } from './assetSummaryDefaultTranslation' /** * Generated by orval v7.10.0 🍺 * Do not edit manually. @@ -21,6 +22,6 @@ export type AssetSummary = { readonly row_count?: number readonly name_quality?: AssetSummaryNameQuality /** @nullable */ - readonly default_translation?: string | null + readonly default_translation?: AssetSummaryDefaultTranslation readonly naming_conflicts?: string[] } diff --git a/jsapp/js/api/models/assetSummaryDefaultTranslation.ts b/jsapp/js/api/models/assetSummaryDefaultTranslation.ts new file mode 100644 index 0000000000..944833cc83 --- /dev/null +++ b/jsapp/js/api/models/assetSummaryDefaultTranslation.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v7.10.0 🍺 + * Do not edit manually. + * KoboToolbox Primary API + * This page documents all KoboToolbox API endpoints, except for those implementing the OpenRosa protocol, which are [documented separately](/api/openrosa/docs/). + +The endpoints are grouped by area of intended use. Each category contains related endpoints, with detailed documentation on usage and configuration. Use this as a reference to quickly find the right endpoint for managing projects, forms, data, permissions, integrations, logs, and organizational resources. + +**General note**: All projects (whether deployed or draft), as well as all library content (questions, blocks, templates, and collections) in the user-facing application are represented in the API as "assets". + * OpenAPI spec version: 2.0.0 (api_v2) + */ + +/** + * @nullable + */ +export type AssetSummaryDefaultTranslation = string | null | null | null diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts b/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts index 9027cb565d..c2267c54b4 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts @@ -70,28 +70,10 @@ export const getApiV2AssetsListResponseMock = ( parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), + sector: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), + country: faker.helpers.arrayElement([faker.helpers.arrayElement([[], null]), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + collects_pii: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), organization: faker.helpers.arrayElement([ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, @@ -102,13 +84,7 @@ export const getApiV2AssetsListResponseMock = ( ), undefined, ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + operational_purpose: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), }, undefined, ]), @@ -634,9 +610,7 @@ export const getApiV2AssetsListResponseMock = ( }, subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + access_types: faker.helpers.arrayElement([[], null]), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { @@ -656,28 +630,10 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), + sector: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), + country: faker.helpers.arrayElement([faker.helpers.arrayElement([[], null]), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + collects_pii: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), organization: faker.helpers.arrayElement([ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, @@ -688,13 +644,7 @@ export const getApiV2AssetsCreateResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + access_types: faker.helpers.arrayElement([[], null]), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { @@ -1235,28 +1183,10 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), + sector: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), + country: faker.helpers.arrayElement([faker.helpers.arrayElement([[], null]), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + collects_pii: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), organization: faker.helpers.arrayElement([ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, @@ -1267,13 +1197,7 @@ export const getApiV2AssetsRetrieveResponseMock = (overrideResponse: Partial i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + access_types: faker.helpers.arrayElement([[], null]), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { @@ -1814,28 +1736,10 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), + sector: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), + country: faker.helpers.arrayElement([faker.helpers.arrayElement([[], null]), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + collects_pii: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), organization: faker.helpers.arrayElement([ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, @@ -1846,13 +1750,7 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia ), undefined, ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + operational_purpose: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), }, undefined, ]), @@ -2372,9 +2270,7 @@ export const getApiV2AssetsPartialUpdateResponseMock = (overrideResponse: Partia }, subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + access_types: faker.helpers.arrayElement([[], null]), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { @@ -2417,28 +2313,10 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), + sector: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), + country: faker.helpers.arrayElement([faker.helpers.arrayElement([[], null]), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + collects_pii: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), organization: faker.helpers.arrayElement([ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, @@ -2449,13 +2327,7 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( ), undefined, ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + operational_purpose: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), }, undefined, ]), @@ -2981,9 +2853,7 @@ export const getApiV2AssetsDeploymentRetrieveResponseMock = ( }, subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + access_types: faker.helpers.arrayElement([[], null]), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { @@ -3009,28 +2879,10 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), + sector: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), + country: faker.helpers.arrayElement([faker.helpers.arrayElement([[], null]), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + collects_pii: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), organization: faker.helpers.arrayElement([ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, @@ -3041,13 +2893,7 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( ), undefined, ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + operational_purpose: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), }, undefined, ]), @@ -3573,9 +3419,7 @@ export const getApiV2AssetsDeploymentCreateResponseMock = ( }, subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + access_types: faker.helpers.arrayElement([[], null]), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { @@ -3601,28 +3445,10 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), + sector: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), + country: faker.helpers.arrayElement([faker.helpers.arrayElement([[], null]), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + collects_pii: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), organization: faker.helpers.arrayElement([ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, @@ -3633,13 +3459,7 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( ), undefined, ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + operational_purpose: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), }, undefined, ]), @@ -4165,9 +3985,7 @@ export const getApiV2AssetsDeploymentPartialUpdateResponseMock = ( }, subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + access_types: faker.helpers.arrayElement([[], null]), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { diff --git a/jsapp/js/api/react-query/user-team-organization-usage/msw.ts b/jsapp/js/api/react-query/user-team-organization-usage/msw.ts index 1acb66798f..d0103d1af2 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage/msw.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage/msw.ts @@ -218,28 +218,10 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( parent: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.internet.url(), null]), undefined]), settings: faker.helpers.arrayElement([ { - sector: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), - country: faker.helpers.arrayElement([ - Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - })), - undefined, - ]), + sector: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), + country: faker.helpers.arrayElement([faker.helpers.arrayElement([[], null]), undefined]), description: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - collects_pii: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + collects_pii: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), organization: faker.helpers.arrayElement([ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), undefined, @@ -250,13 +232,7 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( ), undefined, ]), - operational_purpose: faker.helpers.arrayElement([ - { - label: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - value: faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), undefined]), - }, - undefined, - ]), + operational_purpose: faker.helpers.arrayElement([faker.helpers.arrayElement([null]), undefined]), }, undefined, ]), @@ -782,9 +758,7 @@ export const getApiV2OrganizationsAssetsRetrieveResponseMock = ( }, subscribers_count: faker.number.int({ min: undefined, max: undefined, multipleOf: undefined }), status: faker.string.alpha({ length: { min: 10, max: 20 } }), - access_types: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => - faker.string.alpha({ length: { min: 10, max: 20 } }), - ), + access_types: faker.helpers.arrayElement([[], null]), data_sharing: faker.helpers.arrayElement([{}, undefined]), paired_data: faker.internet.url(), project_ownership: { diff --git a/static/openapi/schema_v2.json b/static/openapi/schema_v2.json index bd51e4ea0b..5e171e5445 100644 --- a/static/openapi/schema_v2.json +++ b/static/openapi/schema_v2.json @@ -21155,7 +21155,10 @@ "type": "object", "properties": { "sector": { - "type": "object", + "type": [ + "object", + "null" + ], "properties": { "label": { "type": "string" @@ -21167,7 +21170,10 @@ "nullable": true }, "country": { - "type": "array", + "type": [ + "array", + "null" + ], "items": { "type": "object", "properties": { @@ -21185,7 +21191,10 @@ "type": "string" }, "collects_pii": { - "type": "object", + "type": [ + "object", + "null" + ], "properties": { "label": { "type": "string" @@ -21197,7 +21206,10 @@ "nullable": true }, "organization": { - "type": "string", + "type": [ + "string", + "null" + ], "nullable": true }, "country_codes": { @@ -21207,7 +21219,10 @@ } }, "operational_purpose": { - "type": "object", + "type": [ + "object", + "null" + ], "properties": { "label": { "type": "string" @@ -21352,7 +21367,10 @@ } }, "default_translation": { - "type": "string", + "type": [ + "string", + "null" + ], "nullable": true }, "naming_conflicts": { @@ -21407,11 +21425,17 @@ "type": "integer" }, "next": { - "type": "string", + "type": [ + "string", + "null" + ], "nullable": true }, "previous": { - "type": "string", + "type": [ + "string", + "null" + ], "nullable": true }, "results": { @@ -21745,14 +21769,20 @@ "label": { "type": "array", "items": { - "type": "string", + "type": [ + "string", + "null" + ], "nullable": true } }, "hint": { "type": "array", "items": { - "type": "string", + "type": [ + "string", + "null" + ], "nullable": true } }, @@ -21817,7 +21847,10 @@ "label": { "type": "array", "items": { - "type": "string", + "type": [ + "string", + "null" + ], "nullable": true } }, @@ -21874,7 +21907,10 @@ "type": "string" }, "default_language": { - "type": "string", + "type": [ + "string", + "null" + ], "nullable": true } } @@ -21888,12 +21924,18 @@ "translations": { "type": "array", "items": { - "type": "string", + "type": [ + "string", + "null" + ], "nullable": true } }, "translations_0": { - "type": "string", + "type": [ + "string", + "null" + ], "nullable": true }, "kobo--locking-profiles": { @@ -22224,7 +22266,10 @@ "readOnly": true }, "access_types": { - "type": "array", + "type": [ + "array", + "null" + ], "items": { "type": "string" }, diff --git a/static/openapi/schema_v2.yaml b/static/openapi/schema_v2.yaml index f8b19286e6..feb6a7da67 100644 --- a/static/openapi/schema_v2.yaml +++ b/static/openapi/schema_v2.yaml @@ -15170,7 +15170,9 @@ components: type: object properties: sector: - type: object + type: + - object + - 'null' properties: label: type: string @@ -15178,7 +15180,9 @@ components: type: string nullable: true country: - type: array + type: + - array + - 'null' items: type: object properties: @@ -15190,7 +15194,9 @@ components: description: type: string collects_pii: - type: object + type: + - object + - 'null' properties: label: type: string @@ -15198,14 +15204,18 @@ components: type: string nullable: true organization: - type: string + type: + - string + - 'null' nullable: true country_codes: type: array items: type: string operational_purpose: - type: object + type: + - object + - 'null' properties: label: type: string @@ -15300,7 +15310,9 @@ components: items: type: string default_translation: - type: string + type: + - string + - 'null' nullable: true naming_conflicts: type: array @@ -15341,10 +15353,14 @@ components: count: type: integer next: - type: string + type: + - string + - 'null' nullable: true previous: - type: string + type: + - string + - 'null' nullable: true results: type: array @@ -15573,12 +15589,16 @@ components: label: type: array items: - type: string + type: + - string + - 'null' nullable: true hint: type: array items: - type: string + type: + - string + - 'null' nullable: true name: type: string @@ -15622,7 +15642,9 @@ components: label: type: array items: - type: string + type: + - string + - 'null' nullable: true list_name: type: string @@ -15660,7 +15682,9 @@ components: kobo--locking-profile: type: string default_language: - type: string + type: + - string + - 'null' nullable: true translated: type: array @@ -15669,10 +15693,14 @@ components: translations: type: array items: - type: string + type: + - string + - 'null' nullable: true translations_0: - type: string + type: + - string + - 'null' nullable: true kobo--locking-profiles: type: array @@ -15898,7 +15926,9 @@ components: type: string readOnly: true access_types: - type: array + type: + - array + - 'null' items: type: string nullable: true From 81b479c74b06399a7d7c036cae6827d10abdbce0 Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 19:02:20 +0200 Subject: [PATCH 81/86] fix test --- jsapp/js/components/activity/FormActivity.stories.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsapp/js/components/activity/FormActivity.stories.tsx b/jsapp/js/components/activity/FormActivity.stories.tsx index 65d5865514..2f8cd34684 100644 --- a/jsapp/js/components/activity/FormActivity.stories.tsx +++ b/jsapp/js/components/activity/FormActivity.stories.tsx @@ -18,7 +18,7 @@ const meta: Meta = { parameters: { msw: { handlers: [ - assetHistoryMock, + // More specific handler must come first getApiV2AssetsHistoryActionsRetrieveMockHandler({ actions: [ 'bulk-processing', @@ -32,6 +32,7 @@ const meta: Meta = { 'delete-submission', ], }), + assetHistoryMock, ], }, reactRouter: reactRouterParameters({ From 4b4c9702a2f872ef35f8cbd76a44fcaed9d7a19d Mon Sep 17 00:00:00 2001 From: Leszek Date: Tue, 7 Jul 2026 19:10:04 +0200 Subject: [PATCH 82/86] fix failing storybook test --- jsapp/js/api/react-query/configuration/msw.ts | 2 +- jsapp/js/api/react-query/form-content/msw.ts | 22 ++-- .../react-query/library-collections/msw.ts | 8 +- jsapp/js/api/react-query/logging/msw.ts | 12 +- .../api/react-query/manage-permissions/msw.ts | 14 +-- .../msw.ts | 56 ++++----- jsapp/js/api/react-query/other/msw.ts | 30 ++--- .../react-query/server-logs-superusers/msw.ts | 16 +-- .../survey-data-rest-services/msw.ts | 18 +-- jsapp/js/api/react-query/survey-data/msw.ts | 110 +++++++++--------- .../user-team-organization-usage/msw.ts | 74 ++++++------ scripts/orval-make-trailing-slash-optional.js | 17 ++- 12 files changed, 193 insertions(+), 186 deletions(-) diff --git a/jsapp/js/api/react-query/configuration/msw.ts b/jsapp/js/api/react-query/configuration/msw.ts index 7e57ce7fd7..eddd8a8e82 100644 --- a/jsapp/js/api/react-query/configuration/msw.ts +++ b/jsapp/js/api/react-query/configuration/msw.ts @@ -124,7 +124,7 @@ export const getApiV2EnvironmentRetrieveMockHandler = ( | EnvironmentResponse | ((info: Parameters[1]>[0]) => Promise | EnvironmentResponse), ) => { - return http.get('*/api/v2/environment/', async (info) => { + return http.get('*/api/v2/environment{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/form-content/msw.ts b/jsapp/js/api/react-query/form-content/msw.ts index 63aa1d2bd5..3538558c8c 100644 --- a/jsapp/js/api/react-query/form-content/msw.ts +++ b/jsapp/js/api/react-query/form-content/msw.ts @@ -346,7 +346,7 @@ export const getApiV2AssetSnapshotsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetSnapshotResponseList), ) => { - return http.get('*/api/v2/asset_snapshots/', async (info) => { + return http.get('*/api/v2/asset_snapshots{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -367,7 +367,7 @@ export const getApiV2AssetSnapshotsCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | AssetSnapshotResponse), ) => { - return http.post('*/api/v2/asset_snapshots/', async (info) => { + return http.post('*/api/v2/asset_snapshots{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -386,7 +386,7 @@ export const getApiV2AssetSnapshotsRetrieveMockHandler = ( | AssetSnapshotResponse | ((info: Parameters[1]>[0]) => Promise | AssetSnapshotResponse), ) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -403,7 +403,7 @@ export const getApiV2AssetSnapshotsRetrieveMockHandler = ( export const getApiV2AssetSnapshotsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot/', async (info) => { + return http.delete('*/api/v2/asset_snapshots/:uidAssetSnapshot{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -414,7 +414,7 @@ export const getApiV2AssetSnapshotsDestroyMockHandler = ( export const getApiV2AssetSnapshotsPreviewRetrieveMockHandler = ( overrideResponse?: unknown | ((info: Parameters[1]>[0]) => Promise | unknown), ) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview/', async (info) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/preview{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -427,7 +427,7 @@ export const getApiV2AssetSnapshotsXformRetrieveMockHandler = ( | OpenRosaXFormResponse | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), ) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform/', async (info) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xform{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -446,7 +446,7 @@ export const getApiV2AssetSnapshotsXmlWithDisclaimerRetrieveMockHandler = ( | OpenRosaXFormResponse | ((info: Parameters[1]>[0]) => Promise | OpenRosaXFormResponse), ) => { - return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer/', async (info) => { + return http.get('*/api/v2/asset_snapshots/:uidAssetSnapshot/xml_with_disclaimer{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -465,7 +465,7 @@ export const getApiV2AssetsContentRetrieveMockHandler = ( | ContentResponse | ((info: Parameters[1]>[0]) => Promise | ContentResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/content/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/content{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -482,7 +482,7 @@ export const getApiV2AssetsContentRetrieveMockHandler = ( export const getApiV2AssetsTableViewRetrieveMockHandler = ( overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), ) => { - return http.get('*/api/v2/assets/:uidAsset/table_view/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/table_view{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -503,7 +503,7 @@ export const getApiV2AssetsValidContentRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | AssetValidContentResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/valid_content/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/valid_content{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -520,7 +520,7 @@ export const getApiV2AssetsValidContentRetrieveMockHandler = ( export const getApiV2AssetsXlsRetrieveMockHandler = ( overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), ) => { - return http.get('*/api/v2/assets/:uidAsset/xls/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/xls{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/library-collections/msw.ts b/jsapp/js/api/react-query/library-collections/msw.ts index bc0298c49d..f359d37a94 100644 --- a/jsapp/js/api/react-query/library-collections/msw.ts +++ b/jsapp/js/api/react-query/library-collections/msw.ts @@ -56,7 +56,7 @@ export const getApiV2AssetSubscriptionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetSubscriptionResponseList), ) => { - return http.get('*/api/v2/asset_subscriptions/', async (info) => { + return http.get('*/api/v2/asset_subscriptions{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -77,7 +77,7 @@ export const getApiV2AssetSubscriptionsCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | AssetSubscriptionResponse), ) => { - return http.post('*/api/v2/asset_subscriptions/', async (info) => { + return http.post('*/api/v2/asset_subscriptions{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -98,7 +98,7 @@ export const getApiV2AssetSubscriptionsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | AssetSubscriptionResponse), ) => { - return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { + return http.get('*/api/v2/asset_subscriptions/:uidAssetSubscription{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -115,7 +115,7 @@ export const getApiV2AssetSubscriptionsRetrieveMockHandler = ( export const getApiV2AssetSubscriptionsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription/', async (info) => { + return http.delete('*/api/v2/asset_subscriptions/:uidAssetSubscription{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } diff --git a/jsapp/js/api/react-query/logging/msw.ts b/jsapp/js/api/react-query/logging/msw.ts index 185e434334..25a30748e7 100644 --- a/jsapp/js/api/react-query/logging/msw.ts +++ b/jsapp/js/api/react-query/logging/msw.ts @@ -285,7 +285,7 @@ export const getApiV2AccessLogsMeListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAccessLogResponseList), ) => { - return http.get('*/api/v2/access-logs/me/', async (info) => { + return http.get('*/api/v2/access-logs/me{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -304,7 +304,7 @@ export const getApiV2AccessLogsMeExportListMockHandler = ( | ExportListResponse[] | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), ) => { - return http.get('*/api/v2/access-logs/me/export/', async (info) => { + return http.get('*/api/v2/access-logs/me/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -323,7 +323,7 @@ export const getApiV2AccessLogsMeExportCreateMockHandler = ( | ExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), ) => { - return http.post('*/api/v2/access-logs/me/export/', async (info) => { + return http.post('*/api/v2/access-logs/me/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -344,7 +344,7 @@ export const getApiV2AssetsHistoryListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedHistoryListResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/history/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/history{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -363,7 +363,7 @@ export const getApiV2AssetsHistoryActionsRetrieveMockHandler = ( | HistoryActionResponse | ((info: Parameters[1]>[0]) => Promise | HistoryActionResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/history/actions/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/history/actions{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -384,7 +384,7 @@ export const getApiV2AssetsHistoryExportCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | HistoryExportResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/history/export/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/history/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/manage-permissions/msw.ts b/jsapp/js/api/react-query/manage-permissions/msw.ts index f42da318e1..938e4e54ff 100644 --- a/jsapp/js/api/react-query/manage-permissions/msw.ts +++ b/jsapp/js/api/react-query/manage-permissions/msw.ts @@ -66,7 +66,7 @@ export const getApiV2AssetsPermissionAssignmentsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PermissionAssignmentResponse[]), ) => { - return http.get('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/permission-assignments{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -87,7 +87,7 @@ export const getApiV2AssetsPermissionAssignmentsCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | PermissionAssignmentResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/permission-assignments/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/permission-assignments{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -108,7 +108,7 @@ export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PermissionAssignmentResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -125,7 +125,7 @@ export const getApiV2AssetsPermissionAssignmentsRetrieveMockHandler = ( export const getApiV2AssetsPermissionAssignmentsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/:uidPermissionAssignment{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -140,7 +140,7 @@ export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | PermissionAssignmentResponse[]), ) => { - return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/permission-assignments/bulk{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -157,7 +157,7 @@ export const getApiV2AssetsPermissionAssignmentsBulkCreateMockHandler = ( export const getApiV2AssetsPermissionAssignmentsBulkDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/permission-assignments/bulk{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -172,7 +172,7 @@ export const getApiV2AssetsPermissionAssignmentsClonePartialUpdateMockHandler = info: Parameters[1]>[0], ) => Promise | PermissionAssignmentResponse[]), ) => { - return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/permission-assignments/clone{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts b/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts index c2267c54b4..871125f013 100644 --- a/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts +++ b/jsapp/js/api/react-query/manage-projects-and-library-content/msw.ts @@ -4454,7 +4454,7 @@ export const getApiV2AssetsListMockHandler = ( | PaginatedAssetList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), ) => { - return http.get('*/api/v2/assets/', async (info) => { + return http.get('*/api/v2/assets{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4471,7 +4471,7 @@ export const getApiV2AssetsListMockHandler = ( export const getApiV2AssetsCreateMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { - return http.post('*/api/v2/assets/', async (info) => { + return http.post('*/api/v2/assets{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4488,7 +4488,7 @@ export const getApiV2AssetsCreateMockHandler = ( export const getApiV2AssetsRetrieveMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { - return http.get('*/api/v2/assets/:uidAsset/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4505,7 +4505,7 @@ export const getApiV2AssetsRetrieveMockHandler = ( export const getApiV2AssetsPartialUpdateMockHandler = ( overrideResponse?: Asset | ((info: Parameters[1]>[0]) => Promise | Asset), ) => { - return http.patch('*/api/v2/assets/:uidAsset/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4522,7 +4522,7 @@ export const getApiV2AssetsPartialUpdateMockHandler = ( export const getApiV2AssetsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -4537,7 +4537,7 @@ export const getApiV2AssetsCountsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetCountResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/counts/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/counts{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4556,7 +4556,7 @@ export const getApiV2AssetsDeploymentRetrieveMockHandler = ( | DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/deployment/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4575,7 +4575,7 @@ export const getApiV2AssetsDeploymentCreateMockHandler = ( | DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/deployment/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4594,7 +4594,7 @@ export const getApiV2AssetsDeploymentPartialUpdateMockHandler = ( | DeploymentResponse | ((info: Parameters[1]>[0]) => Promise | DeploymentResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/deployment/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/deployment{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4615,7 +4615,7 @@ export const getApiV2AssetsVersionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedVersionListResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/versions/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/versions{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4636,7 +4636,7 @@ export const getApiV2AssetsVersionsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | VersionRetrieveResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/versions/:uidVersion{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4653,7 +4653,7 @@ export const getApiV2AssetsVersionsRetrieveMockHandler = ( export const getApiV2AssetsXformRetrieveMockHandler = ( overrideResponse?: string | ((info: Parameters[1]>[0]) => Promise | string), ) => { - return http.get('*/api/v2/assets/:uidAsset/xform/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/xform{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4672,7 +4672,7 @@ export const getApiV2AssetsBulkCreateMockHandler = ( | AssetBulkResponse | ((info: Parameters[1]>[0]) => Promise | AssetBulkResponse), ) => { - return http.post('*/api/v2/assets/bulk/', async (info) => { + return http.post('*/api/v2/assets/bulk{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4691,7 +4691,7 @@ export const getApiV2AssetsCountsRetrieveMockHandler = ( | AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount), ) => { - return http.get('*/api/v2/assets/counts/', async (info) => { + return http.get('*/api/v2/assets/counts{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4710,7 +4710,7 @@ export const getApiV2AssetsHashRetrieveMockHandler = ( | HashResponse | ((info: Parameters[1]>[0]) => Promise | HashResponse), ) => { - return http.get('*/api/v2/assets/hash/', async (info) => { + return http.get('*/api/v2/assets/hash{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4729,7 +4729,7 @@ export const getApiV2AssetsMetadataRetrieveMockHandler = ( | AssetMetadataResponse | ((info: Parameters[1]>[0]) => Promise | AssetMetadataResponse), ) => { - return http.get('*/api/v2/assets/metadata/', async (info) => { + return http.get('*/api/v2/assets/metadata{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4750,7 +4750,7 @@ export const getApiV2AssetsMinimalListRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetMinimalListList), ) => { - return http.get('*/api/v2/assets/minimal-list/', async (info) => { + return http.get('*/api/v2/assets/minimal-list{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4771,7 +4771,7 @@ export const getApiV2ImportsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedImportResponseList), ) => { - return http.get('*/api/v2/imports/', async (info) => { + return http.get('*/api/v2/imports{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4790,7 +4790,7 @@ export const getApiV2ImportsCreateMockHandler = ( | ImportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ImportCreateResponse), ) => { - return http.post('*/api/v2/imports/', async (info) => { + return http.post('*/api/v2/imports{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4809,7 +4809,7 @@ export const getApiV2ImportsRetrieveMockHandler = ( | ImportResponse | ((info: Parameters[1]>[0]) => Promise | ImportResponse), ) => { - return http.get('*/api/v2/imports/:uidImport/', async (info) => { + return http.get('*/api/v2/imports/:uidImport{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4830,7 +4830,7 @@ export const getApiV2ProjectOwnershipInvitesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectInviteResponseList), ) => { - return http.get('*/api/v2/project-ownership/invites/', async (info) => { + return http.get('*/api/v2/project-ownership/invites{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4851,7 +4851,7 @@ export const getApiV2ProjectOwnershipInvitesCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectInviteResponse), ) => { - return http.post('*/api/v2/project-ownership/invites/', async (info) => { + return http.post('*/api/v2/project-ownership/invites{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4870,7 +4870,7 @@ export const getApiV2ProjectOwnershipInvitesRetrieveMockHandler = ( | ProjectInviteResponse | ((info: Parameters[1]>[0]) => Promise | ProjectInviteResponse), ) => { - return http.get('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { + return http.get('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4891,7 +4891,7 @@ export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectInviteResponse), ) => { - return http.patch('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { + return http.patch('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4908,7 +4908,7 @@ export const getApiV2ProjectOwnershipInvitesPartialUpdateMockHandler = ( export const getApiV2ProjectOwnershipInvitesDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/project-ownership/invites/:uidInvite/', async (info) => { + return http.delete('*/api/v2/project-ownership/invites/:uidInvite{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -4921,7 +4921,7 @@ export const getApiV2ProjectOwnershipInvitesTransfersRetrieveMockHandler = ( | TransferListResponse | ((info: Parameters[1]>[0]) => Promise | TransferListResponse), ) => { - return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer/', async (info) => { + return http.get('*/api/v2/project-ownership/invites/:uidInvite/transfers/:uidTransfer{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4942,7 +4942,7 @@ export const getApiV2TagsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedTagListResponseList), ) => { - return http.get('*/api/v2/tags/', async (info) => { + return http.get('*/api/v2/tags{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -4961,7 +4961,7 @@ export const getApiV2TagsRetrieveMockHandler = ( | TagRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | TagRetrieveResponse), ) => { - return http.get('*/api/v2/tags/:taguidUid/', async (info) => { + return http.get('*/api/v2/tags/:taguidUid{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/other/msw.ts b/jsapp/js/api/react-query/other/msw.ts index 073484048d..de2cdd0fcc 100644 --- a/jsapp/js/api/react-query/other/msw.ts +++ b/jsapp/js/api/react-query/other/msw.ts @@ -679,7 +679,7 @@ export const getApiV2LanguagesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedLanguageListList), ) => { - return http.get('*/api/v2/languages/', async (info) => { + return http.get('*/api/v2/languages{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -696,7 +696,7 @@ export const getApiV2LanguagesListMockHandler = ( export const getApiV2LanguagesRetrieveMockHandler = ( overrideResponse?: Language | ((info: Parameters[1]>[0]) => Promise | Language), ) => { - return http.get('*/api/v2/languages/:code/', async (info) => { + return http.get('*/api/v2/languages/:code{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -717,7 +717,7 @@ export const getApiV2PermissionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedPermissionResponseList), ) => { - return http.get('*/api/v2/permissions/', async (info) => { + return http.get('*/api/v2/permissions{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -736,7 +736,7 @@ export const getApiV2PermissionsRetrieveMockHandler = ( | PermissionResponse | ((info: Parameters[1]>[0]) => Promise | PermissionResponse), ) => { - return http.get('*/api/v2/permissions/:codename/', async (info) => { + return http.get('*/api/v2/permissions/:codename{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -757,7 +757,7 @@ export const getApiV2StripeAddonsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedOneTimeAddOnList), ) => { - return http.get('*/api/v2/stripe/addons/', async (info) => { + return http.get('*/api/v2/stripe/addons{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -776,7 +776,7 @@ export const getApiV2StripeAddonsRetrieveMockHandler = ( | OneTimeAddOn | ((info: Parameters[1]>[0]) => Promise | OneTimeAddOn), ) => { - return http.get('*/api/v2/stripe/addons/:id/', async (info) => { + return http.get('*/api/v2/stripe/addons/:id{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -854,7 +854,7 @@ export const getApiV2StripeProductsListMockHandler = ( | PaginatedProductList | ((info: Parameters[1]>[0]) => Promise | PaginatedProductList), ) => { - return http.get('*/api/v2/stripe/products/', async (info) => { + return http.get('*/api/v2/stripe/products{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -875,7 +875,7 @@ export const getApiV2StripeSubscriptionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedSubscriptionList), ) => { - return http.get('*/api/v2/stripe/subscriptions/', async (info) => { + return http.get('*/api/v2/stripe/subscriptions{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -894,7 +894,7 @@ export const getApiV2StripeSubscriptionsRetrieveMockHandler = ( | Subscription | ((info: Parameters[1]>[0]) => Promise | Subscription), ) => { - return http.get('*/api/v2/stripe/subscriptions/:id/', async (info) => { + return http.get('*/api/v2/stripe/subscriptions/:id{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -915,7 +915,7 @@ export const getApiV2TermsOfServiceListMockHandler = ( info: Parameters[1]>[0], ) => Promise | TermsOfServiceResponse[]), ) => { - return http.get('*/api/v2/terms-of-service/', async (info) => { + return http.get('*/api/v2/terms-of-service{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -936,7 +936,7 @@ export const getApiV2TermsOfServiceRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | TermsOfServiceResponse), ) => { - return http.get('*/api/v2/terms-of-service/:slug/', async (info) => { + return http.get('*/api/v2/terms-of-service/:slug{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -957,7 +957,7 @@ export const getApiV2TranscriptionServicesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedTranscriptionServiceList), ) => { - return http.get('*/api/v2/transcription-services/', async (info) => { + return http.get('*/api/v2/transcription-services{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -976,7 +976,7 @@ export const getApiV2TranscriptionServicesRetrieveMockHandler = ( | TranscriptionService | ((info: Parameters[1]>[0]) => Promise | TranscriptionService), ) => { - return http.get('*/api/v2/transcription-services/:code/', async (info) => { + return http.get('*/api/v2/transcription-services/:code{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -997,7 +997,7 @@ export const getApiV2TranslationServicesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedTranslationServiceList), ) => { - return http.get('*/api/v2/translation-services/', async (info) => { + return http.get('*/api/v2/translation-services{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1016,7 +1016,7 @@ export const getApiV2TranslationServicesRetrieveMockHandler = ( | TranslationService | ((info: Parameters[1]>[0]) => Promise | TranslationService), ) => { - return http.get('*/api/v2/translation-services/:code/', async (info) => { + return http.get('*/api/v2/translation-services/:code{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/server-logs-superusers/msw.ts b/jsapp/js/api/react-query/server-logs-superusers/msw.ts index 4b094c7f3a..ad1322e8d1 100644 --- a/jsapp/js/api/react-query/server-logs-superusers/msw.ts +++ b/jsapp/js/api/react-query/server-logs-superusers/msw.ts @@ -896,7 +896,7 @@ export const getApiV2AccessLogsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedSuperUserAccessLogResponseList), ) => { - return http.get('*/api/v2/access-logs/', async (info) => { + return http.get('*/api/v2/access-logs{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -915,7 +915,7 @@ export const getApiV2AccessLogsExportListMockHandler = ( | ExportListResponse[] | ((info: Parameters[1]>[0]) => Promise | ExportListResponse[]), ) => { - return http.get('*/api/v2/access-logs/export/', async (info) => { + return http.get('*/api/v2/access-logs/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -934,7 +934,7 @@ export const getApiV2AccessLogsExportCreateMockHandler = ( | ExportCreateResponse | ((info: Parameters[1]>[0]) => Promise | ExportCreateResponse), ) => { - return http.post('*/api/v2/access-logs/export/', async (info) => { + return http.post('*/api/v2/access-logs/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -955,7 +955,7 @@ export const getApiV2AuditLogsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAuditLogResponseList), ) => { - return http.get('*/api/v2/audit-logs/', async (info) => { + return http.get('*/api/v2/audit-logs{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -976,7 +976,7 @@ export const getApiV2ProjectHistoryLogsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectHistoryLogResponseList), ) => { - return http.get('*/api/v2/project-history-logs/', async (info) => { + return http.get('*/api/v2/project-history-logs{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -995,7 +995,7 @@ export const getApiV2ProjectHistoryLogsExportRetrieveMockHandler = ( | ExportHistoryResponse | ((info: Parameters[1]>[0]) => Promise | ExportHistoryResponse), ) => { - return http.get('*/api/v2/project-history-logs/export/', async (info) => { + return http.get('*/api/v2/project-history-logs/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1016,7 +1016,7 @@ export const getApiV2ProjectHistoryLogsExportCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ExportHistoryResponse), ) => { - return http.post('*/api/v2/project-history-logs/export/', async (info) => { + return http.post('*/api/v2/project-history-logs/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1037,7 +1037,7 @@ export const getApiV2UserReportsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedUserReportsListResponseList), ) => { - return http.get('*/api/v2/user-reports/', async (info) => { + return http.get('*/api/v2/user-reports{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/survey-data-rest-services/msw.ts b/jsapp/js/api/react-query/survey-data-rest-services/msw.ts index 3de9d07081..d8af3bbb76 100644 --- a/jsapp/js/api/react-query/survey-data-rest-services/msw.ts +++ b/jsapp/js/api/react-query/survey-data-rest-services/msw.ts @@ -271,7 +271,7 @@ export const getApiV2AssetsHooksListMockHandler = ( | PaginatedHookList | ((info: Parameters[1]>[0]) => Promise | PaginatedHookList), ) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/hooks{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -288,7 +288,7 @@ export const getApiV2AssetsHooksListMockHandler = ( export const getApiV2AssetsHooksCreateMockHandler = ( overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), ) => { - return http.post('*/api/v2/assets/:uidAsset/hooks/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/hooks{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -305,7 +305,7 @@ export const getApiV2AssetsHooksCreateMockHandler = ( export const getApiV2AssetsHooksRetrieveMockHandler = ( overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), ) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -322,7 +322,7 @@ export const getApiV2AssetsHooksRetrieveMockHandler = ( export const getApiV2AssetsHooksPartialUpdateMockHandler = ( overrideResponse?: Hook | ((info: Parameters[1]>[0]) => Promise | Hook), ) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -339,7 +339,7 @@ export const getApiV2AssetsHooksPartialUpdateMockHandler = ( export const getApiV2AssetsHooksDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/hooks/:uidHook{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -352,7 +352,7 @@ export const getApiV2AssetsHooksLogsListMockHandler = ( | PaginatedHookLogList | ((info: Parameters[1]>[0]) => Promise | PaginatedHookLogList), ) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -369,7 +369,7 @@ export const getApiV2AssetsHooksLogsListMockHandler = ( export const getApiV2AssetsHooksLogsRetrieveMockHandler = ( overrideResponse?: HookLog | ((info: Parameters[1]>[0]) => Promise | HookLog), ) => { - return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -388,7 +388,7 @@ export const getApiV2AssetsHooksLogsRetryPartialUpdateMockHandler = ( | LogsRetryResponse | ((info: Parameters[1]>[0]) => Promise | LogsRetryResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/logs/:uidLog/retry{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -407,7 +407,7 @@ export const getApiV2AssetsHooksRetryPartialUpdateMockHandler = ( | HookRetryResponse | ((info: Parameters[1]>[0]) => Promise | HookRetryResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/hooks/:uidHook/retry{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/survey-data/msw.ts b/jsapp/js/api/react-query/survey-data/msw.ts index 5a558c1404..408f279f27 100644 --- a/jsapp/js/api/react-query/survey-data/msw.ts +++ b/jsapp/js/api/react-query/survey-data/msw.ts @@ -2008,7 +2008,7 @@ export const getApiV2AssetsAdvancedFeaturesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | AdvancedFeatureResponse[]), ) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2029,7 +2029,7 @@ export const getApiV2AssetsAdvancedFeaturesCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | AdvancedFeatureCreateResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/advanced-features/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/advanced-features{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2050,7 +2050,7 @@ export const getApiV2AssetsAdvancedFeaturesRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | AdvancedFeatureResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2071,7 +2071,7 @@ export const getApiV2AssetsAdvancedFeaturesPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | AdvancedFeatureResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/:uidAdvancedFeature{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2092,7 +2092,7 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | BulkActionListResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2113,7 +2113,7 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | BulkActionCreateResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2132,7 +2132,7 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveMockHandler = ( | BulkActionResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2151,7 +2151,7 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = | BulkActionResponse | ((info: Parameters[1]>[0]) => Promise | BulkActionResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/advanced-features/bulk-actions/:actionUid{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2168,7 +2168,7 @@ export const getApiV2AssetsAdvancedFeaturesBulkActionsPartialUpdateMockHandler = export const getApiV2AssetsAttachmentsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/attachments/:id/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/attachments/:id{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2183,7 +2183,7 @@ export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | AssetAttachmentAudioDurationResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/attachments/audio-duration{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2200,7 +2200,7 @@ export const getApiV2AssetsAttachmentsAudioDurationCreateMockHandler = ( export const getApiV2AssetsAttachmentsBulkDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/attachments/bulk{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2215,7 +2215,7 @@ export const getApiV2AssetsDataListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedDataResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2234,7 +2234,7 @@ export const getApiV2AssetsDataRetrieveMockHandler = ( | DataResponse | ((info: Parameters[1]>[0]) => Promise | DataResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2251,7 +2251,7 @@ export const getApiV2AssetsDataRetrieveMockHandler = ( export const getApiV2AssetsDataDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/data/:id/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/data/:id{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2264,7 +2264,7 @@ export const getApiV2AssetsDataDuplicateCreateMockHandler = ( | DataResponse | ((info: Parameters[1]>[0]) => Promise | DataResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/data/:id/duplicate{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2283,7 +2283,7 @@ export const getApiV2AssetsDataEditRetrieveMockHandler = ( | EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/edit/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/edit{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2302,7 +2302,7 @@ export const getApiV2AssetsDataEnketoEditRetrieveMockHandler = ( | EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/edit{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2321,7 +2321,7 @@ export const getApiV2AssetsDataEnketoRedirectEditRetrieveMockHandler = ( | EnketoEditResponse | ((info: Parameters[1]>[0]) => Promise | EnketoEditResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/edit{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2340,7 +2340,7 @@ export const getApiV2AssetsDataEnketoRedirectViewRetrieveMockHandler = ( | EnketoViewResponse | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/redirect/view{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2359,7 +2359,7 @@ export const getApiV2AssetsDataEnketoViewRetrieveMockHandler = ( | EnketoViewResponse | ((info: Parameters[1]>[0]) => Promise | EnketoViewResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/enketo/view{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2380,7 +2380,7 @@ export const getApiV2AssetsDataValidationStatusRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | DataValidationStatusUpdateResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2401,7 +2401,7 @@ export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | DataValidationStatusUpdateResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2418,7 +2418,7 @@ export const getApiV2AssetsDataValidationStatusPartialUpdateMockHandler = ( export const getApiV2AssetsDataValidationStatusDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/data/:id/validation_status{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2433,7 +2433,7 @@ export const getApiV2AssetsDataSupplementRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | DataSupplementResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2454,7 +2454,7 @@ export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | DataSupplementResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/data/:rootUuid/supplement{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2471,7 +2471,7 @@ export const getApiV2AssetsDataSupplementPartialUpdateMockHandler = ( export const getApiV2AssetsDataAttachmentsListMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2482,7 +2482,7 @@ export const getApiV2AssetsDataAttachmentsListMockHandler = ( export const getAttachmentRetrieveMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2493,7 +2493,7 @@ export const getAttachmentRetrieveMockHandler = ( export const getAttachmentThumbnailMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/data/:uidData/attachments/:id/:suffix{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2508,7 +2508,7 @@ export const getApiV2AssetsDataBulkPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | DataBulkUpdateResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/data/bulk{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2525,7 +2525,7 @@ export const getApiV2AssetsDataBulkPartialUpdateMockHandler = ( export const getApiV2AssetsDataBulkDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/data/bulk/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/data/bulk{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2538,7 +2538,7 @@ export const getApiV2AssetsDataSupplementsBulkCreateMockHandler = ( | BulkAcceptResponse | ((info: Parameters[1]>[0]) => Promise | BulkAcceptResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/data/supplements/bulk{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2557,7 +2557,7 @@ export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = ( | DataStatusesUpdate | ((info: Parameters[1]>[0]) => Promise | DataStatusesUpdate), ) => { - return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/data/validation_statuses{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2574,7 +2574,7 @@ export const getApiV2AssetsDataValidationStatusesPartialUpdateMockHandler = ( export const getApiV2AssetsDataValidationStatusesDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/data/validation_statuses{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2589,7 +2589,7 @@ export const getApiV2AssetsExportSettingsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedExportSettingResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2610,7 +2610,7 @@ export const getApiV2AssetsExportSettingsCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ExportSettingResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/export-settings/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/export-settings{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2629,7 +2629,7 @@ export const getApiV2AssetsExportSettingsRetrieveMockHandler = ( | ExportSettingResponse | ((info: Parameters[1]>[0]) => Promise | ExportSettingResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2650,7 +2650,7 @@ export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ExportSettingResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2667,7 +2667,7 @@ export const getApiV2AssetsExportSettingsPartialUpdateMockHandler = ( export const getApiV2AssetsExportSettingsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2678,7 +2678,7 @@ export const getApiV2AssetsExportSettingsDestroyMockHandler = ( export const getApiV2AssetsExportSettingsDataRetrieveMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/export-settings/:uidExportSetting/data{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2693,7 +2693,7 @@ export const getApiV2AssetsExportsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedExportResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/exports/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/exports{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2712,7 +2712,7 @@ export const getApiV2AssetsExportsCreateMockHandler = ( | ExportResponse | ((info: Parameters[1]>[0]) => Promise | ExportResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/exports/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/exports{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2731,7 +2731,7 @@ export const getApiV2AssetsExportsRetrieveMockHandler = ( | ExportResponse | ((info: Parameters[1]>[0]) => Promise | ExportResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/exports/:uidExport{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2748,7 +2748,7 @@ export const getApiV2AssetsExportsRetrieveMockHandler = ( export const getApiV2AssetsExportsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/exports/:uidExport{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2763,7 +2763,7 @@ export const getApiV2AssetsFilesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedFilesResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/files/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/files{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2782,7 +2782,7 @@ export const getApiV2AssetsFilesCreateMockHandler = ( | FilesResponse | ((info: Parameters[1]>[0]) => Promise | FilesResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/files/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/files{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2801,7 +2801,7 @@ export const getApiV2AssetsFilesRetrieveMockHandler = ( | FilesResponse | ((info: Parameters[1]>[0]) => Promise | FilesResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2818,7 +2818,7 @@ export const getApiV2AssetsFilesRetrieveMockHandler = ( export const getApiV2AssetsFilesDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/files/:uidFile{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2829,7 +2829,7 @@ export const getApiV2AssetsFilesDestroyMockHandler = ( export const getApiV2AssetsFilesContentRetrieveMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/files/:uidFile/content{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2844,7 +2844,7 @@ export const getApiV2AssetsPairedDataListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedPairedDataResponseList), ) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2863,7 +2863,7 @@ export const getApiV2AssetsPairedDataCreateMockHandler = ( | PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), ) => { - return http.post('*/api/v2/assets/:uidAsset/paired-data/', async (info) => { + return http.post('*/api/v2/assets/:uidAsset/paired-data{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2882,7 +2882,7 @@ export const getApiV2AssetsPairedDataRetrieveMockHandler = ( | PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2901,7 +2901,7 @@ export const getApiV2AssetsPairedDataPartialUpdateMockHandler = ( | PairedDataResponse | ((info: Parameters[1]>[0]) => Promise | PairedDataResponse), ) => { - return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + return http.patch('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2918,7 +2918,7 @@ export const getApiV2AssetsPairedDataPartialUpdateMockHandler = ( export const getApiV2AssetsPairedDataDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/', async (info) => { + return http.delete('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2931,7 +2931,7 @@ export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = ( | ExternalResponse | ((info: Parameters[1]>[0]) => Promise | ExternalResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/paired-data/:uidPairedData/external{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2950,7 +2950,7 @@ export const getApiV2AssetsReportsRetrieveMockHandler = ( | ReportResponse | ((info: Parameters[1]>[0]) => Promise | ReportResponse), ) => { - return http.get('*/api/v2/assets/:uidAsset/reports/', async (info) => { + return http.get('*/api/v2/assets/:uidAsset/reports{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined diff --git a/jsapp/js/api/react-query/user-team-organization-usage/msw.ts b/jsapp/js/api/react-query/user-team-organization-usage/msw.ts index d0103d1af2..b5cb7c222a 100644 --- a/jsapp/js/api/react-query/user-team-organization-usage/msw.ts +++ b/jsapp/js/api/react-query/user-team-organization-usage/msw.ts @@ -1521,7 +1521,7 @@ export const getApiV2AssetUsageListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetUsageResponseList), ) => { - return http.get('*/api/v2/asset_usage/', async (info) => { + return http.get('*/api/v2/asset_usage{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1542,7 +1542,7 @@ export const getApiV2OrganizationsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedOrganizationResponseList), ) => { - return http.get('*/api/v2/organizations/', async (info) => { + return http.get('*/api/v2/organizations{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1561,7 +1561,7 @@ export const getApiV2OrganizationsRetrieveMockHandler = ( | OrganizationResponse | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/', async (info) => { + return http.get('*/api/v2/organizations/:uidOrganization{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1580,7 +1580,7 @@ export const getApiV2OrganizationsPartialUpdateMockHandler = ( | OrganizationResponse | ((info: Parameters[1]>[0]) => Promise | OrganizationResponse), ) => { - return http.patch('*/api/v2/organizations/:uidOrganization/', async (info) => { + return http.patch('*/api/v2/organizations/:uidOrganization{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1601,7 +1601,7 @@ export const getApiV2OrganizationsAssetUsageListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedCustomAssetUsageList), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/asset_usage/', async (info) => { + return http.get('*/api/v2/organizations/:uidOrganization/asset_usage{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1620,7 +1620,7 @@ export const getApiV2OrganizationsAssetsRetrieveMockHandler = ( | PaginatedAssetList | ((info: Parameters[1]>[0]) => Promise | PaginatedAssetList), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/', async (info) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1639,7 +1639,7 @@ export const getApiV2OrganizationsAssetsCountsRetrieveMockHandler = ( | AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/counts/', async (info) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/counts{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1660,7 +1660,7 @@ export const getApiV2OrganizationsAssetsMinimalListRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetMinimalListList), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list/', async (info) => { + return http.get('*/api/v2/organizations/:uidOrganization/assets/minimal-list{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1681,7 +1681,7 @@ export const getApiV2OrganizationsInvitesListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedInviteResponseList), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { + return http.get('*/api/v2/organizations/:uidOrganization/invites{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1700,7 +1700,7 @@ export const getApiV2OrganizationsInvitesCreateMockHandler = ( | InviteCreateResponse | ((info: Parameters[1]>[0]) => Promise | InviteCreateResponse), ) => { - return http.post('*/api/v2/organizations/:uidOrganization/invites/', async (info) => { + return http.post('*/api/v2/organizations/:uidOrganization/invites{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1719,7 +1719,7 @@ export const getApiV2OrganizationsInvitesRetrieveMockHandler = ( | InviteResponse | ((info: Parameters[1]>[0]) => Promise | InviteResponse), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + return http.get('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1738,7 +1738,7 @@ export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = ( | InviteResponse | ((info: Parameters[1]>[0]) => Promise | InviteResponse), ) => { - return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + return http.patch('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1755,7 +1755,7 @@ export const getApiV2OrganizationsInvitesPartialUpdateMockHandler = ( export const getApiV2OrganizationsInvitesDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid/', async (info) => { + return http.delete('*/api/v2/organizations/:uidOrganization/invites/:guid{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -1770,7 +1770,7 @@ export const getApiV2OrganizationsMembersListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedMemberListResponseList), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/members/', async (info) => { + return http.get('*/api/v2/organizations/:uidOrganization/members{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1789,7 +1789,7 @@ export const getApiV2OrganizationsMembersRetrieveMockHandler = ( | MemberListResponse | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + return http.get('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1808,7 +1808,7 @@ export const getApiV2OrganizationsMembersPartialUpdateMockHandler = ( | MemberListResponse | ((info: Parameters[1]>[0]) => Promise | MemberListResponse), ) => { - return http.patch('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + return http.patch('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1825,7 +1825,7 @@ export const getApiV2OrganizationsMembersPartialUpdateMockHandler = ( export const getApiV2OrganizationsMembersDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/api/v2/organizations/:uidOrganization/members/:username/', async (info) => { + return http.delete('*/api/v2/organizations/:uidOrganization/members/:username{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -1840,7 +1840,7 @@ export const getApiV2OrganizationsServiceUsageRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | OrganizationServiceUsageResponse), ) => { - return http.get('*/api/v2/organizations/:uidOrganization/service_usage/', async (info) => { + return http.get('*/api/v2/organizations/:uidOrganization/service_usage{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1861,7 +1861,7 @@ export const getApiV2ProjectViewsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectViewListResponseList), ) => { - return http.get('*/api/v2/project-views/', async (info) => { + return http.get('*/api/v2/project-views{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1882,7 +1882,7 @@ export const getApiV2ProjectViewsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectViewListResponse), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/', async (info) => { + return http.get('*/api/v2/project-views/:uidProjectView{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1903,7 +1903,7 @@ export const getApiV2ProjectViewsExportRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectViewExportResponse), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { + return http.get('*/api/v2/project-views/:uidProjectView/:objType/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1924,7 +1924,7 @@ export const getApiV2ProjectViewsExportCreateMockHandler = ( info: Parameters[1]>[0], ) => Promise | ProjectViewExportCreateResponse), ) => { - return http.post('*/api/v2/project-views/:uidProjectView/:objType/export/', async (info) => { + return http.post('*/api/v2/project-views/:uidProjectView/:objType/export{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1945,7 +1945,7 @@ export const getApiV2ProjectViewsAssetsRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectViewAssetResponseList), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/', async (info) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1964,7 +1964,7 @@ export const getApiV2ProjectViewsAssetsCountsRetrieveMockHandler = ( | AssetListCount | ((info: Parameters[1]>[0]) => Promise | AssetListCount), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/counts/', async (info) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/counts{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -1985,7 +1985,7 @@ export const getApiV2ProjectViewsAssetsMinimalListRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedAssetMinimalListList), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list/', async (info) => { + return http.get('*/api/v2/project-views/:uidProjectView/assets/minimal-list{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2006,7 +2006,7 @@ export const getApiV2ProjectViewsUsersRetrieveMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedProjectViewUserResponseList), ) => { - return http.get('*/api/v2/project-views/:uidProjectView/users/', async (info) => { + return http.get('*/api/v2/project-views/:uidProjectView/users{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2027,7 +2027,7 @@ export const getApiV2ServiceUsageListMockHandler = ( info: Parameters[1]>[0], ) => Promise | ServiceUsageResponse[]), ) => { - return http.get('*/api/v2/service_usage/', async (info) => { + return http.get('*/api/v2/service_usage{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2048,7 +2048,7 @@ export const getApiV2UsersListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedUserListResponseList), ) => { - return http.get('*/api/v2/users/', async (info) => { + return http.get('*/api/v2/users{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2067,7 +2067,7 @@ export const getApiV2UsersRetrieveMockHandler = ( | UserRetrieveResponse | ((info: Parameters[1]>[0]) => Promise | UserRetrieveResponse), ) => { - return http.get('*/api/v2/users/:username/', async (info) => { + return http.get('*/api/v2/users/:username{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2086,7 +2086,7 @@ export const getMeRetrieveMockHandler = ( | MeListResponse | ((info: Parameters[1]>[0]) => Promise | MeListResponse), ) => { - return http.get('*/me/', async (info) => { + return http.get('*/me{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2105,7 +2105,7 @@ export const getMePartialUpdateMockHandler = ( | MeListResponse | ((info: Parameters[1]>[0]) => Promise | MeListResponse), ) => { - return http.patch('*/me/', async (info) => { + return http.patch('*/me{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2122,7 +2122,7 @@ export const getMePartialUpdateMockHandler = ( export const getMeDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/me/', async (info) => { + return http.delete('*/me{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } @@ -2137,7 +2137,7 @@ export const getMeEmailsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedEmailAddressList), ) => { - return http.get('*/me/emails/', async (info) => { + return http.get('*/me/emails{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2156,7 +2156,7 @@ export const getMeEmailsCreateMockHandler = ( | EmailAddress | ((info: Parameters[1]>[0]) => Promise | EmailAddress), ) => { - return http.post('*/me/emails/', async (info) => { + return http.post('*/me/emails{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2177,7 +2177,7 @@ export const getMeSocialAccountsListMockHandler = ( info: Parameters[1]>[0], ) => Promise | PaginatedSocialAccountList), ) => { - return http.get('*/me/social-accounts/', async (info) => { + return http.get('*/me/social-accounts{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2196,7 +2196,7 @@ export const getMeSocialAccountsRetrieveMockHandler = ( | SocialAccount | ((info: Parameters[1]>[0]) => Promise | SocialAccount), ) => { - return http.get('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { + return http.get('*/me/social-accounts/:provider/:uidSocialAccount{/}?', async (info) => { return new HttpResponse( JSON.stringify( overrideResponse !== undefined @@ -2213,7 +2213,7 @@ export const getMeSocialAccountsRetrieveMockHandler = ( export const getMeSocialAccountsDestroyMockHandler = ( overrideResponse?: void | ((info: Parameters[1]>[0]) => Promise | void), ) => { - return http.delete('*/me/social-accounts/:provider/:uidSocialAccount/', async (info) => { + return http.delete('*/me/social-accounts/:provider/:uidSocialAccount{/}?', async (info) => { if (typeof overrideResponse === 'function') { await overrideResponse(info) } diff --git a/scripts/orval-make-trailing-slash-optional.js b/scripts/orval-make-trailing-slash-optional.js index c58e2c8cf7..2e970c7177 100644 --- a/scripts/orval-make-trailing-slash-optional.js +++ b/scripts/orval-make-trailing-slash-optional.js @@ -38,13 +38,20 @@ function processFile(filePath) { return modified } -const files = fs.readdirSync(REACT_QUERY_DIR) -for (const file of files) { - if (!file.endsWith('.ts')) continue - const filePath = path.join(REACT_QUERY_DIR, file) - processFile(filePath) +function processDirectory(dirPath) { + const entries = fs.readdirSync(dirPath, { withFileTypes: true }) + for (const entry of entries) { + const fullPath = path.join(dirPath, entry.name) + if (entry.isDirectory()) { + processDirectory(fullPath) + } else if (entry.name.endsWith('.ts')) { + processFile(fullPath) + } + } } +processDirectory(REACT_QUERY_DIR) + if (totalFixed > 0) { console.log(`✔ Made trailing slashes optional in ${totalFixed} react-query files`) } From 9a4ad807387e706f03cf84fb5f091482debf298f Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 13 Jul 2026 11:15:36 +0200 Subject: [PATCH 83/86] add missing factory fn --- .../alerts/alertEvaluators.tests.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/jsapp/js/components/submissions/BulkProcessingModals/alerts/alertEvaluators.tests.ts b/jsapp/js/components/submissions/BulkProcessingModals/alerts/alertEvaluators.tests.ts index cd4a286dff..8279b5c57f 100644 --- a/jsapp/js/components/submissions/BulkProcessingModals/alerts/alertEvaluators.tests.ts +++ b/jsapp/js/components/submissions/BulkProcessingModals/alerts/alertEvaluators.tests.ts @@ -1,8 +1,9 @@ import { expect } from 'chai' import { ActionIdEnum } from '#/api/models/actionIdEnum' +import type { BulkActionResponse } from '#/api/models/bulkActionResponse' import { BulkActionResponseStatusEnum } from '#/api/models/bulkActionResponseStatusEnum' +import { getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock } from '#/api/react-query/survey-data/msw' import assetDataFactory from '#/endpoints/assetData.factory' -import bulkActionFactory from '#/endpoints/bulkAction.factory' import { asrExceeded, mtExceeded, withinLimits } from '#/endpoints/serviceUsage.factory' import { evaluateAlreadyTranslated, @@ -13,6 +14,18 @@ import { } from './alertEvaluators' import type { AlertEvaluationContext } from './types' +function bulkActionFactory( + uid: string, + language: string, + overrides: Partial = {}, +): BulkActionResponse { + return getApiV2AssetsAdvancedFeaturesBulkActionsRetrieveResponseMock({ + uid, + params: { language }, + ...overrides, + }) +} + describe('evaluateNoEligibleSubmissions', () => { const mockSubmissions = [ assetDataFactory(1, { _uuid: 'uuid-1' }), From 6dae720d27a56b4dd06ba1e3fcdec3935ddd3255 Mon Sep 17 00:00:00 2001 From: Leszek Date: Mon, 13 Jul 2026 11:18:25 +0200 Subject: [PATCH 84/86] rebuild orval --- jsapp/js/api/react-query/survey-data/msw.ts | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/jsapp/js/api/react-query/survey-data/msw.ts b/jsapp/js/api/react-query/survey-data/msw.ts index 408f279f27..dba650224a 100644 --- a/jsapp/js/api/react-query/survey-data/msw.ts +++ b/jsapp/js/api/react-query/survey-data/msw.ts @@ -93,6 +93,8 @@ import type { PaginatedPairedDataResponseList } from '../../models/paginatedPair import type { PairedDataResponse } from '../../models/pairedDataResponse' +import type { QATagTracker } from '../../models/qATagTracker' + import { QualSelectQuestionParamsTypeEnum } from '../../models/qualSelectQuestionParamsTypeEnum' import { QualSimpleQuestionParamsTypeEnum } from '../../models/qualSimpleQuestionParamsTypeEnum' @@ -1966,6 +1968,11 @@ export const getApiV2AssetsPairedDataExternalRetrieveResponseMock = ( ...overrideResponse, }) +export const getApiV2AssetsQualQuestionsTagsListResponseMock = (): QATagTracker[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + value: faker.string.alpha({ length: { min: 10, max: 255 } }), + })) + export const getApiV2AssetsReportsRetrieveResponseMock = ( overrideResponse: Partial = {}, ): ReportResponse => ({ @@ -2945,6 +2952,25 @@ export const getApiV2AssetsPairedDataExternalRetrieveMockHandler = ( }) } +export const getApiV2AssetsQualQuestionsTagsListMockHandler = ( + overrideResponse?: + | QATagTracker[] + | ((info: Parameters[1]>[0]) => Promise | QATagTracker[]), +) => { + return http.get('*/api/v2/assets/:uidAsset/qual-questions/:uidQaQuestion/tags{/}?', async (info) => { + return new HttpResponse( + JSON.stringify( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApiV2AssetsQualQuestionsTagsListResponseMock(), + ), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + ) + }) +} + export const getApiV2AssetsReportsRetrieveMockHandler = ( overrideResponse?: | ReportResponse @@ -3018,5 +3044,6 @@ export const getSurveyDataMock = () => [ getApiV2AssetsPairedDataPartialUpdateMockHandler(), getApiV2AssetsPairedDataDestroyMockHandler(), getApiV2AssetsPairedDataExternalRetrieveMockHandler(), + getApiV2AssetsQualQuestionsTagsListMockHandler(), getApiV2AssetsReportsRetrieveMockHandler(), ] From 6be6c674cf753a88db388152387d2bd8efd7bfcf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Jul 2026 08:42:34 +0000 Subject: [PATCH 85/86] fix(jest): add rettime to transformIgnorePatterns for ESM support --- jsapp/jest/unit.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsapp/jest/unit.config.ts b/jsapp/jest/unit.config.ts index 5241a594c4..77564ddf38 100644 --- a/jsapp/jest/unit.config.ts +++ b/jsapp/jest/unit.config.ts @@ -41,8 +41,8 @@ const config: Config = { ...defaults.testPathIgnorePatterns, // 📦 exclude '/node_modules/' ], - // Transform ESM modules from node_modules (MSW and its dependencies) - transformIgnorePatterns: ['node_modules/(?!(msw|@mswjs|@bundled-es-modules|statuses|until-async)/)'], + // Transform ESM modules from node_modules (MSW and its dependencies, faker's rettime) + transformIgnorePatterns: ['node_modules/(?!(msw|@mswjs|@bundled-es-modules|statuses|until-async|rettime)/)'], // Set up test environment testEnvironment: 'jsdom', From f9c0d66d58e5f7e9a64e27feea61f03de2397c23 Mon Sep 17 00:00:00 2001 From: Leszek Date: Wed, 15 Jul 2026 10:54:41 +0200 Subject: [PATCH 86/86] fix tests --- jsapp/jest/setupUnitTest.ts | 19 ++++++++++++++++++- jsapp/jest/unit.config.ts | 12 ++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/jsapp/jest/setupUnitTest.ts b/jsapp/jest/setupUnitTest.ts index 101c7c46df..2814c3963a 100644 --- a/jsapp/jest/setupUnitTest.ts +++ b/jsapp/jest/setupUnitTest.ts @@ -1,6 +1,7 @@ // Polyfill global fetch (for Node 20 and older) import 'whatwg-fetch' import { TextDecoder, TextEncoder } from 'util' +import { ReadableStream, TransformStream, WritableStream } from 'stream/web' import chai from 'chai' import $ from 'jquery' @@ -9,7 +10,23 @@ import $ from 'jquery' Object.defineProperty(globalThis, 'TextEncoder', { value: TextEncoder, configurable: true }) Object.defineProperty(globalThis, 'TextDecoder', { value: TextDecoder, configurable: true }) -// MSW needs BroadcastChannel for WebSocket mocking +// MSW now uses Web Streams for SSE/WebSocket internals. +// jsdom does not always expose these globals, so we provide them from Node. +// This prevents runtime errors like "WritableStream is not defined". +if (typeof globalThis.WritableStream === 'undefined') { + Object.defineProperty(globalThis, 'WritableStream', { value: WritableStream, configurable: true }) +} + +if (typeof globalThis.ReadableStream === 'undefined') { + Object.defineProperty(globalThis, 'ReadableStream', { value: ReadableStream, configurable: true }) +} + +if (typeof globalThis.TransformStream === 'undefined') { + Object.defineProperty(globalThis, 'TransformStream', { value: TransformStream, configurable: true }) +} + +// Some test environments miss BroadcastChannel. +// MSW expects it for WebSocket mocking, so this minimal fallback keeps tests stable. if (typeof globalThis.BroadcastChannel === 'undefined') { // @ts-expect-error: Minimal polyfill for test environment globalThis.BroadcastChannel = class BroadcastChannel { diff --git a/jsapp/jest/unit.config.ts b/jsapp/jest/unit.config.ts index 77564ddf38..5ff676f9f1 100644 --- a/jsapp/jest/unit.config.ts +++ b/jsapp/jest/unit.config.ts @@ -27,11 +27,11 @@ const config: Config = { }, // Extensions to try in order (for import statements with no extension) - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'coffee'], + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'mjs', 'coffee'], // Transformers (SWC for JS/TS, CoffeeScript for .coffee) transform: { - '^.+\\.(js|jsx|ts|tsx)$': '@swc/jest', + '^.+\\.(mjs|js|jsx|ts|tsx)$': '@swc/jest', '^.+\\.coffee$': '/coffeeTransformer.js', }, @@ -41,8 +41,12 @@ const config: Config = { ...defaults.testPathIgnorePatterns, // 📦 exclude '/node_modules/' ], - // Transform ESM modules from node_modules (MSW and its dependencies, faker's rettime) - transformIgnorePatterns: ['node_modules/(?!(msw|@mswjs|@bundled-es-modules|statuses|until-async|rettime)/)'], + // By default Jest skips transforming node_modules. + // These packages are explicitly allowlisted because they can publish ESM output, + // which otherwise causes parse errors like "unexpected token export/import" in tests. + transformIgnorePatterns: [ + 'node_modules/(?!(msw|@mswjs|@open-draft|@bundled-es-modules|headers-polyfill|outvariant|is-node-process|strict-event-emitter|statuses|until-async|rettime)/)', + ], // Set up test environment testEnvironment: 'jsdom',