@antelopejs/dms-database 0.5.0 → 0.5.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/README.md +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/config.js.map +1 -1
- package/dist/routes/connections.js +7 -2
- package/dist/routes/connections.js.map +1 -1
- package/dist/routes/data.js +4 -1
- package/dist/routes/data.js.map +1 -1
- package/dist/service/builderRefusal.d.ts +2 -0
- package/dist/service/builderRefusal.js +28 -0
- package/dist/service/builderRefusal.js.map +1 -0
- package/dist/service/connectionRefusals.d.ts +17 -0
- package/dist/service/connectionRefusals.js +26 -0
- package/dist/service/connectionRefusals.js.map +1 -0
- package/dist/service/connectionState.d.ts +0 -2
- package/dist/service/connectionState.js +21 -11
- package/dist/service/connectionState.js.map +1 -1
- package/dist/service/connections.js +3 -2
- package/dist/service/connections.js.map +1 -1
- package/frontend-vue/app/build/components/DataGridFooter.vue +16 -1
- package/frontend-vue/app/build/composables/reloadForSelection.ts +3 -5
- package/frontend-vue/app/build/composables/useDataBrowserGrid.ts +1 -0
- package/frontend-vue/app/build/composables/useDataBrowserTabs.ts +91 -15
- package/frontend-vue/app/build/data/gridData.ts +22 -1
- package/frontend-vue/app/build/data/recentTables.ts +15 -14
- package/frontend-vue/app/build/data/useStagedSave.ts +0 -3
- package/frontend-vue/app/components/DataBrowser.vue +9 -14
- package/frontend-vue/app/components/DataBrowserSidebar.vue +1 -0
- package/frontend-vue/app/components/DataGrid.vue +5 -12
- package/frontend-vue/app/components/DatabaseSwitcher.vue +0 -2
- package/frontend-vue/app/components/TableInspector.vue +11 -6
- package/frontend-vue/i18n/locales/database-en-GB.json +12 -0
- package/frontend-vue/i18n/locales/database-fr-FR.json +12 -0
- package/frontend-vue/tests/dataBrowserDatabase.test.ts +89 -0
- package/frontend-vue/tests/databaseSwitcher.test.ts +11 -7
- package/frontend-vue/tests/editRequest.test.ts +0 -51
- package/frontend-vue/tests/externalBrowser.test.ts +125 -0
- package/frontend-vue/tests/persistence.test.ts +254 -4
- package/frontend-vue/tests/recentTables.test.ts +70 -0
- package/frontend-vue/tests/serverRender.test.ts +22 -0
- package/package.json +1 -1
- package/frontend-vue/app/build/data/staleDatabase.ts +0 -58
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const STALE_MESSAGE =
|
|
2
|
-
'The selected database changed in another tab: reload the page'
|
|
3
|
-
const STALE_KEY = 'dms_database.data.save.database_changed'
|
|
4
|
-
const CONFLICT = 409
|
|
5
|
-
const READ_ONLY_MESSAGE = /^Access to (.+) is read only$/
|
|
6
|
-
const READ_ONLY_KEY = 'dms_database.data.save.read_only_access'
|
|
7
|
-
const FORBIDDEN = 403
|
|
8
|
-
|
|
9
|
-
function read(value: unknown, key: string): unknown {
|
|
10
|
-
return typeof value === 'object' && value !== null
|
|
11
|
-
? Reflect.get(value, key)
|
|
12
|
-
: undefined
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** A refusal of the edit route, as the error API presents it: a translated key with its parameters. */
|
|
16
|
-
export class PresentableWriteError extends Error {
|
|
17
|
-
readonly data: {
|
|
18
|
-
message: string
|
|
19
|
-
params: Record<string, string>
|
|
20
|
-
severity: 'warning'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
constructor(
|
|
24
|
-
readonly statusCode: number,
|
|
25
|
-
readonly response: unknown,
|
|
26
|
-
key: string,
|
|
27
|
-
params: Record<string, string> = {},
|
|
28
|
-
) {
|
|
29
|
-
super(key)
|
|
30
|
-
this.data = { message: key, params, severity: 'warning' }
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Turns the edit route's refusals whose body the API sends as text (a write
|
|
36
|
-
* from a stale tab, a write to a connection whose access is read only) into
|
|
37
|
-
* ones the error API translates; any other error comes back as it is.
|
|
38
|
-
*/
|
|
39
|
-
export function presentableWriteError(error: unknown): unknown {
|
|
40
|
-
const response = read(error, 'response')
|
|
41
|
-
const status =
|
|
42
|
-
read(error, 'statusCode') ??
|
|
43
|
-
read(error, 'status') ??
|
|
44
|
-
read(response, 'status')
|
|
45
|
-
const body = read(error, 'data') ?? read(response, '_data')
|
|
46
|
-
const message = typeof body === 'string' ? body : read(body, 'message')
|
|
47
|
-
if (status === CONFLICT && message === STALE_MESSAGE)
|
|
48
|
-
return new PresentableWriteError(CONFLICT, response, STALE_KEY)
|
|
49
|
-
const readOnly =
|
|
50
|
-
status === FORBIDDEN && typeof message === 'string'
|
|
51
|
-
? READ_ONLY_MESSAGE.exec(message)
|
|
52
|
-
: null
|
|
53
|
-
return readOnly?.[1] === undefined
|
|
54
|
-
? error
|
|
55
|
-
: new PresentableWriteError(FORBIDDEN, response, READ_ONLY_KEY, {
|
|
56
|
-
connection: readOnly[1],
|
|
57
|
-
})
|
|
58
|
-
}
|