@inflector/aura 0.1.13 → 0.1.14

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/auth.d.ts CHANGED
@@ -665,7 +665,7 @@ export declare const AuraAuth: (url: string, workspace: string) => {
665
665
  statusText: string;
666
666
  };
667
667
  }>;
668
- Redit: (data?: Omit<import("better-auth").Prettify<{
668
+ Reddit: (data?: Omit<import("better-auth").Prettify<{
669
669
  provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
670
670
  callbackURL?: string | undefined;
671
671
  newUserCallbackURL?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAKA,KAAK,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElD,UAAU,iBAAiB;IACzB,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC1D,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;CACjC;AAGD,eAAO,MAAM,aAAa,EAAE,iBA+BxB,CAAC;AACL,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA6D3B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;yBAQxB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAnErD,CAAC;iBAAe,CAAC;;;;;;;;;;;;;;;;qBAfO,CAAC;;;;;;;;;;;;;;;;CAyJ3B,CAAC"}
package/dist/auth.js CHANGED
@@ -2,7 +2,15 @@ import { createAuthClient } from "better-auth/client";
2
2
  import { anonymousClient } from "better-auth/client/plugins";
3
3
  import { computed } from "nanostores";
4
4
  // Only create once on the global object
5
+ // Returns a no-op implementation for SSR/Node.js environments
5
6
  export const SessionEvents = (() => {
7
+ // Check if running in browser environment
8
+ if (typeof window === 'undefined') {
9
+ return {
10
+ on: () => () => { },
11
+ emit: () => { },
12
+ };
13
+ }
6
14
  if (window.__SessionEvents)
7
15
  return window.__SessionEvents;
8
16
  const listeners = {
@@ -43,15 +51,16 @@ export const AuraAuth = (url, workspace) => {
43
51
  },
44
52
  });
45
53
  authClient.useSession.subscribe(() => {
46
- const Events = window.__SessionEvents;
47
- if (Events) {
48
- Events.emit("change");
54
+ if (typeof window !== 'undefined') {
55
+ const Events = window.__SessionEvents;
56
+ if (Events) {
57
+ Events.emit("change");
58
+ }
49
59
  }
50
60
  });
51
61
  const Session = computed(authClient.useSession, (session) => {
52
62
  if (!session?.data?.user)
53
63
  return session;
54
- const Events = window.__SessionEvents;
55
64
  return {
56
65
  ...session,
57
66
  data: {
@@ -88,7 +97,7 @@ export const AuraAuth = (url, workspace) => {
88
97
  };
89
98
  const OnUserLoaded = (fn) => {
90
99
  if (_initialized && User) {
91
- Promise.resolve(fn());
100
+ Promise.resolve(fn()).catch(console.error);
92
101
  }
93
102
  else {
94
103
  _onUserLoadedCallbacks.push(fn);
@@ -96,7 +105,7 @@ export const AuraAuth = (url, workspace) => {
96
105
  };
97
106
  const OnUserNotFound = (fn) => {
98
107
  if (_initialized && !User) {
99
- Promise.resolve(fn());
108
+ Promise.resolve(fn()).catch(console.error);
100
109
  }
101
110
  else {
102
111
  _onUserNotFoundCallbacks.push(fn);
@@ -133,7 +142,7 @@ export const AuraAuth = (url, workspace) => {
133
142
  HuggingFace: (data) => withDefaultCallback("hf", data),
134
143
  Linkedin: (data) => withDefaultCallback("linkedin", data),
135
144
  Microsoft: (data) => withDefaultCallback("microsoft", data),
136
- Redit: (data) => withDefaultCallback("redit", data),
145
+ Reddit: (data) => withDefaultCallback("reddit", data),
137
146
  Polar: (data) => withDefaultCallback("polar", data),
138
147
  Spotify: (data) => withDefaultCallback("spotify", data),
139
148
  Tiktok: (data) => withDefaultCallback("tiktok", data),
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"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AA,IAAI,EAAC,GAAG,GAAC,GAAG,EAAE,CAAA;KAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAC;QAAC,MAAM,EAAC,MAAM,CAAC;QAAA,IAAI,EAAC,GAAG,CAAA;KAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,EAAC,QAAO,GAAG,EAAC,OAAM,OAAO,gBAa3I;CACJ;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,EACzE,KAAK,MAAM,EACX,WAAW,MAAM,EACjB,QAAQ,CAAC,QAEe,CAAC,kCAY5B,CAAA"}
package/dist/database.js CHANGED
@@ -70,6 +70,7 @@ class RemoteTable {
70
70
  return (await axios.post(`${this.URL}/api/db/${this.WorkSpace}/${this.Name}`, {
71
71
  operation: 'Update',
72
72
  settings: { ...data, returning: true },
73
+ data: record
73
74
  }, {
74
75
  withCredentials: true
75
76
  })).data;
@@ -1 +1 @@
1
- {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../src/function.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,GAAG,CAqGvG"}
1
+ {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../src/function.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,GAAG,CAmHvG"}
package/dist/function.js CHANGED
@@ -27,8 +27,8 @@ export function createFunctionHandler(baseUrl, workspace, functionsFolder) {
27
27
  headers,
28
28
  credentials: "include",
29
29
  });
30
- // 3. Return a custom "Thenable" object immediately
31
- return {
30
+ // 3. Return a custom "Thenable" object with full Promise interface
31
+ const thenable = {
32
32
  then(onFulfilled, onRejected) {
33
33
  requestPromise.then(async (response) => {
34
34
  const contentType = response.headers.get("Content-Type") || "";
@@ -36,6 +36,11 @@ export function createFunctionHandler(baseUrl, workspace, functionsFolder) {
36
36
  // SSE PATH
37
37
  // ─────────────────────────────────────────────
38
38
  if (contentType.includes("text/event-stream")) {
39
+ if (!response.body) {
40
+ if (onRejected)
41
+ onRejected(new Error("Response body is null"));
42
+ return;
43
+ }
39
44
  const reader = response.body.getReader();
40
45
  const decoder = new TextDecoder("utf-8");
41
46
  let buffer = "";
@@ -84,10 +89,17 @@ export function createFunctionHandler(baseUrl, workspace, functionsFolder) {
84
89
  if (onRejected)
85
90
  onRejected(err);
86
91
  });
87
- // Return 'this' to allow chaining, though strictly custom behavior
88
- return this;
92
+ // Return 'this' to allow chaining
93
+ return thenable;
94
+ },
95
+ catch(onRejected) {
96
+ return thenable.then(() => { }, onRejected);
97
+ },
98
+ finally(onFinally) {
99
+ return thenable.then((value) => { onFinally?.(); return value; }, (err) => { onFinally?.(); throw err; });
89
100
  }
90
101
  };
102
+ return thenable;
91
103
  },
92
104
  });
93
105
  }
@@ -2,7 +2,7 @@ import type { CreateAura } from '..';
2
2
  type ValueOf<T> = T[keyof T];
3
3
  export declare function useTable<TDef extends ValueOf<Awaited<ReturnType<typeof CreateAura<any, any>>>['Database']>>(table: TDef, Options?: {
4
4
  where: Parameters<Awaited<ReturnType<TDef['GetOne']>['where']>>[0];
5
- }): ({ [K_1 in keyof TDef as K_1 extends `__${string}` ? never : TDef[K_1] extends import("@inflector/optima").ColumnBuilder<any, infer C extends import("@inflector/optima").ColumnConfig, any> ? C["notnull"] extends true ? K_1 : never : never]: TDef[K_1] extends import("@inflector/optima").ColumnBuilder<infer U, any, any> ? U : never; } & { [K_2 in keyof TDef as K_2 extends `__${string}` ? never : TDef[K_2] extends import("@inflector/optima").ColumnBuilder<any, infer C extends import("@inflector/optima").ColumnConfig, any> ? C["notnull"] extends true ? never : K_2 : never]: TDef[K_2] extends import("@inflector/optima").ColumnBuilder<infer U, any, any> ? U | null : never; } extends infer T ? { [K in keyof T]: T[K]; } : never)[] | undefined;
5
+ }): ({ [K_1 in keyof TDef as K_1 extends `__${string}` ? never : TDef[K_1] extends import("@inflector/optima").ColumnBuilder<any, infer C extends import("@inflector/optima").ColumnConfig, any> ? C["notnull"] extends true ? K_1 : never : never]: TDef[K_1] extends import("@inflector/optima").ColumnBuilder<infer U, any, any> ? U : never; } & { [K_2 in keyof TDef as K_2 extends `__${string}` ? never : TDef[K_2] extends import("@inflector/optima").ColumnBuilder<any, infer C extends import("@inflector/optima").ColumnConfig, any> ? C["notnull"] extends true ? never : K_2 : never]: TDef[K_2] extends import("@inflector/optima").ColumnBuilder<infer U, any, any> ? U | null : never; } extends infer T ? { [K in keyof T]: T[K]; } : never)[];
6
6
  export declare function useRecord<TDef extends ValueOf<Awaited<ReturnType<typeof CreateAura<any, any>>>['Database']>>(table: TDef, Options: {
7
7
  where: Parameters<Awaited<ReturnType<TDef['GetOne']>['where']>>[0];
8
8
  }): ({ [K_1 in keyof TDef as K_1 extends `__${string}` ? never : TDef[K_1] extends import("@inflector/optima").ColumnBuilder<any, infer C extends import("@inflector/optima").ColumnConfig, any> ? C["notnull"] extends true ? K_1 : never : never]: TDef[K_1] extends import("@inflector/optima").ColumnBuilder<infer U, any, any> ? U : never; } & { [K_2 in keyof TDef as K_2 extends `__${string}` ? never : TDef[K_2] extends import("@inflector/optima").ColumnBuilder<any, infer C extends import("@inflector/optima").ColumnConfig, any> ? C["notnull"] extends true ? never : K_2 : never]: TDef[K_2] extends import("@inflector/optima").ColumnBuilder<infer U, any, any> ? U | null : never; } extends infer T ? { [K in keyof T]: T[K]; } : never) | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/hooks/react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAS,MAAM,IAAI,CAAA;AAI3C,KAAK,OAAO,CAAC,CAAC,I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OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EAElF,KAAK,EAAE,IAAI,EACX,OAAO,CAAC,EAAE;IACR,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CACnE,guBAiEF;AAED,wBAAgB,SAAS,CACvB,IAAI,SAAS,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EAElF,KAAK,EAAE,IAAI,EACX,OAAO,EAAE;IACP,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CACnE,0uBA+DF;AAED,eAAO,MAAM,OAAO,GAAI,UAAU,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;;;;;;;;;aAGjF,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,UAAU,GAAG,QAGvC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { useStore } from '@nanostores/react';
2
- import { useEffect, useState } from 'react';
2
+ import { useEffect, useState, useRef } from 'react';
3
3
  function deepEqual(a, b) {
4
4
  if (a === b)
5
5
  return true;
@@ -21,6 +21,12 @@ export function useTable(table, Options) {
21
21
  const [data, setData] = useState([]);
22
22
  // Dummy state to force rerun when session changes
23
23
  const [sessionVersion, setSessionVersion] = useState(0);
24
+ // Use ref to track where clause changes with deep comparison
25
+ const whereRef = useRef(Options?.where);
26
+ const whereString = JSON.stringify(Options?.where);
27
+ if (JSON.stringify(whereRef.current) !== whereString) {
28
+ whereRef.current = Options?.where;
29
+ }
24
30
  useEffect(() => {
25
31
  const handler = () => {
26
32
  setSessionVersion((v) => v + 1);
@@ -57,13 +63,19 @@ export function useTable(table, Options) {
57
63
  return () => {
58
64
  unsubscribe();
59
65
  };
60
- }, [table, JSON.stringify(Options?.where), sessionVersion]); // <--- include sessionVersion here
66
+ }, [table, whereString, sessionVersion]); // <--- include sessionVersion here
61
67
  return data;
62
68
  }
63
69
  export function useRecord(table, Options) {
64
- const [data, setData] = useState();
70
+ const [data, setData] = useState(undefined);
65
71
  // Dummy state to trigger rerun on session change
66
72
  const [sessionVersion, setSessionVersion] = useState(0);
73
+ // Use ref to track where clause changes with deep comparison
74
+ const whereRef = useRef(Options.where);
75
+ const whereString = JSON.stringify(Options.where);
76
+ if (JSON.stringify(whereRef.current) !== whereString) {
77
+ whereRef.current = Options.where;
78
+ }
67
79
  // Subscribe to global session changes
68
80
  useEffect(() => {
69
81
  const handler = () => {
@@ -100,7 +112,7 @@ export function useRecord(table, Options) {
100
112
  });
101
113
  }, Options.where, true);
102
114
  return () => unsubscribe();
103
- }, [table, JSON.stringify(Options.where), sessionVersion]); // <--- include sessionVersion
115
+ }, [table, whereString, sessionVersion]); // <--- include sessionVersion
104
116
  return data;
105
117
  }
106
118
  export const useUser = (provider) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,cAAc,yBAAyB,CAAC;AACxC,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAE9B,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IACnD,MAAM,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,SAA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M,EAAE,GAAG,CAAC,IAAI;IAClD,QAAQ,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,QAAQ,EAAE,CAAC,CAAC;IACZ,OAAO,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IACxC,IAAI,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,UAAU,GACnB,CAAC,EACD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAE7B,QAAQ,gBAAgB,CAAC,CAAC,CAAC,KAC5B,YAAY,CAAC,CAAC,EAAE,CAAC,CAgBnB,CAAC"}
package/dist/index.js CHANGED
@@ -6,6 +6,13 @@ export * from "@inflector/optima/types";
6
6
  export * from "./lib";
7
7
  export * from "./hooks/react";
8
8
  export const CreateAura = (Config) => {
9
+ // Validate required config properties
10
+ if (!Config.config?.Url || typeof Config.config.Url !== 'string') {
11
+ throw new Error("CreateAura: Config.Url is required and must be a string");
12
+ }
13
+ if (!Config.config?.WorkSpace || typeof Config.config.WorkSpace !== 'string') {
14
+ throw new Error("CreateAura: Config.WorkSpace is required and must be a string");
15
+ }
9
16
  const auth = AuraAuth(Config.config.Url, Config.config.WorkSpace);
10
17
  return {
11
18
  Database: AuraDatabase(Config.config.Url, Config.config.WorkSpace, Config.Tables),
package/dist/storage.d.ts CHANGED
@@ -11,16 +11,16 @@ export declare const AuraStorage: (url: string, workspace: string, userAtom: any
11
11
  Upload: (file?: File, config?: {
12
12
  openSelector?: boolean;
13
13
  allowedTypes?: string[];
14
- }) => Promise<any>;
14
+ }) => Promise<FileAura>;
15
15
  File: (id: string) => string;
16
16
  Delete: (id: string) => Promise<any>;
17
- Get: (id: string) => Promise<FileAura | undefined>;
17
+ Get: (id: string) => Promise<FileAura>;
18
18
  List: () => Promise<FileAura[]>;
19
19
  UploadMultiple: (files?: File[], config?: {
20
20
  openSelector?: boolean;
21
21
  allowedTypes?: string[];
22
- }) => Promise<any[]>;
23
- Exists: (id: string) => Promise<boolean | undefined>;
22
+ }) => Promise<FileAura[]>;
23
+ Exists: (id: string) => Promise<boolean>;
24
24
  Download: (id: string, download?: boolean, asBase64?: boolean) => Promise<{
25
25
  blob: any;
26
26
  fileName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,IAAI,CAAC;CACpB,CAAC;AAIF,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,WAAW,MAAM,EAAE,UAAU,GAAG;oBAG1D,IAAI,WACH;QAAE,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;eAkDhD,MAAM;iBAGE,MAAM;cAYT,MAAM;;6BAwBV,IAAI,EAAE,WACN;QAAE,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;iBAuC5C,MAAM;mBAYJ,MAAM,aAAY,OAAO,aAAmB,OAAO;;;;;CA6B/E,CAAA"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,IAAI,CAAC;CACpB,CAAC;AAIF,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,WAAW,MAAM,EAAE,UAAU,GAAG;oBAG1D,IAAI,WACH;QAAE,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,KAC5D,OAAO,CAAC,QAAQ,CAAC;eA6DL,MAAM;iBAGE,MAAM;cAYT,MAAM,KAAG,OAAO,CAAC,QAAQ,CAAC;gBAY1B,OAAO,CAAC,QAAQ,EAAE,CAAC;6BAYvB,IAAI,EAAE,WACN;QAAE,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE;iBAmD5C,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;mBAYvB,MAAM,aAAY,OAAO,aAAoB,OAAO;;;;;CA6BhF,CAAA"}
package/dist/storage.js CHANGED
@@ -2,7 +2,7 @@ import axios from "axios";
2
2
  export const AuraStorage = (url, workspace, userAtom) => {
3
3
  const UploadFn = async (file, config = {}) => {
4
4
  if (!userAtom.get().data)
5
- return;
5
+ throw new Error("User not authenticated");
6
6
  // If no file is passed, or openSelector is true, open a file input dialog automatically
7
7
  if (!file || config.openSelector) {
8
8
  return new Promise(async (resolve, reject) => {
@@ -14,12 +14,17 @@ export const AuraStorage = (url, workspace, userAtom) => {
14
14
  }
15
15
  input.style.display = "none";
16
16
  document.body.appendChild(input);
17
+ const cleanup = () => {
18
+ if (document.body.contains(input)) {
19
+ document.body.removeChild(input);
20
+ }
21
+ };
17
22
  input.onchange = async () => {
18
23
  try {
19
24
  const selectedFile = input.files?.[0];
20
25
  if (!selectedFile) {
21
26
  reject(new Error("No file selected"));
22
- document.body.removeChild(input);
27
+ cleanup();
23
28
  return;
24
29
  }
25
30
  const fd = new FormData();
@@ -28,13 +33,18 @@ export const AuraStorage = (url, workspace, userAtom) => {
28
33
  fd.set("file", selectedFile);
29
34
  const result = (await axios.post(url + "/api/storage/" + workspace, fd)).data;
30
35
  resolve(result);
31
- document.body.removeChild(input);
36
+ cleanup();
32
37
  }
33
38
  catch (e) {
34
39
  reject(e);
35
- document.body.removeChild(input);
40
+ cleanup();
36
41
  }
37
42
  };
43
+ // Handle cancel - cleanup after a delay if no file selected
44
+ input.addEventListener('cancel', () => {
45
+ reject(new Error("File selection cancelled"));
46
+ cleanup();
47
+ });
38
48
  input.click();
39
49
  });
40
50
  }
@@ -55,7 +65,7 @@ export const AuraStorage = (url, workspace, userAtom) => {
55
65
  },
56
66
  Delete: async (id) => {
57
67
  if (!userAtom.get().data)
58
- return;
68
+ throw new Error("User not authenticated");
59
69
  return (await axios.post(url + "/api/storage/" + workspace, {
60
70
  operation: "Delete",
61
71
  settings: {
@@ -68,7 +78,7 @@ export const AuraStorage = (url, workspace, userAtom) => {
68
78
  },
69
79
  Get: async (id) => {
70
80
  if (!userAtom.get().data)
71
- return;
81
+ throw new Error("User not authenticated");
72
82
  return (await axios.post(url + "/api/storage/" + workspace, {
73
83
  operation: "Get",
74
84
  settings: {
@@ -81,7 +91,7 @@ export const AuraStorage = (url, workspace, userAtom) => {
81
91
  },
82
92
  List: async () => {
83
93
  if (!userAtom.get().data)
84
- return [];
94
+ throw new Error("User not authenticated");
85
95
  return (await axios.post(url + "/api/storage/" + workspace, {
86
96
  operation: "List",
87
97
  settings: {
@@ -104,12 +114,17 @@ export const AuraStorage = (url, workspace, userAtom) => {
104
114
  }
105
115
  input.style.display = "none";
106
116
  document.body.appendChild(input);
117
+ const cleanup = () => {
118
+ if (document.body.contains(input)) {
119
+ document.body.removeChild(input);
120
+ }
121
+ };
107
122
  input.onchange = async () => {
108
123
  const selectedFiles = Array.from(input.files ?? []);
109
124
  try {
110
125
  if (selectedFiles.length === 0) {
111
126
  reject(new Error("No files selected"));
112
- document.body.removeChild(input);
127
+ cleanup();
113
128
  return;
114
129
  }
115
130
  const uploadResults = await Promise.all(selectedFiles.map(f => UploadFn(f, config)));
@@ -119,9 +134,14 @@ export const AuraStorage = (url, workspace, userAtom) => {
119
134
  reject(e);
120
135
  }
121
136
  finally {
122
- document.body.removeChild(input);
137
+ cleanup();
123
138
  }
124
139
  };
140
+ // Handle cancel
141
+ input.addEventListener('cancel', () => {
142
+ reject(new Error("File selection cancelled"));
143
+ cleanup();
144
+ });
125
145
  input.click();
126
146
  });
127
147
  }
@@ -132,9 +152,9 @@ export const AuraStorage = (url, workspace, userAtom) => {
132
152
  },
133
153
  Exists: async (id) => {
134
154
  if (!userAtom.get().data)
135
- return;
155
+ throw new Error("User not authenticated");
136
156
  return (await axios.post(url + "/api/storage/" + workspace, {
137
- operation: "Get",
157
+ operation: "Exists",
138
158
  settings: {
139
159
  FileID: id,
140
160
  Owner: userAtom.get().data.user.id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inflector/aura",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",