Skip to content

Commit

Permalink
chore: upgrade to latest api-client (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
knz authored Dec 17, 2024
1 parent d6f4f7b commit 2fddb81
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 42 deletions.
Binary file modified bun.lockb
Binary file not shown.
14 changes: 8 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"vitest": "^1.6.0"
},
"dependencies": {
"@neondatabase/api-client": "1.10.0",
"@neondatabase/api-client": "1.11.1",
"@segment/analytics-node": "^1.0.0-beta.26",
"axios": "^1.4.0",
"axios-debug-log": "^1.0.0",
Expand Down
4 changes: 3 additions & 1 deletion src/commands/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ async function deployApp({
}) {
let {
data: { branches },
} = await props.apiClient.listProjectBranches(project.id);
} = await props.apiClient.listProjectBranches({
projectId: project.id,
});

branches = branches.filter((branch) => branch.name !== devBranchName);

Expand Down
6 changes: 4 additions & 2 deletions src/commands/branches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ export const handler = (args: yargs.Argv) => {
};

const list = async (props: ProjectScopeProps) => {
const { data } = await props.apiClient.listProjectBranches(props.projectId);
const { data } = await props.apiClient.listProjectBranches({
projectId: props.projectId,
});
writer(props).end(data.branches, {
fields: BRANCH_FIELDS,
});
Expand All @@ -278,7 +280,7 @@ const create = async (
},
) => {
const branches = await props.apiClient
.listProjectBranches(props.projectId)
.listProjectBranches({ projectId: props.projectId })
.then(({ data }) => data.branches);

const parentProps = (() => {
Expand Down
13 changes: 6 additions & 7 deletions src/commands/schema_diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ const fetchSchema = async (
projectId: props.projectId,
branchId: pointInTime.branchId,
db_name: database.name,
role: database.owner_name,
...pointInTimeParams(pointInTime),
})
.then((response) => response.data.sql ?? '');
Expand Down Expand Up @@ -188,9 +187,9 @@ export const parseSchemaDiffParams = async (props: SchemaDiffProps) => {
props.compareSource = props.baseBranch;
props.baseBranch = props.branch;
} else if (props.branch) {
const { data } = await props.apiClient.listProjectBranches(
props.projectId,
);
const { data } = await props.apiClient.listProjectBranches({
projectId: props.projectId,
});
const contextBranch = data.branches.find(
(b) => b.id === props.branch || b.name === props.branch,
);
Expand All @@ -206,9 +205,9 @@ export const parseSchemaDiffParams = async (props: SchemaDiffProps) => {
);
props.compareSource = '^parent';
} else {
const { data } = await props.apiClient.listProjectBranches(
props.projectId,
);
const { data } = await props.apiClient.listProjectBranches({
projectId: props.projectId,
});
const defaultBranch = data.branches.find((b) => b.default);

if (defaultBranch?.parent_id == undefined) {
Expand Down
93 changes: 70 additions & 23 deletions src/parameters.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,34 @@ export const projectCreateRequest = {
description: "If true, the list will be applied only to protected branches.",
demandOption: false,
},
'project.settings.allowed_ips.primary_branch_only': {
'project.settings.enable_logical_replication': {
type: "boolean",
description: "DEPRECATED: Use `protected_branches_only`.\nIf true, the list will be applied only to the default branch.\n",
description: "Sets wal_level=logical for all compute endpoints in this project.\nAll active endpoints will be suspended.\nOnce enabled, logical replication cannot be disabled.\n",
demandOption: false,
},
'project.settings.enable_logical_replication': {
'project.settings.maintenance_window.weekdays': {
type: "array",
description: "A list of weekdays when the maintenance window is active.\nEncoded as ints, where 1 - Monday, and 7 - Sunday.\n",
demandOption: true,
},
'project.settings.maintenance_window.start_time': {
type: "string",
description: "Start time of the maintenance window, in the format of \"HH:MM\". Uses UTC.\n",
demandOption: true,
},
'project.settings.maintenance_window.end_time': {
type: "string",
description: "End time of the maintenance window, in the format of \"HH:MM\". Uses UTC.\n",
demandOption: true,
},
'project.settings.block_public_connections': {
type: "boolean",
description: "Sets wal_level=logical for all compute endpoints in this project.\nAll active endpoints will be suspended.\nOnce enabled, logical replication cannot be disabled.\n",
description: "When set, connections from the public internet\nare disallowed. This supersedes the AllowedIPs list.\n(IN DEVELOPMENT - NOT AVAILABLE YET)\n",
demandOption: false,
},
'project.settings.block_vpc_connections': {
type: "boolean",
description: "When set, connections using VPC endpoints\nare disallowed.\n(IN DEVELOPMENT - NOT AVAILABLE YET)\n",
demandOption: false,
},
'project.name': {
Expand All @@ -53,24 +73,23 @@ export const projectCreateRequest = {
},
'project.branch.name': {
type: "string",
description: "The branch name. If not specified, the default branch name will be used.\n",
description: "The default branch name. If not specified, the default branch name, `main`, will be used.\n",
demandOption: false,
},
'project.branch.role_name': {
type: "string",
description: "The role name. If not specified, the default role name will be used.\n",
description: "The role name. If not specified, the default role name, `{database_name}_owner`, will be used.\n",
demandOption: false,
},
'project.branch.database_name': {
type: "string",
description: "The database name. If not specified, the default database name will be used.\n",
description: "The database name. If not specified, the default database name, `neondb`, will be used.\n",
demandOption: false,
},
'project.provisioner': {
type: "string",
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n\nProvisioner can be one of the following values:\n* k8s-pod\n* k8s-neonvm\n\nClients must expect, that any string value that is not documented in the description above should be treated as a error. UNKNOWN value if safe to treat as an error too.\n",
demandOption: false,
choices: ["k8s-pod","k8s-neonvm"],
},
'project.region_id': {
type: "string",
Expand All @@ -84,7 +103,7 @@ export const projectCreateRequest = {
},
'project.pg_version': {
type: "number",
description: "The major Postgres version number. Currently supported versions are `14`, `15`, and `16`.",
description: "The major Postgres version number. Currently supported versions are `14`, `15`, `16`, and `17`.",
demandOption: false,
},
'project.store_passwords': {
Expand All @@ -94,7 +113,7 @@ export const projectCreateRequest = {
},
'project.history_retention_seconds': {
type: "number",
description: "The number of seconds to retain the point-in-time restore (PITR) backup history for this project.\nThe default is 604800 seconds (7 days).\n",
description: "The number of seconds to retain the shared history for all branches in this project.\nThe default is 1 day (86400 seconds).\n",
demandOption: false,
},
'project.org_id': {
Expand Down Expand Up @@ -140,14 +159,34 @@ export const projectUpdateRequest = {
description: "If true, the list will be applied only to protected branches.",
demandOption: false,
},
'project.settings.allowed_ips.primary_branch_only': {
'project.settings.enable_logical_replication': {
type: "boolean",
description: "DEPRECATED: Use `protected_branches_only`.\nIf true, the list will be applied only to the default branch.\n",
description: "Sets wal_level=logical for all compute endpoints in this project.\nAll active endpoints will be suspended.\nOnce enabled, logical replication cannot be disabled.\n",
demandOption: false,
},
'project.settings.enable_logical_replication': {
'project.settings.maintenance_window.weekdays': {
type: "array",
description: "A list of weekdays when the maintenance window is active.\nEncoded as ints, where 1 - Monday, and 7 - Sunday.\n",
demandOption: true,
},
'project.settings.maintenance_window.start_time': {
type: "string",
description: "Start time of the maintenance window, in the format of \"HH:MM\". Uses UTC.\n",
demandOption: true,
},
'project.settings.maintenance_window.end_time': {
type: "string",
description: "End time of the maintenance window, in the format of \"HH:MM\". Uses UTC.\n",
demandOption: true,
},
'project.settings.block_public_connections': {
type: "boolean",
description: "Sets wal_level=logical for all compute endpoints in this project.\nAll active endpoints will be suspended.\nOnce enabled, logical replication cannot be disabled.\n",
description: "When set, connections from the public internet\nare disallowed. This supersedes the AllowedIPs list.\n(IN DEVELOPMENT - NOT AVAILABLE YET)\n",
demandOption: false,
},
'project.settings.block_vpc_connections': {
type: "boolean",
description: "When set, connections using VPC endpoints\nare disallowed.\n(IN DEVELOPMENT - NOT AVAILABLE YET)\n",
demandOption: false,
},
'project.name': {
Expand All @@ -162,7 +201,7 @@ export const projectUpdateRequest = {
},
'project.history_retention_seconds': {
type: "number",
description: "The number of seconds to retain the point-in-time restore (PITR) backup history for this project.\nThe default is 604800 seconds (7 days).\n",
description: "The number of seconds to retain the shared history for all branches in this project.\nThe default is 1 day (604800 seconds).\n",
demandOption: false,
},
} as const;
Expand Down Expand Up @@ -198,6 +237,17 @@ export const branchCreateRequest = {
description: "Whether the branch is protected\n",
demandOption: false,
},
'branch.archived': {
type: "boolean",
description: "Whether to create the branch as archived\n",
demandOption: false,
},
'branch.schema_initialization_type': {
type: "string",
description: "The type of schema initialization. Defines how the schema is initialized, currently only empty is supported. This parameter is under\nactive development and may change its semantics in the future.\n",
demandOption: false,
choices: ["empty"],
},
} as const;

export const branchCreateRequestEndpointOptions = {
Expand All @@ -209,9 +259,8 @@ export const branchCreateRequestEndpointOptions = {
},
'provisioner': {
type: "string",
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n\nProvisioner can be one of the following values:\n* k8s-pod\n* k8s-neonvm\n\nClients must expect, that any string value that is not documented in the description above should be treated as a error. UNKNOWN value if safe to treat as an error too.\n",
demandOption: false,
choices: ["k8s-pod","k8s-neonvm"],
},
'suspend_timeout_seconds': {
type: "number",
Expand Down Expand Up @@ -252,9 +301,8 @@ export const endpointCreateRequest = {
},
'endpoint.provisioner': {
type: "string",
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n\nProvisioner can be one of the following values:\n* k8s-pod\n* k8s-neonvm\n\nClients must expect, that any string value that is not documented in the description above should be treated as a error. UNKNOWN value if safe to treat as an error too.\n",
demandOption: false,
choices: ["k8s-pod","k8s-neonvm"],
},
'endpoint.pooler_enabled': {
type: "boolean",
Expand Down Expand Up @@ -287,14 +335,13 @@ export const endpointCreateRequest = {
export const endpointUpdateRequest = {
'endpoint.branch_id': {
type: "string",
description: "The destination branch ID. The destination branch must not have an exsiting read-write endpoint.\n",
description: "DEPRECATED: This field will be removed in a future release.\nThe destination branch ID. The destination branch must not have an exsiting read-write endpoint.\n",
demandOption: false,
},
'endpoint.provisioner': {
type: "string",
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n",
description: "The Neon compute provisioner.\nSpecify the `k8s-neonvm` provisioner to create a compute endpoint that supports Autoscaling.\n\nProvisioner can be one of the following values:\n* k8s-pod\n* k8s-neonvm\n\nClients must expect, that any string value that is not documented in the description above should be treated as a error. UNKNOWN value if safe to treat as an error too.\n",
demandOption: false,
choices: ["k8s-pod","k8s-neonvm"],
},
'endpoint.pooler_enabled': {
type: "boolean",
Expand Down
8 changes: 6 additions & 2 deletions src/utils/enrichers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export const branchIdResolve = async ({
return branch;
}

const { data } = await apiClient.listProjectBranches(projectId);
const { data } = await apiClient.listProjectBranches({
projectId,
});
const branchData = data.branches.find((b) => b.name === branch);
if (!branchData) {
throw new Error(
Expand All @@ -41,7 +43,9 @@ export const branchIdFromProps = async (props: BranchScopeProps) => {
});
}

const { data } = await props.apiClient.listProjectBranches(props.projectId);
const { data } = await props.apiClient.listProjectBranches({
projectId: props.projectId,
});
const defaultBranch = data.branches.find((b) => b.default);

if (defaultBranch) {
Expand Down

0 comments on commit 2fddb81

Please sign in to comment.