@axium/storage 0.1.4 → 0.1.5

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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { StorageItemMetadata, StorageItemUpdate, UserFilesInfo } from './common.js';
2
2
  import type { ItemSelection } from './selection.js';
3
+ export declare function parseItem(result: StorageItemMetadata): StorageItemMetadata;
3
4
  export declare function uploadItem(file: File): Promise<StorageItemMetadata>;
4
5
  export declare function updateItem(fileId: string, data: Blob): Promise<StorageItemMetadata>;
5
6
  export declare function getItemMetadata(fileId: string): Promise<StorageItemMetadata>;
package/dist/client.js CHANGED
@@ -22,7 +22,7 @@ async function _upload(method, url, data) {
22
22
  json.modifiedAt = new Date(json.modifiedAt);
23
23
  return json;
24
24
  }
25
- function _parse(result) {
25
+ export function parseItem(result) {
26
26
  result.createdAt = new Date(result.createdAt);
27
27
  result.modifiedAt = new Date(result.modifiedAt);
28
28
  if (result.trashedAt)
@@ -30,19 +30,19 @@ function _parse(result) {
30
30
  return result;
31
31
  }
32
32
  export async function uploadItem(file) {
33
- return _parse(await _upload('PUT', '/raw/storage', file));
33
+ return parseItem(await _upload('PUT', '/raw/storage', file));
34
34
  }
35
35
  export async function updateItem(fileId, data) {
36
- return _parse(await _upload('POST', '/raw/storage/' + fileId, data));
36
+ return parseItem(await _upload('POST', '/raw/storage/' + fileId, data));
37
37
  }
38
38
  export async function getItemMetadata(fileId) {
39
39
  const result = await fetchAPI('GET', 'storage/item/:id', undefined, fileId);
40
- return _parse(result);
40
+ return parseItem(result);
41
41
  }
42
42
  export async function getDirectoryMetadata(parentId) {
43
43
  const result = await fetchAPI('GET', 'storage/directory/:id', undefined, parentId);
44
44
  for (const item of result)
45
- _parse(item);
45
+ parseItem(item);
46
46
  return result;
47
47
  }
48
48
  export async function downloadItem(fileId) {
@@ -55,15 +55,15 @@ export async function downloadItem(fileId) {
55
55
  }
56
56
  export async function updateItemMetadata(fileId, metadata) {
57
57
  const result = await fetchAPI('PATCH', 'storage/item/:id', metadata, fileId);
58
- return _parse(result);
58
+ return parseItem(result);
59
59
  }
60
60
  export async function deleteItem(fileId) {
61
61
  const result = await fetchAPI('DELETE', 'storage/item/:id', undefined, fileId);
62
- return _parse(result);
62
+ return parseItem(result);
63
63
  }
64
64
  export async function getUserFiles(userId) {
65
65
  const result = await fetchAPI('GET', 'users/:id/storage', undefined, userId);
66
66
  for (const item of result.items)
67
- _parse(item);
67
+ parseItem(item);
68
68
  return result;
69
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/storage",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
5
5
  "description": "User file storage for Axium",
6
6
  "funding": {