@legendapp/state 3.0.0-beta.26 → 3.0.0-beta.27
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/crud.js
CHANGED
|
@@ -54,6 +54,7 @@ function retrySet(params, retry, action, itemKey, itemValue, change, queuedRetri
|
|
|
54
54
|
itemValue = Object.assign(queuedRetry, itemValue);
|
|
55
55
|
}
|
|
56
56
|
queuedRetries[action].set(itemKey, itemValue);
|
|
57
|
+
const clonedValue = clone(itemValue);
|
|
57
58
|
const paramsWithChanges = { ...params, changes: [change] };
|
|
58
59
|
return runWithRetry(
|
|
59
60
|
paramsWithChanges,
|
|
@@ -61,7 +62,7 @@ function retrySet(params, retry, action, itemKey, itemValue, change, queuedRetri
|
|
|
61
62
|
"create_" + itemKey,
|
|
62
63
|
() => actionFn(itemValue, paramsWithChanges).then((result) => {
|
|
63
64
|
queuedRetries[action].delete(itemKey);
|
|
64
|
-
return saveResult(itemKey,
|
|
65
|
+
return saveResult(itemKey, clonedValue, result, true, change);
|
|
65
66
|
})
|
|
66
67
|
);
|
|
67
68
|
}
|
package/sync-plugins/crud.mjs
CHANGED
|
@@ -52,6 +52,7 @@ function retrySet(params, retry, action, itemKey, itemValue, change, queuedRetri
|
|
|
52
52
|
itemValue = Object.assign(queuedRetry, itemValue);
|
|
53
53
|
}
|
|
54
54
|
queuedRetries[action].set(itemKey, itemValue);
|
|
55
|
+
const clonedValue = clone(itemValue);
|
|
55
56
|
const paramsWithChanges = { ...params, changes: [change] };
|
|
56
57
|
return runWithRetry(
|
|
57
58
|
paramsWithChanges,
|
|
@@ -59,7 +60,7 @@ function retrySet(params, retry, action, itemKey, itemValue, change, queuedRetri
|
|
|
59
60
|
"create_" + itemKey,
|
|
60
61
|
() => actionFn(itemValue, paramsWithChanges).then((result) => {
|
|
61
62
|
queuedRetries[action].delete(itemKey);
|
|
62
|
-
return saveResult(itemKey,
|
|
63
|
+
return saveResult(itemKey, clonedValue, result, true, change);
|
|
63
64
|
})
|
|
64
65
|
);
|
|
65
66
|
}
|
package/sync-plugins/supabase.js
CHANGED
|
@@ -54,6 +54,7 @@ function syncedSupabase(props) {
|
|
|
54
54
|
fieldUpdatedAt,
|
|
55
55
|
fieldDeleted,
|
|
56
56
|
realtime,
|
|
57
|
+
fieldId = "id",
|
|
57
58
|
changesSince,
|
|
58
59
|
transform: transformParam,
|
|
59
60
|
stringifyDates,
|
|
@@ -124,7 +125,7 @@ function syncedSupabase(props) {
|
|
|
124
125
|
} : void 0;
|
|
125
126
|
const update = !actions || actions.includes("update") ? updateParam ? wrapSupabaseFn(updateParam, "update") : async (input, params) => {
|
|
126
127
|
const { onError } = params;
|
|
127
|
-
const res = await client.from(collection).update(input).eq(
|
|
128
|
+
const res = await client.from(collection).update(input).eq(fieldId, input[fieldId]).select();
|
|
128
129
|
const { data, error } = res;
|
|
129
130
|
if (data) {
|
|
130
131
|
const created = data[0];
|
|
@@ -144,8 +145,7 @@ function syncedSupabase(props) {
|
|
|
144
145
|
// prettier-ignore
|
|
145
146
|
deleteParam ? wrapSupabaseFn(deleteParam, "delete") : async (input, params) => {
|
|
146
147
|
const { onError } = params;
|
|
147
|
-
const
|
|
148
|
-
const res = await client.from(collection).delete().eq("id", id).select();
|
|
148
|
+
const res = await client.from(collection).delete().eq(fieldId, input[fieldId]).select();
|
|
149
149
|
const { data, error } = res;
|
|
150
150
|
if (data) {
|
|
151
151
|
const created = data[0];
|
|
@@ -176,7 +176,7 @@ function syncedSupabase(props) {
|
|
|
176
176
|
var _a;
|
|
177
177
|
const { eventType, new: value, old } = payload;
|
|
178
178
|
if (eventType === "INSERT" || eventType === "UPDATE") {
|
|
179
|
-
const cur = (_a = value$.peek()) == null ? void 0 : _a[value
|
|
179
|
+
const cur = (_a = value$.peek()) == null ? void 0 : _a[value[fieldId]];
|
|
180
180
|
let isOk = !fieldUpdatedAt;
|
|
181
181
|
let lastSync = void 0;
|
|
182
182
|
if (!isOk) {
|
|
@@ -219,6 +219,7 @@ function syncedSupabase(props) {
|
|
|
219
219
|
fieldUpdatedAt,
|
|
220
220
|
fieldDeleted,
|
|
221
221
|
updatePartial: false,
|
|
222
|
+
fieldId,
|
|
222
223
|
transform,
|
|
223
224
|
generateId,
|
|
224
225
|
waitFor: () => isEnabled$.get() && (waitFor ? state.computeSelector(waitFor) : true),
|
|
@@ -52,6 +52,7 @@ function syncedSupabase(props) {
|
|
|
52
52
|
fieldUpdatedAt,
|
|
53
53
|
fieldDeleted,
|
|
54
54
|
realtime,
|
|
55
|
+
fieldId = "id",
|
|
55
56
|
changesSince,
|
|
56
57
|
transform: transformParam,
|
|
57
58
|
stringifyDates,
|
|
@@ -122,7 +123,7 @@ function syncedSupabase(props) {
|
|
|
122
123
|
} : void 0;
|
|
123
124
|
const update = !actions || actions.includes("update") ? updateParam ? wrapSupabaseFn(updateParam, "update") : async (input, params) => {
|
|
124
125
|
const { onError } = params;
|
|
125
|
-
const res = await client.from(collection).update(input).eq(
|
|
126
|
+
const res = await client.from(collection).update(input).eq(fieldId, input[fieldId]).select();
|
|
126
127
|
const { data, error } = res;
|
|
127
128
|
if (data) {
|
|
128
129
|
const created = data[0];
|
|
@@ -142,8 +143,7 @@ function syncedSupabase(props) {
|
|
|
142
143
|
// prettier-ignore
|
|
143
144
|
deleteParam ? wrapSupabaseFn(deleteParam, "delete") : async (input, params) => {
|
|
144
145
|
const { onError } = params;
|
|
145
|
-
const
|
|
146
|
-
const res = await client.from(collection).delete().eq("id", id).select();
|
|
146
|
+
const res = await client.from(collection).delete().eq(fieldId, input[fieldId]).select();
|
|
147
147
|
const { data, error } = res;
|
|
148
148
|
if (data) {
|
|
149
149
|
const created = data[0];
|
|
@@ -174,7 +174,7 @@ function syncedSupabase(props) {
|
|
|
174
174
|
var _a;
|
|
175
175
|
const { eventType, new: value, old } = payload;
|
|
176
176
|
if (eventType === "INSERT" || eventType === "UPDATE") {
|
|
177
|
-
const cur = (_a = value$.peek()) == null ? void 0 : _a[value
|
|
177
|
+
const cur = (_a = value$.peek()) == null ? void 0 : _a[value[fieldId]];
|
|
178
178
|
let isOk = !fieldUpdatedAt;
|
|
179
179
|
let lastSync = void 0;
|
|
180
180
|
if (!isOk) {
|
|
@@ -217,6 +217,7 @@ function syncedSupabase(props) {
|
|
|
217
217
|
fieldUpdatedAt,
|
|
218
218
|
fieldDeleted,
|
|
219
219
|
updatePartial: false,
|
|
220
|
+
fieldId,
|
|
220
221
|
transform,
|
|
221
222
|
generateId,
|
|
222
223
|
waitFor: () => isEnabled$.get() && (waitFor ? computeSelector(waitFor) : true),
|