@axium/storage 0.18.1 → 0.18.3
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/dist/server/api.js +6 -20
- package/lib/List.svelte +3 -1
- package/package.json +3 -3
package/dist/server/api.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getConfig } from '@axium/core';
|
|
2
|
+
import * as acl from '@axium/server/acl';
|
|
2
3
|
import { authRequestForItem, checkAuthForUser, requireSession } from '@axium/server/auth';
|
|
3
4
|
import { database } from '@axium/server/database';
|
|
4
5
|
import { error, json, parseBody, withError } from '@axium/server/requests';
|
|
@@ -9,7 +10,6 @@ import { batchFormatVersion, StorageItemInit, StorageItemUpdate, syncProtocolVer
|
|
|
9
10
|
import '../polyfills.js';
|
|
10
11
|
import { getLimits } from './config.js';
|
|
11
12
|
import { deleteRecursive, getRecursive, getUserStats, parseItem } from './db.js';
|
|
12
|
-
import { from as aclFrom } from '@axium/server/acl';
|
|
13
13
|
import { checkNewItem, createNewItem, startUpload } from './item.js';
|
|
14
14
|
addRoute({
|
|
15
15
|
path: '/api/storage',
|
|
@@ -89,7 +89,7 @@ addRoute({
|
|
|
89
89
|
error(409, 'Item is not a directory');
|
|
90
90
|
const items = await database
|
|
91
91
|
.selectFrom('storage')
|
|
92
|
-
.select(
|
|
92
|
+
.select(acl.from('storage'))
|
|
93
93
|
.where('parentId', '=', itemId)
|
|
94
94
|
.where('trashedAt', 'is', null)
|
|
95
95
|
.selectAll()
|
|
@@ -141,7 +141,7 @@ addRoute({
|
|
|
141
141
|
await checkAuthForUser(request, userId);
|
|
142
142
|
const items = await database
|
|
143
143
|
.selectFrom('storage')
|
|
144
|
-
.select(
|
|
144
|
+
.select(acl.from('storage'))
|
|
145
145
|
.where('userId', '=', userId)
|
|
146
146
|
.where('trashedAt', 'is', null)
|
|
147
147
|
.where('parentId', 'is', null)
|
|
@@ -151,20 +151,6 @@ addRoute({
|
|
|
151
151
|
return items.map(parseItem);
|
|
152
152
|
},
|
|
153
153
|
});
|
|
154
|
-
function existsInACL(column, user) {
|
|
155
|
-
return (eb) => eb.exists(eb
|
|
156
|
-
.selectFrom('acl.storage')
|
|
157
|
-
.whereRef('itemId', '=', `item.${column}`)
|
|
158
|
-
.where('userId', '=', user.id)
|
|
159
|
-
.where(eb => {
|
|
160
|
-
const ors = [eb('userId', '=', user.id)];
|
|
161
|
-
if (user.roles.length)
|
|
162
|
-
ors.push(eb('role', 'in', user.roles));
|
|
163
|
-
if (user.tags.length)
|
|
164
|
-
ors.push(eb('tag', 'in', user.tags));
|
|
165
|
-
return eb.or(ors);
|
|
166
|
-
}));
|
|
167
|
-
}
|
|
168
154
|
addRoute({
|
|
169
155
|
path: '/api/users/:id/storage/shared',
|
|
170
156
|
params: { id: z.uuid() },
|
|
@@ -175,10 +161,10 @@ addRoute({
|
|
|
175
161
|
const items = await database
|
|
176
162
|
.selectFrom('storage as item')
|
|
177
163
|
.selectAll('item')
|
|
178
|
-
.select(
|
|
164
|
+
.select(acl.from('storage', { alias: 'item' }))
|
|
179
165
|
.where('trashedAt', 'is', null)
|
|
180
|
-
.where(
|
|
181
|
-
.where(eb => eb.not(
|
|
166
|
+
.where(acl.existsIn('storage', user, { alias: 'item' }))
|
|
167
|
+
.where(eb => eb.not(acl.existsIn('storage', user, { alias: 'item', itemId: 'parentId' })))
|
|
182
168
|
.execute()
|
|
183
169
|
.catch(withError('Could not get storage items'));
|
|
184
170
|
return items.map(parseItem);
|
package/lib/List.svelte
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { copyShortURL } from '@axium/storage/client/frontend';
|
|
10
10
|
import type { StorageItemMetadata } from '@axium/storage/common';
|
|
11
11
|
import Preview from './Preview.svelte';
|
|
12
|
+
import { copy } from '@axium/client/clipboard';
|
|
12
13
|
|
|
13
14
|
let {
|
|
14
15
|
items = $bindable(),
|
|
@@ -64,7 +65,8 @@
|
|
|
64
65
|
{ i: 'user-group', text: 'Share', action: () => ((activeIndex = i), dialogs['share:' + item.id].showModal()) },
|
|
65
66
|
{ i: 'download', text: 'Download', action: () => ((activeIndex = i), dialogs.download.showModal()) },
|
|
66
67
|
{ i: 'link-horizontal', text: 'Copy Link', action: () => ((activeIndex = i), copyShortURL(item)) },
|
|
67
|
-
{ i: 'trash', text: 'Trash', action: () => ((activeIndex = i), dialogs.trash.showModal()) }
|
|
68
|
+
{ i: 'trash', text: 'Trash', action: () => ((activeIndex = i), dialogs.trash.showModal()) },
|
|
69
|
+
user?.preferences?.debug && { i: 'hashtag', text: 'Copy ID', action: () => copy('text/plain', item.id) }
|
|
68
70
|
)}
|
|
69
71
|
>
|
|
70
72
|
<dfn class="type" title={item.type}><Icon i={iconForMime(item.type)} /></dfn>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axium/storage",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"author": "James Prevett <axium@jamespre.dev>",
|
|
5
5
|
"description": "User file storage for Axium",
|
|
6
6
|
"funding": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"build": "tsc"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@axium/client": ">=0.14.
|
|
42
|
+
"@axium/client": ">=0.14.2",
|
|
43
43
|
"@axium/core": ">=0.19.0",
|
|
44
|
-
"@axium/server": ">=0.
|
|
44
|
+
"@axium/server": ">=0.36.0",
|
|
45
45
|
"@sveltejs/kit": "^2.27.3",
|
|
46
46
|
"utilium": "^2.3.8"
|
|
47
47
|
},
|