diff --git a/packages/client/src/api/dataPlaneComponents.ts b/packages/client/src/api/dataPlaneComponents.ts index e82b51c71..d68aadade 100644 --- a/packages/client/src/api/dataPlaneComponents.ts +++ b/packages/client/src/api/dataPlaneComponents.ts @@ -60,6 +60,49 @@ export const applyMigration = (variables: ApplyMigrationVariables, signal?: Abor ApplyMigrationPathParams >({ url: '/db/{dbBranchName}/pgroll/apply', method: 'post', ...variables, signal }); +export type AdaptTablePathParams = { + /** + * The DBBranchName matches the pattern `{db_name}:{branch_name}`. + */ + dbBranchName: Schemas.DBBranchName; + /** + * The Table name + */ + tableName: Schemas.TableName; + workspace: string; + region: string; +}; + +export type AdaptTableError = Fetcher.ErrorWrapper< + | { + status: 400; + payload: Responses.BadRequestError; + } + | { + status: 401; + payload: Responses.AuthError; + } + | { + status: 404; + payload: Responses.SimpleError; + } +>; + +export type AdaptTableVariables = { + pathParams: AdaptTablePathParams; +} & DataPlaneFetcherExtraProps; + +/** + * Adapt a table to be used from Xata, this will add the Xata metadata fields to the table, making it accessible through the data API. + */ +export const adaptTable = (variables: AdaptTableVariables, signal?: AbortSignal) => + dataPlaneFetch({ + url: '/db/{dbBranchName}/pgroll/adapt/{tableName}', + method: 'post', + ...variables, + signal + }); + export type PgRollStatusPathParams = { /** * The DBBranchName matches the pattern `{db_name}:{branch_name}`. @@ -4638,6 +4681,7 @@ export const sqlQuery = (variables: SqlQueryVariables, signal?: AbortSignal) => export const operationsByTag = { branch: { applyMigration, + adaptTable, pgRollStatus, pgRollJobStatus, pgRollMigrationHistory, diff --git a/packages/client/src/api/dataPlaneParameters.ts b/packages/client/src/api/dataPlaneParameters.ts index 9842d6b4c..056b55095 100644 --- a/packages/client/src/api/dataPlaneParameters.ts +++ b/packages/client/src/api/dataPlaneParameters.ts @@ -7,6 +7,8 @@ import type * as Schemas from './dataPlaneSchemas'; export type DBBranchNameParam = Schemas.DBBranchName; +export type TableNameParam = Schemas.TableName; + export type PgRollMigrationJobIDParam = Schemas.PgRollMigrationJobID; export type DBNameParam = Schemas.DBName; @@ -15,8 +17,6 @@ export type MigrationRequestNumberParam = Schemas.MigrationRequestNumber; export type BranchNameParam = Schemas.BranchName; -export type TableNameParam = Schemas.TableName; - export type ColumnNameParam = Schemas.ColumnName; export type ColumnsProjectionParam = Schemas.ColumnsProjection; diff --git a/packages/client/src/api/dataPlaneSchemas.ts b/packages/client/src/api/dataPlaneSchemas.ts index a3f5b2969..0fd08cf9c 100644 --- a/packages/client/src/api/dataPlaneSchemas.ts +++ b/packages/client/src/api/dataPlaneSchemas.ts @@ -19,6 +19,13 @@ export type PgRollApplyMigrationResponse = { jobID: string; }; +/** + * @maxLength 255 + * @minLength 1 + * @pattern [a-zA-Z0-9_\-~]+ + */ +export type TableName = string; + export type PgRollJobType = 'apply' | 'start' | 'complete' | 'rollback'; export type PgRollJobStatus = 'pending' | 'in_progress' | 'completed' | 'failed'; @@ -147,13 +154,6 @@ export type StartedFromMetadata = { migrationID: string; }; -/** - * @maxLength 255 - * @minLength 1 - * @pattern [a-zA-Z0-9_\-~]+ - */ -export type TableName = string; - export type ColumnLink = { table: string; }; @@ -236,15 +236,13 @@ export type DBBranch = { export type MigrationStatus = 'completed' | 'pending' | 'failed'; -/** - * @x-go-type schema.Schema - */ export type PgRollSchema = { name: string; tables: { [key: string]: { oid: string; name: string; + xataCompatible: boolean; comment: string; columns: { [key: string]: {