@postgres.ai/shared 4.0.1-pr-1054.10 → 4.0.1-pr-1059.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postgres.ai/shared",
3
- "version": "4.0.1-pr-1054.10",
3
+ "version": "4.0.1-pr-1059.1",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "peerDependencies": {
@@ -92,8 +92,8 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
92
92
  }
93
93
  });
94
94
  };
95
- const fetchSnapshots = async (branchName) => {
96
- await getSnapshots(instanceId, branchName).then((response) => {
95
+ const fetchSnapshots = async (branchName, dataset) => {
96
+ await getSnapshots(instanceId, branchName, dataset).then((response) => {
97
97
  var _a;
98
98
  if (response) {
99
99
  setBranchSnapshots(response);
@@ -103,14 +103,22 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
103
103
  };
104
104
  const handleParentBranchChange = async (e) => {
105
105
  const branchName = e.target.value;
106
+ const selectedBranch = branchesList === null || branchesList === void 0 ? void 0 : branchesList.find((b) => b.name === branchName);
107
+ const dataset = selectedBranch === null || selectedBranch === void 0 ? void 0 : selectedBranch.baseDataset;
106
108
  formik.setFieldValue('baseBranch', branchName);
107
- await fetchSnapshots(branchName);
109
+ await fetchSnapshots(branchName, dataset);
108
110
  };
109
111
  const [{ formik }] = useForm(handleSubmit);
110
112
  useEffect(() => {
111
113
  load(instanceId);
112
- fetchSnapshots(formik.values.baseBranch);
113
- }, [formik.values.baseBranch]);
114
+ }, [instanceId]);
115
+ useEffect(() => {
116
+ if (!(branchesList === null || branchesList === void 0 ? void 0 : branchesList.length))
117
+ return;
118
+ const selected = branchesList.find(b => b.name === formik.values.baseBranch);
119
+ const dataset = selected === null || selected === void 0 ? void 0 : selected.baseDataset;
120
+ fetchSnapshots(formik.values.baseBranch, dataset);
121
+ }, [branchesList, formik.values.baseBranch]);
114
122
  if (isBranchesLoading) {
115
123
  return _jsx(StubSpinner, {});
116
124
  }
@@ -118,9 +126,12 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
118
126
  shrink: true,
119
127
  }, value: formik.values.branchName, error: Boolean(formik.errors.branchName), helperText: formik.errors.branchName, className: classes.marginBottom, onChange: (e) => formik.setFieldValue('branchName', e.target.value) }), _jsx("p", { className: cn(classes.marginTop, classes.marginBottom), children: "Choose an existing branch. The new branch will initially point at the same snapshot as the parent branch but going further, their evolution paths will be independent - new snapshots can be created for both branches." }), _jsx(Select, { fullWidth: true, label: "Parent branch", value: formik.values.baseBranch, disabled: !branchesList || formik.isSubmitting, onChange: handleParentBranchChange, error: Boolean(formik.errors.baseBranch), items: branchesList
120
128
  ? branchesList.map((branch) => {
129
+ const displayName = branch.dataset
130
+ ? `${branch.name} (${branch.dataset})`
131
+ : branch.name;
121
132
  return {
122
133
  value: branch.name,
123
- children: branch.name,
134
+ children: displayName,
124
135
  };
125
136
  })
126
137
  : [] }), _jsx("strong", { children: "Snapshot ID" }), _jsx("p", { className: cn(classes.marginTop, classes.marginBottom), children: "Choose an existing snapshot. This snapshot will be memorized as a forking point for the new branch; it cannot be deleted while the branch exists." }), _jsx(Select, { fullWidth: true, className: classes.marginBottom2x, label: "Snapshot ID", value: formik.values.snapshotID, disabled: !branchesList || formik.isSubmitting, onChange: (e) => formik.setFieldValue('snapshotID', e.target.value), error: Boolean(formik.errors.baseBranch), items: branchSnapshots
@@ -25,7 +25,7 @@ export declare class MainStore {
25
25
  load: (instanceId: string) => Promise<void>;
26
26
  createBranch: (values: CreateBranchFormValues) => Promise<import("../../../types/api/entities/createBranch").CreateBranchDTO | null | undefined>;
27
27
  getBranches: (instanceId: string) => Promise<Branch[] | null | undefined>;
28
- getSnapshots: (instanceId: string, branchName?: string) => Promise<{
28
+ getSnapshots: (instanceId: string, branchName?: string, dataset?: string) => Promise<{
29
29
  createdAtDate: Date;
30
30
  dataStateAtDate: Date;
31
31
  numClones: string | number;
@@ -41,12 +41,13 @@ export class MainStore {
41
41
  this.getBranchesError = await error.json().then((err) => err);
42
42
  return response;
43
43
  };
44
- this.getSnapshots = async (instanceId, branchName) => {
44
+ this.getSnapshots = async (instanceId, branchName, dataset) => {
45
45
  if (!this.api.getSnapshots)
46
46
  return;
47
47
  const { response, error } = await this.api.getSnapshots({
48
48
  instanceId,
49
49
  branchName,
50
+ dataset,
50
51
  });
51
52
  if (error) {
52
53
  this.snapshotsError = await error.json().then((err) => err);
@@ -15,6 +15,7 @@ const dockerImagesConfig = {
15
15
  '15': ['0.5.3', '0.5.2', '0.5.1'],
16
16
  '16': ['0.5.3', '0.5.2', '0.5.1'],
17
17
  '17': ['0.5.3', '0.5.2', '0.5.1'],
18
+ '18': ['0.6.1'],
18
19
  };
19
20
  export const uniqueChipValue = (values) => {
20
21
  const splitChipArray = values.split(/[,(\s)(\n)(\r)(\t)(\r\n)]/);
@@ -119,7 +120,7 @@ export const postUniqueCustomOptions = (options) => {
119
120
  };
120
121
  export const customOrGenericImage = (dockerImage) => dockerImage === 'Generic Postgres' || dockerImage === 'custom';
121
122
  export const createFallbackDockerImage = (dockerPath, dockerTag) => {
122
- const majorVersion = getImageMajorVersion(dockerPath) || '17'; // Default to 17 if version can't be extracted
123
+ const majorVersion = getImageMajorVersion(dockerPath) || '18'; // Default to 18 if version can't be extracted
123
124
  return {
124
125
  package_group: 'postgresai',
125
126
  pg_major_version: majorVersion,
@@ -1,15 +1,19 @@
1
1
  export interface Branch {
2
2
  name: string;
3
+ baseDataset: string;
3
4
  parent: string;
4
5
  dataStateAt: string;
5
6
  snapshotID: string;
7
+ dataset: string;
6
8
  numSnapshots: number;
7
9
  }
8
10
  export declare const formatBranchesDto: (dto: Branch[]) => {
9
11
  dataStateAt: string;
10
12
  name: string;
13
+ baseDataset: string;
11
14
  parent: string;
12
15
  snapshotID: string;
16
+ dataset: string;
13
17
  numSnapshots: number;
14
18
  }[];
15
19
  export declare type GetBranches = (instanceId: string) => Promise<{
@@ -2,6 +2,7 @@ import { Snapshot } from '@postgres.ai/shared/types/api/entities/snapshot';
2
2
  export declare type GetSnapshots = (args: {
3
3
  instanceId: string;
4
4
  branchName?: string;
5
+ dataset?: string;
5
6
  }) => Promise<{
6
7
  response: Snapshot[] | null;
7
8
  error: Response | null;