UNPKG

@xata.io/client

Version:

Xata.io SDK for TypeScript and JavaScript

2,067 lines (2,059 loc) • 401 kB
interface CacheImpl { defaultQueryTTL: number; getAll(): Promise<Record<string, unknown>>; get: <T>(key: string) => Promise<T | null>; set: <T>(key: string, value: T) => Promise<void>; delete: (key: string) => Promise<void>; clear: () => Promise<void>; } interface SimpleCacheOptions { max?: number; defaultQueryTTL?: number; } declare class SimpleCache implements CacheImpl { #private; capacity: number; defaultQueryTTL: number; constructor(options?: SimpleCacheOptions); getAll(): Promise<Record<string, unknown>>; get<T>(key: string): Promise<T | null>; set<T>(key: string, value: T): Promise<void>; delete(key: string): Promise<void>; clear(): Promise<void>; } declare abstract class XataPlugin { abstract build(options: XataPluginOptions): unknown; } type XataPluginOptions = ApiExtraProps & { cache: CacheImpl; host: HostProvider; tables: Table[]; branch: string; }; type AttributeDictionary = Record<string, string | number | boolean | undefined>; type TraceFunction = <T>(name: string, fn: (options: { name?: string; setAttributes: (attrs: AttributeDictionary) => void; }) => T, options?: AttributeDictionary) => Promise<T>; type RequestInit = { body?: any; headers?: Record<string, string>; method?: string; signal?: any; }; type Response = { ok: boolean; status: number; url: string; json(): Promise<any>; text(): Promise<string>; blob(): Promise<Blob>; headers?: { get(name: string): string | null; }; }; type FetchImpl = (url: string, init?: RequestInit) => Promise<Response>; type StringKeys<O> = Extract<keyof O, string>; type Values<O> = O[StringKeys<O>]; type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never; type If<Condition, Then, Else> = Condition extends true ? Then : Else; type IsObject<T> = T extends Record<string, any> ? true : false; type IsArray<T> = T extends Array<any> ? true : false; type RequiredBy<T, K extends keyof T> = T & { [P in K]-?: NonNullable<T[P]>; }; type GetArrayInnerType<T extends readonly any[]> = T[number]; type SingleOrArray<T> = T | T[]; type Dictionary<T> = Record<string, T>; type OmitBy<T, K extends keyof T> = T extends any ? Omit<T, K> : never; type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never; }; type ExclusiveOr<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U; type Explode<T> = keyof T extends infer K ? K extends unknown ? { [I in keyof T]: I extends K ? T[I] : never; } : never : never; type AtMostOne<T> = Explode<Partial<T>>; type AtLeastOne<T, U = { [K in keyof T]: Pick<T, K>; }> = Partial<T> & U[keyof U]; type ExactlyOne<T> = AtMostOne<T> & AtLeastOne<T>; type Fn = (...args: any[]) => any; type NarrowRaw<A> = (A extends [] ? [] : never) | (A extends Narrowable ? A : never) | { [K in keyof A]: A[K] extends Fn ? A[K] : NarrowRaw<A[K]>; }; type Narrowable = string | number | bigint | boolean; type Try<A1, A2, Catch = never> = A1 extends A2 ? A1 : Catch; type Narrow<A> = Try<A, [], NarrowRaw<A>>; type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K; }[keyof T]; /** * Generated by @openapi-codegen * * @version 1.0 */ type TaskStatus = 'scheduled' | 'pending' | 'active' | 'retry' | 'archived' | 'completed'; type TaskStatusResponse = { /** * The id of the task */ taskID: string; /** * The type of the task */ type: string; /** * The status of the task */ status: TaskStatus; /** * Any error message associated with the task */ error?: string; }; /** * @maxLength 255 * @minLength 1 * @pattern [a-zA-Z0-9_\-~]+ */ type TaskID = string; /** * @x-internal true * @pattern [a-zA-Z0-9_-~:]+ */ type ClusterID$1 = string; /** * Page size. * * @x-internal true * @default 25 * @minimum 0 */ type PageSize$1 = number; /** * Page token * * @x-internal true * @maxLength 255 * @minLength 24 */ type PageToken$1 = string; /** * @format date-time * @x-go-type string */ type DateTime$1 = string; /** * @x-internal true */ type BranchDetails = { name: string; id: string; /** * The cluster where this branch resides. * * @minLength 1 */ clusterID: string; state: string; createdAt: DateTime$1; databaseName: string; databaseID: string; }; /** * @x-internal true */ type PageResponse$1 = { size: number; hasMore: boolean; token?: string; }; /** * @x-internal true */ type ListClusterBranchesResponse = { branches: BranchDetails[]; page?: PageResponse$1; }; /** * @x-internal true */ type ExtensionDetails = { name: string; description: string; builtIn: boolean; status: 'installed' | 'not_installed'; version: string; }; /** * @x-internal true */ type ListClusterExtensionsResponse = { extensions: ExtensionDetails[]; }; /** * @x-internal true */ type ClusterExtensionInstallationResponse = { extension: string; status: 'success' | 'failure'; reason?: string; }; /** * @x-internal true */ type MetricMessage = { code?: string; value?: string; }; /** * @x-internal true */ type MetricData = { id?: string; label?: string; messages?: MetricMessage[] | null; status: 'complete' | 'error' | 'partial' | 'forbidden'; timestamps: string[]; values: number[]; }; /** * @x-internal true */ type MetricsResponse = { metrics: MetricData[]; messages: MetricMessage[]; page?: PageResponse$1; }; /** * The DBBranchName matches the pattern `{db_name}:{branch_name}`. * * @maxLength 511 * @minLength 1 * @pattern [a-zA-Z0-9_\-~]+:[a-zA-Z0-9_\-~]+ */ type DBBranchName = string; type ApplyMigrationResponse = { /** * The id of the migration job */ jobID: string; }; type StartMigrationResponse = { /** * The id of the migration job */ jobID: string; }; type CompleteMigrationResponse = { /** * The id of the migration job */ jobID: string; }; type RollbackMigrationResponse = { /** * The id of the migration job */ jobID: string; }; /** * @maxLength 255 * @minLength 1 * @pattern [a-zA-Z0-9_\-~]+ */ type TableName = string; type MigrationJobType = 'apply' | 'start' | 'complete' | 'rollback'; type MigrationJobStatus = 'pending' | 'in_progress' | 'completed' | 'failed'; /** * The effect of a migration operation in terms of CRUD operations on the underlying schema */ type MigrationOperationDescription = { /** * A new database object created by the operation */ create?: { /** * The type of object created */ type: 'table' | 'column' | 'index'; /** * The name of the object created */ name: string; /** * The name of the table on which the object is created, if applicable */ table?: string; /** * The mapping between the virtual and physical name of the new object, if applicable */ mapping?: Record<string, any>; }; /** * A database object updated by the operation */ update?: { /** * The type of updated object */ type: 'table' | 'column'; /** * The name of the updated object */ name: string; /** * The name of the table on which the object is updated, if applicable */ table?: string; /** * The mapping between the virtual and physical name of the updated object, if applicable */ mapping?: Record<string, any>; }; /** * A database object renamed by the operation */ rename?: { /** * The type of the renamed object */ type: 'table' | 'column' | 'constraint'; /** * The name of the table on which the object is renamed, if applicable */ table?: string; /** * The old name of the renamed object */ from: string; /** * The new name of the renamed object */ to: string; }; /** * A database object deleted by the operation */ ['delete']?: { /** * The type of the deleted object */ type: 'table' | 'column' | 'constraint' | 'index'; /** * The name of the deleted object */ name: string; /** * The name of the table on which the object is deleted, if applicable */ table: string; }; }; /** * @minItems 1 */ type MigrationDescription = MigrationOperationDescription[]; type MigrationJobStatusResponse = { /** * The id of the migration job */ jobID: string; /** * The type of the migration job */ type: MigrationJobType; /** * The status of the migration job */ status: MigrationJobStatus; /** * The effect of any active migration on the schema */ description?: MigrationDescription; /** * The timestamp at which the migration job completed or failed * * @format date-time */ completedAt?: string; /** * The error message associated with the migration job */ error?: string; }; type MigrationJobItem = { /** * The id of the migration job */ jobID: string; /** * The type of the migration job */ type: MigrationJobType; /** * The status of the migration job */ status: MigrationJobStatus; /** * The pgroll migration that was applied */ migration?: string; /** * The effect of any active migration on the schema */ description?: MigrationDescription; /** * The timestamp at which the migration job was enqueued * * @format date-time */ enqueuedAt: string; /** * The timestamp at which the migration job completed or failed * * @format date-time */ completedAt?: string; /** * The error message associated with the migration job */ error?: string; }; type GetMigrationJobsResponse = { /** * The list of migration jobs */ jobs: MigrationJobItem[]; /** * The cursor (timestamp) for the next page of results */ cursor?: string; }; /** * @maxLength 255 * @minLength 1 * @pattern [a-zA-Z0-9_\-~]+ */ type MigrationJobID = string; type MigrationType = 'pgroll' | 'inferred'; type MigrationHistoryItem = { /** * The name of the migration */ name: string; /** * The schema in which the migration was applied */ schema: string; /** * The pgroll migration that was applied */ migration: string; /** * The timestamp at which the migration was started * * @format date-time */ startedAt: string; /** * The name of the parent migration, if any */ parent?: string; /** * Whether the migration is completed or not */ done: boolean; /** * The type of the migration */ migrationType: MigrationType; }; type MigrationHistoryResponse = { /** * The migrations that have been applied to the branch */ migrations: MigrationHistoryItem[]; /** * The cursor (timestamp) for the next page of results */ cursor?: string; }; /** * @maxLength 255 * @minLength 1 * @pattern [a-zA-Z0-9_\-~]+ */ type DBName$1 = string; /** * Represent the state of the branch, used for branch lifecycle management */ type BranchState = 'active' | 'move_scheduled' | 'moving'; type Branch = { name: string; /** * The cluster where this branch resides. Value of 'shared-cluster' for branches in shared clusters * * @minLength 1 */ clusterID?: string; state: BranchState; createdAt: DateTime$1; searchDisabled?: boolean; inactiveSharedCluster?: boolean; }; type ListBranchesResponse = { databaseName: string; branches: Branch[]; }; type DatabaseSettings = { searchEnabled: boolean; }; /** * @maxLength 255 * @minLength 1 * @pattern [a-zA-Z0-9_\-~]+ */ type BranchName$1 = string; /** * @example {"repository":"github.com/my/repository","branch":"feature-login","stage":"testing","labels":["epic-100"]} * @x-go-type xata.BranchMetadata */ type BranchMetadata$1 = { /** * @minLength 1 */ repository?: string; branch?: BranchName$1; /** * @minLength 1 */ stage?: string; labels?: string[]; }; type CreateBranchResponse$1 = { /** * The id of the branch creation task */ taskID: string; }; type StartedFromMetadata = { branchName: BranchName$1; dbBranchID: string; migrationID: string; }; type ColumnLink = { table: string; }; type ColumnVector = { /** * @maximum 10000 * @minimum 2 */ dimension: number; }; type ColumnFile = { defaultPublicAccess?: boolean; }; type Column = { name: string; type: string; link?: ColumnLink; vector?: ColumnVector; file?: ColumnFile; ['file[]']?: ColumnFile; notNull?: boolean; defaultValue?: string; unique?: boolean; }; type RevLink = { table: string; column: string; }; type Table = { id?: string; name: TableName; columns: Column[]; revLinks?: RevLink[]; }; /** * @x-go-type xata.Schema */ type Schema = { tables: Table[]; tablesOrder?: string[]; }; type DBBranch = { databaseName: DBName$1; branchName: BranchName$1; createdAt: DateTime$1; id: string; /** * The cluster where this branch resides. Value of 'shared-cluster' for branches in shared clusters * * @minLength 1 * @x-internal true */ clusterID?: string; version: number; state: BranchState; lastMigrationID: string; metadata?: BranchMetadata$1; startedFrom?: StartedFromMetadata; schema: Schema; }; type MigrationStatus$1 = 'completed' | 'pending' | 'failed'; type BranchSchema = { name: string; tables: { [key: string]: { oid: string; name: string; xataCompatible: boolean; comment: string; columns: { [key: string]: { name: string; type: string; ['default']: string | null; nullable: boolean; unique: boolean; comment: string; }; }; indexes: { [key: string]: { name: string; unique: boolean; columns: string[]; }; }; primaryKey: string[]; foreignKeys: { [key: string]: { name: string; columns: string[]; referencedTable: string; referencedColumns: string[]; }; }; checkConstraints: { [key: string]: { name: string; columns: string[]; definition: string; }; }; uniqueConstraints: { [key: string]: { name: string; columns: string[]; }; }; }; }; }; type BranchWithCopyID = { branchName: BranchName$1; dbBranchID: string; copyID: string; }; type MetricsDatapoint = { timestamp: string; value: number; }; type MetricsLatency = { p50?: MetricsDatapoint[]; p90?: MetricsDatapoint[]; }; type ListGitBranchesResponse = { mapping: { gitBranch: string; xataBranch: string; }[]; }; type ColumnMigration = { old: Column; ['new']: Column; }; type TableMigration = { newColumns?: { [key: string]: Column; }; removedColumns?: string[]; modifiedColumns?: ColumnMigration[]; newColumnOrder: string[]; }; /** * @example {"newName":"newName","oldName":"oldName"} */ type TableRename = { /** * @minLength 1 */ newName: string; /** * @minLength 1 */ oldName: string; }; type BranchMigration = { id?: string; parentID?: string; status: string; title?: string; lastGitRevision?: string; localChanges: boolean; createdAt?: DateTime$1; newTables?: { [key: string]: Table; }; removedTables?: string[]; tableMigrations?: { [key: string]: TableMigration; }; newTableOrder: string[]; renamedTables?: TableRename[]; }; /** * @minProperties 1 */ type FilterExpression = { $exists?: string; $existsNot?: string; $any?: FilterList; $all?: FilterList; $none?: FilterList; $not?: FilterList; } & { [key: string]: FilterColumn; }; type FilterList = FilterExpression | FilterExpression[]; type FilterValue = number | string | boolean; type FilterPredicate = FilterValue | FilterPredicate[] | FilterPredicateOp | FilterPredicateRangeOp; type FilterRangeValue = number | string; /** * @maxProperties 1 * @minProperties 1 */ type FilterPredicateOp = { $any?: FilterPredicate[]; $all?: FilterPredicate[]; $none?: FilterPredicate | FilterPredicate[]; $not?: FilterPredicate | FilterPredicate[]; $is?: FilterValue | FilterValue[]; $isNot?: FilterValue | FilterValue[]; $lt?: FilterRangeValue; $le?: FilterRangeValue; $gt?: FilterRangeValue; $ge?: FilterRangeValue; $contains?: string; $iContains?: string; $startsWith?: string; $endsWith?: string; $pattern?: string; $iPattern?: string; }; /** * @maxProperties 2 * @minProperties 2 */ type FilterPredicateRangeOp = { $lt?: FilterRangeValue; $le?: FilterRangeValue; $gt?: FilterRangeValue; $ge?: FilterRangeValue; }; /** * @maxProperties 1 * @minProperties 1 */ type FilterColumnIncludes = { $includes?: FilterPredicate; $includesAny?: FilterPredicate; $includesAll?: FilterPredicate; $includesNone?: FilterPredicate; }; type FilterColumn = FilterColumnIncludes | FilterPredicate | FilterList; type SortOrder = 'asc' | 'desc' | 'random'; type SortExpression = string[] | { [key: string]: SortOrder; } | { [key: string]: SortOrder; }[]; /** * Pagination settings. */ type PageConfig = { /** * Query the next page that follow the cursor. */ after?: string; /** * Query the previous page before the cursor. */ before?: string; /** * Query the first page from the cursor. */ start?: string; /** * Query the last page from the cursor. */ end?: string; /** * Set page size. If the size is missing it is read from the cursor. If no cursor is given Xata will choose the default page size. * * @default 20 */ size?: number; /** * Use offset to skip entries. To skip pages set offset to a multiple of size. * * @default 0 */ offset?: number; }; /** * @example name * @example email * @example created_at */ type ColumnsProjection = string[]; /** * The migration request number. * * @minimum 0 * @x-go-type migration.RequestNumber */ type MigrationRequestNumber = number; type MigrationRequest = { number?: MigrationRequestNumber; /** * Migration request creation timestamp. */ createdAt?: DateTime$1; /** * Last modified timestamp. */ modifiedAt?: DateTime$1; /** * Timestamp when the migration request was closed. */ closedAt?: DateTime$1; /** * Timestamp when the migration request was merged. */ mergedAt?: DateTime$1; status?: 'open' | 'closed' | 'merging' | 'merged' | 'failed'; /** * The migration request title. */ title?: string; /** * The migration request body with detailed description. */ body?: string; /** * Name of the source branch. */ source?: string; /** * Name of the target branch. */ target?: string; }; /** * Records metadata */ type RecordsMetadata = { page: { /** * last record id */ cursor: string; /** * true if more records can be fetched */ more: boolean; /** * the number of records returned per page */ size: number; }; }; type TableOpAdd = { table: string; }; type TableOpRemove = { table: string; }; type TableOpRename = { oldName: string; newName: string; }; type MigrationTableOp = { addTable: TableOpAdd; } | { removeTable: TableOpRemove; } | { renameTable: TableOpRename; }; type ColumnOpAdd = { table: string; column: Column; }; type ColumnOpRemove = { table: string; column: string; }; type ColumnOpRename = { table: string; oldName: string; newName: string; }; type MigrationColumnOp = { addColumn: ColumnOpAdd; } | { removeColumn: ColumnOpRemove; } | { renameColumn: ColumnOpRename; }; /** * Branch schema migration operations. */ type MigrationOp = MigrationTableOp | MigrationColumnOp; type Commit = { title?: string; message?: string; id: string; parentID?: string; checksum: string; mergeParentID?: string; createdAt: DateTime$1; operations: MigrationOp[]; }; type SchemaEditScript = { sourceMigrationID?: string; targetMigrationID?: string; operations: MigrationOp[]; }; type BranchOp = { id: string; parentID?: string; title?: string; message?: string; status: MigrationStatus$1; createdAt: DateTime$1; modifiedAt?: DateTime$1; migration?: Commit; }; /** * Branch schema migration. */ type Migration = { parentID?: string; operations: MigrationOp[]; }; type MigrationObject = { title?: string; message?: string; id: string; parentID?: string; checksum: string; operations: MigrationOp[]; }; /** * @pattern [a-zA-Z0-9_\-~\.]+ */ type ColumnName = string; /** * Insert operation */ type TransactionInsertOp = { /** * The table name */ table: string; /** * The record to insert. The `id` field is optional; when specified, it will be used as the ID for the record. */ record: { [key: string]: any; }; /** * The version of the record you expect to be overwriting. Only valid with an * explicit ID is also set in the `record` key. */ ifVersion?: number; /** * createOnly is used to change how Xata acts when an explicit ID is set in the `record` key. * * If `createOnly` is set to `true`, Xata will only attempt to insert the record. If there's a conflict, Xata * will cancel the transaction. * * If `createOnly` is set to `false`, Xata will attempt to insert the record. If there's no * conflict, the record is inserted. If there is a conflict, Xata will replace the record. */ createOnly?: boolean; /** * If set, the call will return the requested fields as part of the response. */ columns?: string[]; }; /** * @maxLength 255 * @minLength 1 * @pattern [a-zA-Z0-9_-~:]+ */ type RecordID = string; /** * Update operation */ type TransactionUpdateOp = { /** * The table name */ table: string; id: RecordID; /** * The fields of the record you'd like to update */ fields: { [key: string]: any; }; /** * The version of the record you expect to be updating */ ifVersion?: number; /** * Xata will insert this record if it cannot be found. */ upsert?: boolean; /** * If set, the call will return the requested fields as part of the response. */ columns?: string[]; }; /** * A delete operation. The transaction will continue if no record matches the ID by default. To override this behaviour, set failIfMissing to true. */ type TransactionDeleteOp = { /** * The table name */ table: string; id: RecordID; /** * If true, the transaction will fail when the record doesn't exist. */ failIfMissing?: boolean; /** * If set, the call will return the requested fields as part of the response. */ columns?: string[]; }; /** * Get by id operation. */ type TransactionGetOp = { /** * The table name */ table: string; id: RecordID; /** * If set, the call will return the requested fields as part of the response. */ columns?: string[]; }; /** * A transaction operation */ type TransactionOperation$1 = { insert: TransactionInsertOp; } | { update: TransactionUpdateOp; } | { ['delete']: TransactionDeleteOp; } | { get: TransactionGetOp; }; /** * Fields to return in the transaction result. */ type TransactionResultColumns = { [key: string]: any; }; /** * A result from an insert operation. */ type TransactionResultInsert = { /** * The type of operation who's result is being returned. */ operation: 'insert'; /** * The number of affected rows */ rows: number; id: RecordID; columns?: TransactionResultColumns; }; /** * A result from an update operation. */ type TransactionResultUpdate = { /** * The type of operation who's result is being returned. */ operation: 'update'; /** * The number of updated rows */ rows: number; id: RecordID; columns?: TransactionResultColumns; }; /** * A result from a delete operation. */ type TransactionResultDelete = { /** * The type of operation who's result is being returned. */ operation: 'delete'; /** * The number of deleted rows */ rows: number; columns?: TransactionResultColumns; }; /** * A result from a get operation. */ type TransactionResultGet = { /** * The type of operation who's result is being returned. */ operation: 'get'; columns?: TransactionResultColumns; }; /** * An ordered array of results from the submitted operations. */ type TransactionSuccess = { results: (TransactionResultInsert | TransactionResultUpdate | TransactionResultDelete | TransactionResultGet)[]; }; /** * An error message from a failing transaction operation */ type TransactionError = { /** * The index of the failing operation */ index: number; /** * The error message */ message: string; }; /** * An array of errors, with indices, from the transaction. */ type TransactionFailure = { /** * The request ID. */ id: string; /** * An array of errors from the submitted operations. */ errors: TransactionError[]; }; /** * Object column value */ type ObjectValue = { [key: string]: string | boolean | number | string[] | number[] | DateTime$1 | ObjectValue; }; /** * Unique file identifier * * @maxLength 255 * @minLength 1 * @pattern [a-zA-Z0-9_-~:]+ */ type FileItemID = string; /** * File name * * @maxLength 1024 * @minLength 0 * @pattern [0-9a-zA-Z!\-_\.\*'\(\)]* */ type FileName = string; /** * Media type * * @maxLength 255 * @minLength 3 * @pattern ^\w+/[-+.\w]+$ */ type MediaType = string; /** * Object representing a file in an array */ type InputFileEntry = { id?: FileItemID; name?: FileName; mediaType?: MediaType; /** * Base64 encoded content * * @maxLength 20971520 */ base64Content?: string; /** * Enable public access to the file */ enablePublicUrl?: boolean; /** * Time to live for signed URLs */ signedUrlTimeout?: number; /** * Time to live for upload URLs */ uploadUrlTimeout?: number; }; /** * Array of file entries * * @maxItems 50 */ type InputFileArray = InputFileEntry[]; /** * Object representing a file * * @x-go-type file.InputFile */ type InputFile = { name: FileName; mediaType?: MediaType; /** * Base64 encoded content * * @maxLength 20971520 */ base64Content?: string; /** * Enable public access to the file */ enablePublicUrl?: boolean; /** * Time to live for signed URLs */ signedUrlTimeout?: number; /** * Time to live for upload URLs */ uploadUrlTimeout?: number; }; /** * Xata input record */ type DataInputRecord = { [key: string]: RecordID | string | boolean | number | string[] | number[] | DateTime$1 | ObjectValue | InputFileArray | InputFile | null; }; /** * Xata Table Record Metadata */ type RecordMeta = { id: RecordID; xata: { /** * The record's version. Can be used for optimistic concurrency control. */ version: number; /** * The time when the record was created. */ createdAt?: string; /** * The time when the record was last updated. */ updatedAt?: string; /** * The record's table name. APIs that return records from multiple tables will set this field accordingly. */ table?: string; /** * Highlights of the record. This is used by the search APIs to indicate which fields and parts of the fields have matched the search. */ highlight?: { [key: string]: string[] | { [key: string]: any; }; }; /** * The record's relevancy score. This is returned by the search APIs. */ score?: number; /** * Encoding/Decoding errors */ warnings?: string[]; }; } | { xata_id: RecordID; /** * The record's version. Can be used for optimistic concurrency control. */ xata_version: number; /** * The time when the record was created. */ xata_createdat?: string; /** * The time when the record was last updated. */ xata_updatedat?: string; /** * The record's table name. APIs that return records from multiple tables will set this field accordingly. */ xata_table?: string; /** * Highlights of the record. This is used by the search APIs to indicate which fields and parts of the fields have matched the search. */ xata_highlight?: { [key: string]: string[] | { [key: string]: any; }; }; /** * The record's relevancy score. This is returned by the search APIs. */ xata_score?: number; /** * Encoding/Decoding errors */ xata_warnings?: string[]; }; /** * File metadata */ type FileResponse = { id?: FileItemID; name: FileName; mediaType: MediaType; /** * Enable public access to the file */ enablePublicUrl: boolean; /** * Time to live for signed URLs */ signedUrlTimeout: number; /** * Time to live for signed URLs */ uploadUrlTimeout: number; /** * @format int64 */ size: number; /** * @format int64 */ version: number; /** * File access URL * * @format uri */ url: string; /** * Signed file access URL * * @format uri */ signedUrl: string; /** * Upload file URL * * @format uri */ uploadUrl: string; attributes?: Record<string, any>; }; type QueryColumnsProjection = (string | ProjectionConfig)[]; /** * A structured projection that allows for some configuration. */ type ProjectionConfig = { /** * The name of the column to project or a reverse link specification, see [API Guide](https://xata.io/docs/concepts/data-model#links-and-relations). */ name?: string; columns?: QueryColumnsProjection; /** * An alias for the projected field, this is how it will be returned in the response. */ as?: string; sort?: SortExpression; /** * @default 20 */ limit?: number; /** * @default 0 */ offset?: number; }; /** * The target expression is used to filter the search results by the target columns. */ type TargetExpression = (string | { /** * The name of the column. */ column: string; /** * The weight of the column. * * @default 1 * @maximum 10 * @minimum 1 */ weight?: number; })[]; /** * Boost records with a particular value for a column. */ type ValueBooster$1 = { /** * The column in which to look for the value. */ column: string; /** * The exact value to boost. */ value: string | number | boolean; /** * The factor with which to multiply the added boost. */ factor: number; /** * Only apply this booster to the records for which the provided filter matches. */ ifMatchesFilter?: FilterExpression; }; /** * Boost records based on the value of a numeric column. */ type NumericBooster$1 = { /** * The column in which to look for the value. */ column: string; /** * The factor with which to multiply the value of the column before adding it to the item score. */ factor: number; /** * Modifier to be applied to the column value, before being multiplied with the factor. The possible values are: * - none (default). * - log: common logarithm (base 10) * - log1p: add 1 then take the common logarithm. This ensures that the value is positive if the * value is between 0 and 1. * - ln: natural logarithm (base e) * - ln1p: add 1 then take the natural logarithm. This ensures that the value is positive if the * value is between 0 and 1. * - square: raise the value to the power of two. * - sqrt: take the square root of the value. * - reciprocal: reciprocate the value (if the value is `x`, the reciprocal is `1/x`). */ modifier?: 'none' | 'log' | 'log1p' | 'ln' | 'ln1p' | 'square' | 'sqrt' | 'reciprocal'; /** * Only apply this booster to the records for which the provided filter matches. */ ifMatchesFilter?: FilterExpression; }; /** * Boost records based on the value of a datetime column. It is configured via "origin", "scale", and "decay". The further away from the "origin", * the more the score is decayed. The decay function uses an exponential function. For example if origin is "now", and scale is 10 days and decay is 0.5, it * should be interpreted as: a record with a date 10 days before/after origin will be boosted 2 times less than a record with the date at origin. * The result of the exponential function is a boost between 0 and 1. The "factor" allows you to control how impactful this boost is, by multiplying it with a given value. */ type DateBooster$1 = { /** * The column in which to look for the value. */ column: string; /** * The datetime (formatted as RFC3339) from where to apply the score decay function. The maximum boost will be applied for records with values at this time. * If it is not specified, the current date and time is used. */ origin?: string; /** * The duration at which distance from origin the score is decayed with factor, using an exponential function. It is formatted as number + units, for example: `5d`, `20m`, `10s`. * * @pattern ^(\d+)(d|h|m|s|ms)$ */ scale: string; /** * The decay factor to expect at "scale" distance from the "origin". */ decay: number; /** * The factor with which to multiply the added boost. * * @minimum 0 */ factor?: number; /** * Only apply this booster to the records for which the provided filter matches. */ ifMatchesFilter?: FilterExpression; }; /** * Booster Expression * * @x-go-type xata.BoosterExpression */ type BoosterExpression = { valueBooster?: ValueBooster$1; } | { numericBooster?: NumericBooster$1; } | { dateBooster?: DateBooster$1; }; /** * Maximum [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) for the search terms. The Levenshtein * distance is the number of one character changes needed to make two strings equal. The default is 1, meaning that single * character typos per word are tolerated by search. You can set it to 0 to remove the typo tolerance or set it to 2 * to allow two typos in a word. * * @default 1 * @maximum 2 * @minimum 0 */ type FuzzinessExpression = number; /** * If the prefix type is set to "disabled" (the default), the search only matches full words. If the prefix type is set to "phrase", the search will return results that match prefixes of the search phrase. */ type PrefixExpression = 'phrase' | 'disabled'; type HighlightExpression = { /** * Set to `false` to disable highlighting. By default it is `true`. */ enabled?: boolean; /** * Set to `false` to disable HTML encoding in highlight snippets. By default it is `true`. */ encodeHTML?: boolean; }; /** * Pagination settings for the search endpoints. */ type SearchPageConfig = { /** * Set page size. * * @default 25 * @maximum 200 */ size?: number; /** * Use offset to skip entries. To skip pages set offset to a multiple of size. * * @default 0 * @maximum 800 */ offset?: number; }; /** * A summary expression is the description of a single summary operation. It consists of a single * key representing the operation, and a value representing the column to be operated on. * * The column being summarized cannot be an internal column (id, xata.*), nor the base of * an object, i.e. if `settings` is an object with `dark_mode` as a field, you may summarize * `settings.dark_mode` but not `settings` nor `settings.*`. * * We currently support several aggregation functions. Not all functions can be run on all column * types. * * - `count` is used to count the number of records in each group. Use `{"count": "*"}` to count * all columns present, otherwise `{"count": "<column_path>"}` to count the number of non-null * values are present at column path. * * Count can be used on any column type, and always returns an int. * * - `min` calculates the minimum value in each group. `min` is compatible with most types; * string, multiple, text, email, int, float, and datetime. It returns a value of the same * type as operated on. This means that `{"lowest_latency": {"min": "latency"}}` where * `latency` is an int, will always return an int. * * - `max` calculates the maximum value in each group. `max` shares the same compatibility as * `min`. * * - `sum` adds up all values in a group. `sum` can be run on `int` and `float` types, and will * return a value of the same type as requested. * * - `average` averages all values in a group. `average` can be run on `int` and `float` types, and * always returns a float. * * @example {"count":"deleted_at"} * @x-go-type xbquery.Summary */ type SummaryExpression = Record<string, any>; /** * The description of the summaries you wish to receive. Set each key to be the field name * you'd like for the summary. These names must not collide with other columns you've * requested from `columns`; including implicit requests like `settings.*`. * * The value for each key needs to be an object. This object should contain one key and one * value only. In this object, the key should be set to the summary function you wish to use * and the value set to the column name to be summarized. * * The column being summarized cannot be an internal column (id, xata.*), nor the base of * an object, i.e. if `settings` is an object with `dark_mode` as a field, you may summarize * `settings.dark_mode` but not `settings` nor `settings.*`. * * @example {"all_users":{"count":"*"},"total_created":{"count":"created_at"},"min_cost":{"min":"cost"},"max_happiness":{"max":"happiness"},"total_revenue":{"sum":"revenue"},"average_speed":{"average":"speed"}} * @x-go-type xbquery.SummaryList */ type SummaryExpressionList = { [key: string]: SummaryExpression; }; /** * Count the number of records with an optional filter. */ type CountAgg = { filter?: FilterExpression; } | '*'; /** * The sum of the numeric values in a particular column. */ type SumAgg = { /** * The column on which to compute the sum. Must be a numeric type. */ column: string; }; /** * The max of the numeric values in a particular column. */ type MaxAgg = { /** * The column on which to compute the max. Must be a numeric type. */ column: string; }; /** * The min of the numeric values in a particular column. */ type MinAgg = { /** * The column on which to compute the min. Must be a numeric type. */ column: string; }; /** * The average of the numeric values in a particular column. */ type AverageAgg = { /** * The column on which to compute the average. Must be a numeric type. */ column: string; }; /** * Calculate given percentiles of the numeric values in a particular column. */ type PercentilesAgg = { /** * The column on which to compute the average. Must be a numeric type. */ column: string; percentiles: number[]; }; /** * Count the number of distinct values in a particular column. */ type UniqueCountAgg = { /** * The column from where to count the unique values. */ column: string; /** * The threshold under which the unique count is exact. If the number of unique * values in the column is higher than this threshold, the results are approximate. * Maximum value is 40,000, default value is 3000. */ precisionThreshold?: number; }; /** * The description of the aggregations you wish to receive. * * @example {"totalCount":{"count":"*"},"dailyActiveUsers":{"dateHistogram":{"column":"date","interval":"1d","aggs":{"uniqueUsers":{"uniqueCount":{"column":"userID"}}}}}} */ type AggExpressionMap = { [key: string]: AggExpression; }; /** * Split data into buckets by a datetime column. Accepts sub-aggregations for each bucket. */ type DateHistogramAgg = { /** * The column to use for bucketing. Must be of type datetime. */ column: string; /** * The fixed interval to use when bucketing. * It is formatted as number + units, for example: `5d`, `20m`, `10s`. * * @pattern ^(\d+)(d|h|m|s|ms)$ */ interval?: string; /** * The calendar-aware interval to use when bucketing. Possible values are: `minute`, * `hour`, `day`, `week`, `month`, `quarter`, `year`. */ calendarInterval?: 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'; /** * The timezone to use for bucketing. By default, UTC is assumed. * The accepted format is as an ISO 8601 UTC offset. For example: `+01:00` or * `-08:00`. * * @pattern ^[+-][01]\d:[0-5]\d$ */ timezone?: string; aggs?: AggExpressionMap; }; /** * Split data into buckets by the unique values in a column. Accepts sub-aggregations for each bucket. * The top values as ordered by the number of records (`$count`) are returned. */ type TopValuesAgg = { /** * The column to use for bucketing. Accepted types are `string`, `email`, `int`, `float`, or `bool`. */ column: string; aggs?: AggExpressionMap; /** * The maximum number of unique values to return. * * @default 10 * @maximum 1000 */ size?: number; }; /** * Split data into buckets by dynamic numeric ranges. Accepts sub-aggregations for each bucket. */ type NumericHistogramAgg = { /** * The column to use for bucketing. Must be of numeric type. */ column: string; /** * The numeric interval to use for bucketing. The resulting buckets will be ranges * with this value as size. * * @minimum 0 */ interval: number; /** * By default the bucket keys start with 0 and then continue in `interval` steps. The bucket * boundaries can be shifted by using the offset option. For example, if the `interval` is 100, * but you prefer the bucket boundaries to be `[50, 150), [150, 250), etc.`, you can set `offset` * to 50. * * @default 0 */ offset?: number; aggs?: AggExpressionMap; }; /** * The description of a single aggregation operation. It is an object with only one key-value pair. * The key represents the aggregation type, while the value is an object with the configuration of * the aggregation. * * @x-go-type xata.AggExpression */ type AggExpression = { count?: CountAgg; } | { sum?: SumAgg; } | { max?: MaxAgg; } | { min?: MinAgg; } | { average?: AverageAgg; } | { percentiles?: PercentilesAgg; } | { uniqueCount?: UniqueCountAgg; } | { dateHistogram?: DateHistogramAgg; } | { topValues?: TopValuesAgg; } | { numericHistogram?: NumericHistogramAgg; }; type AggResponse$1 = (number | null) | { values: ({ $key: string | number; $count: number; } & { [key: string]: AggResponse$1; })[] | { [key: string]: number; }; }; /** * File identifier in access URLs * * @maxLength 296 * @minLength 88 * @pattern [a-v0-9=]+ */ type FileAccessID = string; /** * File signature */ type FileSignature = string; /** * Xata Table SQL Record */ type SQLRecord = { [key: string]: any; }; /** * @default strong */ type SQLConsistency = 'strong' | 'eventual'; /** * @default json */ type SQLResponseType$1 = 'json' | 'array'; type PreparedStatement = { /** * The SQL statement. * * @minLength 1 */ statement: string; /** * The query parameter list. * * @x-go-type []any */ params?: any[] | null; }; type SQLResponseBase = { /** * Name of the column and its PostgreSQL type * * @x-go-type []sqlproxy.ColumnMeta */ columns: { name: string; type: string; }[]; /** * Number of selected columns */ total: number; warning?: string; }; type SQLResponseJSON = SQLResponseBase & { /** * @x-go-type []xata.Record */ records: SQLRecord[]; }; type SQLResponseArray = SQLResponseBase & { /** * @x-go-type []xata.Row */ rows: any[][]; }; type SQLResponse$1 = SQLResponseJSON | SQLResponseArray; /** * Xata Table Record Metadata */ type XataRecord$1 = RecordMeta & { [key: string]: any; }; /** * Generated by @openapi-codegen * * @version 1.0 */ type BadRequestError$1 = { id?: string; message: string; }; /** * @example {"message":"invalid API key"} */ type AuthError$1 = { id?: string; message: string; }; type SimpleError$1 = { id?: string; message: string; }; type BranchMigrationPlan = { version: number; migration: BranchMigration; }; type SchemaUpdateResponse = { /** * @minLength 1 */ migrationID: string; parentMigrationID: string; status: MigrationStatus$1; }; type SchemaCompareResponse = { source: Schema; target: Schema; edits: SchemaEditScript; }; type RateLimitError = { id?: string; message: string; }; type RecordUpdateResponse = XataRecord$1 | { id: string; xata: { version: number; createdAt: string; updatedAt: string; }; } | { xata_id: string; xata_version: number; xata_createdat: string; xata_updatedat: string; }; type PutFileResponse = FileResponse; type RecordResponse = XataRecord$1; type BulkInsertResponse = { recordIDs: string[]; } | { records: XataRecord$1[]; }; type BulkError = { errors: { message?: string; status?: number; }[]; }; type QueryResponse = { records: XataRecord$1[]; meta: RecordsMetadata; }; type ServiceUnavailableError = { id?: string; message: string; }; type SearchResponse = { records: XataRecord$1[]; warning?: string; /** * The total count of records matched. It will be accurately returned up to 10000 records. */ totalCount: number; }; type SummarizeResponse = { summaries: Record<string, any>[]; }; /** * @example {"aggs":{"dailyUniqueUsers":{"values":[{"$count":321,"$key":"2022-02-22T22:22:22Z","uniqueUsers":134},{"$count":202,"$key":"2022-02-23T22:22:22Z","uniqueUsers":90}]}}} */ type AggResponse = { aggs?: { [key: string]: AggResponse$1; }; }; type SQLResponse = SQLResponse$1; type SQLBatchResponse = { results: SQLResponse$1[]; }; /** * Generated by @openapi-codegen * * @version 1.0 */ type OAuthResponseType = 'code'; type OAuthScope = 'admin:all'; type AuthorizationCodeResponse = { state?: string; redirectUri?: string; scopes?: OAuthScope[]; clientId?: string; /** * @format date-time */ expires?: string; code?: string; }; type AuthorizationCodeRequest = { state?: string; redirectUri?: string; scopes?: OAuthScope[]; clientId: string; responseType: OAuthResponseType; }; type User = { /** * @format email */ email: string; fullname: string; image: string; }; /** * @pattern [a-zA-Z0-9_-~:]+ */ type UserID = string; type UserWithID = User & { id: UserID; }; /** * @format date-time * @x-go-type string */ type DateTime = string; /** * @pattern [a-zA-Z0-9_\-~]* */ type APIKeyName = string; type OAuthClientPublicDetails = { name?: string; description?: string; icon?: string; clientId: string; }; type OAuthClientID = string; type OAuthAccessToken = { token: string; scopes: string[]; /** * @format date-time */ createdAt: string; /** * @format date-time */ updatedAt: string; /** * @format dat