@postgres.ai/shared 3.5.1-pr-1027.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.
Files changed (202) hide show
  1. package/.gitlab-ci.yml +60 -0
  2. package/components/AlertSnackbar/index.tsx +23 -0
  3. package/components/AlertSnackbar/useAlertSnackbar.tsx +65 -0
  4. package/components/Button/index.tsx +79 -0
  5. package/components/Button2/index.tsx +43 -0
  6. package/components/Button2/styles.module.scss +82 -0
  7. package/components/DestroyCloneModal/index.tsx +56 -0
  8. package/components/DestroyCloneRestrictionModal/index.tsx +50 -0
  9. package/components/ErrorStub/index.tsx +83 -0
  10. package/components/FormattedText/index.tsx +44 -0
  11. package/components/FormattedText/styles.module.scss +34 -0
  12. package/components/GatewayLink/index.tsx +33 -0
  13. package/components/HorizontalScrollContainer/index.tsx +131 -0
  14. package/components/HorizontalScrollContainer/types.ts +12 -0
  15. package/components/HorizontalScrollContainer/utils.ts +16 -0
  16. package/components/ImportantText/index.tsx +29 -0
  17. package/components/Link2/index.tsx +31 -0
  18. package/components/Link2/styles.module.scss +12 -0
  19. package/components/MenuButton/index.tsx +80 -0
  20. package/components/MenuButton/styles.module.scss +42 -0
  21. package/components/Modal/index.tsx +93 -0
  22. package/components/PageSpinner/index.tsx +18 -0
  23. package/components/PageSpinner/styles.module.scss +13 -0
  24. package/components/ResetCloneModal/index.tsx +154 -0
  25. package/components/SectionTitle/index.tsx +74 -0
  26. package/components/Select/index.tsx +42 -0
  27. package/components/SimpleModalControls/index.tsx +56 -0
  28. package/components/Spinner/icon.tsx +29 -0
  29. package/components/Spinner/index.tsx +16 -0
  30. package/components/Spinner/styles.module.scss +33 -0
  31. package/components/Status/index.tsx +61 -0
  32. package/components/Status/styles.module.scss +45 -0
  33. package/components/StubContainer/index.tsx +41 -0
  34. package/components/StubSpinner/index.tsx +49 -0
  35. package/components/StubSpinnerFlex/index.tsx +20 -0
  36. package/components/StubSpinnerFlex/styles.module.scss +20 -0
  37. package/components/SyntaxHighlight/index.tsx +107 -0
  38. package/components/Table/RowMenu/index.tsx +111 -0
  39. package/components/Table/index.tsx +140 -0
  40. package/components/Text/index.tsx +28 -0
  41. package/components/TextField/index.tsx +117 -0
  42. package/components/Tooltip/index.tsx +52 -0
  43. package/config/index.ts +32 -0
  44. package/config/links.ts +6 -0
  45. package/craco.config.js +80 -0
  46. package/helpers/getEntropy.ts +232 -0
  47. package/helpers/localStorage.ts +15 -0
  48. package/helpers/request.ts +47 -0
  49. package/hooks/useWindowDimensions.ts +16 -0
  50. package/icons/ArrowDropDown/index.tsx +29 -0
  51. package/icons/Circle/index.tsx +27 -0
  52. package/icons/External/index.tsx +14 -0
  53. package/icons/Info/index.tsx +12 -0
  54. package/icons/Renewable/index.tsx +65 -0
  55. package/icons/Shield/index.tsx +33 -0
  56. package/icons/Warning/index.tsx +29 -0
  57. package/meta.json +1 -0
  58. package/package.json +55 -0
  59. package/pages/Clone/Status/index.tsx +73 -0
  60. package/pages/Clone/context.ts +22 -0
  61. package/pages/Clone/index.tsx +634 -0
  62. package/pages/Clone/stores/Main.ts +206 -0
  63. package/pages/Clone/useCreatedStores.ts +11 -0
  64. package/pages/Configuration/Header/index.tsx +84 -0
  65. package/pages/Configuration/InputWithTooltip/index.tsx +240 -0
  66. package/pages/Configuration/ResponseMessage/index.tsx +71 -0
  67. package/pages/Configuration/configOptions.ts +60 -0
  68. package/pages/Configuration/index.tsx +1184 -0
  69. package/pages/Configuration/styles.module.scss +122 -0
  70. package/pages/Configuration/tooltipText.tsx +157 -0
  71. package/pages/Configuration/useForm.ts +108 -0
  72. package/pages/Configuration/utils/index.ts +153 -0
  73. package/pages/CreateClone/index.tsx +311 -0
  74. package/pages/CreateClone/stores/Main.ts +107 -0
  75. package/pages/CreateClone/styles.module.scss +71 -0
  76. package/pages/CreateClone/useCreatedStores.ts +11 -0
  77. package/pages/CreateClone/useForm.ts +36 -0
  78. package/pages/Instance/Clones/Header/Item/index.tsx +15 -0
  79. package/pages/Instance/Clones/Header/Item/styles.module.scss +17 -0
  80. package/pages/Instance/Clones/Header/index.tsx +74 -0
  81. package/pages/Instance/Clones/Header/styles.module.scss +11 -0
  82. package/pages/Instance/Clones/index.tsx +135 -0
  83. package/pages/Instance/ClonesModal/index.tsx +71 -0
  84. package/pages/Instance/ClonesModal/utils.ts +21 -0
  85. package/pages/Instance/InactiveInstance/index.tsx +165 -0
  86. package/pages/Instance/InactiveInstance/utils.ts +9 -0
  87. package/pages/Instance/Info/Connection/ConnectModal/Content/index.tsx +176 -0
  88. package/pages/Instance/Info/Connection/ConnectModal/Content/utils.ts +24 -0
  89. package/pages/Instance/Info/Connection/ConnectModal/index.tsx +36 -0
  90. package/pages/Instance/Info/Connection/index.tsx +81 -0
  91. package/pages/Instance/Info/Details/index.tsx +20 -0
  92. package/pages/Instance/Info/Disks/Disk/ActionsMenu/index.tsx +100 -0
  93. package/pages/Instance/Info/Disks/Disk/Marker/index.tsx +26 -0
  94. package/pages/Instance/Info/Disks/Disk/ProgressBar/PointerIcon.tsx +20 -0
  95. package/pages/Instance/Info/Disks/Disk/ProgressBar/index.tsx +73 -0
  96. package/pages/Instance/Info/Disks/Disk/Status/index.tsx +75 -0
  97. package/pages/Instance/Info/Disks/Disk/index.tsx +168 -0
  98. package/pages/Instance/Info/Disks/index.tsx +65 -0
  99. package/pages/Instance/Info/Icons/index.tsx +39 -0
  100. package/pages/Instance/Info/Retrieval/RefreshFailedAlert/index.tsx +32 -0
  101. package/pages/Instance/Info/Retrieval/RefreshFailedAlert/styles.module.scss +33 -0
  102. package/pages/Instance/Info/Retrieval/RetrievalModal/index.tsx +49 -0
  103. package/pages/Instance/Info/Retrieval/RetrievalModal/styles.module.scss +6 -0
  104. package/pages/Instance/Info/Retrieval/RetrievalTable/index.tsx +53 -0
  105. package/pages/Instance/Info/Retrieval/RetrievalTable/styles.module.scss +29 -0
  106. package/pages/Instance/Info/Retrieval/index.tsx +95 -0
  107. package/pages/Instance/Info/Retrieval/utils.ts +10 -0
  108. package/pages/Instance/Info/Snapshots/Calendar/Day/index.tsx +125 -0
  109. package/pages/Instance/Info/Snapshots/Calendar/index.tsx +133 -0
  110. package/pages/Instance/Info/Snapshots/Calendar/utils.ts +74 -0
  111. package/pages/Instance/Info/Snapshots/TimeLine/Day/index.tsx +79 -0
  112. package/pages/Instance/Info/Snapshots/TimeLine/index.tsx +57 -0
  113. package/pages/Instance/Info/Snapshots/index.tsx +97 -0
  114. package/pages/Instance/Info/Snapshots/utils.ts +18 -0
  115. package/pages/Instance/Info/Status/InstanceResponseModal/index.tsx +32 -0
  116. package/pages/Instance/Info/Status/InstanceResponseModal/styles.module.scss +3 -0
  117. package/pages/Instance/Info/Status/index.tsx +85 -0
  118. package/pages/Instance/Info/Status/styles.module.scss +12 -0
  119. package/pages/Instance/Info/Status/utils.ts +24 -0
  120. package/pages/Instance/Info/components/Property/index.tsx +32 -0
  121. package/pages/Instance/Info/components/Property/styles.module.scss +21 -0
  122. package/pages/Instance/Info/components/Section/index.tsx +50 -0
  123. package/pages/Instance/Info/components/ValueStatus/index.tsx +51 -0
  124. package/pages/Instance/Info/index.tsx +129 -0
  125. package/pages/Instance/SnapshotsModal/index.tsx +169 -0
  126. package/pages/Instance/SnapshotsModal/utils.ts +17 -0
  127. package/pages/Instance/Tabs/index.tsx +98 -0
  128. package/pages/Instance/components/ClonesList/ConnectionModal/index.tsx +196 -0
  129. package/pages/Instance/components/ClonesList/MenuCell/index.tsx +98 -0
  130. package/pages/Instance/components/ClonesList/MenuCell/utils.ts +21 -0
  131. package/pages/Instance/components/ClonesList/index.tsx +189 -0
  132. package/pages/Instance/components/ClonesList/styles.module.scss +32 -0
  133. package/pages/Instance/components/ErrorStub/index.tsx +77 -0
  134. package/pages/Instance/components/ModalReloadButton/index.tsx +43 -0
  135. package/pages/Instance/components/Tags/Tag/index.tsx +60 -0
  136. package/pages/Instance/components/Tags/index.tsx +42 -0
  137. package/pages/Instance/context.ts +39 -0
  138. package/pages/Instance/index.tsx +235 -0
  139. package/pages/Instance/stores/ClonesModal.ts +35 -0
  140. package/pages/Instance/stores/Main.ts +335 -0
  141. package/pages/Instance/stores/SnapshotsModal.ts +35 -0
  142. package/pages/Instance/styles.scss +40 -0
  143. package/pages/Instance/useCreatedStores.ts +14 -0
  144. package/pages/Logs/Icons/PlusIcon.tsx +8 -0
  145. package/pages/Logs/constants/index.ts +7 -0
  146. package/pages/Logs/hooks/useWsScroll.tsx +44 -0
  147. package/pages/Logs/index.tsx +267 -0
  148. package/pages/Logs/utils/index.ts +20 -0
  149. package/pages/Logs/wsLogs.ts +110 -0
  150. package/pages/Logs/wsSnackbar.ts +27 -0
  151. package/postgres.ai-shared-3.5.0.tgz +0 -0
  152. package/react-app-env.d.ts +71 -0
  153. package/scripts/copy-assets.js +30 -0
  154. package/scripts/pack.js +70 -0
  155. package/stores/Snapshots.ts +54 -0
  156. package/styles/colors.ts +67 -0
  157. package/styles/global.scss +29 -0
  158. package/styles/icons.tsx +1917 -0
  159. package/styles/mixins.scss +30 -0
  160. package/styles/styles.ts +87 -0
  161. package/styles/theme.ts +53 -0
  162. package/styles/vars.scss +43 -0
  163. package/styles/vars.ts +40 -0
  164. package/tsconfig.build.json +37 -0
  165. package/tsconfig.json +30 -0
  166. package/types/api/endpoints/createClone.ts +10 -0
  167. package/types/api/endpoints/destroyClone.ts +7 -0
  168. package/types/api/endpoints/getClone.ts +6 -0
  169. package/types/api/endpoints/getConfig.ts +6 -0
  170. package/types/api/endpoints/getEngine.ts +13 -0
  171. package/types/api/endpoints/getFullConfig.ts +4 -0
  172. package/types/api/endpoints/getInstance.ts +6 -0
  173. package/types/api/endpoints/getInstanceRetrieval.ts +6 -0
  174. package/types/api/endpoints/getSeImages.ts +22 -0
  175. package/types/api/endpoints/getSnapshots.ts +6 -0
  176. package/types/api/endpoints/getWSToken.ts +6 -0
  177. package/types/api/endpoints/initWS.ts +1 -0
  178. package/types/api/endpoints/refreshInstance.ts +4 -0
  179. package/types/api/endpoints/resetClone.ts +8 -0
  180. package/types/api/endpoints/testDbSource.ts +48 -0
  181. package/types/api/endpoints/updateClone.ts +10 -0
  182. package/types/api/endpoints/updateConfig.ts +6 -0
  183. package/types/api/entities/clone.ts +42 -0
  184. package/types/api/entities/config.ts +114 -0
  185. package/types/api/entities/dbSource.ts +13 -0
  186. package/types/api/entities/instance.ts +67 -0
  187. package/types/api/entities/instanceRetrieval.ts +46 -0
  188. package/types/api/entities/instanceState.ts +102 -0
  189. package/types/api/entities/pool.ts +27 -0
  190. package/types/api/entities/snapshot.ts +18 -0
  191. package/types/api/entities/wsToken.ts +7 -0
  192. package/types/byte-size/index.d.ts +22 -0
  193. package/utils/api.ts +30 -0
  194. package/utils/clone.ts +31 -0
  195. package/utils/connection.ts +38 -0
  196. package/utils/date.ts +87 -0
  197. package/utils/instance.ts +10 -0
  198. package/utils/numbers.ts +11 -0
  199. package/utils/react.ts +10 -0
  200. package/utils/snapshot.ts +4 -0
  201. package/utils/strings.ts +11 -0
  202. package/utils/units.ts +23 -0
@@ -0,0 +1,30 @@
1
+ // Screen width.
2
+ @mixin screen-max-width ($width) {
3
+ @media screen and (max-width: $width) {
4
+ @content;
5
+ }
6
+ }
7
+
8
+ @mixin sm {
9
+ @include screen-max-width(600px) {
10
+ @content;
11
+ }
12
+ }
13
+
14
+ // Transitions.
15
+ @mixin transition($properties, $duration, $function) {
16
+ $transition: ();
17
+ @for $i from 1 through length($properties) {
18
+ $transition: append($transition, $duration nth($properties, $i) $function, $separator: comma);
19
+ }
20
+
21
+ transition: $transition;
22
+ }
23
+
24
+ @mixin touch-transition ($properties) {
25
+ @include transition(($properties), .2s, ease-out);
26
+ }
27
+
28
+ @mixin animation-transition ($properties) {
29
+ @include transition(($properties), .4s, ease-out);
30
+ }
@@ -0,0 +1,87 @@
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
+ import { colors } from './colors'
9
+ import { theme } from './theme'
10
+
11
+ export const styles: Record<string, any> = {
12
+ root: {
13
+ 'minHeight': '100%',
14
+ width: '100%',
15
+ 'zIndex': 1,
16
+ position: 'relative',
17
+ [theme.breakpoints.down('sm')]: {
18
+ maxWidth: '100vw',
19
+ },
20
+ [theme.breakpoints.up('md')]: {
21
+ maxWidth: 'calc(100vw - 200px)',
22
+ },
23
+ [theme.breakpoints.up('lg')]: {
24
+ maxWidth: 'calc(100vw - 200px)',
25
+ },
26
+ '& h2': {
27
+ ...theme.typography.h2,
28
+ },
29
+ '& h3': {
30
+ ...theme.typography.h3,
31
+ },
32
+ '& h4': {
33
+ ...theme.typography.h4,
34
+ },
35
+ '& th': {
36
+ fontSize: '14px',
37
+ lineHeight: '16px',
38
+ fontWeight: 'bold',
39
+ color: colors.consoleFadedFont,
40
+ },
41
+ },
42
+ inputField: {
43
+ 'margin-bottom': '10px',
44
+ '& > div.MuiFormControl- > label': {
45
+ fontSize: '14px!important',
46
+ },
47
+ '& .MuiOutlinedInput-input, & .MuiOutlinedInput-multiline, & .MuiSelect-select':
48
+ {
49
+ padding: '8px!important',
50
+ fontSize: 14,
51
+ },
52
+ '& .MuiSelect-icon': {
53
+ fontSize: 22,
54
+ },
55
+ '& .MuiInputBase-multiline': {
56
+ padding: '0px!important',
57
+ },
58
+ },
59
+ inputFieldLabel: {
60
+ fontSize: 14,
61
+ },
62
+ inputFieldHelper: {
63
+ fontSize: 11,
64
+ marginLeft: '10px',
65
+ },
66
+ checkbox: {
67
+ 'font-size': '14px!important',
68
+ '& > span.MuiFormControlLabel-label': {
69
+ fontSize: 14,
70
+ },
71
+ },
72
+
73
+ tableHead: {
74
+ height: '30px',
75
+ lineHeight: '30px',
76
+ position: 'relative',
77
+ },
78
+ tableHeadActions: {
79
+ position: 'absolute',
80
+ right: '0px',
81
+ top: '0px',
82
+ },
83
+ bottomSpace: {
84
+ display: 'block',
85
+ height: 130,
86
+ },
87
+ }
@@ -0,0 +1,53 @@
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
+ import { createTheme } from '@material-ui/core'
9
+
10
+ import { colors } from './colors'
11
+
12
+ export const theme = createTheme({
13
+ // @ts-ignore
14
+ fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
15
+ palette: {
16
+ primary: {
17
+ main: colors.secondary2.main,
18
+ contrastText: colors.secondary2.contrastText,
19
+ dark: colors.secondary2.dark,
20
+ },
21
+ secondary: {
22
+ main: colors.secondary2.main,
23
+ contrastText: colors.secondary2.contrastText,
24
+ dark: colors.secondary2.dark,
25
+ },
26
+ },
27
+ typography: {
28
+ htmlFontSize: 14,
29
+ fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
30
+ // @ts-ignore
31
+ fontSize: '14px!important',
32
+ h1: {
33
+ fontSize: '16px!important',
34
+ },
35
+ h2: {
36
+ fontSize: '14px!important',
37
+ fontWeight: 'bold',
38
+ },
39
+ h3: {
40
+ fontSize: '14px!important',
41
+ fontWeight: 'normal',
42
+ },
43
+ button: {
44
+ fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
45
+ textTransform: 'unset',
46
+ fontStyle: 'normal',
47
+ fontSize: '14px',
48
+ lineHeight: '18px',
49
+ alignItems: 'center',
50
+ textAlign: 'center',
51
+ },
52
+ },
53
+ })
@@ -0,0 +1,43 @@
1
+ // Colors.
2
+ $color-white: #fff;
3
+
4
+ $color-white--100: #FBFBFB;
5
+
6
+ $color-black: #000;
7
+
8
+ $color-gray-100: #CCD7DA;
9
+ $color-gray: #b4b4b4;
10
+
11
+ $color-gray-semi-dark: #808080;
12
+
13
+ $color-gray-dark: #444;
14
+
15
+ $color-gray-darkest: #333;
16
+ $color-gray-darkest--hover: darken($color-gray-darkest, 5);
17
+
18
+ $color-orange: #ff6212;
19
+ $color-orange--hover: darken($color-orange, 10);
20
+
21
+ $color-status-ok: #0db94d;
22
+ $color-status-warning: #fd8411;
23
+ $color-status-error: #ff2020;
24
+ $color-status-waiting: #ffad5f;
25
+ $color-status-unknown: #c0c0c0; // prev color-gray
26
+
27
+
28
+ $color-blue-main: #0F879D;
29
+ $color-blue-dark: #026173;
30
+
31
+ // Fonts.
32
+ $font-family-text: 'Roboto', sans-serif;
33
+ $font-family-code: 'Roboto Mono', monospace;
34
+
35
+ // Typography.
36
+ $font-size-small: 12px;
37
+ $font-size-main: 14px;
38
+
39
+ // Shadows.
40
+ $box-shadow-layer: 0 2px 6px rgba(0, 0, 0, 0.1);
41
+
42
+ // Sizes.
43
+ $border-radius--small: 4px;
package/styles/vars.ts ADDED
@@ -0,0 +1,40 @@
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
+ // Colors.
9
+ const colorGray = '#c0c0c0'
10
+
11
+ export const colors = {
12
+ white: '#fff',
13
+ gray: '#D6D6D6',
14
+
15
+ status: {
16
+ ok: '#0db94d',
17
+ warning: '#fd8411',
18
+ error: '#ff2020',
19
+ waiting: '#ffad5f',
20
+ unknown: colorGray
21
+ }
22
+ }
23
+
24
+ // Mixins.
25
+ export const createTransitionInteractive = (...props: string[]) =>
26
+ props.map((prop) => `${prop} .2s ease-out`).join(',');
27
+
28
+ export const borderRadius = '4px';
29
+
30
+ export const resetStyles = {
31
+ margin: 0,
32
+ padding: 0,
33
+ }
34
+
35
+ export const resetStylesRoot = {
36
+ ...resetStyles,
37
+ '& *': {
38
+ ...resetStyles
39
+ }
40
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "outDir": "dist",
6
+ "declaration": true,
7
+ "emitDeclarationOnly": false,
8
+ "noEmit": false,
9
+ "module": "esnext",
10
+ "target": "es2019",
11
+ "moduleResolution": "node",
12
+ "jsx": "react-jsx",
13
+ "resolveJsonModule": true,
14
+ "esModuleInterop": true
15
+ },
16
+ "include": [
17
+ "components/**/*",
18
+ "config/**/*",
19
+ "helpers/**/*",
20
+ "hooks/**/*",
21
+ "icons/**/*",
22
+ "pages/**/*",
23
+ "stores/**/*",
24
+ "styles/**/*",
25
+ "types/**/*",
26
+ "utils/**/*",
27
+ "react-app-env.d.ts",
28
+ ],
29
+ "exclude": [
30
+ "node_modules",
31
+ "dist",
32
+ "meta.json",
33
+ "craco.config.js",
34
+ "**/*.test.ts",
35
+ "**/*.test.tsx"
36
+ ]
37
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "lib": [
5
+ "dom",
6
+ "dom.iterable",
7
+ "esnext"
8
+ ],
9
+ "allowJs": true,
10
+ "skipLibCheck": true,
11
+ "esModuleInterop": true,
12
+ "allowSyntheticDefaultImports": true,
13
+ "strict": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "noFallthroughCasesInSwitch": true,
16
+ "module": "esnext",
17
+ "moduleResolution": "node",
18
+ "resolveJsonModule": true,
19
+ "isolatedModules": true,
20
+ "noEmit": true,
21
+ "jsx": "react-jsx",
22
+ "baseUrl": ".",
23
+ "paths": {
24
+ "@postgres.ai/shared/*": ["./*"]
25
+ }
26
+ },
27
+ "include": [
28
+ "."
29
+ ]
30
+ }
@@ -0,0 +1,10 @@
1
+ import { Clone } from '@postgres.ai/shared/types/api/entities/clone'
2
+
3
+ export type CreateClone = (args: {
4
+ instanceId: string
5
+ cloneId: string
6
+ snapshotId: string
7
+ dbUser: string
8
+ dbPassword: string
9
+ isProtected: boolean
10
+ }) => Promise<{ response: Clone | null; error: Response | null }>
@@ -0,0 +1,7 @@
1
+ export type DestroyClone = (args: {
2
+ instanceId: string
3
+ cloneId: string
4
+ }) => Promise<{
5
+ response: true | null
6
+ error: Response | null
7
+ }>
@@ -0,0 +1,6 @@
1
+ import { Clone } from '@postgres.ai/shared/types/api/entities/clone'
2
+
3
+ export type GetClone = (args: {
4
+ instanceId: string
5
+ cloneId: string
6
+ }) => Promise<{ response: Clone | null; error: Response | null }>
@@ -0,0 +1,6 @@
1
+ import { Config } from "../entities/config"
2
+
3
+ export type GetConfig = () => Promise<{
4
+ response: Config | null
5
+ error: Response | null
6
+ }>
@@ -0,0 +1,13 @@
1
+ export type EngineDto = {
2
+ version: string
3
+ edition?: string
4
+ }
5
+
6
+ export type GetEngine = () => Promise<{
7
+ response: EngineType | null
8
+ error: Response | null
9
+ }>
10
+
11
+ export const formatEngineDto = (dto: EngineDto) => dto
12
+
13
+ export type EngineType = ReturnType<typeof formatEngineDto>
@@ -0,0 +1,4 @@
1
+ export type GetFullConfig = () => Promise<{
2
+ response: string | null
3
+ error: Response | any | null
4
+ }>
@@ -0,0 +1,6 @@
1
+ import { Instance } from '@postgres.ai/shared/types/api/entities/instance'
2
+
3
+ export type GetInstance = (args: { instanceId: string }) => Promise<{
4
+ response: Instance | null
5
+ error: Response | null
6
+ }>
@@ -0,0 +1,6 @@
1
+ import { InstanceRetrievalType } from '@postgres.ai/shared/types/api/entities/instanceRetrieval'
2
+
3
+ export type GetInstanceRetrieval = (args: { instanceId: string }) => Promise<{
4
+ response: InstanceRetrievalType | null
5
+ error: Response | null
6
+ }>
@@ -0,0 +1,22 @@
1
+ export type GetSeImages = (args: {
2
+ packageGroup: string
3
+ platformUrl?: string
4
+ }) => Promise<{
5
+ response: InstanceRetrievalType | null
6
+ error: Response | null
7
+ }>
8
+
9
+ export interface SeImages {
10
+ org_id?: number
11
+ package_group: string
12
+ pg_major_version: string
13
+ tag: string
14
+ pg_config_presets?: {
15
+ shared_preload_libraries: string
16
+ }
17
+ location: string
18
+ }
19
+
20
+ export const formatSeImages = (seImages: SeImages[]) => seImages
21
+
22
+ export type InstanceRetrievalType = ReturnType<typeof formatSeImages>
@@ -0,0 +1,6 @@
1
+ import { Snapshot } from '@postgres.ai/shared/types/api/entities/snapshot'
2
+
3
+ export type GetSnapshots = (args: { instanceId: string }) => Promise<{
4
+ response: Snapshot[] | null
5
+ error: Response | null
6
+ }>
@@ -0,0 +1,6 @@
1
+ import { WSToken } from '@postgres.ai/shared/types/api/entities/wsToken'
2
+
3
+ export type GetWSToken = (args: { instanceId: string }) => Promise<{
4
+ response: WSToken | null
5
+ error: Response | null
6
+ }>
@@ -0,0 +1 @@
1
+ export type InitWS = ( path: string, token: string ) => WebSocket
@@ -0,0 +1,4 @@
1
+ export type RefreshInstance = (args: { instanceId: string }) => Promise<{
2
+ response: boolean | null
3
+ error: Response | null
4
+ }>
@@ -0,0 +1,8 @@
1
+ export type ResetClone = (args: {
2
+ instanceId: string
3
+ cloneId: string
4
+ snapshotId: string
5
+ }) => Promise<{
6
+ response: true | null
7
+ error: Response | null
8
+ }>
@@ -0,0 +1,48 @@
1
+ import { dbSource } from '@postgres.ai/shared/types/api/entities/dbSource'
2
+
3
+ export type TestDbSource = (values: dbSource) => Promise<{
4
+ response: {
5
+ status: number
6
+ message: string
7
+ result: string
8
+ dbVersion: number
9
+ tuningParams: {
10
+ [key: string]: string
11
+ }
12
+ } | null
13
+ error: {
14
+ status: number
15
+ message: string
16
+ }
17
+ }>
18
+
19
+ export const formatTuningParams = (
20
+ tuningParams: { [key: string]: string } | undefined,
21
+ ) => {
22
+ let formattedTuningParams = ''
23
+
24
+ if (tuningParams && Object.keys(tuningParams).length > 0) {
25
+ Object.entries(tuningParams).forEach(([key, value], index) => {
26
+ if (key !== 'shared_preload_libraries' && key !== 'shared_buffers') {
27
+ formattedTuningParams += `${key}=${value}\n`
28
+ }
29
+ })
30
+ formattedTuningParams = formattedTuningParams.slice(0, -1)
31
+ }
32
+
33
+ return formattedTuningParams
34
+ }
35
+
36
+ export const formatTuningParamsToObj = (tuningParams: string | undefined) => {
37
+ let formattedTuningParams: { [key: string]: string } = {}
38
+
39
+ if (tuningParams) {
40
+ const tuningParamsArr = tuningParams.split('\n')
41
+ tuningParamsArr.forEach((param) => {
42
+ const paramArr = param.split('=')
43
+ formattedTuningParams[paramArr[0]] = paramArr[1]
44
+ })
45
+ }
46
+
47
+ return formattedTuningParams
48
+ }
@@ -0,0 +1,10 @@
1
+ export type UpdateClone = (args: {
2
+ instanceId: string
3
+ cloneId: string
4
+ clone: {
5
+ isProtected: boolean
6
+ }
7
+ }) => Promise<{
8
+ response: true | null
9
+ error: Response | null
10
+ }>
@@ -0,0 +1,6 @@
1
+ import { Config } from '@postgres.ai/shared/types/api/entities/config'
2
+
3
+ export type UpdateConfig = (values: Config) => Promise<{
4
+ response: Response | null
5
+ error: Response | null
6
+ }>
@@ -0,0 +1,42 @@
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
+ import { parseDate } from '@postgres.ai/shared/utils/date'
9
+ import {
10
+ SnapshotDto,
11
+ formatSnapshotDto,
12
+ } from '@postgres.ai/shared/types/api/entities/snapshot'
13
+
14
+ export type CloneDto = {
15
+ createdAt: string
16
+ id: string
17
+ status: {
18
+ code: 'OK' | 'CREATING' | 'DELETING' | 'RESETTING' | 'FATAL'
19
+ message: string
20
+ }
21
+ protected: boolean
22
+ metadata: {
23
+ cloneDiffSize: number
24
+ cloningTime: number
25
+ }
26
+ db: {
27
+ username: string
28
+ port: string
29
+ host: string
30
+ }
31
+ // Possible bug, when snapshot is null.
32
+ snapshot: SnapshotDto | null
33
+ }
34
+
35
+ export const formatCloneDto = (dto: CloneDto) => ({
36
+ ...dto,
37
+ createdAt: dto.createdAt,
38
+ createdAtDate: parseDate(dto.createdAt),
39
+ snapshot: dto.snapshot ? formatSnapshotDto(dto.snapshot) : null,
40
+ })
41
+
42
+ export type Clone = ReturnType<typeof formatCloneDto>
@@ -0,0 +1,114 @@
1
+ import {
2
+ formatDatabases,
3
+ formatDumpCustomOptions,
4
+ getImageMajorVersion,
5
+ getImageType,
6
+ isSeDockerImage,
7
+ } from '@postgres.ai/shared/pages/Configuration/utils'
8
+ import { formatTuningParams } from '../endpoints/testDbSource'
9
+
10
+ export interface DatabaseType {
11
+ [name: string]: string | Object
12
+ }
13
+
14
+ export type configTypes = {
15
+ global?: {
16
+ debug?: boolean
17
+ }
18
+ databaseContainer?: {
19
+ dockerImage?: string
20
+ dockerPath?: string
21
+ }
22
+ databaseConfigs?: {
23
+ configs?: {
24
+ [key: string]: string
25
+ }
26
+ }
27
+ retrieval?: {
28
+ refresh?: {
29
+ timetable?: string
30
+ }
31
+ spec?: {
32
+ logicalDump?: {
33
+ options?: {
34
+ customOptions?: string[]
35
+ databases?: DatabaseType | null
36
+ parallelJobs?: string | number
37
+ ignoreErrors?: boolean
38
+ source?: {
39
+ connection?: {
40
+ dbname?: string
41
+ host?: string
42
+ port?: string | number
43
+ username?: string
44
+ password?: string
45
+ }
46
+ }
47
+ }
48
+ }
49
+ logicalRestore?: {
50
+ options?: {
51
+ customOptions?: string[]
52
+ parallelJobs?: string | number
53
+ ignoreErrors?: boolean
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ export const formatConfig = (config: configTypes) => {
61
+ const dockerImage = config.databaseContainer?.dockerImage
62
+ return {
63
+ debug: config.global?.debug,
64
+ dockerImage: isSeDockerImage(dockerImage)
65
+ ? getImageMajorVersion(dockerImage)
66
+ : dockerImage,
67
+ ...(dockerImage && {
68
+ dockerImageType: getImageType(dockerImage),
69
+ }),
70
+ ...(isSeDockerImage(dockerImage) && {
71
+ dockerTag: dockerImage?.split(':')[1],
72
+ }),
73
+ dockerPath: dockerImage,
74
+ tuningParams: formatTuningParams(config.databaseConfigs?.configs),
75
+ sharedBuffers: config.databaseConfigs?.configs?.shared_buffers,
76
+ sharedPreloadLibraries:
77
+ config.databaseConfigs?.configs?.shared_preload_libraries,
78
+ timetable: config.retrieval?.refresh?.timetable,
79
+ dbname:
80
+ config.retrieval?.spec?.logicalDump?.options?.source?.connection?.dbname,
81
+ host: config.retrieval?.spec?.logicalDump?.options?.source?.connection
82
+ ?.host,
83
+ port: config.retrieval?.spec?.logicalDump?.options?.source?.connection
84
+ ?.port,
85
+ username:
86
+ config.retrieval?.spec?.logicalDump?.options?.source?.connection
87
+ ?.username,
88
+ password:
89
+ config.retrieval?.spec?.logicalDump?.options?.source?.connection
90
+ ?.password,
91
+ databases: formatDatabases(
92
+ config.retrieval?.spec?.logicalDump?.options
93
+ ?.databases as DatabaseType | null,
94
+ ),
95
+ dumpParallelJobs:
96
+ config.retrieval?.spec?.logicalDump?.options?.parallelJobs,
97
+ dumpIgnoreErrors:
98
+ config.retrieval?.spec?.logicalDump?.options?.ignoreErrors,
99
+ restoreParallelJobs:
100
+ config.retrieval?.spec?.logicalRestore?.options?.parallelJobs,
101
+ restoreIgnoreErrors:
102
+ config.retrieval?.spec?.logicalRestore?.options?.ignoreErrors,
103
+ pgDumpCustomOptions: formatDumpCustomOptions(
104
+ (config.retrieval?.spec?.logicalDump?.options
105
+ ?.customOptions as string[]) || null,
106
+ ),
107
+ pgRestoreCustomOptions: formatDumpCustomOptions(
108
+ (config.retrieval?.spec?.logicalRestore?.options
109
+ ?.customOptions as string[]) || null,
110
+ ),
111
+ }
112
+ }
113
+
114
+ export type Config = ReturnType<typeof formatConfig>