@axium/storage 0.18.2 → 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.
Files changed (2) hide show
  1. package/dist/server/api.js +6 -20
  2. package/package.json +2 -2
@@ -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(aclFrom('storage'))
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(aclFrom('storage'))
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(aclFrom('storage', { alias: 'item' }))
164
+ .select(acl.from('storage', { alias: 'item' }))
179
165
  .where('trashedAt', 'is', null)
180
- .where(existsInACL('id', user))
181
- .where(eb => eb.not(existsInACL('parentId', user)))
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/storage",
3
- "version": "0.18.2",
3
+ "version": "0.18.3",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "User file storage for Axium",
6
6
  "funding": {
@@ -41,7 +41,7 @@
41
41
  "peerDependencies": {
42
42
  "@axium/client": ">=0.14.2",
43
43
  "@axium/core": ">=0.19.0",
44
- "@axium/server": ">=0.35.0",
44
+ "@axium/server": ">=0.36.0",
45
45
  "@sveltejs/kit": "^2.27.3",
46
46
  "utilium": "^2.3.8"
47
47
  },