import {z} from 'zod' export type ProjectVisibility = 'public' | 'private'; export type ModelEngineShortEnum = 'tflite-eon' | 'tflite-eon-ram-optimized' | 'tflite'; export type ProjectLabelingMethod = 'single_label' | 'object_detection' | 'label_map'; export type TutorialType = 'kws' | 'cv'; export type KerasModelVariantEnum = 'int8' | 'float32' | 'akida'; export type AnomalyLabelsConfig = {anomalyLabels: Array, noAnomalyLabels: Array}; export type UpdateProjectRequest = {logo?: string | undefined, name?: string | undefined, description?: string | undefined, projectVisibility?: ProjectVisibility | undefined, publicProjectListed?: boolean | undefined, lastDeployEonCompiler?: boolean | undefined, lastDeployModelEngine?: ModelEngineShortEnum | undefined, latencyDevice?: string | undefined, experiments?: Array | undefined, showCreateFirstImpulse?: boolean | undefined, labelingMethod?: ProjectLabelingMethod | undefined, selectedProjectTypeInWizard?: ('accelerometer' | 'audio' | 'image_classification' | 'object_detection' | 'something_else') | undefined, gettingStartedStep?: number | undefined, gettingStartedTutorial?: TutorialType | undefined, gettingStartedClasses?: Array | undefined, useGpu?: boolean | undefined, computeTimeLimitM?: number | undefined, dspFileSizeMb?: number | undefined, enterprisePerformance?: boolean | undefined, trainJobRamMb?: number | undefined, metadata?: Record | undefined, readme?: string | undefined, lastAcquisitionLabel?: string | undefined, trainJobNotificationUids?: Array | undefined, dspJobNotificationUids?: Array | undefined, modelTestingJobNotificationUids?: Array | undefined, exportJobNotificationUids?: Array | undefined, csvImportConfig?: Record | undefined, inPretrainedModelFlow?: boolean | undefined, dspPageSize?: number | undefined, windowJobConcurrency?: number | undefined, indPauseProcessingSamples?: boolean | undefined, showSensorDataInAcquisitionGraph?: boolean | undefined, lastDeploymentTarget?: string | undefined, dataAcquisitionPageSize?: number | undefined, dataAcquisitionViewType?: ('list' | 'grid') | undefined, dataAcquisitionGridColumnCount?: number | undefined, dataAcquisitionGridColumnCountDetailed?: number | undefined, showExactSampleLength?: boolean | undefined, inlineEditBoundingBoxes?: boolean | undefined, defaultProfilingVariant?: KerasModelVariantEnum | undefined, enabledModelProfilingVariants?: Array | undefined, impulseListCoreMetricsHiddenColumns?: Array | undefined, impulseListAdditionalMetricsShownColumns?: Array | undefined, impulseListExtraColumns?: Array | undefined, aiActionsGridColumnCount?: number | undefined, lastShownModelEngine?: ModelEngineShortEnum | undefined, versioningStorageSizeMib?: number | undefined, anomalyLabelsConfig?: AnomalyLabelsConfig | undefined, explicitValidationEnabled?: boolean | undefined}; export type CreateApiApiOrganizationsOrganizationIdWhitelabelProjectsProjectIdArgs = {organizationId: number, projectId: number, body: UpdateProjectRequest}; export type CreateApiApiOrganizationsOrganizationIdWhitelabelProjectsProjectIdOptions = {baseUrl?: string | undefined, ApiKeyAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; export const genericApiResponse = z.object({success: z.boolean(), error: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * White Label Admin - Update white label project * * POST /api/organizations/{organizationId}/whitelabel/projects/{projectId} * * Also accepts auth: JWTAuthentication, JWTHttpHeaderAuthentication, OAuth2 */ export const createApiApiOrganizationsOrganizationIdWhitelabelProjectsProjectId = async (args: CreateApiApiOrganizationsOrganizationIdWhitelabelProjectsProjectIdArgs, options?: CreateApiApiOrganizationsOrganizationIdWhitelabelProjectsProjectIdOptions) => { const {baseUrl = "https://studio.edgeimpulse.com/v1", fetch: fetchFn = fetch, ApiKeyAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKeyAuthentication !== undefined) headers.set("x-api-key", ApiKeyAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/api/organizations/${encodeURIComponent(String(args.organizationId))}/whitelabel/projects/${encodeURIComponent(String(args.projectId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(genericApiResponse, await res.json()) };