@postgres.ai/shared 4.1.2 → 4.2.0
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/.gitlab-ci.yml +7 -3
- package/components/UpgradeCloneModal/index.tsx +145 -0
- package/dist/components/UpgradeCloneModal/index.d.ts +11 -0
- package/dist/components/UpgradeCloneModal/index.js +75 -0
- package/dist/package.json +2 -2
- package/dist/pages/Branches/Branch/index.js +27 -2
- package/dist/pages/Branches/Branch/stores/Main.d.ts +5 -0
- package/dist/pages/Branches/Branch/stores/Main.js +29 -0
- package/dist/pages/Branches/components/BranchesTable/index.js +2 -2
- package/dist/pages/Branches/index.js +10 -1
- package/dist/pages/Clone/Status/index.js +3 -0
- package/dist/pages/Clone/index.js +12 -4
- package/dist/pages/Clone/stores/Main.d.ts +9 -1
- package/dist/pages/Clone/stores/Main.js +40 -3
- package/dist/pages/CreateBranch/stores/Main.d.ts +3 -0
- package/dist/pages/CreateClone/index.js +2 -0
- package/dist/pages/CreateClone/stores/Main.d.ts +5 -1
- package/dist/pages/CreateClone/stores/Main.js +8 -3
- package/dist/pages/Instance/Configuration/PhysicalMode/EnvsEditor/index.d.ts +11 -0
- package/dist/pages/Instance/Configuration/PhysicalMode/EnvsEditor/index.js +24 -0
- package/dist/pages/Instance/Configuration/PhysicalMode/PgBackRest/index.d.ts +10 -0
- package/dist/pages/Instance/Configuration/PhysicalMode/PgBackRest/index.js +29 -0
- package/dist/pages/Instance/Configuration/PhysicalMode/Sync/index.d.ts +9 -0
- package/dist/pages/Instance/Configuration/PhysicalMode/Sync/index.js +14 -0
- package/dist/pages/Instance/Configuration/PhysicalMode/Walg/index.d.ts +10 -0
- package/dist/pages/Instance/Configuration/PhysicalMode/Walg/index.js +21 -0
- package/dist/pages/Instance/Configuration/PhysicalMode/index.d.ts +10 -0
- package/dist/pages/Instance/Configuration/PhysicalMode/index.js +17 -0
- package/dist/pages/Instance/Configuration/SimpleMode/PreviewCard.d.ts +13 -0
- package/dist/pages/Instance/Configuration/SimpleMode/PreviewCard.js +14 -0
- package/dist/pages/Instance/Configuration/SimpleMode/index.d.ts +19 -0
- package/dist/pages/Instance/Configuration/SimpleMode/index.js +166 -0
- package/dist/pages/Instance/Configuration/configMode.d.ts +2 -0
- package/dist/pages/Instance/Configuration/configMode.js +7 -0
- package/dist/pages/Instance/Configuration/configOptions.d.ts +16 -0
- package/dist/pages/Instance/Configuration/configOptions.js +71 -0
- package/dist/pages/Instance/Configuration/connectionString.d.ts +20 -0
- package/dist/pages/Instance/Configuration/connectionString.js +129 -0
- package/dist/pages/Instance/Configuration/dockerCatalog.d.ts +2 -0
- package/dist/pages/Instance/Configuration/dockerCatalog.js +19 -0
- package/dist/pages/Instance/Configuration/index.d.ts +1 -2
- package/dist/pages/Instance/Configuration/index.js +115 -86
- package/dist/pages/Instance/Configuration/useForm.d.ts +20 -0
- package/dist/pages/Instance/Configuration/useForm.js +126 -5
- package/dist/pages/Instance/Configuration/utils/index.js +1 -17
- package/dist/pages/Instance/Info/Snapshots/Calendar/Day/index.js +3 -3
- package/dist/pages/Instance/Info/Snapshots/Calendar/utils.d.ts +3 -0
- package/dist/pages/Instance/Info/Snapshots/utils.d.ts +6 -0
- package/dist/pages/Instance/Snapshots/components/SnapshotsList/index.js +11 -1
- package/dist/pages/Instance/Snapshots/index.js +11 -3
- package/dist/pages/Instance/Snapshots/utils/index.d.ts +3 -0
- package/dist/pages/Instance/Tabs/styles.js +6 -6
- package/dist/pages/Instance/index.js +1 -3
- package/dist/pages/Instance/stores/Main.d.ts +22 -2
- package/dist/pages/Instance/stores/Main.js +26 -9
- package/dist/pages/Snapshots/Snapshot/index.js +28 -2
- package/dist/pages/Snapshots/Snapshot/stores/Main.d.ts +5 -0
- package/dist/pages/Snapshots/Snapshot/stores/Main.js +29 -0
- package/dist/stores/Snapshots.d.ts +1 -1
- package/dist/stores/Snapshots.js +12 -6
- package/dist/types/api/endpoints/getBranches.d.ts +6 -0
- package/dist/types/api/endpoints/probeSource.d.ts +32 -0
- package/dist/types/api/endpoints/probeSource.js +1 -0
- package/dist/types/api/endpoints/testDbSource.d.ts +3 -1
- package/dist/types/api/endpoints/testDbSource.js +6 -0
- package/dist/types/api/endpoints/updateBranch.d.ts +11 -0
- package/dist/types/api/endpoints/updateBranch.js +1 -0
- package/dist/types/api/endpoints/updateSnapshot.d.ts +11 -0
- package/dist/types/api/endpoints/updateSnapshot.js +1 -0
- package/dist/types/api/endpoints/upgradeClone.d.ts +8 -0
- package/dist/types/api/endpoints/upgradeClone.js +1 -0
- package/dist/types/api/entities/branchSnapshots.d.ts +3 -0
- package/dist/types/api/entities/clone.d.ts +9 -2
- package/dist/types/api/entities/config.d.ts +32 -0
- package/dist/types/api/entities/config.js +45 -18
- package/dist/types/api/entities/instance.d.ts +11 -1
- package/dist/types/api/entities/instanceState.d.ts +16 -1
- package/dist/types/api/entities/snapshot.d.ts +6 -0
- package/dist/utils/api.d.ts +1 -1
- package/dist/utils/api.js +6 -0
- package/dist/utils/clone.d.ts +3 -1
- package/dist/utils/clone.js +7 -1
- package/dist/utils/clonePoller.d.ts +12 -0
- package/dist/utils/clonePoller.js +41 -0
- package/dist/utils/date.js +12 -12
- package/dist/utils/protection.d.ts +5 -0
- package/dist/utils/protection.js +23 -0
- package/package.json +2 -2
- package/pages/Branches/Branch/index.tsx +70 -0
- package/pages/Branches/Branch/stores/Main.ts +40 -0
- package/pages/Branches/components/BranchesTable/index.tsx +2 -0
- package/pages/Branches/index.tsx +13 -1
- package/pages/Clone/Status/index.tsx +3 -0
- package/pages/Clone/index.tsx +58 -0
- package/pages/Clone/stores/Main.ts +51 -8
- package/pages/CreateClone/index.tsx +3 -0
- package/pages/CreateClone/stores/Main.ts +10 -8
- package/pages/Instance/Configuration/PhysicalMode/EnvsEditor/index.tsx +129 -0
- package/pages/Instance/Configuration/PhysicalMode/PgBackRest/index.tsx +89 -0
- package/pages/Instance/Configuration/PhysicalMode/Sync/index.tsx +64 -0
- package/pages/Instance/Configuration/PhysicalMode/Walg/index.tsx +63 -0
- package/pages/Instance/Configuration/PhysicalMode/index.tsx +93 -0
- package/pages/Instance/Configuration/SimpleMode/PreviewCard.tsx +176 -0
- package/pages/Instance/Configuration/SimpleMode/index.tsx +303 -0
- package/pages/Instance/Configuration/configMode.ts +12 -0
- package/pages/Instance/Configuration/configOptions.ts +111 -0
- package/pages/Instance/Configuration/connectionString.ts +157 -0
- package/pages/Instance/Configuration/dockerCatalog.ts +21 -0
- package/pages/Instance/Configuration/index.tsx +151 -49
- package/pages/Instance/Configuration/useForm.ts +155 -5
- package/pages/Instance/Configuration/utils/index.ts +1 -17
- package/pages/Instance/Info/Snapshots/Calendar/Day/index.tsx +3 -3
- package/pages/Instance/Snapshots/components/SnapshotsList/index.tsx +21 -1
- package/pages/Instance/Snapshots/index.tsx +15 -5
- package/pages/Instance/Tabs/styles.ts +7 -7
- package/pages/Instance/index.tsx +0 -4
- package/pages/Instance/stores/Main.ts +29 -7
- package/pages/Snapshots/Snapshot/index.tsx +71 -0
- package/pages/Snapshots/Snapshot/stores/Main.ts +40 -0
- package/postgres.ai-shared-4.2.0.tgz +0 -0
- package/stores/Snapshots.ts +16 -7
- package/types/api/endpoints/getBranches.ts +3 -0
- package/types/api/endpoints/probeSource.ts +34 -0
- package/types/api/endpoints/testDbSource.ts +10 -1
- package/types/api/endpoints/updateBranch.ts +11 -0
- package/types/api/endpoints/updateSnapshot.ts +11 -0
- package/types/api/endpoints/upgradeClone.ts +8 -0
- package/types/api/entities/clone.ts +13 -1
- package/types/api/entities/config.ts +46 -0
- package/types/api/entities/instanceState.ts +6 -0
- package/types/api/entities/snapshot.ts +3 -0
- package/utils/api.ts +8 -0
- package/utils/clone.ts +7 -1
- package/utils/clonePoller.ts +47 -0
- package/utils/date.ts +19 -14
- package/utils/protection.ts +25 -0
- package/postgres.ai-shared-4.1.2.tgz +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*--------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
|
|
3
|
+
* All Rights Reserved. Proprietary and confidential.
|
|
4
|
+
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
5
|
+
*--------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// interval between clone status polls while a clone is still unstable.
|
|
9
|
+
export const UNSTABLE_CLONE_UPDATE_TIMEOUT = 1000
|
|
10
|
+
|
|
11
|
+
// ClonePoller owns a single self-rescheduling timeout used to poll clone status
|
|
12
|
+
// until it becomes stable. It is reusable: start() re-arms a poller that was
|
|
13
|
+
// previously stopped, and stop() cancels any pending tick and blocks further
|
|
14
|
+
// scheduling — including a tick that an in-flight request is about to queue.
|
|
15
|
+
export class ClonePoller {
|
|
16
|
+
private timeout?: ReturnType<typeof setTimeout>
|
|
17
|
+
private stopped = false
|
|
18
|
+
|
|
19
|
+
constructor(private readonly intervalMs: number = UNSTABLE_CLONE_UPDATE_TIMEOUT) {}
|
|
20
|
+
|
|
21
|
+
get isStopped() {
|
|
22
|
+
return this.stopped
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// start re-arms the poller so a reused store polls again.
|
|
26
|
+
start = () => {
|
|
27
|
+
this.stopped = false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// stop halts polling and cancels any pending tick.
|
|
31
|
+
stop = () => {
|
|
32
|
+
this.stopped = true
|
|
33
|
+
clearTimeout(this.timeout)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// cancel drops a pending tick without blocking future scheduling.
|
|
37
|
+
cancel = () => {
|
|
38
|
+
clearTimeout(this.timeout)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// scheduleNext queues the next tick, unless the poller has been stopped.
|
|
42
|
+
scheduleNext = (tick: () => void) => {
|
|
43
|
+
clearTimeout(this.timeout)
|
|
44
|
+
if (this.stopped) return
|
|
45
|
+
this.timeout = setTimeout(tick, this.intervalMs)
|
|
46
|
+
}
|
|
47
|
+
}
|
package/utils/date.ts
CHANGED
|
@@ -21,25 +21,30 @@ import {
|
|
|
21
21
|
formatDistanceToNowStrict,
|
|
22
22
|
} from 'date-fns'
|
|
23
23
|
|
|
24
|
+
const compactDatePattern = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/
|
|
25
|
+
|
|
26
|
+
// formatDateToISO converts a compact UTC timestamp ('20060102150405') to RFC3339 ('2006-01-02T15:04:05Z').
|
|
27
|
+
// The value is a UTC wall-clock, so it must never be interpreted in the browser timezone.
|
|
24
28
|
export const formatDateToISO = (dateString: string) => {
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
const parts = compactDatePattern.exec(dateString?.trim() ?? '')
|
|
30
|
+
|
|
31
|
+
if (!parts) {
|
|
27
32
|
return ''
|
|
28
33
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return format(parsedDate, "yyyy-MM-dd'T'HH:mm:ssXXX")
|
|
39
|
-
} catch (error) {
|
|
40
|
-
// Return empty string for invalid date formats
|
|
34
|
+
|
|
35
|
+
const [compact, year, month, day, hours, minutes, seconds] = parts
|
|
36
|
+
const parsedDate = new Date(
|
|
37
|
+
Date.UTC(+year, +month - 1, +day, +hours, +minutes, +seconds),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
if (!isValidDate(parsedDate)) {
|
|
41
41
|
return ''
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
const isoDate = parsedDate.toISOString().replace(/\.\d+Z$/, 'Z')
|
|
45
|
+
|
|
46
|
+
// reject values rolled over by Date.UTC, e.g. month 13 or hour 25.
|
|
47
|
+
return isoDate.replace(/[-:TZ]/g, '') === compact ? isoDate : ''
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
// parseDate parses date of both format: '2006-01-02 15:04:05 UTC' and `2006-01-02T15:04:05Z` (RFC3339).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// protectionOptions lists the deletion-protection choices shared by the branch and snapshot
|
|
2
|
+
// detail pages: no protection, a set of bounded durations, and forever. The values are the
|
|
3
|
+
// protectionDurationMinutes passed to the update endpoints ('0' means forever, 'none' clears
|
|
4
|
+
// protection).
|
|
5
|
+
export const protectionOptions = [
|
|
6
|
+
{ value: 'none', children: 'No protection' },
|
|
7
|
+
{ value: '60', children: '1 hour' },
|
|
8
|
+
{ value: '720', children: '12 hours' },
|
|
9
|
+
{ value: '1440', children: '1 day' },
|
|
10
|
+
{ value: '4320', children: '3 days' },
|
|
11
|
+
{ value: '10080', children: '7 days' },
|
|
12
|
+
{ value: '43200', children: '30 days' },
|
|
13
|
+
{ value: '0', children: 'Forever' },
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
// getProtectionSelectValue maps an entity's protection state to the Select value: 'none' when
|
|
17
|
+
// unprotected, 'current' when protected until a specific time, '0' when protected forever.
|
|
18
|
+
export const getProtectionSelectValue = (
|
|
19
|
+
isProtected: boolean,
|
|
20
|
+
protectedTillDate: Date | null,
|
|
21
|
+
): string => {
|
|
22
|
+
if (!isProtected) return 'none'
|
|
23
|
+
if (!protectedTillDate) return '0'
|
|
24
|
+
return 'current'
|
|
25
|
+
}
|
|
Binary file
|