import { gql } from 'graphql-request' import { RequestDocument } from 'graphql-request/dist/types' import { PostgrestClient } from '@supabase/postgrest-js' import type { UpsertUserInput, UpsertUserOutput, UserOutput, CreateUploadInput, ListUploadsOptions, CreateUploadOutput, UploadItemOutput, ContentItemOutput, Deal, CreateAuthKeyInput, CreateAuthKeyOutput, AuthKey, AuthKeyItemOutput, PinItemOutput, PinSyncRequestOutput, PinUpsertInput, PinsUpsertInput, BackupOutput, PsaPinRequestItem, PsaPinRequestUpsertOutput, PsaPinRequestUpsertInput, ListPsaPinRequestOptions, ListPsaPinRequestResults, StorageUsedOutput, UserTagInput, UserTagInfo, EmailSentInput, LogEmailSentInput, GetUserOptions, } from './db-client-types' export { gql } export class DBClient { constructor(config: { endpoint?: string; token: string, postgres?: boolean }) client: PostgrestClient getMetricsValue (key: string): Promise<{ total: number }> upsertUser (user: UpsertUserInput): Promise getUser(issuer: string, options: GetUserOptions): Promise getUserByEmail (email: string): Promise getStorageUsed (userId: number): Promise emailHasBeenSent(email: EmailSentInput): Promise logEmailSent(email : LogEmailSentInput): Promise<{id: string}> createUpload (data: CreateUploadInput): Promise getUpload (cid: string, userId: number): Promise listUploads (userId: number, opts?: ListUploadsOptions): Promise renameUpload (userId: number, cid: string, name: string): Promise<{ name: string }> deleteUpload (userId: number, cid: string): Promise<{ _id: number }> getStatus (cid: string): Promise getBackups (uploadId: number): Promise> upsertPin (cid: string, pin: PinUpsertInput): Promise upsertPins (pins: Array): Promise getPins (cid: string): Promise> createPinSyncRequests (pinSyncRequests: Array): Promise getPinSyncRequests ({ to, after, size }: { to?: string, after?: string, size?: number }): Promise deletePinSyncRequests (ids: Array): Promise getDeals (cid: string): Promise getDealsForCids (cids: string[]): Promise> createKey (key: CreateAuthKeyInput): Promise getKey (issuer: string, secret: string): Promise listKeys (userId: number): Promise> createPsaPinRequest (pinRequest: PsaPinRequestUpsertInput): Promise getPsaPinRequest (authKey: string, pinRequestId: string) : Promise listPsaPinRequests (authKey: string, opts?: ListPsaPinRequestOptions ) : Promise deletePsaPinRequest (pinRequestId: string, authKey: string) : Promise deleteKey (id: number): Promise query(document: RequestDocument, variables: V): Promise createUserTag(userId: string, tag: UserTagInput): Promise getUserTags(userId: string): Promise } export function parseTextToNumber(n: string): number export { EMAIL_TYPE } from './constants.js'