@axium/storage 0.3.13 → 0.3.15
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/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/plugin.js +1 -1
- package/dist/server.js +4 -4
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface UploadOptions {
|
|
|
5
5
|
parentId?: string;
|
|
6
6
|
name?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function uploadItem(file: Blob | File, opt
|
|
8
|
+
export declare function uploadItem(file: Blob | File, opt?: UploadOptions): Promise<StorageItemMetadata>;
|
|
9
9
|
export declare function updateItem(fileId: string, data: Blob): Promise<StorageItemMetadata>;
|
|
10
10
|
export declare function getItemMetadata(fileId: string): Promise<StorageItemMetadata>;
|
|
11
11
|
export declare function getDirectoryMetadata(parentId: string): Promise<StorageItemMetadata[]>;
|
package/dist/client.js
CHANGED
|
@@ -30,7 +30,7 @@ export function parseItem(result) {
|
|
|
30
30
|
result.trashedAt = new Date(result.trashedAt);
|
|
31
31
|
return result;
|
|
32
32
|
}
|
|
33
|
-
export async function uploadItem(file, opt) {
|
|
33
|
+
export async function uploadItem(file, opt = {}) {
|
|
34
34
|
const headers = {};
|
|
35
35
|
if (opt.parentId)
|
|
36
36
|
headers['x-parent'] = opt.parentId;
|
package/dist/plugin.js
CHANGED
|
@@ -26,7 +26,7 @@ async function db_init(opt) {
|
|
|
26
26
|
.addColumn('modifiedAt', 'timestamptz', col => col.notNull().defaultTo(sql `now()`))
|
|
27
27
|
.addColumn('size', 'integer', col => col.notNull())
|
|
28
28
|
.addColumn('trashedAt', 'timestamptz', col => col.defaultTo(null))
|
|
29
|
-
.addColumn('hash', 'bytea', col => col
|
|
29
|
+
.addColumn('hash', 'bytea', col => col)
|
|
30
30
|
.addColumn('name', 'text', col => col.defaultTo(null))
|
|
31
31
|
.addColumn('type', 'text', col => col.notNull())
|
|
32
32
|
.addColumn('immutable', 'boolean', col => col.notNull())
|
package/dist/server.js
CHANGED
|
@@ -13,7 +13,7 @@ import { StorageItemUpdate } from './common.js';
|
|
|
13
13
|
import './polyfills.js';
|
|
14
14
|
expectedTypes.storage = {
|
|
15
15
|
createdAt: { type: 'timestamptz', required: true, hasDefault: true },
|
|
16
|
-
hash: { type: 'bytea'
|
|
16
|
+
hash: { type: 'bytea' },
|
|
17
17
|
id: { type: 'uuid', required: true, hasDefault: true },
|
|
18
18
|
immutable: { type: 'bool', required: true },
|
|
19
19
|
modifiedAt: { type: 'timestamptz', required: true, hasDefault: true },
|
|
@@ -223,6 +223,7 @@ addRoute({
|
|
|
223
223
|
if (!useCAS) {
|
|
224
224
|
if (!isDirectory)
|
|
225
225
|
writeFileSync(path, content);
|
|
226
|
+
await tx.commit().execute();
|
|
226
227
|
return item;
|
|
227
228
|
}
|
|
228
229
|
const existing = await tx
|
|
@@ -235,18 +236,17 @@ addRoute({
|
|
|
235
236
|
if (!existing) {
|
|
236
237
|
if (!isDirectory)
|
|
237
238
|
writeFileSync(path, content);
|
|
239
|
+
await tx.commit().execute();
|
|
238
240
|
return item;
|
|
239
241
|
}
|
|
240
242
|
linkSync(join(config.storage.data, existing.id), path);
|
|
243
|
+
await tx.commit().execute();
|
|
241
244
|
return item;
|
|
242
245
|
}
|
|
243
246
|
catch (error) {
|
|
244
247
|
await tx.rollback().execute();
|
|
245
248
|
throw withError('Could not create item', 500)(error);
|
|
246
249
|
}
|
|
247
|
-
finally {
|
|
248
|
-
await tx.commit().execute();
|
|
249
|
-
}
|
|
250
250
|
},
|
|
251
251
|
});
|
|
252
252
|
addRoute({
|