@axium/storage 0.3.0 → 0.3.2

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,7 +1,7 @@
1
1
  import type { StorageItemMetadata, StorageItemUpdate, UserFilesInfo } from './common.js';
2
2
  import type { ItemSelection } from './selection.js';
3
3
  export declare function parseItem(result: StorageItemMetadata): StorageItemMetadata;
4
- export declare function uploadItem(file: File): Promise<StorageItemMetadata>;
4
+ export declare function uploadItem(file: File, parentId?: string): Promise<StorageItemMetadata>;
5
5
  export declare function updateItem(fileId: string, data: Blob): Promise<StorageItemMetadata>;
6
6
  export declare function getItemMetadata(fileId: string): Promise<StorageItemMetadata>;
7
7
  export declare function getDirectoryMetadata(parentId: string): Promise<StorageItemMetadata[]>;
package/dist/client.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { fetchAPI, token } from '@axium/client/requests';
2
- async function _upload(method, url, data) {
2
+ async function _upload(method, url, data, extraHeaders = {}) {
3
3
  const init = {
4
4
  method,
5
5
  headers: {
6
6
  'Content-Type': data.type,
7
7
  'Content-Length': data.size.toString(),
8
+ ...extraHeaders,
8
9
  },
9
10
  body: data,
10
11
  };
@@ -29,8 +30,8 @@ export function parseItem(result) {
29
30
  result.trashedAt = new Date(result.trashedAt);
30
31
  return result;
31
32
  }
32
- export async function uploadItem(file) {
33
- return parseItem(await _upload('PUT', '/raw/storage', file));
33
+ export async function uploadItem(file, parentId) {
34
+ return parseItem(await _upload('PUT', '/raw/storage', file, parentId ? { 'x-parent': parentId } : {}));
34
35
  }
35
36
  export async function updateItem(fileId, data) {
36
37
  return parseItem(await _upload('POST', '/raw/storage/' + fileId, data));
package/dist/plugin.d.ts CHANGED
@@ -37,6 +37,8 @@ declare const _default: {
37
37
  exports: {
38
38
  ".": string;
39
39
  "./*": string;
40
+ "./lib": string;
41
+ "./lib/*": string;
40
42
  };
41
43
  files: string[];
42
44
  scripts: {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import * as icon from '@axium/core/icons';
3
3
  import { ClipboardCopy, FormDialog, Icon } from '@axium/server/lib';
4
- import { deleteItem, updateItem, type _Sidebar } from '@axium/storage/client';
4
+ import { deleteItem, updateItemMetadata, type _Sidebar } from '@axium/storage/client';
5
5
  import type { StorageItemMetadata } from '@axium/storage/common';
6
6
  import { getContext } from 'svelte';
7
7
  import StorageSidebarItem from './StorageSidebarItem.svelte';
@@ -101,7 +101,7 @@
101
101
  bind:dialog={dialogs.rename}
102
102
  submitText="Rename"
103
103
  submit={async (data: { name: string }) => {
104
- await updateItem(item.id, data);
104
+ await updateItemMetadata(item.id, data);
105
105
  item.name = data.name;
106
106
  }}
107
107
  >
package/lib/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { default as StorageList } from './StorageList.svelte';
2
+ export { default as StorageSidebar } from './StorageSidebar.svelte';
3
+ export { default as StorageSidebarItem } from './StorageSidebarItem.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/storage",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
5
5
  "description": "User file storage for Axium",
6
6
  "funding": {
@@ -21,7 +21,9 @@
21
21
  "types": "dist/index.d.ts",
22
22
  "exports": {
23
23
  ".": "./dist/index.js",
24
- "./*": "./dist/*.js"
24
+ "./*": "./dist/*.js",
25
+ "./lib": "./lib/index.js",
26
+ "./lib/*": "./lib/*.js"
25
27
  },
26
28
  "files": [
27
29
  "dist",