@supatype/svelte 0.1.0-alpha.9
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/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/dist/context.d.ts +4 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +13 -0
- package/dist/context.js.map +1 -0
- package/dist/createAuth.d.ts +24 -0
- package/dist/createAuth.d.ts.map +1 -0
- package/dist/createAuth.js +58 -0
- package/dist/createAuth.js.map +1 -0
- package/dist/createFunction.d.ts +13 -0
- package/dist/createFunction.d.ts.map +1 -0
- package/dist/createFunction.js +27 -0
- package/dist/createFunction.js.map +1 -0
- package/dist/createMutation.d.ts +16 -0
- package/dist/createMutation.d.ts.map +1 -0
- package/dist/createMutation.js +57 -0
- package/dist/createMutation.js.map +1 -0
- package/dist/createQuery.d.ts +21 -0
- package/dist/createQuery.d.ts.map +1 -0
- package/dist/createQuery.js +54 -0
- package/dist/createQuery.js.map +1 -0
- package/dist/createSubscription.d.ts +13 -0
- package/dist/createSubscription.d.ts.map +1 -0
- package/dist/createSubscription.js +60 -0
- package/dist/createSubscription.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +28 -0
- package/src/context.ts +16 -0
- package/src/createAuth.ts +79 -0
- package/src/createFunction.ts +43 -0
- package/src/createMutation.ts +82 -0
- package/src/createQuery.ts +85 -0
- package/src/createSubscription.ts +87 -0
- package/src/index.ts +18 -0
- package/tsconfig.json +13 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SupatypeClient, AnyDatabase } from "@supatype/client";
|
|
2
|
+
export declare function setSupatypeClient(client: SupatypeClient): void;
|
|
3
|
+
export declare function getSupatypeClient<TDatabase extends AnyDatabase = AnyDatabase>(): SupatypeClient<TDatabase>;
|
|
4
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAE9D;AAED,wBAAgB,iBAAiB,CAAC,SAAS,SAAS,WAAW,GAAG,WAAW,KAAK,cAAc,CAAC,SAAS,CAAC,CAM1G"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
const SUPATYPE_KEY = Symbol("supatype");
|
|
3
|
+
export function setSupatypeClient(client) {
|
|
4
|
+
setContext(SUPATYPE_KEY, client);
|
|
5
|
+
}
|
|
6
|
+
export function getSupatypeClient() {
|
|
7
|
+
const client = getContext(SUPATYPE_KEY);
|
|
8
|
+
if (!client) {
|
|
9
|
+
throw new Error("getSupatypeClient() requires setSupatypeClient() to be called in a parent component.");
|
|
10
|
+
}
|
|
11
|
+
return client;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAG/C,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;AAEvC,MAAM,UAAU,iBAAiB,CAAC,MAAsB;IACtD,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,MAAM,MAAM,GAAG,UAAU,CAAwC,YAAY,CAAC,CAAA;IAC9E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,sFAAsF,CAAC,CAAA;IACzG,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Readable } from "svelte/store";
|
|
2
|
+
import type { AnyDatabase, SupatypeError, User, Session } from "@supatype/client";
|
|
3
|
+
export interface AuthStore {
|
|
4
|
+
user: Readable<User | null>;
|
|
5
|
+
session: Readable<Session | null>;
|
|
6
|
+
loading: Readable<boolean>;
|
|
7
|
+
signIn: (email: string, password: string) => Promise<{
|
|
8
|
+
error: SupatypeError | null;
|
|
9
|
+
}>;
|
|
10
|
+
signUp: (email: string, password: string) => Promise<{
|
|
11
|
+
error: SupatypeError | null;
|
|
12
|
+
}>;
|
|
13
|
+
signOut: () => Promise<{
|
|
14
|
+
error: SupatypeError | null;
|
|
15
|
+
}>;
|
|
16
|
+
signInWithOAuth: (provider: string) => Promise<{
|
|
17
|
+
error: SupatypeError | null;
|
|
18
|
+
}>;
|
|
19
|
+
resetPassword: (email: string) => Promise<{
|
|
20
|
+
error: SupatypeError | null;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
export declare function createAuth<TDatabase extends AnyDatabase = AnyDatabase>(): AuthStore;
|
|
24
|
+
//# sourceMappingURL=createAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAuth.d.ts","sourceRoot":"","sources":["../src/createAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAmB,MAAM,kBAAkB,CAAA;AAGlG,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,CAAA;IAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACjC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;IACrF,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;IACrF,OAAO,EAAE,MAAM,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;IACvD,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;IAC/E,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;CAC3E;AAED,wBAAgB,UAAU,CAAC,SAAS,SAAS,WAAW,GAAG,WAAW,KAAK,SAAS,CA8DnF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { writable } from "svelte/store";
|
|
2
|
+
import { onDestroy } from "svelte";
|
|
3
|
+
import { getSupatypeClient } from "./context.js";
|
|
4
|
+
export function createAuth() {
|
|
5
|
+
const client = getSupatypeClient();
|
|
6
|
+
const user = writable(null);
|
|
7
|
+
const session = writable(null);
|
|
8
|
+
const loading = writable(true);
|
|
9
|
+
// Get initial session
|
|
10
|
+
client.auth.getSession().then(({ data }) => {
|
|
11
|
+
if (data.session) {
|
|
12
|
+
session.set(data.session);
|
|
13
|
+
user.set(data.session.user);
|
|
14
|
+
}
|
|
15
|
+
loading.set(false);
|
|
16
|
+
}).catch(() => {
|
|
17
|
+
loading.set(false);
|
|
18
|
+
});
|
|
19
|
+
// Subscribe to auth changes
|
|
20
|
+
const { data: { subscription } } = client.auth.onAuthStateChange((_event, newSession) => {
|
|
21
|
+
session.set(newSession);
|
|
22
|
+
user.set(newSession?.user ?? null);
|
|
23
|
+
});
|
|
24
|
+
onDestroy(() => {
|
|
25
|
+
subscription.unsubscribe();
|
|
26
|
+
});
|
|
27
|
+
const signIn = async (email, password) => {
|
|
28
|
+
const { error } = await client.auth.signInWithPassword({ email, password });
|
|
29
|
+
return { error };
|
|
30
|
+
};
|
|
31
|
+
const signUp = async (email, password) => {
|
|
32
|
+
const { error } = await client.auth.signUp({ email, password });
|
|
33
|
+
return { error };
|
|
34
|
+
};
|
|
35
|
+
const signOut = async () => {
|
|
36
|
+
const { error } = await client.auth.signOut();
|
|
37
|
+
return { error };
|
|
38
|
+
};
|
|
39
|
+
const signInWithOAuth = async (provider) => {
|
|
40
|
+
const { error } = await client.auth.signInWithOAuth({ provider });
|
|
41
|
+
return { error };
|
|
42
|
+
};
|
|
43
|
+
const resetPassword = async (email) => {
|
|
44
|
+
const { error } = await client.auth.resetPasswordForEmail(email);
|
|
45
|
+
return { error };
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
user: { subscribe: user.subscribe },
|
|
49
|
+
session: { subscribe: session.subscribe },
|
|
50
|
+
loading: { subscribe: loading.subscribe },
|
|
51
|
+
signIn,
|
|
52
|
+
signUp,
|
|
53
|
+
signOut,
|
|
54
|
+
signInWithOAuth,
|
|
55
|
+
resetPassword,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=createAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAuth.js","sourceRoot":"","sources":["../src/createAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAahD,MAAM,UAAU,UAAU;IACxB,MAAM,M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able } from "svelte/store";
|
|
2
|
+
import type { AnyDatabase, SupatypeError } from "@supatype/client";
|
|
3
|
+
export interface FunctionStore<TResponse> {
|
|
4
|
+
invoke: (body?: unknown) => Promise<{
|
|
5
|
+
data: TResponse | null;
|
|
6
|
+
error: SupatypeError | null;
|
|
7
|
+
}>;
|
|
8
|
+
data: Readable<TResponse | null>;
|
|
9
|
+
error: Readable<SupatypeError | null>;
|
|
10
|
+
loading: Readable<boolean>;
|
|
11
|
+
}
|
|
12
|
+
export declare function createFunction<TResponse = unknown, TDatabase extends AnyDatabase = AnyDatabase>(functionName: string): FunctionStore<TResponse>;
|
|
13
|
+
//# sourceMappingURL=createFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFunction.d.ts","sourceRoot":"","sources":["../src/createFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGlE,MAAM,WAAW,aAAa,CAAC,SAAS;IACtC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;IAC5F,IAAI,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,CAAA;IAChC,KAAK,EAAE,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;IACrC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;CAC3B;AAED,wBAAgB,cAAc,CAC5B,SAAS,GAAG,OAAO,EACnB,SAAS,SAAS,WAAW,GAAG,WAAW,EAE3C,YAAY,EAAE,MAAM,GACnB,aAAa,CAAC,SAAS,CAAC,CA0B1B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { writable } from "svelte/store";
|
|
2
|
+
import { getSupatypeClient } from "./context.js";
|
|
3
|
+
export function createFunction(functionName) {
|
|
4
|
+
const client = getSupatypeClient();
|
|
5
|
+
const data = writable(null);
|
|
6
|
+
const error = writable(null);
|
|
7
|
+
const loading = writable(false);
|
|
8
|
+
const invoke = async (body) => {
|
|
9
|
+
loading.set(true);
|
|
10
|
+
error.set(null);
|
|
11
|
+
const result = await client.functions.invoke(functionName, {
|
|
12
|
+
...(body !== undefined ? { body } : {}),
|
|
13
|
+
});
|
|
14
|
+
loading.set(false);
|
|
15
|
+
data.set(result.data);
|
|
16
|
+
if (result.error)
|
|
17
|
+
error.set(result.error);
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
invoke,
|
|
22
|
+
data: { subscribe: data.subscribe },
|
|
23
|
+
error: { subscribe: error.subscribe },
|
|
24
|
+
loading: { subscribe: loading.subscribe },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=createFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFunction.js","sourceRoot":"","sources":["../src/createFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,cAAc,CAAA;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAShD,MAAM,UAAU,cAAc,CAI5B,YAAoB;IAEpB,MAAM,MAAM,GAAG,iBAAiB,EAAa,CAAA;IAC7C,MAAM,IAAI,GAAG,QAAQ,CAAmB,IAAI,CAAC,CAAA;IAC7C,MAAM,KAAK,GAAG,QAAQ,CAAuB,IAAI,CAAC,CAAA;IAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAE/B,MAAM,MAAM,GAAG,KAAK,EAAE,IAAc,EAAE,EAAE;QACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACjB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEf,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,EAAE;YACzD,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACxC,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAClB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAwB,CAAC,CAAA;QACzC,IAAI,MAAM,CAAC,KAAK;YAAE,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACzC,OAAO,MAAiE,CAAA;IAC1E,CAAC,CAAA;IAED,OAAO;QACL,MAAM;QACN,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE;QACnC,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE;QACrC,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE;KAC1C,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Readable } from "svelte/store";
|
|
2
|
+
import type { AnyDatabase, SupatypeError } from "@supatype/client";
|
|
3
|
+
export type MutationOperation = "insert" | "update" | "delete" | "upsert";
|
|
4
|
+
export interface MutationOptions {
|
|
5
|
+
filter?: Record<string, unknown> | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface MutationStore<TRow> {
|
|
8
|
+
mutate: (data?: Record<string, unknown> | Record<string, unknown>[] | undefined, options?: MutationOptions | undefined) => Promise<{
|
|
9
|
+
data: TRow[] | null;
|
|
10
|
+
error: SupatypeError | null;
|
|
11
|
+
}>;
|
|
12
|
+
loading: Readable<boolean>;
|
|
13
|
+
error: Readable<SupatypeError | null>;
|
|
14
|
+
}
|
|
15
|
+
export declare function createMutation<TDatabase extends AnyDatabase = AnyDatabase, TTable extends keyof TDatabase["public"]["Tables"] & string = keyof TDatabase["public"]["Tables"] & string, TRow = TDatabase["public"]["Tables"][TTable]["Row"]>(table: TTable, operation: MutationOperation): MutationStore<TRow>;
|
|
16
|
+
//# sourceMappingURL=createMutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMutation.d.ts","sourceRoot":"","sources":["../src/createMutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGlE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEzE,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CAC7C;AAED,MAAM,WAAW,aAAa,CAAC,IAAI;IACjC,MAAM,EAAE,CACN,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,SAAS,EACtE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,KAClC,OAAO,CAAC;QAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;KAAE,CAAC,CAAA;IAClE,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC1B,KAAK,EAAE,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;CACtC;AAED,wBAAgB,cAAc,CAC5B,SAAS,SAAS,WAAW,GAAG,WAAW,EAC3C,MAAM,SAAS,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,EAC1G,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAEnD,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,iBAAiB,GAC3B,aAAa,CAAC,IAAI,CAAC,CAuDrB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { writable } from "svelte/store";
|
|
2
|
+
import { getSupatypeClient } from "./context.js";
|
|
3
|
+
export function createMutation(table, operation) {
|
|
4
|
+
const client = getSupatypeClient();
|
|
5
|
+
const loading = writable(false);
|
|
6
|
+
const error = writable(null);
|
|
7
|
+
const mutate = async (data, options) => {
|
|
8
|
+
loading.set(true);
|
|
9
|
+
error.set(null);
|
|
10
|
+
try {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
const tableClient = client.from(table);
|
|
13
|
+
let result;
|
|
14
|
+
if (operation === "insert") {
|
|
15
|
+
result = await tableClient.insert(data);
|
|
16
|
+
}
|
|
17
|
+
else if (operation === "upsert") {
|
|
18
|
+
result = await tableClient.upsert(data);
|
|
19
|
+
}
|
|
20
|
+
else if (operation === "update") {
|
|
21
|
+
let q = tableClient.update(data);
|
|
22
|
+
if (options?.filter) {
|
|
23
|
+
for (const [col, val] of Object.entries(options.filter)) {
|
|
24
|
+
q = q.eq(col, val);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
result = await q;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
let q = tableClient.delete();
|
|
31
|
+
if (options?.filter) {
|
|
32
|
+
for (const [col, val] of Object.entries(options.filter)) {
|
|
33
|
+
q = q.eq(col, val);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
result = await q;
|
|
37
|
+
}
|
|
38
|
+
if (result.error)
|
|
39
|
+
error.set(result.error);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
const err = { message: e instanceof Error ? e.message : "Unknown error" };
|
|
44
|
+
error.set(err);
|
|
45
|
+
return { data: null, error: err };
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
loading.set(false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
mutate,
|
|
53
|
+
loading: { subscribe: loading.subscribe },
|
|
54
|
+
error: { subscribe: error.subscribe },
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=createMutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMutation.js","sourceRoot":"","sources":["../src/createMutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,cAAc,CAAA;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAiBhD,MAAM,UAAU,cAAc,CAK5B,KAAa,EACb,SAA4B;IAE5B,MAAM,MAAM,GAAG,iBAAiB,EAAa,CAAA;IAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC/B,MAAM,KAAK,GAAG,QAAQ,CAAuB,IAAI,CAAC,CAAA;IAElD,MAAM,MAAM,GAAG,KAAK,EAClB,IAAsE,EACtE,OAAqC,EACrC,EAAE;QACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACjB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEf,IAAI,CAAC;YACH,8DAA8D;YAC9D,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAQ,CAAA;YAC7C,IAAI,MAA4D,CAAA;YAEhE,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;gBAC3B,MAAM,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACzC,CAAC;iBAAM,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;gBAClC,MAAM,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,IAA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AC;gBAAS,CAAC;YACT,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACpB,CAAC;IACH,CAAC,CAAA;IAED,OAAO;QACL,MAAM;QACN,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE;QACzC,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE;KACtC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Readable } from "svelte/store";
|
|
2
|
+
import type { AnyDatabase, SupatypeError } from "@supatype/client";
|
|
3
|
+
export interface QueryOptions {
|
|
4
|
+
columns?: string | undefined;
|
|
5
|
+
filter?: Record<string, unknown> | undefined;
|
|
6
|
+
order?: {
|
|
7
|
+
column: string;
|
|
8
|
+
ascending?: boolean;
|
|
9
|
+
} | undefined;
|
|
10
|
+
limit?: number | undefined;
|
|
11
|
+
offset?: number | undefined;
|
|
12
|
+
enabled?: boolean | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface QueryStore<TRow> {
|
|
15
|
+
data: Readable<TRow[] | null>;
|
|
16
|
+
error: Readable<SupatypeError | null>;
|
|
17
|
+
loading: Readable<boolean>;
|
|
18
|
+
refetch: () => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export declare function createQuery<TDatabase extends AnyDatabase = AnyDatabase, TTable extends keyof TDatabase["public"]["Tables"] & string = keyof TDatabase["public"]["Tables"] & string, TRow = TDatabase["public"]["Tables"][TTable]["Row"]>(table: TTable, options?: QueryOptions | undefined): QueryStore<TRow>;
|
|
21
|
+
//# sourceMappingURL=createQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createQuery.d.ts","sourceRoot":"","sources":["../src/createQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CA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options) {
|
|
4
|
+
const client = getSupatypeClient();
|
|
5
|
+
const data = writable(null);
|
|
6
|
+
const error = writable(null);
|
|
7
|
+
const loading = writable(false);
|
|
8
|
+
const fetchData = async () => {
|
|
9
|
+
if (options?.enabled === false)
|
|
10
|
+
return;
|
|
11
|
+
loading.set(true);
|
|
12
|
+
error.set(null);
|
|
13
|
+
try {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
let query = client.from(table).select(options?.columns);
|
|
16
|
+
if (options?.filter) {
|
|
17
|
+
for (const [col, val] of Object.entries(options.filter)) {
|
|
18
|
+
query = query.eq(col, val);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (options?.order) {
|
|
22
|
+
query = query.order(options.order.column, {
|
|
23
|
+
ascending: options.order.ascending ?? true,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (options?.limit !== undefined) {
|
|
27
|
+
query = query.limit(options.limit);
|
|
28
|
+
}
|
|
29
|
+
if (options?.offset !== undefined) {
|
|
30
|
+
query = query.range(options.offset, options.offset + (options.limit ?? 100) - 1);
|
|
31
|
+
}
|
|
32
|
+
const result = await query;
|
|
33
|
+
data.set(result.data);
|
|
34
|
+
if (result.error) {
|
|
35
|
+
error.set(result.error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
error.set({ message: e instanceof Error ? e.message : "Unknown error" });
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
loading.set(false);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
// Auto-fetch on creation
|
|
46
|
+
fetchData();
|
|
47
|
+
return {
|
|
48
|
+
data: { subscribe: data.subscribe },
|
|
49
|
+
error: { subscribe: error.subscribe },
|
|
50
|
+
loading: { subscribe: loading.subscribe },
|
|
51
|
+
refetch: fetchData,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=createQuery.js.map
|
|
@@ -0,0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";
|
|
2
|
+
import type { AnyDatabase, SupatypeError, RealtimeEvent } from "@supatype/client";
|
|
3
|
+
export interface SubscriptionOptions {
|
|
4
|
+
event?: RealtimeEvent | undefined;
|
|
5
|
+
filter?: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface SubscriptionStore<TRow> {
|
|
8
|
+
data: Readable<TRow[] | null>;
|
|
9
|
+
error: Readable<SupatypeError | null>;
|
|
10
|
+
status: Readable<"connecting" | "connected" | "disconnected" | "error">;
|
|
11
|
+
}
|
|
12
|
+
export declare function createSubscription<TDatabase extends AnyDatabase = AnyDatabase, TTable extends keyof TDatabase["public"]["Tables"] & string = keyof TDatabase["public"]["Tables"] & string, TRow = TDatabase["public"]["Tables"][TTable]["Row"]>(table: TTable, options?: SubscriptionOptions | undefined): SubscriptionStore<TRow>;
|
|
13
|
+
//# sourceMappingURL=createSubscription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSubscription.d.ts","sourceRoot":"","sources":["../src/createSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAmB,aAAa,EAAiB,MAAM,kBAAkB,CAAA;AAGjH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,iBAAiB,CAAC,IAAI;IACrC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAA;IAC7B,KAAK,EAAE,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;IACrC,MAAM,EAAE,QAAQ,CAAC,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,OAAO,CAAC,CAAA;CACxE;AAED,wBAAgB,kBAAkB,CAChC,SAAS,SAAS,WAAW,GAAG,WAAW,EAC3C,MAAM,SAAS,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,EAC1G,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAEnD,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,GACxC,iBAAiB,CAAC,IAAI,CAAC,CA+DzB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { writable } from "svelte/store";
|
|
2
|
+
import { onDestroy } from "svelte";
|
|
3
|
+
import { getSupatypeClient } from "./context.js";
|
|
4
|
+
export function createSubscription(table, options) {
|
|
5
|
+
const client = getSupatypeClient();
|
|
6
|
+
const data = writable(null);
|
|
7
|
+
const error = writable(null);
|
|
8
|
+
const status = writable("connecting");
|
|
9
|
+
const event = options?.event ?? "*";
|
|
10
|
+
const channelOpts = {
|
|
11
|
+
event,
|
|
12
|
+
schema: "public",
|
|
13
|
+
table,
|
|
14
|
+
};
|
|
15
|
+
if (options?.filter) {
|
|
16
|
+
channelOpts.filter = options.filter;
|
|
17
|
+
}
|
|
18
|
+
const channel = client.realtime.channel(`public:${table}`);
|
|
19
|
+
channel.on("postgres_changes", channelOpts, (payload) => {
|
|
20
|
+
data.update((current) => {
|
|
21
|
+
const rows = current ?? [];
|
|
22
|
+
if (payload.eventType === "INSERT") {
|
|
23
|
+
return [...rows, payload.new];
|
|
24
|
+
}
|
|
25
|
+
else if (payload.eventType === "UPDATE") {
|
|
26
|
+
return rows.map((row) => {
|
|
27
|
+
const r = row;
|
|
28
|
+
const n = payload.new;
|
|
29
|
+
return r["id"] === n["id"] ? payload.new : row;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else if (payload.eventType === "DELETE") {
|
|
33
|
+
const old = payload.old;
|
|
34
|
+
return rows.filter((row) => row["id"] !== old["id"]);
|
|
35
|
+
}
|
|
36
|
+
return rows;
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
channel.subscribe((newStatus) => {
|
|
40
|
+
if (newStatus === "SUBSCRIBED") {
|
|
41
|
+
status.set("connected");
|
|
42
|
+
}
|
|
43
|
+
else if (newStatus === "CHANNEL_ERROR") {
|
|
44
|
+
status.set("error");
|
|
45
|
+
error.set({ message: "Subscription error" });
|
|
46
|
+
}
|
|
47
|
+
else if (newStatus === "CLOSED") {
|
|
48
|
+
status.set("disconnected");
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
onDestroy(() => {
|
|
52
|
+
channel.unsubscribe();
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
data: { subscribe: data.subscribe },
|
|
56
|
+
error: { subscribe: error.subscribe },
|
|
57
|
+
status: { subscribe: status.subscribe },
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=createSubscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSubscription.js","sourceRoot":"","sources":["../src/createSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAahD,MAAM,UAAU,kBAAkB,CAKhC,KAAa,EACb,OAAyC;IAEzC,MAAM,MAAM,GAAG,iBAAiB,EAAa,CAAA;IAC7C,MAAM,IAAI,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAA;IAC1C,MAAM,KAAK,GAAG,QAAQ,CAAuB,IAAI,CAAC,CAAA;IAClD,MAAM,MAAM,GAAG,QAAQ,CAAwD,YAAY,CAAC,CAAA;IAE5F,MAAM,KAAK,GAAmB,OAAO,EAAE,KAAuB,IAAI,GAAG,CAAA;IACrE,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ACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,SAAS,CAAC,CAAC,SAAwB,EAAE,EAAE;QAC7C,IAAI,SAAS,KAAK,YAAY,EAAE,CAAC;YAC/B,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACzB,CAAC;aAAM,IAAI,SAAS,KAAK,eAAe,EAAE,CAAC;YACzC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACnB,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAA;QAC9C,CAAC;aAAM,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YAClC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,WAAW,EAAE,CAAA;IACvB,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE;QACnC,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE;QACrC,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE;KACxC,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { setSupatypeClient, getSupatypeClient } from "./context.js";
|
|
2
|
+
export { createQuery } from "./createQuery.js";
|
|
3
|
+
export type { QueryOptions, QueryStore } from "./createQuery.js";
|
|
4
|
+
export { createMutation } from "./createMutation.js";
|
|
5
|
+
export type { MutationStore, MutationOperation, MutationOptions } from "./createMutation.js";
|
|
6
|
+
export { createAuth } from "./createAuth.js";
|
|
7
|
+
export type { AuthStore } from "./createAuth.js";
|
|
8
|
+
export { createSubscription } from "./createSubscription.js";
|
|
9
|
+
export type { SubscriptionOptions, SubscriptionStore } from "./createSubscription.js";
|
|
10
|
+
export { createFunction } from "./createFunction.js";
|
|
11
|
+
export type { FunctionStore } from "./createFunction.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE5F,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAErF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @supatype/svelte — Svelte stores for Supatype
|
|
2
|
+
export { setSupatypeClient, getSupatypeClient } from "./context.js";
|
|
3
|
+
export { createQuery } from "./createQuery.js";
|
|
4
|
+
export { createMutation } from "./createMutation.js";
|
|
5
|
+
export { createAuth } from "./createAuth.js";
|
|
6
|
+
export { createSubscription } from "./createSubscription.js";
|
|
7
|
+
export { createFunction } from "./createFunction.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@supatype/svelte",
|
|
3
|
+
"version": "0.1.0-alpha.9",
|
|
4
|
+
"description": "Svelte stores for Supatype — createQuery, createMutation, createAuth, createSubscription",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"svelte": "^5.0.0",
|
|
16
|
+
"@supatype/client": "0.1.0-alpha.9"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5",
|
|
20
|
+
"svelte": "^5.0.0",
|
|
21
|
+
"@supatype/client": "0.1.0-alpha.9"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc --project tsconfig.json",
|
|
25
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
26
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/context.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getContext, setContext } from "svelte"
|
|
2
|
+
import type { SupatypeClient, AnyDatabase } from "@supatype/client"
|
|
3
|
+
|
|
4
|
+
const SUPATYPE_KEY = Symbol("supatype")
|
|
5
|
+
|
|
6
|
+
export function setSupatypeClient(client: SupatypeClient): void {
|
|
7
|
+
setContext(SUPATYPE_KEY, client)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getSupatypeClient<TDatabase extends AnyDatabase = AnyDatabase>(): SupatypeClient<TDatabase> {
|
|
11
|
+
const client = getContext<SupatypeClient<TDatabase> | undefined>(SUPATYPE_KEY)
|
|
12
|
+
if (!client) {
|
|
13
|
+
throw new Error("getSupatypeClient() requires setSupatypeClient() to be called in a parent component.")
|
|
14
|
+
}
|
|
15
|
+
return client
|
|
16
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { writable, type Readable } from "svelte/store"
|
|
2
|
+
import { onDestroy } from "svelte"
|
|
3
|
+
import type { AnyDatabase, SupatypeError, User, Session, AuthChangeEvent } from "@supatype/client"
|
|
4
|
+
import { getSupatypeClient } from "./context.js"
|
|
5
|
+
|
|
6
|
+
export interface AuthStore {
|
|
7
|
+
user: Readable<User | null>
|
|
8
|
+
session: Readable<Session | null>
|
|
9
|
+
loading: Readable<boolean>
|
|
10
|
+
signIn: (email: string, password: string) => Promise<{ error: SupatypeError | null }>
|
|
11
|
+
signUp: (email: string, password: string) => Promise<{ error: SupatypeError | null }>
|
|
12
|
+
signOut: () => Promise<{ error: SupatypeError | null }>
|
|
13
|
+
signInWithOAuth: (provider: string) => Promise<{ error: SupatypeError | null }>
|
|
14
|
+
resetPassword: (email: string) => Promise<{ error: SupatypeError | null }>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function createAuth<TDatabase extends AnyDatabase = AnyDatabase>(): AuthStore {
|
|
18
|
+
const client = getSupatypeClient<TDatabase>()
|
|
19
|
+
const user = writable<User | null>(null)
|
|
20
|
+
const session = writable<Session | null>(null)
|
|
21
|
+
const loading = writable(true)
|
|
22
|
+
|
|
23
|
+
// Get initial session
|
|
24
|
+
client.auth.getSession().then(({ data }) => {
|
|
25
|
+
if (data.session) {
|
|
26
|
+
session.set(data.session)
|
|
27
|
+
user.set(data.session.user)
|
|
28
|
+
}
|
|
29
|
+
loading.set(false)
|
|
30
|
+
}).catch(() => {
|
|
31
|
+
loading.set(false)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// Subscribe to auth changes
|
|
35
|
+
const { data: { subscription } } = client.auth.onAuthStateChange((_event: AuthChangeEvent, newSession: Session | null) => {
|
|
36
|
+
session.set(newSession)
|
|
37
|
+
user.set(newSession?.user ?? null)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
onDestroy(() => {
|
|
41
|
+
subscription.unsubscribe()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const signIn = async (email: string, password: string) => {
|
|
45
|
+
const { error } = await client.auth.signInWithPassword({ email, password })
|
|
46
|
+
return { error }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const signUp = async (email: string, password: string) => {
|
|
50
|
+
const { error } = await client.auth.signUp({ email, password })
|
|
51
|
+
return { error }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const signOut = async () => {
|
|
55
|
+
const { error } = await client.auth.signOut()
|
|
56
|
+
return { error }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const signInWithOAuth = async (provider: string) => {
|
|
60
|
+
const { error } = await client.auth.signInWithOAuth({ provider })
|
|
61
|
+
return { error }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const resetPassword = async (email: string) => {
|
|
65
|
+
const { error } = await client.auth.resetPasswordForEmail(email)
|
|
66
|
+
return { error }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
user: { subscribe: user.subscribe },
|
|
71
|
+
session: { subscribe: session.subscribe },
|
|
72
|
+
loading: { subscribe: loading.subscribe },
|
|
73
|
+
signIn,
|
|
74
|
+
signUp,
|
|
75
|
+
signOut,
|
|
76
|
+
signInWithOAuth,
|
|
77
|
+
resetPassword,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { writable, type Readable } from "svelte/store"
|
|
2
|
+
import type { AnyDatabase, SupatypeError } from "@supatype/client"
|
|
3
|
+
import { getSupatypeClient } from "./context.js"
|
|
4
|
+
|
|
5
|
+
export interface FunctionStore<TResponse> {
|
|
6
|
+
invoke: (body?: unknown) => Promise<{ data: TResponse | null; error: SupatypeError | null }>
|
|
7
|
+
data: Readable<TResponse | null>
|
|
8
|
+
error: Readable<SupatypeError | null>
|
|
9
|
+
loading: Readable<boolean>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function createFunction<
|
|
13
|
+
TResponse = unknown,
|
|
14
|
+
TDatabase extends AnyDatabase = AnyDatabase,
|
|
15
|
+
>(
|
|
16
|
+
functionName: string,
|
|
17
|
+
): FunctionStore<TResponse> {
|
|
18
|
+
const client = getSupatypeClient<TDatabase>()
|
|
19
|
+
const data = writable<TResponse | null>(null)
|
|
20
|
+
const error = writable<SupatypeError | null>(null)
|
|
21
|
+
const loading = writable(false)
|
|
22
|
+
|
|
23
|
+
const invoke = async (body?: unknown) => {
|
|
24
|
+
loading.set(true)
|
|
25
|
+
error.set(null)
|
|
26
|
+
|
|
27
|
+
const result = await client.functions.invoke(functionName, {
|
|
28
|
+
...(body !== undefined ? { body } : {}),
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
loading.set(false)
|
|
32
|
+
data.set(result.data as TResponse | null)
|
|
33
|
+
if (result.error) error.set(result.error)
|
|
34
|
+
return result as { data: TResponse | null; error: SupatypeError | null }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
invoke,
|
|
39
|
+
data: { subscribe: data.subscribe },
|
|
40
|
+
error: { subscribe: error.subscribe },
|
|
41
|
+
loading: { subscribe: loading.subscribe },
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { writable, type Readable } from "svelte/store"
|
|
2
|
+
import type { AnyDatabase, SupatypeError } from "@supatype/client"
|
|
3
|
+
import { getSupatypeClient } from "./context.js"
|
|
4
|
+
|
|
5
|
+
export type MutationOperation = "insert" | "update" | "delete" | "upsert"
|
|
6
|
+
|
|
7
|
+
export interface MutationOptions {
|
|
8
|
+
filter?: Record<string, unknown> | undefined
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface MutationStore<TRow> {
|
|
12
|
+
mutate: (
|
|
13
|
+
data?: Record<string, unknown> | Record<string, unknown>[] | undefined,
|
|
14
|
+
options?: MutationOptions | undefined,
|
|
15
|
+
) => Promise<{ data: TRow[] | null; error: SupatypeError | null }>
|
|
16
|
+
loading: Readable<boolean>
|
|
17
|
+
error: Readable<SupatypeError | null>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function createMutation<
|
|
21
|
+
TDatabase extends AnyDatabase = AnyDatabase,
|
|
22
|
+
TTable extends keyof TDatabase["public"]["Tables"] & string = keyof TDatabase["public"]["Tables"] & string,
|
|
23
|
+
TRow = TDatabase["public"]["Tables"][TTable]["Row"],
|
|
24
|
+
>(
|
|
25
|
+
table: TTable,
|
|
26
|
+
operation: MutationOperation,
|
|
27
|
+
): MutationStore<TRow> {
|
|
28
|
+
const client = getSupatypeClient<TDatabase>()
|
|
29
|
+
const loading = writable(false)
|
|
30
|
+
const error = writable<SupatypeError | null>(null)
|
|
31
|
+
|
|
32
|
+
const mutate = async (
|
|
33
|
+
data?: Record<string, unknown> | Record<string, unknown>[] | undefined,
|
|
34
|
+
options?: MutationOptions | undefined,
|
|
35
|
+
) => {
|
|
36
|
+
loading.set(true)
|
|
37
|
+
error.set(null)
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
const tableClient = client.from(table) as any
|
|
42
|
+
let result: { data: TRow[] | null; error: SupatypeError | null }
|
|
43
|
+
|
|
44
|
+
if (operation === "insert") {
|
|
45
|
+
result = await tableClient.insert(data)
|
|
46
|
+
} else if (operation === "upsert") {
|
|
47
|
+
result = await tableClient.upsert(data)
|
|
48
|
+
} else if (operation === "update") {
|
|
49
|
+
let q = tableClient.update(data)
|
|
50
|
+
if (options?.filter) {
|
|
51
|
+
for (const [col, val] of Object.entries(options.filter)) {
|
|
52
|
+
q = q.eq(col, val)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
result = await q
|
|
56
|
+
} else {
|
|
57
|
+
let q = tableClient.delete()
|
|
58
|
+
if (options?.filter) {
|
|
59
|
+
for (const [col, val] of Object.entries(options.filter)) {
|
|
60
|
+
q = q.eq(col, val)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
result = await q
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (result.error) error.set(result.error)
|
|
67
|
+
return result
|
|
68
|
+
} catch (e) {
|
|
69
|
+
const err = { message: e instanceof Error ? e.message : "Unknown error" }
|
|
70
|
+
error.set(err)
|
|
71
|
+
return { data: null, error: err }
|
|
72
|
+
} finally {
|
|
73
|
+
loading.set(false)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
mutate,
|
|
79
|
+
loading: { subscribe: loading.subscribe },
|
|
80
|
+
error: { subscribe: error.subscribe },
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { writable, type Readable } from "svelte/store"
|
|
2
|
+
import type { AnyDatabase, SupatypeError } from "@supatype/client"
|
|
3
|
+
import { getSupatypeClient } from "./context.js"
|
|
4
|
+
|
|
5
|
+
export interface QueryOptions {
|
|
6
|
+
columns?: string | undefined
|
|
7
|
+
filter?: Record<string, unknown> | undefined
|
|
8
|
+
order?: { column: string; ascending?: boolean } | undefined
|
|
9
|
+
limit?: number | undefined
|
|
10
|
+
offset?: number | undefined
|
|
11
|
+
enabled?: boolean | undefined
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface QueryStore<TRow> {
|
|
15
|
+
data: Readable<TRow[] | null>
|
|
16
|
+
error: Readable<SupatypeError | null>
|
|
17
|
+
loading: Readable<boolean>
|
|
18
|
+
refetch: () => Promise<void>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createQuery<
|
|
22
|
+
TDatabase extends AnyDatabase = AnyDatabase,
|
|
23
|
+
TTable extends keyof TDatabase["public"]["Tables"] & string = keyof TDatabase["public"]["Tables"] & string,
|
|
24
|
+
TRow = TDatabase["public"]["Tables"][TTable]["Row"],
|
|
25
|
+
>(
|
|
26
|
+
table: TTable,
|
|
27
|
+
options?: QueryOptions | undefined,
|
|
28
|
+
): QueryStore<TRow> {
|
|
29
|
+
const client = getSupatypeClient<TDatabase>()
|
|
30
|
+
const data = writable<TRow[] | null>(null)
|
|
31
|
+
const error = writable<SupatypeError | null>(null)
|
|
32
|
+
const loading = writable(false)
|
|
33
|
+
|
|
34
|
+
const fetchData = async () => {
|
|
35
|
+
if (options?.enabled === false) return
|
|
36
|
+
|
|
37
|
+
loading.set(true)
|
|
38
|
+
error.set(null)
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
let query = (client.from(table) as any).select(options?.columns)
|
|
43
|
+
|
|
44
|
+
if (options?.filter) {
|
|
45
|
+
for (const [col, val] of Object.entries(options.filter)) {
|
|
46
|
+
query = query.eq(col, val)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (options?.order) {
|
|
51
|
+
query = query.order(options.order.column, {
|
|
52
|
+
ascending: options.order.ascending ?? true,
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (options?.limit !== undefined) {
|
|
57
|
+
query = query.limit(options.limit)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (options?.offset !== undefined) {
|
|
61
|
+
query = query.range(options.offset, options.offset + (options.limit ?? 100) - 1)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const result = await query
|
|
65
|
+
data.set(result.data as TRow[] | null)
|
|
66
|
+
if (result.error) {
|
|
67
|
+
error.set(result.error)
|
|
68
|
+
}
|
|
69
|
+
} catch (e) {
|
|
70
|
+
error.set({ message: e instanceof Error ? e.message : "Unknown error" })
|
|
71
|
+
} finally {
|
|
72
|
+
loading.set(false)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Auto-fetch on creation
|
|
77
|
+
fetchData()
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
data: { subscribe: data.subscribe },
|
|
81
|
+
error: { subscribe: error.subscribe },
|
|
82
|
+
loading: { subscribe: loading.subscribe },
|
|
83
|
+
refetch: fetchData,
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { writable, type Readable } from "svelte/store"
|
|
2
|
+
import { onDestroy } from "svelte"
|
|
3
|
+
import type { AnyDatabase, SupatypeError, RealtimePayload, RealtimeEvent, ChannelStatus } from "@supatype/client"
|
|
4
|
+
import { getSupatypeClient } from "./context.js"
|
|
5
|
+
|
|
6
|
+
export interface SubscriptionOptions {
|
|
7
|
+
event?: RealtimeEvent | undefined
|
|
8
|
+
filter?: string | undefined
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface SubscriptionStore<TRow> {
|
|
12
|
+
data: Readable<TRow[] | null>
|
|
13
|
+
error: Readable<SupatypeError | null>
|
|
14
|
+
status: Readable<"connecting" | "connected" | "disconnected" | "error">
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function createSubscription<
|
|
18
|
+
TDatabase extends AnyDatabase = AnyDatabase,
|
|
19
|
+
TTable extends keyof TDatabase["public"]["Tables"] & string = keyof TDatabase["public"]["Tables"] & string,
|
|
20
|
+
TRow = TDatabase["public"]["Tables"][TTable]["Row"],
|
|
21
|
+
>(
|
|
22
|
+
table: TTable,
|
|
23
|
+
options?: SubscriptionOptions | undefined,
|
|
24
|
+
): SubscriptionStore<TRow> {
|
|
25
|
+
const client = getSupatypeClient<TDatabase>()
|
|
26
|
+
const data = writable<TRow[] | null>(null)
|
|
27
|
+
const error = writable<SupatypeError | null>(null)
|
|
28
|
+
const status = writable<"connecting" | "connected" | "disconnected" | "error">("connecting")
|
|
29
|
+
|
|
30
|
+
const event: RealtimeEvent = (options?.event as RealtimeEvent) ?? "*"
|
|
31
|
+
const channelOpts: {
|
|
32
|
+
event: RealtimeEvent
|
|
33
|
+
schema: string
|
|
34
|
+
table: string
|
|
35
|
+
filter?: string | undefined
|
|
36
|
+
} = {
|
|
37
|
+
event,
|
|
38
|
+
schema: "public",
|
|
39
|
+
table,
|
|
40
|
+
}
|
|
41
|
+
if (options?.filter) {
|
|
42
|
+
channelOpts.filter = options.filter
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const channel = client.realtime.channel<TRow>(`public:${table}`)
|
|
46
|
+
|
|
47
|
+
channel.on("postgres_changes", channelOpts, (payload: RealtimePayload<TRow>) => {
|
|
48
|
+
data.update((current) => {
|
|
49
|
+
const rows = current ?? []
|
|
50
|
+
|
|
51
|
+
if (payload.eventType === "INSERT") {
|
|
52
|
+
return [...rows, payload.new as TRow]
|
|
53
|
+
} else if (payload.eventType === "UPDATE") {
|
|
54
|
+
return rows.map((row) => {
|
|
55
|
+
const r = row as Record<string, unknown>
|
|
56
|
+
const n = payload.new as Record<string, unknown>
|
|
57
|
+
return r["id"] === n["id"] ? (payload.new as TRow) : row
|
|
58
|
+
})
|
|
59
|
+
} else if (payload.eventType === "DELETE") {
|
|
60
|
+
const old = payload.old as Record<string, unknown>
|
|
61
|
+
return rows.filter((row) => (row as Record<string, unknown>)["id"] !== old["id"])
|
|
62
|
+
}
|
|
63
|
+
return rows
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
channel.subscribe((newStatus: ChannelStatus) => {
|
|
68
|
+
if (newStatus === "SUBSCRIBED") {
|
|
69
|
+
status.set("connected")
|
|
70
|
+
} else if (newStatus === "CHANNEL_ERROR") {
|
|
71
|
+
status.set("error")
|
|
72
|
+
error.set({ message: "Subscription error" })
|
|
73
|
+
} else if (newStatus === "CLOSED") {
|
|
74
|
+
status.set("disconnected")
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
onDestroy(() => {
|
|
79
|
+
channel.unsubscribe()
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
data: { subscribe: data.subscribe },
|
|
84
|
+
error: { subscribe: error.subscribe },
|
|
85
|
+
status: { subscribe: status.subscribe },
|
|
86
|
+
}
|
|
87
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @supatype/svelte — Svelte stores for Supatype
|
|
2
|
+
|
|
3
|
+
export { setSupatypeClient, getSupatypeClient } from "./context.js"
|
|
4
|
+
|
|
5
|
+
export { createQuery } from "./createQuery.js"
|
|
6
|
+
export type { QueryOptions, QueryStore } from "./createQuery.js"
|
|
7
|
+
|
|
8
|
+
export { createMutation } from "./createMutation.js"
|
|
9
|
+
export type { MutationStore, MutationOperation, MutationOptions } from "./createMutation.js"
|
|
10
|
+
|
|
11
|
+
export { createAuth } from "./createAuth.js"
|
|
12
|
+
export type { AuthStore } from "./createAuth.js"
|
|
13
|
+
|
|
14
|
+
export { createSubscription } from "./createSubscription.js"
|
|
15
|
+
export type { SubscriptionOptions, SubscriptionStore } from "./createSubscription.js"
|
|
16
|
+
|
|
17
|
+
export { createFunction } from "./createFunction.js"
|
|
18
|
+
export type { FunctionStore } from "./createFunction.js"
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/typescript.d.ts","../../node_modules/.pnpm/@typescript-eslint+types@8.57.1/node_modules/@typescript-eslint/types/dist/generated/ast-spec.d.ts","../../node_modules/.pnpm/@typescript-eslint+types@8.57.1/node_modules/@typescript-eslint/types/dist/lib.d.ts","../../node_modules/.pnpm/@typescript-eslint+types@8.57.1/node_modules/@typescript-eslint/types/dist/parser-options.d.ts","../../node_modules/.pnpm/@typescript-eslint+types@8.57.1/node_modules/@typescript-eslint/types/dist/ts-estree.d.ts","../../node_modules/.pnpm/@typescript-eslint+types@8.57.1/node_modules/@typescript-eslint/types/dist/index.d.ts","../../node_modules/.pnpm/esrap@2.2.4/node_modules/esrap/types/index.d.ts","../../node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.d.mts","../../node_modules/.pnpm/@types+estree@1.0.8/node_modules/@types/estree/index.d.ts","../../node_modules/.pnpm/locate-character@3.0.0/node_modules/locate-character/types/index.d.ts","../../node_modules/.pnpm/svelte@5.54.0/node_modules/svelte/types/index.d.ts","../client/dist/types.d.ts","../client/dist/auth.d.ts","../client/dist/query.d.ts","../client/dist/storage.d.ts","../client/dist/realtime.d.ts","../client/dist/errors.d.ts","../client/dist/fetch-with-retry.d.ts","../client/dist/retry.d.ts","../client/dist/error-codes-doc.d.ts","../client/dist/serverless-docs.d.ts","../client/dist/index.d.ts","./src/context.ts","./src/createAuth.ts","./src/createFunction.ts","./src/createMutation.ts","./src/createQuery.ts","./src/createSubscription.ts","./src/index.ts"],"fileIdsList":[[59],[60,61,62,63],[59,61],[60,63],[64,65],[65,66,67,68,69],[70],[70,71,72,73,74,75,76,77,78,79],[76],[69,80],[69,80,81],[81,82,83,84,85,86]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"8cdf8847677ac7d20486e54dd3fcf09eda95812ac8ace44b4418da1bbbab6eb8","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"e134052a6b1ded61693b4037f615dc72f14e2881e79c1ddbff6c514c8a516b05","impliedFormat":1},{"version":"33a1caf57a6f7318c7ce2c8a8a35137bd7c064d140f324e8f47b94cd129305b5","impliedFormat":1},{"version":"cc512139c85c41ba2dc95076b1ce05786c98129bcfe875017946ba2c82607ef1","impliedFormat":1},{"version":"12bffdbf179bfe787334d1aa31393bac5b79a84d2285ad94bcf36c1cce9eed57","impliedFormat":1},{"version":"e81484fc62d5e6add90882339bb2cdba0c87b85ca4002add438d0771ce2fdfa7","impliedFormat":1},{"version":"92ebc3261b20037c4e078cd3d26bccedb719b3eec653925e103b6ced4a936c0d","impliedFormat":1},{"version":"d8f8d36a0350f1b4e25f0d6c8cab7fb484a770cb02c4c92b8215ad421615d248","impliedFormat":99},{"version":"2be2227c3810dfd84e46674fd33b8d09a4a28ad9cb633ed536effd411665ea1e","impliedFormat":99},{"version":"151ff381ef9ff8da2da9b9663ebf657eac35c4c9a19183420c05728f31a6761d","impliedFormat":1},{"version":"ecd7b4429a2b12f50ef619043fca298eb99a9b7f9e8edabd60c9bbb7fa8f036b","impliedFormat":99},{"version":"c5c4280379b7f36801b1419663fe3d4f53cb1400bea8df529b20ae58cbf13ea8","affectsGlobalScope":true,"impliedFormat":99},{"version":"d3ed160939e7f93a97a35a37c42cad50799885f564a7b3957c9e9f1221ced9e7","impliedFormat":99},{"version":"d58e244c6d3aa676939aaa26e7bc5c6de22e408c195f69ee118eddd68377d17c","impliedFormat":99},{"version":"20fac2f073582881eeccdd3b04819084684fd296f3d6a0fa53e48ed3de83d35a","impliedFormat":99},{"version":"e5363db20ce3327d96a0e8c9a326259764eaf94e2b34eee3c74e5e6a988e5532","impliedFormat":99},{"version":"00f9fbcf8c7f9957b087eb4922fc153085c112d7f386c2cc211995a47fe7e07e","impliedFormat":99},{"version":"1600ade5611547c843e1da83f4180fa9d63e76f86503ac94e10ae55d87bfda02","impliedFormat":99},{"version":"ccbb4f957666793ea28e67b0748ba838841e641330b661bae31a5974612c73fd","impliedFormat":99},{"version":"9143a4409f10ae9f6362706e00e3b7ed082d4b2af0125aab31ecd30a6fefab13","impliedFormat":99},{"version":"6c9f37788061375db19a85ad684e2e08c5d0517200fae8479226ed1e82034ed1","impliedFormat":99},{"version":"e0856e33bfa821d4ab90b555ec6311122f178620eceb8effcaf6344abdb0bb75","impliedFormat":99},{"version":"509349be18cb0f2a92947dca43f5cd0af31ba579ebf8c75d2d2abb48a82f9042","impliedFormat":99},{"version":"be54c76e464aef194ff0a28d6c4e79b178524ca50d8623b5ea1be22c13d4f24f","signature":"a4c2aba890f20dd79c8aacfb97717d1d2c9b980ee61cb2c22f84b733f86bb9bf","impliedFormat":99},{"version":"901a0a90f5cba4f9a4ea329d6ce3aa4560874a4e4c21ab99384a15d1b519ee65","signature":"6dbbae2ee80eca51e85ef5a8da02df6ce118207b0f3fc894d502c728e9be5608","impliedFormat":99},{"version":"b07fc5eeca1a0cd524b2c5a81a16dfb4aec94dc81de5169517457aea90769ddd","signature":"f0a5cc14bcb4523551b95804d18cbb0b371f21365d1581fdcb40a00b9583a9a5","impliedFormat":99},{"version":"3cd1637b43aa20f4f5400621a324e32d810fcd0e5fc0e8410102a95ec9d7c097","signature":"7cab0b53f45d89e9870dc69e6f9b0e790ce5c4b94d46acae89b5d782e373ff24","impliedFormat":99},{"version":"b4a3026562fe4f24b1e2907d325a1eb86c9c3a2b9b50cc7525015481f65adf44","signature":"c0da4115e5f21395a5f2794e4bf0e44341a58c383d2ec2c2f8e35d1f464ba5e7","impliedFormat":99},{"version":"ecdef68d1cd7534b9299b121a7ff286818888e27e72da2072b41f972523ba27f","signature":"724261d9068dc0c733f09e3ee39cef2bbac3d973bd12da3bab7300aaa7b2892f","impliedFormat":99},{"version":"4cb589db52228dd50c56493ff0014a85d58cf72b2384b40292b16d1415811c75","signature":"2d6dd4853cf329d0b317aff87bc2d76afc219924d0dbaa0587fc03759fc43002","impliedFormat":99}],"root":[[81,87]],"options":{"composite":true,"declaration":true,"declarationMap":true,"esModuleInterop":true,"exactOptionalPropertyTypes":true,"module":199,"noUncheckedIndexedAccess":true,"outDir":"./dist","rootDir":"./src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9},"referencedMap":[[60,1],[64,2],[62,3],[63,4],[65,5],[69,6],[71,7],[80,8],[72,7],[77,9],[73,7],[81,10],[82,11],[83,11],[84,11],[85,11],[86,11],[87,12]],"latestChangedDtsFile":"./dist/index.d.ts","version":"5.9.3"}
|