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

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",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "peerDependencies": {
@@ -77,7 +77,7 @@ export const BranchesTable = ({ branches, emptyTableText, deleteBranch, branches
77
77
  if (!state.branches.length) {
78
78
  return _jsx("p", { className: classes.marginTop, children: emptyTableText });
79
79
  }
80
- return (_jsx(HorizontalScrollContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableHeaderCell, {}), _jsx(TableHeaderCell, { children: "Branch" }), _jsx(TableHeaderCell, { children: _jsxs("div", { onClick: handlesortByParent, className: cn(classes.interactiveRow, classes.verticalCentered), children: ["Parent", _jsx(ArrowDropDownIcon, { className: cn(state.sortByParent === 'asc' && classes.sortIconUp, classes.sortIcon) })] }) }), _jsx(TableHeaderCell, { children: "Data state time" }), _jsx(TableHeaderCell, { children: "Latest Snapshot ID" }), _jsx(TableHeaderCell, { children: "Number of snapshots" })] }) }), _jsx(TableBody, { children: (_a = state.branches) === null || _a === void 0 ? void 0 : _a.map((branch) => {
80
+ return (_jsx(HorizontalScrollContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableHeaderCell, {}), _jsx(TableHeaderCell, { children: "Branch" }), _jsx(TableHeaderCell, { children: "Dataset" }), _jsx(TableHeaderCell, { children: _jsxs("div", { onClick: handlesortByParent, className: cn(classes.interactiveRow, classes.verticalCentered), children: ["Parent", _jsx(ArrowDropDownIcon, { className: cn(state.sortByParent === 'asc' && classes.sortIconUp, classes.sortIcon) })] }) }), _jsx(TableHeaderCell, { children: "Data state time" }), _jsx(TableHeaderCell, { children: "Latest Snapshot ID" }), _jsx(TableHeaderCell, { children: "Number of snapshots" })] }) }), _jsx(TableBody, { children: (_a = state.branches) === null || _a === void 0 ? void 0 : _a.map((branch) => {
81
81
  const branchPagePath = host.routes.branch(branch.name);
82
82
  return (_jsxs(TableRow, { hover: true, onClick: () => history.push(branchPagePath), className: classes.pointerCursor, children: [_jsx(TableBodyCellMenu, { actions: [
83
83
  {
@@ -91,7 +91,7 @@ export const BranchesTable = ({ branches, emptyTableText, deleteBranch, branches
91
91
  setIsOpenDestroyModal(true);
92
92
  },
93
93
  },
94
- ] }), _jsx(TableBodyCell, { children: branch.name }), _jsx(TableBodyCell, { children: branch.parent }), _jsx(TableBodyCell, { children: formatDateWithDistance(branch.dataStateAt, new Date(branch.dataStateAt)) }), _jsx(TableBodyCell, { children: branch.snapshotID }), _jsx(TableBodyCell, { children: branch.numSnapshots })] }, branch.name));
94
+ ] }), _jsx(TableBodyCell, { children: branch.name }), _jsx(TableBodyCell, { children: branch.dataset }), _jsx(TableBodyCell, { children: branch.parent }), _jsx(TableBodyCell, { children: formatDateWithDistance(branch.dataStateAt, new Date(branch.dataStateAt)) }), _jsx(TableBodyCell, { children: branch.snapshotID }), _jsx(TableBodyCell, { children: branch.numSnapshots })] }, branch.name));
95
95
  }) }), _jsx(DeleteBranchModal, { isOpen: isOpenDestroyModal, onClose: () => {
96
96
  setIsOpenDestroyModal(false);
97
97
  setBranchId('');
@@ -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,13 +103,18 @@ 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.dataset;
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
- load(instanceId);
112
- fetchSnapshots(formik.values.baseBranch);
113
+ load(instanceId).then(() => {
114
+ const selectedBranch = branchesList === null || branchesList === void 0 ? void 0 : branchesList.find((b) => b.name === formik.values.baseBranch);
115
+ const dataset = selectedBranch === null || selectedBranch === void 0 ? void 0 : selectedBranch.dataset;
116
+ fetchSnapshots(formik.values.baseBranch, dataset);
117
+ });
113
118
  }, [formik.values.baseBranch]);
114
119
  if (isBranchesLoading) {
115
120
  return _jsx(StubSpinner, {});
@@ -118,9 +123,12 @@ export const CreateBranchPage = observer(({ instanceId, api, elements, routes, i
118
123
  shrink: true,
119
124
  }, 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
125
  ? branchesList.map((branch) => {
126
+ const displayName = branch.dataset
127
+ ? `${branch.name} (${branch.dataset})`
128
+ : branch.name;
121
129
  return {
122
130
  value: branch.name,
123
- children: branch.name,
131
+ children: displayName,
124
132
  };
125
133
  })
126
134
  : [] }), _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,
@@ -3,6 +3,7 @@ export interface Branch {
3
3
  parent: string;
4
4
  dataStateAt: string;
5
5
  snapshotID: string;
6
+ dataset: string;
6
7
  numSnapshots: number;
7
8
  }
8
9
  export declare const formatBranchesDto: (dto: Branch[]) => {
@@ -10,6 +11,7 @@ export declare const formatBranchesDto: (dto: Branch[]) => {
10
11
  name: string;
11
12
  parent: string;
12
13
  snapshotID: string;
14
+ dataset: string;
13
15
  numSnapshots: number;
14
16
  }[];
15
17
  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;