Skip to content

Commit

Permalink
[OpenAPI] Spec updates (#1379)
Browse files Browse the repository at this point in the history
Co-authored-by: exekias <[email protected]>
  • Loading branch information
xata-bot and exekias authored Feb 21, 2024
1 parent b3adb3c commit 7c9422f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 12 deletions.
44 changes: 44 additions & 0 deletions packages/client/src/api/dataPlaneComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Schemas.PgRollApplyMigrationResponse, AdaptTableError, undefined, {}, {}, AdaptTablePathParams>({
url: '/db/{dbBranchName}/pgroll/adapt/{tableName}',
method: 'post',
...variables,
signal
});

export type PgRollStatusPathParams = {
/**
* The DBBranchName matches the pattern `{db_name}:{branch_name}`.
Expand Down Expand Up @@ -4638,6 +4681,7 @@ export const sqlQuery = (variables: SqlQueryVariables, signal?: AbortSignal) =>
export const operationsByTag = {
branch: {
applyMigration,
adaptTable,
pgRollStatus,
pgRollJobStatus,
pgRollMigrationHistory,
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/api/dataPlaneParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
18 changes: 8 additions & 10 deletions packages/client/src/api/dataPlaneSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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]: {
Expand Down

0 comments on commit 7c9422f

Please sign in to comment.