@linabase/js 0.2.1 → 0.2.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/index.cjs +16 -10
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +16 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -191,7 +191,12 @@ var DatabaseClient = class {
|
|
|
191
191
|
order(column, options) {
|
|
192
192
|
const dir = options?.ascending === false ? "desc" : "asc";
|
|
193
193
|
const nulls = options?.nullsFirst === true ? ".nullsfirst" : options?.nullsFirst === false ? ".nullslast" : "";
|
|
194
|
-
this.params.
|
|
194
|
+
const existing = this.params.get("order");
|
|
195
|
+
if (existing) {
|
|
196
|
+
this.params.set("order", `${existing},${column}.${dir}${nulls}`);
|
|
197
|
+
} else {
|
|
198
|
+
this.params.set("order", `${column}.${dir}${nulls}`);
|
|
199
|
+
}
|
|
195
200
|
return this;
|
|
196
201
|
}
|
|
197
202
|
limit(count) {
|
|
@@ -626,12 +631,13 @@ var AuthClient = class {
|
|
|
626
631
|
/**
|
|
627
632
|
* Set (or clear) the current session. Use this to restore a persisted
|
|
628
633
|
* session on app launch (e.g., from AsyncStorage / SecureStore).
|
|
629
|
-
* Emits INITIAL_SESSION to onAuthStateChange listeners.
|
|
634
|
+
* Emits INITIAL_SESSION to onAuthStateChange listeners when called externally.
|
|
635
|
+
* Internal callers (signIn, signUp, etc.) pass _internal=true to skip the emit.
|
|
630
636
|
*/
|
|
631
|
-
setSession(session) {
|
|
637
|
+
setSession(session, _internal) {
|
|
632
638
|
this.currentSession = session;
|
|
633
639
|
if (this.onSessionChange) this.onSessionChange(session);
|
|
634
|
-
this.emit("INITIAL_SESSION", session);
|
|
640
|
+
if (!_internal) this.emit("INITIAL_SESSION", session);
|
|
635
641
|
}
|
|
636
642
|
// ─── Email/Password ────────────────────────────────────────
|
|
637
643
|
async signUp(params) {
|
|
@@ -643,7 +649,7 @@ var AuthClient = class {
|
|
|
643
649
|
const data = await res.json();
|
|
644
650
|
if (!res.ok) return { data: null, error: data };
|
|
645
651
|
const session = this.parseAuthResponse(data);
|
|
646
|
-
this.setSession(session);
|
|
652
|
+
this.setSession(session, true);
|
|
647
653
|
this.emit("SIGNED_IN", session);
|
|
648
654
|
return { data: session, error: null };
|
|
649
655
|
} catch (err) {
|
|
@@ -659,7 +665,7 @@ var AuthClient = class {
|
|
|
659
665
|
const data = await res.json();
|
|
660
666
|
if (!res.ok) return { data: null, error: data };
|
|
661
667
|
const session = this.parseAuthResponse(data);
|
|
662
|
-
this.setSession(session);
|
|
668
|
+
this.setSession(session, true);
|
|
663
669
|
this.emit("SIGNED_IN", session);
|
|
664
670
|
return { data: session, error: null };
|
|
665
671
|
} catch (err) {
|
|
@@ -684,7 +690,7 @@ var AuthClient = class {
|
|
|
684
690
|
const data = await res.json();
|
|
685
691
|
if (!res.ok) return { data: null, error: data };
|
|
686
692
|
const session = this.parseAuthResponse(data);
|
|
687
|
-
this.setSession(session);
|
|
693
|
+
this.setSession(session, true);
|
|
688
694
|
this.emit("SIGNED_IN", session);
|
|
689
695
|
return { data: session, error: null };
|
|
690
696
|
} catch (err) {
|
|
@@ -705,7 +711,7 @@ var AuthClient = class {
|
|
|
705
711
|
async signOut() {
|
|
706
712
|
try {
|
|
707
713
|
await this.request("/auth/v1/logout", { method: "POST" });
|
|
708
|
-
this.setSession(null);
|
|
714
|
+
this.setSession(null, true);
|
|
709
715
|
this.emit("SIGNED_OUT", null);
|
|
710
716
|
return { error: null };
|
|
711
717
|
} catch (err) {
|
|
@@ -745,12 +751,12 @@ var AuthClient = class {
|
|
|
745
751
|
});
|
|
746
752
|
const data = await res.json();
|
|
747
753
|
if (!res.ok) {
|
|
748
|
-
this.setSession(null);
|
|
754
|
+
this.setSession(null, true);
|
|
749
755
|
this.emit("SIGNED_OUT", null);
|
|
750
756
|
return { data: null, error: data };
|
|
751
757
|
}
|
|
752
758
|
const session = this.parseAuthResponse(data);
|
|
753
|
-
this.setSession(session);
|
|
759
|
+
this.setSession(session, true);
|
|
754
760
|
this.emit("TOKEN_REFRESHED", session);
|
|
755
761
|
return { data: session, error: null };
|
|
756
762
|
} catch (err) {
|
package/dist/index.d.cts
CHANGED
|
@@ -236,9 +236,10 @@ declare class AuthClient {
|
|
|
236
236
|
/**
|
|
237
237
|
* Set (or clear) the current session. Use this to restore a persisted
|
|
238
238
|
* session on app launch (e.g., from AsyncStorage / SecureStore).
|
|
239
|
-
* Emits INITIAL_SESSION to onAuthStateChange listeners.
|
|
239
|
+
* Emits INITIAL_SESSION to onAuthStateChange listeners when called externally.
|
|
240
|
+
* Internal callers (signIn, signUp, etc.) pass _internal=true to skip the emit.
|
|
240
241
|
*/
|
|
241
|
-
setSession(session: AuthSession | null): void;
|
|
242
|
+
setSession(session: AuthSession | null, _internal?: boolean): void;
|
|
242
243
|
signUp(params: {
|
|
243
244
|
email: string;
|
|
244
245
|
password: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -236,9 +236,10 @@ declare class AuthClient {
|
|
|
236
236
|
/**
|
|
237
237
|
* Set (or clear) the current session. Use this to restore a persisted
|
|
238
238
|
* session on app launch (e.g., from AsyncStorage / SecureStore).
|
|
239
|
-
* Emits INITIAL_SESSION to onAuthStateChange listeners.
|
|
239
|
+
* Emits INITIAL_SESSION to onAuthStateChange listeners when called externally.
|
|
240
|
+
* Internal callers (signIn, signUp, etc.) pass _internal=true to skip the emit.
|
|
240
241
|
*/
|
|
241
|
-
setSession(session: AuthSession | null): void;
|
|
242
|
+
setSession(session: AuthSession | null, _internal?: boolean): void;
|
|
242
243
|
signUp(params: {
|
|
243
244
|
email: string;
|
|
244
245
|
password: string;
|
package/dist/index.js
CHANGED
|
@@ -159,7 +159,12 @@ var DatabaseClient = class {
|
|
|
159
159
|
order(column, options) {
|
|
160
160
|
const dir = options?.ascending === false ? "desc" : "asc";
|
|
161
161
|
const nulls = options?.nullsFirst === true ? ".nullsfirst" : options?.nullsFirst === false ? ".nullslast" : "";
|
|
162
|
-
this.params.
|
|
162
|
+
const existing = this.params.get("order");
|
|
163
|
+
if (existing) {
|
|
164
|
+
this.params.set("order", `${existing},${column}.${dir}${nulls}`);
|
|
165
|
+
} else {
|
|
166
|
+
this.params.set("order", `${column}.${dir}${nulls}`);
|
|
167
|
+
}
|
|
163
168
|
return this;
|
|
164
169
|
}
|
|
165
170
|
limit(count) {
|
|
@@ -594,12 +599,13 @@ var AuthClient = class {
|
|
|
594
599
|
/**
|
|
595
600
|
* Set (or clear) the current session. Use this to restore a persisted
|
|
596
601
|
* session on app launch (e.g., from AsyncStorage / SecureStore).
|
|
597
|
-
* Emits INITIAL_SESSION to onAuthStateChange listeners.
|
|
602
|
+
* Emits INITIAL_SESSION to onAuthStateChange listeners when called externally.
|
|
603
|
+
* Internal callers (signIn, signUp, etc.) pass _internal=true to skip the emit.
|
|
598
604
|
*/
|
|
599
|
-
setSession(session) {
|
|
605
|
+
setSession(session, _internal) {
|
|
600
606
|
this.currentSession = session;
|
|
601
607
|
if (this.onSessionChange) this.onSessionChange(session);
|
|
602
|
-
this.emit("INITIAL_SESSION", session);
|
|
608
|
+
if (!_internal) this.emit("INITIAL_SESSION", session);
|
|
603
609
|
}
|
|
604
610
|
// ─── Email/Password ────────────────────────────────────────
|
|
605
611
|
async signUp(params) {
|
|
@@ -611,7 +617,7 @@ var AuthClient = class {
|
|
|
611
617
|
const data = await res.json();
|
|
612
618
|
if (!res.ok) return { data: null, error: data };
|
|
613
619
|
const session = this.parseAuthResponse(data);
|
|
614
|
-
this.setSession(session);
|
|
620
|
+
this.setSession(session, true);
|
|
615
621
|
this.emit("SIGNED_IN", session);
|
|
616
622
|
return { data: session, error: null };
|
|
617
623
|
} catch (err) {
|
|
@@ -627,7 +633,7 @@ var AuthClient = class {
|
|
|
627
633
|
const data = await res.json();
|
|
628
634
|
if (!res.ok) return { data: null, error: data };
|
|
629
635
|
const session = this.parseAuthResponse(data);
|
|
630
|
-
this.setSession(session);
|
|
636
|
+
this.setSession(session, true);
|
|
631
637
|
this.emit("SIGNED_IN", session);
|
|
632
638
|
return { data: session, error: null };
|
|
633
639
|
} catch (err) {
|
|
@@ -652,7 +658,7 @@ var AuthClient = class {
|
|
|
652
658
|
const data = await res.json();
|
|
653
659
|
if (!res.ok) return { data: null, error: data };
|
|
654
660
|
const session = this.parseAuthResponse(data);
|
|
655
|
-
this.setSession(session);
|
|
661
|
+
this.setSession(session, true);
|
|
656
662
|
this.emit("SIGNED_IN", session);
|
|
657
663
|
return { data: session, error: null };
|
|
658
664
|
} catch (err) {
|
|
@@ -673,7 +679,7 @@ var AuthClient = class {
|
|
|
673
679
|
async signOut() {
|
|
674
680
|
try {
|
|
675
681
|
await this.request("/auth/v1/logout", { method: "POST" });
|
|
676
|
-
this.setSession(null);
|
|
682
|
+
this.setSession(null, true);
|
|
677
683
|
this.emit("SIGNED_OUT", null);
|
|
678
684
|
return { error: null };
|
|
679
685
|
} catch (err) {
|
|
@@ -713,12 +719,12 @@ var AuthClient = class {
|
|
|
713
719
|
});
|
|
714
720
|
const data = await res.json();
|
|
715
721
|
if (!res.ok) {
|
|
716
|
-
this.setSession(null);
|
|
722
|
+
this.setSession(null, true);
|
|
717
723
|
this.emit("SIGNED_OUT", null);
|
|
718
724
|
return { data: null, error: data };
|
|
719
725
|
}
|
|
720
726
|
const session = this.parseAuthResponse(data);
|
|
721
|
-
this.setSession(session);
|
|
727
|
+
this.setSession(session, true);
|
|
722
728
|
this.emit("TOKEN_REFRESHED", session);
|
|
723
729
|
return { data: session, error: null };
|
|
724
730
|
} catch (err) {
|