@axium/storage 0.18.2 → 0.18.4

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.
@@ -39,7 +39,7 @@ declare const StorageCache: z.ZodObject<{
39
39
  isSuspended: z.ZodOptional<z.ZodBoolean>;
40
40
  }, z.core.$strip>>>;
41
41
  createdAt: z.ZodCoercedDate<unknown>;
42
- }, z.core.$loose>>>;
42
+ }, z.core.$catchall<z.ZodBoolean>>>>;
43
43
  }, z.core.$strip>>;
44
44
  users: z.ZodRecord<z.ZodUUID, z.ZodObject<{
45
45
  id: z.ZodUUID;
package/dist/common.d.ts CHANGED
@@ -43,7 +43,7 @@ export declare const StorageItemMetadata: z.ZodObject<{
43
43
  isSuspended: z.ZodOptional<z.ZodBoolean>;
44
44
  }, z.core.$strip>>>;
45
45
  createdAt: z.ZodCoercedDate<unknown>;
46
- }, z.core.$loose>>>;
46
+ }, z.core.$catchall<z.ZodBoolean>>>>;
47
47
  }, z.core.$strip>;
48
48
  export interface StorageItemMetadata<T extends Record<string, unknown> = Record<string, unknown>> extends z.infer<typeof StorageItemMetadata> {
49
49
  metadata: T;
@@ -113,7 +113,7 @@ export declare const UserStorage: z.ZodObject<{
113
113
  isSuspended: z.ZodOptional<z.ZodBoolean>;
114
114
  }, z.core.$strip>>>;
115
115
  createdAt: z.ZodCoercedDate<unknown>;
116
- }, z.core.$loose>>>;
116
+ }, z.core.$catchall<z.ZodBoolean>>>>;
117
117
  }, z.core.$strip>>;
118
118
  limits: z.ZodObject<{
119
119
  item_size: z.ZodInt;
@@ -247,7 +247,7 @@ export declare const UploadInitResult: z.ZodDiscriminatedUnion<[z.ZodObject<{
247
247
  isSuspended: z.ZodOptional<z.ZodBoolean>;
248
248
  }, z.core.$strip>>>;
249
249
  createdAt: z.ZodCoercedDate<unknown>;
250
- }, z.core.$loose>>>;
250
+ }, z.core.$catchall<z.ZodBoolean>>>>;
251
251
  }, z.core.$strip>;
252
252
  }, z.core.$strip>], "status">;
253
253
  export type UploadInitResult = z.infer<typeof UploadInitResult>;
@@ -300,7 +300,7 @@ declare const StorageAPI: {
300
300
  isSuspended: z.ZodOptional<z.ZodBoolean>;
301
301
  }, z.core.$strip>>>;
302
302
  createdAt: z.ZodCoercedDate<unknown>;
303
- }, z.core.$loose>>>;
303
+ }, z.core.$catchall<z.ZodBoolean>>>>;
304
304
  }, z.core.$strip>>;
305
305
  limits: z.ZodObject<{
306
306
  item_size: z.ZodInt;
@@ -349,7 +349,7 @@ declare const StorageAPI: {
349
349
  isSuspended: z.ZodOptional<z.ZodBoolean>;
350
350
  }, z.core.$strip>>>;
351
351
  createdAt: z.ZodCoercedDate<unknown>;
352
- }, z.core.$loose>>>;
352
+ }, z.core.$catchall<z.ZodBoolean>>>>;
353
353
  }, z.core.$strip>>;
354
354
  };
355
355
  readonly 'users/:id/storage/trash': {
@@ -388,7 +388,7 @@ declare const StorageAPI: {
388
388
  isSuspended: z.ZodOptional<z.ZodBoolean>;
389
389
  }, z.core.$strip>>>;
390
390
  createdAt: z.ZodCoercedDate<unknown>;
391
- }, z.core.$loose>>>;
391
+ }, z.core.$catchall<z.ZodBoolean>>>>;
392
392
  }, z.core.$strip>>;
393
393
  };
394
394
  readonly 'users/:id/storage/shared': {
@@ -427,7 +427,7 @@ declare const StorageAPI: {
427
427
  isSuspended: z.ZodOptional<z.ZodBoolean>;
428
428
  }, z.core.$strip>>>;
429
429
  createdAt: z.ZodCoercedDate<unknown>;
430
- }, z.core.$loose>>>;
430
+ }, z.core.$catchall<z.ZodBoolean>>>>;
431
431
  }, z.core.$strip>>;
432
432
  };
433
433
  readonly storage: {
@@ -493,7 +493,7 @@ declare const StorageAPI: {
493
493
  isSuspended: z.ZodOptional<z.ZodBoolean>;
494
494
  }, z.core.$strip>>>;
495
495
  createdAt: z.ZodCoercedDate<unknown>;
496
- }, z.core.$loose>>>;
496
+ }, z.core.$catchall<z.ZodBoolean>>>>;
497
497
  }, z.core.$strip>;
498
498
  }, z.core.$strip>], "status">];
499
499
  };
@@ -544,7 +544,7 @@ declare const StorageAPI: {
544
544
  isSuspended: z.ZodOptional<z.ZodBoolean>;
545
545
  }, z.core.$strip>>>;
546
546
  createdAt: z.ZodCoercedDate<unknown>;
547
- }, z.core.$loose>>>;
547
+ }, z.core.$catchall<z.ZodBoolean>>>>;
548
548
  }, z.core.$strip>>];
549
549
  };
550
550
  readonly 'storage/item/:id': {
@@ -583,7 +583,7 @@ declare const StorageAPI: {
583
583
  isSuspended: z.ZodOptional<z.ZodBoolean>;
584
584
  }, z.core.$strip>>>;
585
585
  createdAt: z.ZodCoercedDate<unknown>;
586
- }, z.core.$loose>>>;
586
+ }, z.core.$catchall<z.ZodBoolean>>>>;
587
587
  }, z.core.$strip>;
588
588
  readonly DELETE: z.ZodObject<{
589
589
  createdAt: z.ZodCoercedDate<unknown>;
@@ -620,7 +620,7 @@ declare const StorageAPI: {
620
620
  isSuspended: z.ZodOptional<z.ZodBoolean>;
621
621
  }, z.core.$strip>>>;
622
622
  createdAt: z.ZodCoercedDate<unknown>;
623
- }, z.core.$loose>>>;
623
+ }, z.core.$catchall<z.ZodBoolean>>>>;
624
624
  }, z.core.$strip>;
625
625
  readonly PATCH: readonly [z.ZodObject<{
626
626
  name: z.ZodOptional<z.ZodString>;
@@ -661,7 +661,7 @@ declare const StorageAPI: {
661
661
  isSuspended: z.ZodOptional<z.ZodBoolean>;
662
662
  }, z.core.$strip>>>;
663
663
  createdAt: z.ZodCoercedDate<unknown>;
664
- }, z.core.$loose>>>;
664
+ }, z.core.$catchall<z.ZodBoolean>>>>;
665
665
  }, z.core.$strip>];
666
666
  };
667
667
  readonly 'storage/directory/:id': {
@@ -700,7 +700,7 @@ declare const StorageAPI: {
700
700
  isSuspended: z.ZodOptional<z.ZodBoolean>;
701
701
  }, z.core.$strip>>>;
702
702
  createdAt: z.ZodCoercedDate<unknown>;
703
- }, z.core.$loose>>>;
703
+ }, z.core.$catchall<z.ZodBoolean>>>>;
704
704
  }, z.core.$strip>>;
705
705
  };
706
706
  readonly 'storage/directory/:id/recursive': {
@@ -739,7 +739,7 @@ declare const StorageAPI: {
739
739
  isSuspended: z.ZodOptional<z.ZodBoolean>;
740
740
  }, z.core.$strip>>>;
741
741
  createdAt: z.ZodCoercedDate<unknown>;
742
- }, z.core.$loose>>>;
742
+ }, z.core.$catchall<z.ZodBoolean>>>>;
743
743
  path: z.ZodString;
744
744
  }, z.core.$strip>>;
745
745
  };
@@ -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);
@@ -39,7 +39,7 @@
39
39
  {#if others.length}
40
40
  <Popover>
41
41
  {#snippet toggle()}
42
- <span class="popover-toggle"><Icon i="caret-down" /></span>
42
+ <Icon i="caret-down" />
43
43
  {/snippet}
44
44
  {#each others as opener}
45
45
  <a href={opener.openURL(item)} target="_blank">{opener.name}</a>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/storage",
3
- "version": "0.18.2",
3
+ "version": "0.18.4",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "User file storage for Axium",
6
6
  "funding": {
@@ -39,11 +39,11 @@
39
39
  "build": "tsc"
40
40
  },
41
41
  "peerDependencies": {
42
- "@axium/client": ">=0.14.2",
42
+ "@axium/client": ">=0.15.0",
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
- "utilium": "^2.3.8"
46
+ "utilium": "^2.6.3"
47
47
  },
48
48
  "dependencies": {
49
49
  "blakejs": "^1.2.1",