@legendapp/state 3.0.0-beta.14 → 3.0.0-beta.15
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/package.json
CHANGED
package/sync-plugins/keel.d.mts
CHANGED
package/sync-plugins/keel.d.ts
CHANGED
package/sync-plugins/keel.js
CHANGED
|
@@ -54,11 +54,14 @@ async function ensureAuthToken(props, force) {
|
|
|
54
54
|
return isAuthed;
|
|
55
55
|
}
|
|
56
56
|
async function handleApiError(props, error) {
|
|
57
|
+
var _a;
|
|
57
58
|
if (error.type === "unauthorized" || error.type === "forbidden") {
|
|
58
59
|
console.warn("Keel token expired, refreshing...");
|
|
59
60
|
isAuthed$.set(false);
|
|
60
61
|
await ensureAuthToken(props);
|
|
61
62
|
return true;
|
|
63
|
+
} else if (((_a = error.error) == null ? void 0 : _a.message) === "Failed to fetch") {
|
|
64
|
+
throw error.error;
|
|
62
65
|
}
|
|
63
66
|
return false;
|
|
64
67
|
}
|
package/sync-plugins/keel.mjs
CHANGED
|
@@ -48,11 +48,14 @@ async function ensureAuthToken(props, force) {
|
|
|
48
48
|
return isAuthed;
|
|
49
49
|
}
|
|
50
50
|
async function handleApiError(props, error) {
|
|
51
|
+
var _a;
|
|
51
52
|
if (error.type === "unauthorized" || error.type === "forbidden") {
|
|
52
53
|
console.warn("Keel token expired, refreshing...");
|
|
53
54
|
isAuthed$.set(false);
|
|
54
55
|
await ensureAuthToken(props);
|
|
55
56
|
return true;
|
|
57
|
+
} else if (((_a = error.error) == null ? void 0 : _a.message) === "Failed to fetch") {
|
|
58
|
+
throw error.error;
|
|
56
59
|
}
|
|
57
60
|
return false;
|
|
58
61
|
}
|
package/sync-plugins/supabase.js
CHANGED
|
@@ -33,6 +33,14 @@ function wrapSupabaseFn(fn, source) {
|
|
|
33
33
|
return data;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
function handleSupabaseError(error, onError, params) {
|
|
37
|
+
var _a;
|
|
38
|
+
if ((_a = error.message) == null ? void 0 : _a.includes("Failed to fetch")) {
|
|
39
|
+
throw error;
|
|
40
|
+
} else {
|
|
41
|
+
onError(new Error(error.message), params);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
36
44
|
function syncedSupabase(props) {
|
|
37
45
|
props = { ...supabaseConfig, ...props };
|
|
38
46
|
const {
|
|
@@ -87,7 +95,7 @@ function syncedSupabase(props) {
|
|
|
87
95
|
if (data) {
|
|
88
96
|
return data || [];
|
|
89
97
|
} else if (error) {
|
|
90
|
-
|
|
98
|
+
handleSupabaseError(error, onError, {
|
|
91
99
|
getParams: params,
|
|
92
100
|
source: "list",
|
|
93
101
|
type: "get",
|
|
@@ -104,7 +112,7 @@ function syncedSupabase(props) {
|
|
|
104
112
|
const created = data[0];
|
|
105
113
|
return created;
|
|
106
114
|
} else if (error) {
|
|
107
|
-
|
|
115
|
+
handleSupabaseError(error, onError, {
|
|
108
116
|
setParams: params,
|
|
109
117
|
source: "create",
|
|
110
118
|
type: "set",
|
|
@@ -122,7 +130,7 @@ function syncedSupabase(props) {
|
|
|
122
130
|
const created = data[0];
|
|
123
131
|
return created;
|
|
124
132
|
} else if (error) {
|
|
125
|
-
|
|
133
|
+
handleSupabaseError(error, onError, {
|
|
126
134
|
setParams: params,
|
|
127
135
|
source: "update",
|
|
128
136
|
type: "set",
|
|
@@ -141,7 +149,7 @@ function syncedSupabase(props) {
|
|
|
141
149
|
const created = data[0];
|
|
142
150
|
return created;
|
|
143
151
|
} else if (error) {
|
|
144
|
-
|
|
152
|
+
handleSupabaseError(error, onError, {
|
|
145
153
|
setParams: params,
|
|
146
154
|
source: "delete",
|
|
147
155
|
type: "set",
|
|
@@ -31,6 +31,14 @@ function wrapSupabaseFn(fn, source) {
|
|
|
31
31
|
return data;
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
+
function handleSupabaseError(error, onError, params) {
|
|
35
|
+
var _a;
|
|
36
|
+
if ((_a = error.message) == null ? void 0 : _a.includes("Failed to fetch")) {
|
|
37
|
+
throw error;
|
|
38
|
+
} else {
|
|
39
|
+
onError(new Error(error.message), params);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
34
42
|
function syncedSupabase(props) {
|
|
35
43
|
props = { ...supabaseConfig, ...props };
|
|
36
44
|
const {
|
|
@@ -85,7 +93,7 @@ function syncedSupabase(props) {
|
|
|
85
93
|
if (data) {
|
|
86
94
|
return data || [];
|
|
87
95
|
} else if (error) {
|
|
88
|
-
|
|
96
|
+
handleSupabaseError(error, onError, {
|
|
89
97
|
getParams: params,
|
|
90
98
|
source: "list",
|
|
91
99
|
type: "get",
|
|
@@ -102,7 +110,7 @@ function syncedSupabase(props) {
|
|
|
102
110
|
const created = data[0];
|
|
103
111
|
return created;
|
|
104
112
|
} else if (error) {
|
|
105
|
-
|
|
113
|
+
handleSupabaseError(error, onError, {
|
|
106
114
|
setParams: params,
|
|
107
115
|
source: "create",
|
|
108
116
|
type: "set",
|
|
@@ -120,7 +128,7 @@ function syncedSupabase(props) {
|
|
|
120
128
|
const created = data[0];
|
|
121
129
|
return created;
|
|
122
130
|
} else if (error) {
|
|
123
|
-
|
|
131
|
+
handleSupabaseError(error, onError, {
|
|
124
132
|
setParams: params,
|
|
125
133
|
source: "update",
|
|
126
134
|
type: "set",
|
|
@@ -139,7 +147,7 @@ function syncedSupabase(props) {
|
|
|
139
147
|
const created = data[0];
|
|
140
148
|
return created;
|
|
141
149
|
} else if (error) {
|
|
142
|
-
|
|
150
|
+
handleSupabaseError(error, onError, {
|
|
143
151
|
setParams: params,
|
|
144
152
|
source: "delete",
|
|
145
153
|
type: "set",
|