import {z} from 'zod' export type GetApiV1RoomsRoomSidArtifactsArgs = {room_sid: string, page_size?: number | undefined, page_token?: string | undefined}; export type GetApiV1RoomsRoomSidArtifactsOptions = {baseUrl?: string | undefined, apiKey?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const streemApiArtifactGpsPosition = z.object({sourced_from_user_sid: z.string().optional(), sourced_from_device_sid: z.string().optional(), client_created_at: z.string().optional(), latitude_degrees: z.number().optional(), longitude_degrees: z.number().optional(), accuracy_meters: z.number().optional(), formatted_address: z.string().optional(), deleted_at: z.string().optional()}); export const streemApiArtifactMesh = z.object({name: z.string().optional(), status: z.enum(["STATUS_REQUESTED", "STATUS_STARTED", "STATUS_ERROR", "STATUS_FULFILLED", "STATUS_INVALID"]).optional(), mesh_storage_url: z.string().optional(), metadata_storage_url: z.string().optional(), requested_at: z.string().optional(), started_at: z.string().optional(), errored_at: z.string().optional(), fulfilled_at: z.string().optional(), url: z.string().optional(), deleted_at: z.string().optional()}); export const streemApiArtifactRecordingTrack = z.object({bucket: z.string().optional(), filename: z.string().optional(), user_sid: z.string().optional(), track_type: z.string().optional(), codec: z.string().optional(), storage_url: z.string().optional(), status: z.enum(["STATUS_STARTED_RECORDING", "STATUS_FINISHED_RECORDING", "STATUS_TRANSFERRING", "STATUS_ERROR", "STATUS_FULFILLED", "STATUS_INVALID"]).optional(), requested_at: z.string().optional(), started_recording_at: z.string().optional(), finished_recording_at: z.string().optional(), started_transferring_at: z.string().optional(), errored_at: z.string().optional(), fulfilled_at: z.string().optional(), url: z.string().optional(), created_at: z.string().optional(), recording_source: z.enum(["SOURCE_TWILIO", "SOURCE_EXTERNAL", "SOURCE_MUXER", "SOURCE_ARAAS", "SOURCE_CHIME", "SOURCE_INVALID"]).optional(), source_recording_track_sid: z.string().optional(), deleted_at: z.string().optional()}); export const googleProtobufDuration = z.object({seconds: z.number().int().optional(), nanos: z.number().int().optional()}); export const streemApiArtifactRecording = z.object({bucket: z.string().optional(), filename: z.string().optional(), storage_url: z.string().optional(), status: z.enum(["STATUS_REQUESTED", "STATUS_TRANSFERRING", "STATUS_ERROR", "STATUS_FULFILLED", "STATUS_INVALID"]).optional(), requested_at: z.string().optional(), started_transferring_at: z.string().optional(), errored_at: z.string().optional(), fulfilled_at: z.string().optional(), created_at: z.string().optional(), url: z.string().optional(), recording_source: z.enum(["SOURCE_TWILIO", "SOURCE_MUXER", "SOURCE_ON_DEVICE", "SOURCE_ARAAS", "SOURCE_CHIME", "SOURCE_INVALID"]).optional(), preview_storage_url: z.string().optional(), preview_url: z.string().optional(), duration: googleProtobufDuration.optional(), recording_status: z.enum(["RECORDING_STATUS_NONE", "RECORDING_STATUS_PAUSED", "RECORDING_STATUS_RESUMED", "RECORDING_STATUS_TEMPORARY_FAILURE", "RECORDING_STATUS_INVALID"]).optional(), deleted_at: z.string().optional()}); export const streemApiPose = z.object({position: z.array(z.number()).optional(), rotation: z.array(z.number()).optional()}); export const streemApiPoint = z.object({x: z.number().optional(), y: z.number().optional(), z: z.number().optional()}); export const cameraIntrinsics = z.object({focal_length_px_x: z.number().optional(), focal_length_px_y: z.number().optional(), axis_skew: z.number().optional(), principal_point_x: z.number().optional(), principal_point_y: z.number().optional()}); export const streemApiArtifactStreemshotSource = z.object({url: z.string().optional(), pose: streemApiPose.optional(), feature_points: z.array(streemApiPoint).optional(), camera_intrinsics: cameraIntrinsics.optional(), deleted_at: z.string().optional()}); export const streemApiDetectionBoundingBox = z.object({x: z.number().optional(), y: z.number().optional(), width: z.number().optional(), height: z.number().optional()}); export const streemApiDetection = z.object({detection_sid: z.string().optional(), type: z.enum(["DETECTION_TYPE_LOGO", "DETECTION_TYPE_LABEL", "DETECTION_TYPE_TEXT", "DETECTION_TYPE_FULL_TEXT", "DETECTION_TYPE_SAFE_SEARCH", "DETECTION_TYPE_SERIAL", "DETECTION_TYPE_MODEL", "DETECTION_TYPE_OBJECT", "DETECTION_TYPE_INVALID"]).optional(), description: z.string().optional(), confidence: z.number().optional(), bounding_box: streemApiDetectionBoundingBox.optional(), source: z.enum(["DETECTION_SOURCE_OCR", "DETECTION_SOURCE_USER", "DETECTION_SOURCE_AUTO", "DETECTION_SOURCE_INVALID"]).optional(), hidden: z.boolean().optional(), extractor: z.string().optional(), last_updated_at: z.string().optional()}); export const streemApiTransform = z.object({position: z.array(z.number()).optional(), rotation: z.array(z.number()).optional(), scale: z.array(z.number()).optional()}); export const streemApiArElementArrow = z.object({transform: streemApiTransform.optional(), rotation: z.number().optional()}); export const streemApiArElementMeasurement = z.object({from: streemApiPoint.optional(), to: streemApiPoint.optional()}); export const streemApiArElementModel3d = z.object({transform: streemApiTransform.optional(), rotation: z.number().optional(), name: z.string().optional()}); export const streemApiArElementText = z.object({transform: streemApiTransform.optional(), rotation: z.number().optional(), text: z.string().optional()}); export const streemApiArElement = z.object({arrow: streemApiArElementArrow.optional(), measurement: streemApiArElementMeasurement.optional(), model3d: streemApiArElementModel3d.optional(), text: streemApiArElementText.optional()}); export const streemApiArtifactStreemshotRevision = z.object({revision_number: z.number().int().optional(), streemshot_sid: z.string().optional(), storage_url: z.string().optional(), ar_elements: z.array(streemApiArElement).optional(), url: z.string().optional(), edited: z.boolean().optional(), deleted_at: z.string().optional()}); export const streemApiNote = z.object({sid: z.string().optional(), created_by_user_sid: z.string().optional(), created_at: z.string().optional(), scope: z.enum(["SCOPE_ROOM", "SCOPE_STREEMSHOT", "SCOPE_INVALID"]).optional(), scope_sid: z.string().optional(), last_updated_by_user_sid: z.string().optional(), last_updated_at: z.string().optional(), text: z.string().optional(), deleted_at: z.string().optional(), is_finalizable: z.boolean().optional(), finalized_at: z.string().optional(), revision_number: z.number().int().optional()}); export const streemApiArtifactStreemshotDepthMap = z.object({streemshot_sid: z.string().optional(), storage_url: z.string().optional(), url: z.string().optional(), deleted_at: z.string().optional()}); export const streemApiArtifactStreemshot = z.object({status: z.enum(["STATUS_REQUESTED", "STATUS_FULFILLED", "STATUS_INVALID"]).optional(), requested_at: z.string().optional(), requested_by_user_sid: z.string().optional(), requested_by_device_sid: z.string().optional(), fulfilled_at: z.string().optional(), fulfilled_by_user_sid: z.string().optional(), fulfilled_by_device_sid: z.string().optional(), source: streemApiArtifactStreemshotSource.optional(), detections: z.array(streemApiDetection).optional(), current_revision: streemApiArtifactStreemshotRevision.optional(), revision_number: z.number().int().optional(), note: streemApiNote.optional(), depth_map: streemApiArtifactStreemshotDepthMap.optional()}); export const streemApiArtifactTranscription = z.object({status: z.enum(["STATUS_UNKNOWN", "STATUS_REJECTED", "STATUS_ERROR", "STATUS_STARTED", "STATUS_CAPTURED", "STATUS_FULFILLED"]).optional(), storage_url: z.string().optional(), started_at: z.string().optional(), errored_at: z.string().optional(), fulfilled_at: z.string().optional(), type: z.enum(["VTT", "TXT"]).optional(), url: z.string().optional(), deleted_at: z.string().optional(), source: z.enum(["AWS", "WHISPER", "INVALID"]).optional(), sid: z.string().optional()}); export const streemApiArtifactSceneshot = z.object({mesh_sid: z.string().optional(), preview_storage_url: z.string().optional(), name: z.string().optional(), pose: streemApiPose.optional(), ar_elements: z.array(streemApiArElement).optional(), status: z.enum(["STATUS_UNKNOWN", "STATUS_REJECTED", "STATUS_ERROR", "STATUS_STARTED", "STATUS_CAPTURED", "STATUS_FULFILLED"]).optional(), started_at: z.string().optional(), errored_at: z.string().optional(), fulfilled_at: z.string().optional(), captured_at: z.string().optional(), deleted_at: z.string().optional()}); export const streemApiArtifactLayoutEstimation = z.object({mesh_sid: z.string().optional(), storage_url: z.string().optional(), status: z.enum(["STATUS_UNKNOWN", "STATUS_REJECTED", "STATUS_ERROR", "STATUS_STARTED", "STATUS_CAPTURED", "STATUS_FULFILLED"]).optional(), started_at: z.string().optional(), errored_at: z.string().optional(), fulfilled_at: z.string().optional(), url: z.string().optional(), captured_at: z.string().optional(), deleted_at: z.string().optional()}); export const streemApiArtifactTexturedMesh = z.object({mesh_sid: z.string().optional(), glb_storage_url: z.string().optional(), usdz_storage_url: z.string().optional(), status: z.enum(["STATUS_UNKNOWN", "STATUS_REJECTED", "STATUS_ERROR", "STATUS_STARTED", "STATUS_CAPTURED", "STATUS_FULFILLED"]).optional(), started_at: z.string().optional(), errored_at: z.string().optional(), fulfilled_at: z.string().optional(), glb_url: z.string().optional(), usdz_url: z.string().optional(), video_recording_track_sid: z.string().optional(), video_recording_sid: z.string().optional(), deleted_at: z.string().optional()}); export const streemApiArtifactBookmark = z.object({label: z.string().optional(), timestamp: z.string().optional(), status: z.enum(["STATUS_UNKNOWN", "STATUS_REJECTED", "STATUS_ERROR", "STATUS_STARTED", "STATUS_CAPTURED", "STATUS_FULFILLED"]).optional(), deleted_at: z.string().optional()}); export const streemApiArtifactRoomOutcomeReportEntry = z.object({code: z.string().optional(), label: z.string().optional()}); export const googleProtobufStruct = z.object({}); export const googleProtobufListValue = z.object({values: z.array(z.lazy(() => googleProtobufValue)).optional()}); export const googleProtobufValue: z.ZodType = z.object({null_value: z.literal("NULL_VALUE").optional(), number_value: z.number().optional(), string_value: z.string().optional(), bool_value: z.boolean().optional(), struct_value: googleProtobufStruct.optional(), list_value: googleProtobufListValue.optional()}); export const streemApiArtifactRoomOutcomeReport = z.object({status: z.enum(["STATUS_UNKNOWN", "STATUS_REJECTED", "STATUS_ERROR", "STATUS_STARTED", "STATUS_CAPTURED", "STATUS_FULFILLED"]).optional(), diagnoses: z.array(streemApiArtifactRoomOutcomeReportEntry).optional(), disposition: streemApiArtifactRoomOutcomeReportEntry.optional(), custom_fields: z.record(z.string(), googleProtobufValue).optional(), created_at: z.string().optional(), deleted_at: z.string().optional()}); export const streemApiArtifact = z.object({sid: z.string().optional(), room_sid: z.string().optional(), type: z.enum(["UNKNOWN", "STREEMSHOT", "RECORDING", "RECORDING_TRACK", "GPS_POSITION", "MESH", "TRANSCRIPTION", "SCENESHOT", "LAYOUT_ESTIMATION", "TEXTURED_MESH", "BOOKMARK", "ROOM_OUTCOME_REPORT"]).optional(), deleted: z.boolean().optional(), scheduled_for_deletion_at: z.string().optional(), deleted_at: z.string().optional(), gps_position: streemApiArtifactGpsPosition.optional(), mesh: streemApiArtifactMesh.optional(), recording_track: streemApiArtifactRecordingTrack.optional(), recording: streemApiArtifactRecording.optional(), streemshot: streemApiArtifactStreemshot.optional(), transcription: streemApiArtifactTranscription.optional(), sceneshot: streemApiArtifactSceneshot.optional(), layout_estimation: streemApiArtifactLayoutEstimation.optional(), textured_mesh: streemApiArtifactTexturedMesh.optional(), bookmark: streemApiArtifactBookmark.optional(), room_outcome_report: streemApiArtifactRoomOutcomeReport.optional()}); export const streemApiListRoomArtifactsResponse = z.object({artifacts: z.array(streemApiArtifact).optional(), next_page_token: z.string().optional(), total_size: z.number().int().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 }; /** * List Artifacts * * GET /v1/rooms/{room_sid}/artifacts * * Also accepts auth: bearer-auth */ export const getApiV1RoomsRoomSidArtifacts = async (args: GetApiV1RoomsRoomSidArtifactsArgs, options?: GetApiV1RoomsRoomSidArtifactsOptions) => { const {baseUrl = "https://api.prod-us.streem.cloud", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.page_size != null) query.append("page_size", String(args.page_size)) if (args.page_token != null) query.append("page_token", String(args.page_token)) if (apiKey !== undefined) headers.set('authorization', `Basic ${btoa(`${apiKey.username}:${apiKey.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/rooms/${encodeURIComponent(String(args.room_sid))}/artifacts${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(streemApiListRoomArtifactsResponse, await res.json()) };