import {z} from 'zod' export type AccountInfo = {emails?: Array | undefined}; export type CalendarOptions = {locationQuery?: Array | undefined, minusWords?: Array | undefined, peopleQuery?: Array | undefined, responseStatuses?: (Array<'ATTENDEE_RESPONSE_UNSPECIFIED' | 'ATTENDEE_RESPONSE_NEEDS_ACTION' | 'ATTENDEE_RESPONSE_ACCEPTED' | 'ATTENDEE_RESPONSE_DECLINED' | 'ATTENDEE_RESPONSE_TENTATIVE'>) | undefined, versionDate?: unknown | undefined}; export type DriveDocumentIds = {ids?: Array | undefined}; export type DriveDocumentInfo = {documentIds?: DriveDocumentIds | undefined}; export type DriveOptions = {clientSideEncryptedOption?: ('CLIENT_SIDE_ENCRYPTED_OPTION_UNSPECIFIED' | 'CLIENT_SIDE_ENCRYPTED_OPTION_ANY' | 'CLIENT_SIDE_ENCRYPTED_OPTION_ENCRYPTED' | 'CLIENT_SIDE_ENCRYPTED_OPTION_UNENCRYPTED') | undefined, includeSharedDrives?: boolean | undefined, includeTeamDrives?: boolean | undefined, sharedDrivesOption?: ('SHARED_DRIVES_OPTION_UNSPECIFIED' | 'NOT_INCLUDED' | 'INCLUDED_IF_ACCOUNT_IS_NOT_A_MEMBER' | 'INCLUDED') | undefined, versionDate?: unknown | undefined}; export type GeminiInWorkspaceOptions = Record; export type GeminiOptions = Record; export type HangoutsChatInfo = {roomId?: Array | undefined}; export type HangoutsChatOptions = {includeRooms?: boolean | undefined}; export type MailOptions = {clientSideEncryptedOption?: ('CLIENT_SIDE_ENCRYPTED_OPTION_UNSPECIFIED' | 'CLIENT_SIDE_ENCRYPTED_OPTION_ANY' | 'CLIENT_SIDE_ENCRYPTED_OPTION_ENCRYPTED' | 'CLIENT_SIDE_ENCRYPTED_OPTION_UNENCRYPTED') | undefined, excludeDrafts?: boolean | undefined}; export type OrgUnitInfo = {orgUnitId?: string | undefined}; export type SharedDriveInfo = {sharedDriveIds?: Array | undefined}; export type SitesUrlInfo = {urls?: Array | undefined}; export type TeamDriveInfo = {teamDriveIds?: Array | undefined}; export type VoiceOptions = {coveredData?: (Array<'COVERED_DATA_UNSPECIFIED' | 'TEXT_MESSAGES' | 'VOICEMAILS' | 'CALL_LOGS'>) | undefined}; export type Query = {accountInfo?: AccountInfo | undefined, calendarOptions?: CalendarOptions | undefined, corpus?: ('CORPUS_TYPE_UNSPECIFIED' | 'DRIVE' | 'MAIL' | 'GROUPS' | 'HANGOUTS_CHAT' | 'VOICE' | 'CALENDAR' | 'GEMINI' | 'GEMINI_IN_WORKSPACE') | undefined, dataScope?: ('DATA_SCOPE_UNSPECIFIED' | 'ALL_DATA' | 'HELD_DATA' | 'UNPROCESSED_DATA') | undefined, driveDocumentInfo?: DriveDocumentInfo | undefined, driveOptions?: DriveOptions | undefined, endTime?: unknown | undefined, geminiInWorkspaceOptions?: GeminiInWorkspaceOptions | undefined, geminiOptions?: GeminiOptions | undefined, hangoutsChatInfo?: HangoutsChatInfo | undefined, hangoutsChatOptions?: HangoutsChatOptions | undefined, mailOptions?: MailOptions | undefined, method?: ('SEARCH_METHOD_UNSPECIFIED' | 'ACCOUNT' | 'ORG_UNIT' | 'TEAM_DRIVE' | 'ENTIRE_ORG' | 'ROOM' | 'SITES_URL' | 'SHARED_DRIVE' | 'DRIVE_DOCUMENT') | undefined, orgUnitInfo?: OrgUnitInfo | undefined, searchMethod?: ('SEARCH_METHOD_UNSPECIFIED' | 'ACCOUNT' | 'ORG_UNIT' | 'TEAM_DRIVE' | 'ENTIRE_ORG' | 'ROOM' | 'SITES_URL' | 'SHARED_DRIVE' | 'DRIVE_DOCUMENT') | undefined, sharedDriveInfo?: SharedDriveInfo | undefined, sitesUrlInfo?: SitesUrlInfo | undefined, startTime?: unknown | undefined, teamDriveInfo?: TeamDriveInfo | undefined, terms?: string | undefined, timeZone?: string | undefined, voiceOptions?: VoiceOptions | undefined}; export type CountArtifactsRequest = {query?: Query | undefined, view?: ('COUNT_RESULT_VIEW_UNSPECIFIED' | 'TOTAL_COUNT' | 'ALL') | undefined}; export type CreateApiV1MattersMatterIdCountArgs = {matterId: string, body: CountArtifactsRequest}; export type CreateApiV1MattersMatterIdCountOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const status = z.object({code: z.number().int().optional(), details: z.array(z.record(z.string(), z.unknown())).optional(), message: z.string().optional()}); export const operation = z.object({done: z.boolean().optional(), error: status.optional(), metadata: z.record(z.string(), z.unknown()).optional(), name: z.string().optional(), response: z.record(z.string(), z.unknown()).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 }; /** * Counts the accounts processed by the specified query. * * POST /v1/matters/{matterId}:count */ export const createApiV1MattersMatterIdCount = async (args: CreateApiV1MattersMatterIdCountArgs, options?: CreateApiV1MattersMatterIdCountOptions) => { const {baseUrl = "https://vault.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/matters/${encodeURIComponent(String(args.matterId))}:count${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(operation, await res.json()) };