@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.
- package/.gitlab-ci.yml +60 -0
- package/components/AlertSnackbar/index.tsx +23 -0
- package/components/AlertSnackbar/useAlertSnackbar.tsx +65 -0
- package/components/Button/index.tsx +79 -0
- package/components/Button2/index.tsx +43 -0
- package/components/Button2/styles.module.scss +82 -0
- package/components/DestroyCloneModal/index.tsx +56 -0
- package/components/DestroyCloneRestrictionModal/index.tsx +50 -0
- package/components/ErrorStub/index.tsx +83 -0
- package/components/FormattedText/index.tsx +44 -0
- package/components/FormattedText/styles.module.scss +34 -0
- package/components/GatewayLink/index.tsx +33 -0
- package/components/HorizontalScrollContainer/index.tsx +131 -0
- package/components/HorizontalScrollContainer/types.ts +12 -0
- package/components/HorizontalScrollContainer/utils.ts +16 -0
- package/components/ImportantText/index.tsx +29 -0
- package/components/Link2/index.tsx +31 -0
- package/components/Link2/styles.module.scss +12 -0
- package/components/MenuButton/index.tsx +80 -0
- package/components/MenuButton/styles.module.scss +42 -0
- package/components/Modal/index.tsx +93 -0
- package/components/PageSpinner/index.tsx +18 -0
- package/components/PageSpinner/styles.module.scss +13 -0
- package/components/ResetCloneModal/index.tsx +154 -0
- package/components/SectionTitle/index.tsx +74 -0
- package/components/Select/index.tsx +42 -0
- package/components/SimpleModalControls/index.tsx +56 -0
- package/components/Spinner/icon.tsx +29 -0
- package/components/Spinner/index.tsx +16 -0
- package/components/Spinner/styles.module.scss +33 -0
- package/components/Status/index.tsx +61 -0
- package/components/Status/styles.module.scss +45 -0
- package/components/StubContainer/index.tsx +41 -0
- package/components/StubSpinner/index.tsx +49 -0
- package/components/StubSpinnerFlex/index.tsx +20 -0
- package/components/StubSpinnerFlex/styles.module.scss +20 -0
- package/components/SyntaxHighlight/index.tsx +107 -0
- package/components/Table/RowMenu/index.tsx +111 -0
- package/components/Table/index.tsx +140 -0
- package/components/Text/index.tsx +28 -0
- package/components/TextField/index.tsx +117 -0
- package/components/Tooltip/index.tsx +52 -0
- package/config/index.ts +32 -0
- package/config/links.ts +6 -0
- package/craco.config.js +80 -0
- package/helpers/getEntropy.ts +232 -0
- package/helpers/localStorage.ts +15 -0
- package/helpers/request.ts +47 -0
- package/hooks/useWindowDimensions.ts +16 -0
- package/icons/ArrowDropDown/index.tsx +29 -0
- package/icons/Circle/index.tsx +27 -0
- package/icons/External/index.tsx +14 -0
- package/icons/Info/index.tsx +12 -0
- package/icons/Renewable/index.tsx +65 -0
- package/icons/Shield/index.tsx +33 -0
- package/icons/Warning/index.tsx +29 -0
- package/meta.json +1 -0
- package/package.json +55 -0
- package/pages/Clone/Status/index.tsx +73 -0
- package/pages/Clone/context.ts +22 -0
- package/pages/Clone/index.tsx +634 -0
- package/pages/Clone/stores/Main.ts +206 -0
- package/pages/Clone/useCreatedStores.ts +11 -0
- package/pages/Configuration/Header/index.tsx +84 -0
- package/pages/Configuration/InputWithTooltip/index.tsx +240 -0
- package/pages/Configuration/ResponseMessage/index.tsx +71 -0
- package/pages/Configuration/configOptions.ts +60 -0
- package/pages/Configuration/index.tsx +1184 -0
- package/pages/Configuration/styles.module.scss +122 -0
- package/pages/Configuration/tooltipText.tsx +157 -0
- package/pages/Configuration/useForm.ts +108 -0
- package/pages/Configuration/utils/index.ts +153 -0
- package/pages/CreateClone/index.tsx +311 -0
- package/pages/CreateClone/stores/Main.ts +107 -0
- package/pages/CreateClone/styles.module.scss +71 -0
- package/pages/CreateClone/useCreatedStores.ts +11 -0
- package/pages/CreateClone/useForm.ts +36 -0
- package/pages/Instance/Clones/Header/Item/index.tsx +15 -0
- package/pages/Instance/Clones/Header/Item/styles.module.scss +17 -0
- package/pages/Instance/Clones/Header/index.tsx +74 -0
- package/pages/Instance/Clones/Header/styles.module.scss +11 -0
- package/pages/Instance/Clones/index.tsx +135 -0
- package/pages/Instance/ClonesModal/index.tsx +71 -0
- package/pages/Instance/ClonesModal/utils.ts +21 -0
- package/pages/Instance/InactiveInstance/index.tsx +165 -0
- package/pages/Instance/InactiveInstance/utils.ts +9 -0
- package/pages/Instance/Info/Connection/ConnectModal/Content/index.tsx +176 -0
- package/pages/Instance/Info/Connection/ConnectModal/Content/utils.ts +24 -0
- package/pages/Instance/Info/Connection/ConnectModal/index.tsx +36 -0
- package/pages/Instance/Info/Connection/index.tsx +81 -0
- package/pages/Instance/Info/Details/index.tsx +20 -0
- package/pages/Instance/Info/Disks/Disk/ActionsMenu/index.tsx +100 -0
- package/pages/Instance/Info/Disks/Disk/Marker/index.tsx +26 -0
- package/pages/Instance/Info/Disks/Disk/ProgressBar/PointerIcon.tsx +20 -0
- package/pages/Instance/Info/Disks/Disk/ProgressBar/index.tsx +73 -0
- package/pages/Instance/Info/Disks/Disk/Status/index.tsx +75 -0
- package/pages/Instance/Info/Disks/Disk/index.tsx +168 -0
- package/pages/Instance/Info/Disks/index.tsx +65 -0
- package/pages/Instance/Info/Icons/index.tsx +39 -0
- package/pages/Instance/Info/Retrieval/RefreshFailedAlert/index.tsx +32 -0
- package/pages/Instance/Info/Retrieval/RefreshFailedAlert/styles.module.scss +33 -0
- package/pages/Instance/Info/Retrieval/RetrievalModal/index.tsx +49 -0
- package/pages/Instance/Info/Retrieval/RetrievalModal/styles.module.scss +6 -0
- package/pages/Instance/Info/Retrieval/RetrievalTable/index.tsx +53 -0
- package/pages/Instance/Info/Retrieval/RetrievalTable/styles.module.scss +29 -0
- package/pages/Instance/Info/Retrieval/index.tsx +95 -0
- package/pages/Instance/Info/Retrieval/utils.ts +10 -0
- package/pages/Instance/Info/Snapshots/Calendar/Day/index.tsx +125 -0
- package/pages/Instance/Info/Snapshots/Calendar/index.tsx +133 -0
- package/pages/Instance/Info/Snapshots/Calendar/utils.ts +74 -0
- package/pages/Instance/Info/Snapshots/TimeLine/Day/index.tsx +79 -0
- package/pages/Instance/Info/Snapshots/TimeLine/index.tsx +57 -0
- package/pages/Instance/Info/Snapshots/index.tsx +97 -0
- package/pages/Instance/Info/Snapshots/utils.ts +18 -0
- package/pages/Instance/Info/Status/InstanceResponseModal/index.tsx +32 -0
- package/pages/Instance/Info/Status/InstanceResponseModal/styles.module.scss +3 -0
- package/pages/Instance/Info/Status/index.tsx +85 -0
- package/pages/Instance/Info/Status/styles.module.scss +12 -0
- package/pages/Instance/Info/Status/utils.ts +24 -0
- package/pages/Instance/Info/components/Property/index.tsx +32 -0
- package/pages/Instance/Info/components/Property/styles.module.scss +21 -0
- package/pages/Instance/Info/components/Section/index.tsx +50 -0
- package/pages/Instance/Info/components/ValueStatus/index.tsx +51 -0
- package/pages/Instance/Info/index.tsx +129 -0
- package/pages/Instance/SnapshotsModal/index.tsx +169 -0
- package/pages/Instance/SnapshotsModal/utils.ts +17 -0
- package/pages/Instance/Tabs/index.tsx +98 -0
- package/pages/Instance/components/ClonesList/ConnectionModal/index.tsx +196 -0
- package/pages/Instance/components/ClonesList/MenuCell/index.tsx +98 -0
- package/pages/Instance/components/ClonesList/MenuCell/utils.ts +21 -0
- package/pages/Instance/components/ClonesList/index.tsx +189 -0
- package/pages/Instance/components/ClonesList/styles.module.scss +32 -0
- package/pages/Instance/components/ErrorStub/index.tsx +77 -0
- package/pages/Instance/components/ModalReloadButton/index.tsx +43 -0
- package/pages/Instance/components/Tags/Tag/index.tsx +60 -0
- package/pages/Instance/components/Tags/index.tsx +42 -0
- package/pages/Instance/context.ts +39 -0
- package/pages/Instance/index.tsx +235 -0
- package/pages/Instance/stores/ClonesModal.ts +35 -0
- package/pages/Instance/stores/Main.ts +335 -0
- package/pages/Instance/stores/SnapshotsModal.ts +35 -0
- package/pages/Instance/styles.scss +40 -0
- package/pages/Instance/useCreatedStores.ts +14 -0
- package/pages/Logs/Icons/PlusIcon.tsx +8 -0
- package/pages/Logs/constants/index.ts +7 -0
- package/pages/Logs/hooks/useWsScroll.tsx +44 -0
- package/pages/Logs/index.tsx +267 -0
- package/pages/Logs/utils/index.ts +20 -0
- package/pages/Logs/wsLogs.ts +110 -0
- package/pages/Logs/wsSnackbar.ts +27 -0
- package/postgres.ai-shared-3.5.0.tgz +0 -0
- package/react-app-env.d.ts +71 -0
- package/scripts/copy-assets.js +30 -0
- package/scripts/pack.js +70 -0
- package/stores/Snapshots.ts +54 -0
- package/styles/colors.ts +67 -0
- package/styles/global.scss +29 -0
- package/styles/icons.tsx +1917 -0
- package/styles/mixins.scss +30 -0
- package/styles/styles.ts +87 -0
- package/styles/theme.ts +53 -0
- package/styles/vars.scss +43 -0
- package/styles/vars.ts +40 -0
- package/tsconfig.build.json +37 -0
- package/tsconfig.json +30 -0
- package/types/api/endpoints/createClone.ts +10 -0
- package/types/api/endpoints/destroyClone.ts +7 -0
- package/types/api/endpoints/getClone.ts +6 -0
- package/types/api/endpoints/getConfig.ts +6 -0
- package/types/api/endpoints/getEngine.ts +13 -0
- package/types/api/endpoints/getFullConfig.ts +4 -0
- package/types/api/endpoints/getInstance.ts +6 -0
- package/types/api/endpoints/getInstanceRetrieval.ts +6 -0
- package/types/api/endpoints/getSeImages.ts +22 -0
- package/types/api/endpoints/getSnapshots.ts +6 -0
- package/types/api/endpoints/getWSToken.ts +6 -0
- package/types/api/endpoints/initWS.ts +1 -0
- package/types/api/endpoints/refreshInstance.ts +4 -0
- package/types/api/endpoints/resetClone.ts +8 -0
- package/types/api/endpoints/testDbSource.ts +48 -0
- package/types/api/endpoints/updateClone.ts +10 -0
- package/types/api/endpoints/updateConfig.ts +6 -0
- package/types/api/entities/clone.ts +42 -0
- package/types/api/entities/config.ts +114 -0
- package/types/api/entities/dbSource.ts +13 -0
- package/types/api/entities/instance.ts +67 -0
- package/types/api/entities/instanceRetrieval.ts +46 -0
- package/types/api/entities/instanceState.ts +102 -0
- package/types/api/entities/pool.ts +27 -0
- package/types/api/entities/snapshot.ts +18 -0
- package/types/api/entities/wsToken.ts +7 -0
- package/types/byte-size/index.d.ts +22 -0
- package/utils/api.ts +30 -0
- package/utils/clone.ts +31 -0
- package/utils/connection.ts +38 -0
- package/utils/date.ts +87 -0
- package/utils/instance.ts +10 -0
- package/utils/numbers.ts +11 -0
- package/utils/react.ts +10 -0
- package/utils/snapshot.ts +4 -0
- package/utils/strings.ts +11 -0
- package/utils/units.ts +23 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
const replaceChars = '!@$&*'
|
|
2
|
+
const sepChars = '_-., '
|
|
3
|
+
const otherSpecialChars = '“#%"()+/:;<=>?[\\]^{|}~'
|
|
4
|
+
const lowerChars = 'abcdefghijklmnopqrstuvwxyz'
|
|
5
|
+
const upperChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
6
|
+
const digitsChars = '0123456789'
|
|
7
|
+
export const MIN_ENTROPY = 60
|
|
8
|
+
|
|
9
|
+
function getBase(password: string): number {
|
|
10
|
+
let uniqueChars: string[] = []
|
|
11
|
+
for (const c of password) {
|
|
12
|
+
if (!uniqueChars.includes(c)) {
|
|
13
|
+
uniqueChars.push(c)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
let hasReplace = false
|
|
17
|
+
let hasSep = false
|
|
18
|
+
let hasOtherSpecial = false
|
|
19
|
+
let hasLower = false
|
|
20
|
+
let hasUpper = false
|
|
21
|
+
let hasDigits = false
|
|
22
|
+
let base = 0
|
|
23
|
+
|
|
24
|
+
for (let i = 0; i < uniqueChars.length; i++) {
|
|
25
|
+
switch (true) {
|
|
26
|
+
case replaceChars.includes(uniqueChars[i]):
|
|
27
|
+
hasReplace = true
|
|
28
|
+
break
|
|
29
|
+
case sepChars.includes(uniqueChars[i]):
|
|
30
|
+
hasSep = true
|
|
31
|
+
break
|
|
32
|
+
case otherSpecialChars.includes(uniqueChars[i]):
|
|
33
|
+
hasOtherSpecial = true
|
|
34
|
+
break
|
|
35
|
+
case lowerChars.includes(uniqueChars[i]):
|
|
36
|
+
hasLower = true
|
|
37
|
+
break
|
|
38
|
+
case upperChars.includes(uniqueChars[i]):
|
|
39
|
+
hasUpper = true
|
|
40
|
+
break
|
|
41
|
+
case digitsChars.includes(uniqueChars[i]):
|
|
42
|
+
hasDigits = true
|
|
43
|
+
break
|
|
44
|
+
default:
|
|
45
|
+
base++
|
|
46
|
+
break
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (hasReplace) {
|
|
50
|
+
base += replaceChars.length
|
|
51
|
+
}
|
|
52
|
+
if (hasSep) {
|
|
53
|
+
base += sepChars.length
|
|
54
|
+
}
|
|
55
|
+
if (hasOtherSpecial) {
|
|
56
|
+
base += otherSpecialChars.length
|
|
57
|
+
}
|
|
58
|
+
if (hasLower) {
|
|
59
|
+
base += lowerChars.length
|
|
60
|
+
}
|
|
61
|
+
if (hasUpper) {
|
|
62
|
+
base += upperChars.length
|
|
63
|
+
}
|
|
64
|
+
if (hasDigits) {
|
|
65
|
+
base += digitsChars.length
|
|
66
|
+
}
|
|
67
|
+
return base
|
|
68
|
+
}
|
|
69
|
+
const seqNums = '0123456789'
|
|
70
|
+
const seqKeyboard0 = 'qwertyuiop'
|
|
71
|
+
const seqKeyboard1 = 'asdfghjkl'
|
|
72
|
+
const seqKeyboard2 = 'zxcvbnm'
|
|
73
|
+
const seqAlphabet = 'abcdefghijklmnopqrstuvwxyz'
|
|
74
|
+
function removeMoreThanTwoFromSequence(s: string, seq: string): string {
|
|
75
|
+
const seqRunes: string[] = Array.from(seq)
|
|
76
|
+
let runes: string[] = Array.from(s)
|
|
77
|
+
let matches = 0
|
|
78
|
+
for (let i = 0; i < runes.length; i++) {
|
|
79
|
+
for (let j = 0; j < seqRunes.length; j++) {
|
|
80
|
+
if (i >= runes.length) {
|
|
81
|
+
break
|
|
82
|
+
}
|
|
83
|
+
const r = runes[i]
|
|
84
|
+
const r2 = seqRunes[j]
|
|
85
|
+
if (r !== r2) {
|
|
86
|
+
matches = 0
|
|
87
|
+
continue
|
|
88
|
+
}
|
|
89
|
+
// found a match, advance the counter
|
|
90
|
+
matches++
|
|
91
|
+
if (matches > 2) {
|
|
92
|
+
runes.splice(i, 1)
|
|
93
|
+
} else {
|
|
94
|
+
i++
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return runes.join('')
|
|
99
|
+
}
|
|
100
|
+
function getReversedString(s: string): string {
|
|
101
|
+
const rune: string[] = Array.from(s)
|
|
102
|
+
const n = rune.length
|
|
103
|
+
for (let i = 0; i < Math.floor(n / 2); i++) {
|
|
104
|
+
;[rune[i], rune[n - 1 - i]] = [rune[n - 1 - i], rune[i]]
|
|
105
|
+
}
|
|
106
|
+
return rune.join('')
|
|
107
|
+
}
|
|
108
|
+
function removeMoreThanTwoRepeatingChars(s: string): string {
|
|
109
|
+
let prevPrev: string = ''
|
|
110
|
+
let prev: string = ''
|
|
111
|
+
const runes: string[] = Array.from(s)
|
|
112
|
+
for (let i = 0; i < runes.length; i++) {
|
|
113
|
+
const r = runes[i]
|
|
114
|
+
if (r === prev && r === prevPrev) {
|
|
115
|
+
runes.splice(i, 1)
|
|
116
|
+
i--
|
|
117
|
+
}
|
|
118
|
+
prevPrev = prev
|
|
119
|
+
prev = r
|
|
120
|
+
}
|
|
121
|
+
return runes.join('')
|
|
122
|
+
}
|
|
123
|
+
function getLength(password: string): number {
|
|
124
|
+
password = removeMoreThanTwoRepeatingChars(password)
|
|
125
|
+
password = removeMoreThanTwoFromSequence(password, seqNums)
|
|
126
|
+
password = removeMoreThanTwoFromSequence(password, seqKeyboard0)
|
|
127
|
+
password = removeMoreThanTwoFromSequence(password, seqKeyboard1)
|
|
128
|
+
password = removeMoreThanTwoFromSequence(password, seqKeyboard2)
|
|
129
|
+
password = removeMoreThanTwoFromSequence(password, seqAlphabet)
|
|
130
|
+
password = removeMoreThanTwoFromSequence(password, getReversedString(seqNums))
|
|
131
|
+
password = removeMoreThanTwoFromSequence(
|
|
132
|
+
password,
|
|
133
|
+
getReversedString(seqKeyboard0),
|
|
134
|
+
)
|
|
135
|
+
password = removeMoreThanTwoFromSequence(
|
|
136
|
+
password,
|
|
137
|
+
getReversedString(seqKeyboard1),
|
|
138
|
+
)
|
|
139
|
+
password = removeMoreThanTwoFromSequence(
|
|
140
|
+
password,
|
|
141
|
+
getReversedString(seqKeyboard2),
|
|
142
|
+
)
|
|
143
|
+
password = removeMoreThanTwoFromSequence(
|
|
144
|
+
password,
|
|
145
|
+
getReversedString(seqAlphabet),
|
|
146
|
+
)
|
|
147
|
+
return password.length
|
|
148
|
+
}
|
|
149
|
+
export function getEntropy(password: string): number {
|
|
150
|
+
return getEntropyInternal(password)
|
|
151
|
+
}
|
|
152
|
+
function getEntropyInternal(password: string): number {
|
|
153
|
+
const base = getBase(password)
|
|
154
|
+
const length = getLength(password)
|
|
155
|
+
// calculate log2(base^length)
|
|
156
|
+
return logPow(base, length, 2)
|
|
157
|
+
}
|
|
158
|
+
function logX(base: number, n: number): number {
|
|
159
|
+
if (base == 0) {
|
|
160
|
+
return 0
|
|
161
|
+
} else {
|
|
162
|
+
return Math.log2(n) / Math.log2(base)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function logPow(expBase: number, pow: number, logBase: number): number {
|
|
166
|
+
let total = 0
|
|
167
|
+
for (let i = 0; i < pow; i++) {
|
|
168
|
+
total += logX(logBase, expBase)
|
|
169
|
+
}
|
|
170
|
+
return total
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function validatePassword(password: string, minEntropy: number): string {
|
|
174
|
+
const entropy: number = getEntropy(password)
|
|
175
|
+
if (entropy >= minEntropy) {
|
|
176
|
+
return ''
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let hasReplace: boolean = false
|
|
180
|
+
let hasSep: boolean = false
|
|
181
|
+
let hasOtherSpecial: boolean = false
|
|
182
|
+
let hasLower: boolean = false
|
|
183
|
+
let hasUpper: boolean = false
|
|
184
|
+
let hasDigits: boolean = false
|
|
185
|
+
|
|
186
|
+
for (const c of password) {
|
|
187
|
+
switch (true) {
|
|
188
|
+
case replaceChars.includes(c):
|
|
189
|
+
hasReplace = true
|
|
190
|
+
break
|
|
191
|
+
case sepChars.includes(c):
|
|
192
|
+
hasSep = true
|
|
193
|
+
break
|
|
194
|
+
case otherSpecialChars.includes(c):
|
|
195
|
+
hasOtherSpecial = true
|
|
196
|
+
break
|
|
197
|
+
case lowerChars.includes(c):
|
|
198
|
+
hasLower = true
|
|
199
|
+
break
|
|
200
|
+
case upperChars.includes(c):
|
|
201
|
+
hasUpper = true
|
|
202
|
+
break
|
|
203
|
+
case digitsChars.includes(c):
|
|
204
|
+
hasDigits = true
|
|
205
|
+
break
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const allMessages: string[] = []
|
|
210
|
+
|
|
211
|
+
if (!hasOtherSpecial || !hasSep || !hasReplace) {
|
|
212
|
+
allMessages.push('including more special characters')
|
|
213
|
+
}
|
|
214
|
+
if (!hasLower) {
|
|
215
|
+
allMessages.push('using lowercase letters')
|
|
216
|
+
}
|
|
217
|
+
if (!hasUpper) {
|
|
218
|
+
allMessages.push('using uppercase letters')
|
|
219
|
+
}
|
|
220
|
+
if (!hasDigits) {
|
|
221
|
+
allMessages.push('using numbers')
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (allMessages.length > 0) {
|
|
225
|
+
const errorMessage: string = `Weak password, try ${allMessages.join(
|
|
226
|
+
', ',
|
|
227
|
+
)} or using a longer password`
|
|
228
|
+
return errorMessage
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return 'Weak password, try using a longer password'
|
|
232
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const keys = {
|
|
2
|
+
// Keep this name.
|
|
3
|
+
authToken: 'token',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export class LocalStorage {
|
|
7
|
+
// Auth token.
|
|
8
|
+
getAuthToken = () => window.localStorage.getItem(keys.authToken)
|
|
9
|
+
|
|
10
|
+
setAuthToken = (value: string) => window.localStorage.setItem(keys.authToken, value)
|
|
11
|
+
|
|
12
|
+
removeAuthToken = () => window.localStorage.removeItem(keys.authToken)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const localStorage = new LocalStorage()
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import 'whatwg-fetch'
|
|
2
|
+
|
|
3
|
+
type RequestParams = Record<string, unknown>
|
|
4
|
+
|
|
5
|
+
export type RequestOptions = RequestInit & {
|
|
6
|
+
params?: RequestParams
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const serializeParams = (params: RequestParams | null) => {
|
|
10
|
+
if (!params) return null
|
|
11
|
+
|
|
12
|
+
const searchParams = new URLSearchParams()
|
|
13
|
+
|
|
14
|
+
Object.entries(params).map((param) => {
|
|
15
|
+
const [key, value] = param
|
|
16
|
+
searchParams.append(key, String(value))
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
return searchParams.toString()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const createUrl = (path: string, params: RequestParams | null) => {
|
|
23
|
+
const serializedParams = serializeParams(params)
|
|
24
|
+
const queryString = serializedParams ? `?${serializedParams}` : ''
|
|
25
|
+
return `${path}${queryString}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const request = async (path: string, options?: RequestOptions) => {
|
|
29
|
+
const { params = null, ...requestInit } = options ?? {}
|
|
30
|
+
|
|
31
|
+
const url = createUrl(path, params)
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
return await window.fetch(url, {
|
|
35
|
+
...requestInit,
|
|
36
|
+
headers: {
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
...requestInit?.headers,
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return new Response(null, {
|
|
43
|
+
status: 500,
|
|
44
|
+
statusText: `Unknown error`,
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
export const useWindowDimensions = () => {
|
|
4
|
+
const [windowDimensions, setWindowDimensions] = useState(window.innerWidth)
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const handleResize = () => {
|
|
8
|
+
setWindowDimensions(window.innerWidth)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
window.addEventListener('resize', handleResize)
|
|
12
|
+
return () => window.removeEventListener('resize', handleResize)
|
|
13
|
+
}, [])
|
|
14
|
+
|
|
15
|
+
return windowDimensions
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 React from 'react'
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
className?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const ArrowDropDownIcon = (props: Props) => {
|
|
15
|
+
return (
|
|
16
|
+
<svg
|
|
17
|
+
className={props.className}
|
|
18
|
+
viewBox="0 0 8 6"
|
|
19
|
+
fill="none"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
>
|
|
22
|
+
<path
|
|
23
|
+
// eslint-disable-next-line max-len
|
|
24
|
+
d="M7.8515 0.898419C7.75261 0.799446 7.63538 0.75 7.49994 0.75H0.500038C0.364534 0.75 0.247392 0.799446 0.148419 0.898419C0.0494455 0.997501 0 1.11464 0 1.25006C0 1.38546 0.0494455 1.5026 0.148419 1.6016L3.64838 5.10156C3.74746 5.20054 3.86461 5.25009 4 5.25009C4.13539 5.25009 4.25265 5.20054 4.35154 5.10156L7.8515 1.60157C7.95036 1.5026 8 1.38546 8 1.25004C8 1.11464 7.95036 0.997501 7.8515 0.898419Z"
|
|
25
|
+
fill="currentColor"
|
|
26
|
+
/>
|
|
27
|
+
</svg>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 React from 'react'
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
className?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const CircleIcon = (props: Props) => {
|
|
15
|
+
const { className } = props
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<svg
|
|
19
|
+
className={className}
|
|
20
|
+
viewBox="0 0 10 10"
|
|
21
|
+
version="1.1"
|
|
22
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
23
|
+
>
|
|
24
|
+
<circle cx="5" cy="5" r="5" fill="currentColor"></circle>
|
|
25
|
+
</svg>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const ExternalIcon = ({ className }: { className: string }) => (
|
|
2
|
+
<svg
|
|
3
|
+
width="24px"
|
|
4
|
+
height="24px"
|
|
5
|
+
viewBox="0 0 24 24"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
className={className}
|
|
8
|
+
>
|
|
9
|
+
<path
|
|
10
|
+
fill="#551A8B"
|
|
11
|
+
d="M18,10.82a1,1,0,0,0-1,1V19a1,1,0,0,1-1,1H5a1,1,0,0,1-1-1V8A1,1,0,0,1,5,7h7.18a1,1,0,0,0,0-2H5A3,3,0,0,0,2,8V19a3,3,0,0,0,3,3H16a3,3,0,0,0,3-3V11.82A1,1,0,0,0,18,10.82Zm3.92-8.2a1,1,0,0,0-.54-.54A1,1,0,0,0,21,2H15a1,1,0,0,0,0,2h3.59L8.29,14.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L20,5.41V9a1,1,0,0,0,2,0V3A1,1,0,0,0,21.92,2.62Z"
|
|
12
|
+
/>
|
|
13
|
+
</svg>
|
|
14
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const InfoIcon = ({ className }: { className?: string }) => (
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
viewBox="0 0 12 12"
|
|
5
|
+
className={className}
|
|
6
|
+
>
|
|
7
|
+
<g fill="currentColor" fillRule="nonzero">
|
|
8
|
+
<path d="M6 0C2.692 0 0 2.692 0 6s2.692 6 6 6 6-2.692 6-6-2.692-6-6-6Zm0 10.91A4.915 4.915 0 0 1 1.09 6 4.915 4.915 0 0 1 6 1.09 4.915 4.915 0 0 1 10.91 6 4.915 4.915 0 0 1 6 10.91Z" />
|
|
9
|
+
<path d="M6 2.545A.728.728 0 0 0 6 4a.728.728 0 0 0 0-1.455ZM6 5.09a.545.545 0 0 0-.545.546V8.91a.545.545 0 0 0 1.09 0V5.636A.545.545 0 0 0 6 5.091Z" />
|
|
10
|
+
</g>
|
|
11
|
+
</svg>
|
|
12
|
+
)
|
|
@@ -0,0 +1,65 @@
|
|
|
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 React from 'react'
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
className?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const RenewableIcon = React.forwardRef<SVGSVGElement, Props>(
|
|
15
|
+
(props, ref) => {
|
|
16
|
+
const { className, ...hiddenProps } = props
|
|
17
|
+
return (
|
|
18
|
+
<svg
|
|
19
|
+
{...hiddenProps}
|
|
20
|
+
ref={ref}
|
|
21
|
+
className={className}
|
|
22
|
+
viewBox="0 0 10 10"
|
|
23
|
+
fill="none"
|
|
24
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
+
>
|
|
26
|
+
<path
|
|
27
|
+
fillRule="evenodd"
|
|
28
|
+
clipRule="evenodd"
|
|
29
|
+
d="M6.14337 0L8.19809 2.9755L4.59387 3.26718L5.16139 2.07055C4.22847 2.10806 3.3161 2.48386 2.66614 3.18795L2.20594 2.76312C3.05679 1.84141 4.26977 1.40592 5.45883 1.44339L6.14337 0Z"
|
|
30
|
+
fill="currentColor"
|
|
31
|
+
/>
|
|
32
|
+
<path
|
|
33
|
+
fillRule="evenodd"
|
|
34
|
+
clipRule="evenodd"
|
|
35
|
+
d="M9.7343 9.13905L6.12728 9.39371L7.71025 6.14261L8.45158 7.24009C8.89401 6.4179 9.03479 5.44126 8.75942 4.52346L9.35931 4.34347C9.71979 5.54495 9.47743 6.81074 8.8401 7.81527L9.7343 9.13905Z"
|
|
36
|
+
fill="currentColor"
|
|
37
|
+
/>
|
|
38
|
+
<path
|
|
39
|
+
fillRule="evenodd"
|
|
40
|
+
clipRule="evenodd"
|
|
41
|
+
d="M0 7.57495L1.61898 4.34163L3.60962 7.36037L2.28757 7.43896C2.76953 8.23862 3.53811 8.85742 4.46813 9.08819L4.3173 9.69607C3.09983 9.39397 2.13422 8.54041 1.59468 7.48015L0 7.57495Z"
|
|
42
|
+
fill="currentColor"
|
|
43
|
+
/>
|
|
44
|
+
<path
|
|
45
|
+
fillRule="evenodd"
|
|
46
|
+
clipRule="evenodd"
|
|
47
|
+
d="M6.26612 2.51078C5.07868 2.17637 3.73747 2.48899 2.89616 3.40036L1.97575 2.55072C3.17071 1.25624 5.01514 0.857134 6.60567 1.30506L6.26612 2.51078Z"
|
|
48
|
+
fill="currentColor"
|
|
49
|
+
/>
|
|
50
|
+
<path
|
|
51
|
+
fillRule="evenodd"
|
|
52
|
+
clipRule="evenodd"
|
|
53
|
+
d="M7.33938 8.11969C8.34588 7.28131 8.83847 5.87691 8.45939 4.61345L9.65917 4.25348C10.1969 6.04581 9.49312 7.95595 8.14107 9.08215L7.33938 8.11969Z"
|
|
54
|
+
fill="currentColor"
|
|
55
|
+
/>
|
|
56
|
+
<path
|
|
57
|
+
fillRule="evenodd"
|
|
58
|
+
clipRule="evenodd"
|
|
59
|
+
d="M2.07072 5.82736C2.20416 7.20026 3.19328 8.44922 4.54348 8.78425L4.24181 10C2.32911 9.5254 1.00387 7.79934 0.823976 5.94853L2.07072 5.82736Z"
|
|
60
|
+
fill="currentColor"
|
|
61
|
+
/>
|
|
62
|
+
</svg>
|
|
63
|
+
)
|
|
64
|
+
},
|
|
65
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
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 React from 'react'
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
className?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const ShieldIcon = React.forwardRef<SVGSVGElement, Props>(
|
|
15
|
+
(props, ref) => {
|
|
16
|
+
const { className, ...hiddenProps } = props
|
|
17
|
+
return (
|
|
18
|
+
<svg
|
|
19
|
+
{...hiddenProps}
|
|
20
|
+
ref={ref}
|
|
21
|
+
className={className}
|
|
22
|
+
viewBox="0 0 8 10"
|
|
23
|
+
fill="none"
|
|
24
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
+
>
|
|
26
|
+
<path
|
|
27
|
+
d="M4.00195 0L0.251953 1.66667V4.16667C0.251953 6.47917 1.85195 8.64167 4.00195 9.16667C6.15195 8.64167 7.75195 6.47917 7.75195 4.16667V1.66667L4.00195 0ZM3.16862 6.66667L1.50195 5L2.08945 4.4125L3.16862 5.4875L5.91445 2.74167L6.50195 3.33333L3.16862 6.66667Z"
|
|
28
|
+
fill="currentColor"
|
|
29
|
+
/>
|
|
30
|
+
</svg>
|
|
31
|
+
)
|
|
32
|
+
},
|
|
33
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
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 React from 'react'
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
className?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const WarningIcon = (props: Props) => {
|
|
15
|
+
return (
|
|
16
|
+
<svg
|
|
17
|
+
className={props.className}
|
|
18
|
+
viewBox="0 0 10 10"
|
|
19
|
+
fill="none"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
>
|
|
22
|
+
<path
|
|
23
|
+
// eslint-disable-next-line max-len
|
|
24
|
+
d="M9.79222 7.49885L6.2597 1.00518C5.69214 0.04969 4.30861 0.0484205 3.74029 1.00518L0.207947 7.49885C-0.372248 8.4752 0.330193 9.71157 1.46736 9.71157H8.53251C9.66873 9.71157 10.3724 8.47619 9.79222 7.49885ZM5 8.53969C4.67699 8.53969 4.41406 8.27676 4.41406 7.95375C4.41406 7.63074 4.67699 7.36782 5 7.36782C5.323 7.36782 5.58593 7.63074 5.58593 7.95375C5.58593 8.27676 5.323 8.53969 5 8.53969ZM5.58593 6.19594C5.58593 6.51895 5.323 6.78188 5 6.78188C4.67699 6.78188 4.41406 6.51895 4.41406 6.19594V3.26625C4.41406 2.94324 4.67699 2.68032 5 2.68032C5.323 2.68032 5.58593 2.94324 5.58593 3.26625V6.19594Z"
|
|
25
|
+
fill="currentColor"
|
|
26
|
+
/>
|
|
27
|
+
</svg>
|
|
28
|
+
)
|
|
29
|
+
}
|
package/meta.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"buildDate":1634829055606}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@postgres.ai/shared",
|
|
3
|
+
"version": "3.5.1-pr-1027.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@babel/core": "^7.13.0",
|
|
9
|
+
"@craco/craco": "^7.0.0-alpha.7",
|
|
10
|
+
"@emotion/react": "^11.10.5",
|
|
11
|
+
"@emotion/styled": "^11.10.5",
|
|
12
|
+
"@material-ui/core": "^4.11.4",
|
|
13
|
+
"@material-ui/icons": "^4.11.2",
|
|
14
|
+
"@material-ui/lab": "^4.0.0-alpha.61",
|
|
15
|
+
"@material-ui/styles": "^4.11.4",
|
|
16
|
+
"@monaco-editor/react": "^4.4.5",
|
|
17
|
+
"@mui/material": "^5.10.12",
|
|
18
|
+
"@types/node": "^12.20.33",
|
|
19
|
+
"@types/react": "^17.0.30",
|
|
20
|
+
"@types/react-dom": "^17.0.10",
|
|
21
|
+
"@types/react-router": "^5.1.17",
|
|
22
|
+
"@types/react-router-dom": "^5.3.1",
|
|
23
|
+
"@types/react-syntax-highlighter": "^15.5.6",
|
|
24
|
+
"classnames": "^2.3.1",
|
|
25
|
+
"clsx": "^1.1.1",
|
|
26
|
+
"copy-to-clipboard": "^3.3.1",
|
|
27
|
+
"create-file-webpack": "^1.0.2",
|
|
28
|
+
"crypto-browserify": "^3.12.0",
|
|
29
|
+
"date-fns": "^2.22.1",
|
|
30
|
+
"formik": "^2.2.9",
|
|
31
|
+
"get-user-locale": "^1.4.0",
|
|
32
|
+
"mobx": "^6.3.5",
|
|
33
|
+
"mobx-react-lite": "^3.2.1",
|
|
34
|
+
"moment": "^2.24.0",
|
|
35
|
+
"prop-types": "^15.7.2",
|
|
36
|
+
"react": "^17.0.2",
|
|
37
|
+
"react-countdown-hook": "^1.1.0",
|
|
38
|
+
"react-scripts": "^5.0.0",
|
|
39
|
+
"react-syntax-highlighter": "^15.5.0",
|
|
40
|
+
"stream-browserify": "^3.0.0",
|
|
41
|
+
"typescript": "^4.8.3",
|
|
42
|
+
"use-timer": "^2.0.1",
|
|
43
|
+
"yup": "^0.32.11"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": "^17.0.0 || ^18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"glob": "^11.0.2"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsc -p tsconfig.build.json && node scripts/copy-assets.js",
|
|
53
|
+
"pack": "node scripts/pack.js"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 React from 'react'
|
|
9
|
+
import { makeStyles } from '@material-ui/core'
|
|
10
|
+
import clsx from 'clsx'
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
CloneDto,
|
|
14
|
+
formatCloneDto,
|
|
15
|
+
} from '@postgres.ai/shared/types/api/entities/clone'
|
|
16
|
+
import { Status as StatusBase } from '@postgres.ai/shared/components/Status'
|
|
17
|
+
import { FormattedText } from '@postgres.ai/shared/components/FormattedText'
|
|
18
|
+
import {
|
|
19
|
+
getCloneStatusType,
|
|
20
|
+
getCloneStatusText,
|
|
21
|
+
} from '@postgres.ai/shared/utils/clone'
|
|
22
|
+
|
|
23
|
+
type Props = {
|
|
24
|
+
rawClone: CloneDto
|
|
25
|
+
className?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const useStyles = makeStyles(
|
|
29
|
+
{
|
|
30
|
+
root: {
|
|
31
|
+
marginTop: '2px',
|
|
32
|
+
},
|
|
33
|
+
status: {
|
|
34
|
+
fontWeight: 500,
|
|
35
|
+
},
|
|
36
|
+
message: {
|
|
37
|
+
margin: '4px 0 0 0',
|
|
38
|
+
},
|
|
39
|
+
errorMessage: {
|
|
40
|
+
marginTop: '8px',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{ index: 1 },
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
export const Status = React.memo((props: Props) => {
|
|
47
|
+
const { rawClone, className } = props
|
|
48
|
+
|
|
49
|
+
const classes = useStyles()
|
|
50
|
+
|
|
51
|
+
const clone = formatCloneDto(rawClone)
|
|
52
|
+
|
|
53
|
+
const { code, message } = clone.status
|
|
54
|
+
|
|
55
|
+
const statusType = getCloneStatusType(code)
|
|
56
|
+
const statusText = getCloneStatusText(code)
|
|
57
|
+
|
|
58
|
+
const isError = statusType === 'error'
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div className={clsx(classes.root, className)}>
|
|
62
|
+
<StatusBase type={statusType} className={classes.status}>
|
|
63
|
+
{statusText}
|
|
64
|
+
</StatusBase>
|
|
65
|
+
|
|
66
|
+
{!isError && <p className={classes.message}>{message}</p>}
|
|
67
|
+
|
|
68
|
+
{isError && (
|
|
69
|
+
<FormattedText value={message} className={classes.errorMessage} />
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
)
|
|
73
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createStrictContext } from '@postgres.ai/shared/utils/react'
|
|
2
|
+
|
|
3
|
+
import { Api } from './stores/Main'
|
|
4
|
+
import { Stores } from './useCreatedStores'
|
|
5
|
+
|
|
6
|
+
export type Host = {
|
|
7
|
+
instanceId: string
|
|
8
|
+
cloneId: string
|
|
9
|
+
routes: {
|
|
10
|
+
instance: () => string
|
|
11
|
+
}
|
|
12
|
+
api: Api
|
|
13
|
+
elements: {
|
|
14
|
+
breadcrumbs: React.ReactNode
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const { useStrictContext: useHost, Provider: HostProvider } =
|
|
19
|
+
createStrictContext<Host>()
|
|
20
|
+
|
|
21
|
+
export const { useStrictContext: useStores, Provider: StoresProvider } =
|
|
22
|
+
createStrictContext<Stores>()
|