@axium/storage 0.9.0 → 0.10.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.
@@ -23,17 +23,15 @@ addRoute({
23
23
  addRoute({
24
24
  path: '/api/storage/item/:id',
25
25
  params: { id: z.uuid() },
26
- async GET(request, params) {
26
+ async GET(request, { id: itemId }) {
27
27
  if (!config.storage.enabled)
28
28
  error(503, 'User storage is disabled');
29
- const itemId = params.id;
30
29
  const { item } = await checkAuthForItem(request, 'storage', itemId, Permission.Read);
31
30
  return parseItem(item);
32
31
  },
33
- async PATCH(request, params) {
32
+ async PATCH(request, { id: itemId }) {
34
33
  if (!config.storage.enabled)
35
34
  error(503, 'User storage is disabled');
36
- const itemId = params.id;
37
35
  const body = await parseBody(request, StorageItemUpdate);
38
36
  await checkAuthForItem(request, 'storage', itemId, Permission.Manage);
39
37
  const values = {};
@@ -55,10 +53,9 @@ addRoute({
55
53
  .executeTakeFirstOrThrow()
56
54
  .catch(withError('Could not update item')));
57
55
  },
58
- async DELETE(request, params) {
56
+ async DELETE(request, { id: itemId }) {
59
57
  if (!config.storage.enabled)
60
58
  error(503, 'User storage is disabled');
61
- const itemId = params.id;
62
59
  const auth = await checkAuthForItem(request, 'storage', itemId, Permission.Manage);
63
60
  const item = parseItem(auth.item);
64
61
  await deleteRecursive(item.type != 'inode/directory', itemId);
@@ -68,10 +65,9 @@ addRoute({
68
65
  addRoute({
69
66
  path: '/api/storage/directory/:id',
70
67
  params: { id: z.uuid() },
71
- async GET(request, params) {
68
+ async GET(request, { id: itemId }) {
72
69
  if (!config.storage.enabled)
73
70
  error(503, 'User storage is disabled');
74
- const itemId = params.id;
75
71
  const { item } = await checkAuthForItem(request, 'storage', itemId, Permission.Read);
76
72
  if (item.type != 'inode/directory')
77
73
  error(409, 'Item is not a directory');
@@ -87,10 +83,9 @@ addRoute({
87
83
  addRoute({
88
84
  path: '/api/storage/directory/:id/recursive',
89
85
  params: { id: z.uuid() },
90
- async GET(request, params) {
86
+ async GET(request, { id: itemId }) {
91
87
  if (!config.storage.enabled)
92
88
  error(503, 'User storage is disabled');
93
- const itemId = params.id;
94
89
  const { item } = await checkAuthForItem(request, 'storage', itemId, Permission.Read);
95
90
  if (item.type != 'inode/directory')
96
91
  error(409, 'Item is not a directory');
@@ -101,18 +96,16 @@ addRoute({
101
96
  addRoute({
102
97
  path: '/api/users/:id/storage',
103
98
  params: { id: z.uuid() },
104
- async OPTIONS(request, params) {
99
+ async OPTIONS(request, { id: userId }) {
105
100
  if (!config.storage.enabled)
106
101
  error(503, 'User storage is disabled');
107
- const userId = params.id;
108
102
  await checkAuthForUser(request, userId);
109
103
  const [stats, limits] = await Promise.all([getUserStats(userId), getLimits(userId)]).catch(withError('Could not fetch data'));
110
104
  return Object.assign(stats, { limits });
111
105
  },
112
- async GET(request, params) {
106
+ async GET(request, { id: userId }) {
113
107
  if (!config.storage.enabled)
114
108
  error(503, 'User storage is disabled');
115
- const userId = params.id;
116
109
  await checkAuthForUser(request, userId);
117
110
  const [items, stats, limits] = await Promise.all([
118
111
  database.selectFrom('storage').where('userId', '=', userId).where('trashedAt', 'is', null).selectAll().execute(),
@@ -125,10 +118,9 @@ addRoute({
125
118
  addRoute({
126
119
  path: '/api/users/:id/storage/root',
127
120
  params: { id: z.uuid() },
128
- async GET(request, params) {
121
+ async GET(request, { id: userId }) {
129
122
  if (!config.storage.enabled)
130
123
  error(503, 'User storage is disabled');
131
- const userId = params.id;
132
124
  await checkAuthForUser(request, userId);
133
125
  const items = await database
134
126
  .selectFrom('storage')
@@ -151,10 +143,9 @@ function existsInACL(column, userId) {
151
143
  addRoute({
152
144
  path: '/api/users/:id/storage/shared',
153
145
  params: { id: z.uuid() },
154
- async GET(request, params) {
146
+ async GET(request, { id: userId }) {
155
147
  if (!config.storage.enabled)
156
148
  error(503, 'User storage is disabled');
157
- const userId = params.id;
158
149
  await checkAuthForUser(request, userId);
159
150
  const items = await database
160
151
  .selectFrom('storage as item')
@@ -170,10 +161,9 @@ addRoute({
170
161
  addRoute({
171
162
  path: '/api/users/:id/storage/trash',
172
163
  params: { id: z.uuid() },
173
- async GET(request, params) {
164
+ async GET(request, { id: userId }) {
174
165
  if (!config.storage.enabled)
175
166
  error(503, 'User storage is disabled');
176
- const userId = params.id;
177
167
  await checkAuthForUser(request, userId);
178
168
  const items = await database
179
169
  .selectFrom('storage')
@@ -2,7 +2,6 @@ import type { InitOptions, OpOptions } from '@axium/server/database';
2
2
  import '../common.js';
3
3
  import './index.js';
4
4
  export declare function statusText(): Promise<string>;
5
- export declare function init(): void;
6
5
  export declare function db_init(opt: InitOptions): Promise<void>;
7
6
  export declare function db_wipe(opt: OpOptions): Promise<void>;
8
7
  export declare function remove(opt: OpOptions): Promise<void>;
@@ -7,6 +7,7 @@ import { sql } from 'kysely';
7
7
  import { mkdirSync } from 'node:fs';
8
8
  import '../common.js';
9
9
  import './index.js';
10
+ mkdirSync(config.storage.data, { recursive: true });
10
11
  export async function statusText() {
11
12
  const { storage: items } = await count('storage');
12
13
  const { size } = await database
@@ -15,9 +16,6 @@ export async function statusText() {
15
16
  .executeTakeFirstOrThrow();
16
17
  return `${items} items totaling ${formatBytes(Number(size))}`;
17
18
  }
18
- export function init() {
19
- mkdirSync(config.storage.data, { recursive: true });
20
- }
21
19
  export async function db_init(opt) {
22
20
  start('Creating table storage');
23
21
  await database.schema
package/lib/List.svelte CHANGED
@@ -1,6 +1,5 @@
1
1
  <script lang="ts">
2
- import { goto } from '$app/navigation';
3
- import { FormDialog, Icon } from '@axium/client/components';
2
+ import { AccessControlDialog, FormDialog, Icon } from '@axium/client/components';
4
3
  import '@axium/client/styles/list';
5
4
  import { formatBytes } from '@axium/core/format';
6
5
  import { forMime as iconForMime } from '@axium/core/icons';
@@ -62,6 +61,7 @@
62
61
  <span>{item.modifiedAt.toLocaleString()}</span>
63
62
  <span>{item.type == 'inode/directory' ? '—' : formatBytes(item.size)}</span>
64
63
  {@render action('rename', 'pencil', i)}
64
+ {@render action('share', 'user-group', i)}
65
65
  {@render action('download', 'download', i)}
66
66
  {@render action('trash', 'trash', i)}
67
67
  </div>
@@ -84,6 +84,7 @@
84
84
  <input name="name" type="text" required value={activeItem?.name} />
85
85
  </div>
86
86
  </FormDialog>
87
+ <AccessControlDialog bind:dialog={dialogs.share} bind:item={activeItem} itemType="storage" editable={true} />
87
88
  <FormDialog
88
89
  bind:dialog={dialogs.trash}
89
90
  submitText="Trash"
@@ -114,6 +115,6 @@
114
115
 
115
116
  <style>
116
117
  .list-item {
117
- grid-template-columns: 1em 4fr 15em 5em repeat(3, 1em);
118
+ grid-template-columns: 1em 4fr 15em 5em repeat(4, 1em);
118
119
  }
119
120
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/storage",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "User file storage for Axium",
6
6
  "funding": {
@@ -38,9 +38,9 @@
38
38
  "build": "tsc"
39
39
  },
40
40
  "peerDependencies": {
41
- "@axium/client": ">=0.6.0",
42
- "@axium/core": ">=0.10.0",
43
- "@axium/server": ">=0.26.0",
41
+ "@axium/client": ">=0.7.0",
42
+ "@axium/core": ">=0.11.0",
43
+ "@axium/server": ">=0.27.0",
44
44
  "@sveltejs/kit": "^2.27.3",
45
45
  "utilium": "^2.3.8"
46
46
  },