@axium/storage 0.3.5 → 0.3.7

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/plugin.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { formatBytes } from '@axium/core/format';
2
+ import * as acl from '@axium/server/acl';
2
3
  import config from '@axium/server/config';
3
- import { count, database, warnExists } from '@axium/server/database';
4
+ import { count, createIndex, database, warnExists } from '@axium/server/database';
4
5
  import { done, start } from '@axium/server/io';
5
6
  import { sql } from 'kysely';
6
7
  import pkg from '../package.json' with { type: 'json' };
@@ -19,8 +20,8 @@ async function db_init(opt) {
19
20
  await database.schema
20
21
  .createTable('storage')
21
22
  .addColumn('id', 'uuid', col => col.primaryKey().defaultTo(sql `gen_random_uuid()`))
22
- .addColumn('userId', 'uuid', col => col.notNull().references('users.id').onDelete('cascade').onUpdate('cascade'))
23
- .addColumn('parentId', 'uuid', col => col.references('storage.itemId').onDelete('cascade').onUpdate('cascade').defaultTo(null))
23
+ .addColumn('userId', 'uuid', col => col.notNull().references('users.id').onDelete('cascade'))
24
+ .addColumn('parentId', 'uuid', col => col.references('storage.id').onDelete('cascade').defaultTo(null))
24
25
  .addColumn('createdAt', 'timestamptz', col => col.notNull().defaultTo(sql `now()`))
25
26
  .addColumn('modifiedAt', 'timestamptz', col => col.notNull().defaultTo(sql `now()`))
26
27
  .addColumn('size', 'integer', col => col.notNull())
@@ -34,19 +35,20 @@ async function db_init(opt) {
34
35
  .execute()
35
36
  .then(done)
36
37
  .catch(warnExists);
37
- start('Creating index for storage.userId');
38
- await database.schema.createIndex('storage_userId_index').on('storage').column('userId').execute().then(done).catch(warnExists);
39
- start('Creating index for storage.parentId');
40
- await database.schema.createIndex('storage_parentId_index').on('storage').column('parentId').execute().then(done).catch(warnExists);
38
+ await createIndex('storage', 'userId');
39
+ await createIndex('storage', 'parentId');
40
+ await acl.createTable('storage');
41
41
  }
42
42
  async function db_wipe(opt) {
43
43
  start('Removing data from user storage');
44
44
  await database.deleteFrom('storage').execute();
45
+ await acl.wipeTable('storage');
45
46
  done();
46
47
  }
47
48
  async function remove(opt) {
48
49
  start('Dropping table storage');
49
50
  await database.schema.dropTable('storage').execute();
51
+ await acl.dropTable('storage');
50
52
  done();
51
53
  }
52
54
  async function clean(opt) {
package/dist/server.js CHANGED
@@ -23,7 +23,7 @@ expectedTypes.storage = {
23
23
  size: { type: 'int4', required: true },
24
24
  trashedAt: { type: 'timestampz' },
25
25
  type: { type: 'text', required: true },
26
- userId: { type: 'uuid', required: true, hasDefault: true },
26
+ userId: { type: 'uuid', required: true },
27
27
  publicPermission: { type: 'int4', required: true, hasDefault: true },
28
28
  metadata: { type: 'jsonb', required: true, hasDefault: true },
29
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/storage",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
5
5
  "description": "User file storage for Axium",
6
6
  "funding": {