@panneau/data 4.0.82 → 4.0.84
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.js +104 -40
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { getJSON, getCSRFHeaders, postJSON } from '@folklore/fetch';
|
|
|
5
5
|
import { generatePath } from '@folklore/routes';
|
|
6
6
|
import queryString from 'query-string';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
8
|
-
import { useQuery, keepPreviousData, hashKey, useMutation, QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
8
|
+
import { useQuery, keepPreviousData, hashKey, useMutation, useQueryClient, QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
9
9
|
import isArray from 'lodash-es/isArray';
|
|
10
10
|
import isObject from 'lodash-es/isObject';
|
|
11
11
|
import isString from 'lodash-es/isString';
|
|
@@ -1057,7 +1057,7 @@ function useResourceStore(resource, t0) {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
|
|
1059
1059
|
function useResourceUpdate(resource, t0, t1) {
|
|
1060
|
-
const $ = c(
|
|
1060
|
+
const $ = c(35);
|
|
1061
1061
|
const id = t0 === undefined ? null : t0;
|
|
1062
1062
|
let t2;
|
|
1063
1063
|
if ($[0] !== t1) {
|
|
@@ -1082,55 +1082,119 @@ function useResourceUpdate(resource, t0, t1) {
|
|
|
1082
1082
|
t3 = $[4];
|
|
1083
1083
|
}
|
|
1084
1084
|
const finalOptions = t3;
|
|
1085
|
-
const api = useApi();
|
|
1086
1085
|
let t4;
|
|
1087
|
-
if ($[5] !==
|
|
1088
|
-
t4 =
|
|
1089
|
-
$[5] =
|
|
1090
|
-
$[6] =
|
|
1091
|
-
$[7] = finalResource;
|
|
1092
|
-
$[8] = t4;
|
|
1086
|
+
if ($[5] !== finalOptions) {
|
|
1087
|
+
t4 = finalOptions || {};
|
|
1088
|
+
$[5] = finalOptions;
|
|
1089
|
+
$[6] = t4;
|
|
1093
1090
|
} else {
|
|
1094
|
-
t4 = $[
|
|
1091
|
+
t4 = $[6];
|
|
1095
1092
|
}
|
|
1093
|
+
let otherOptions;
|
|
1096
1094
|
let t5;
|
|
1097
|
-
if ($[
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
...
|
|
1095
|
+
if ($[7] !== t4) {
|
|
1096
|
+
({
|
|
1097
|
+
onSuccess: t5,
|
|
1098
|
+
...otherOptions
|
|
1099
|
+
} = t4);
|
|
1100
|
+
$[7] = t4;
|
|
1101
|
+
$[8] = otherOptions;
|
|
1102
|
+
$[9] = t5;
|
|
1103
|
+
} else {
|
|
1104
|
+
otherOptions = $[8];
|
|
1105
|
+
t5 = $[9];
|
|
1106
|
+
}
|
|
1107
|
+
const customOnSuccess = t5 === undefined ? null : t5;
|
|
1108
|
+
let t6;
|
|
1109
|
+
if ($[10] !== finalResource) {
|
|
1110
|
+
t6 = finalResource || {};
|
|
1111
|
+
$[10] = finalResource;
|
|
1112
|
+
$[11] = t6;
|
|
1113
|
+
} else {
|
|
1114
|
+
t6 = $[11];
|
|
1115
|
+
}
|
|
1116
|
+
const {
|
|
1117
|
+
id: t7
|
|
1118
|
+
} = t6;
|
|
1119
|
+
const resourceId = t7 === undefined ? null : t7;
|
|
1120
|
+
const api = useApi();
|
|
1121
|
+
const queryClient = useQueryClient();
|
|
1122
|
+
let t8;
|
|
1123
|
+
if ($[12] !== api || $[13] !== finalId || $[14] !== finalResource) {
|
|
1124
|
+
t8 = data => api.resources.update(finalResource, finalId, data);
|
|
1125
|
+
$[12] = api;
|
|
1126
|
+
$[13] = finalId;
|
|
1127
|
+
$[14] = finalResource;
|
|
1128
|
+
$[15] = t8;
|
|
1129
|
+
} else {
|
|
1130
|
+
t8 = $[15];
|
|
1131
|
+
}
|
|
1132
|
+
let t9;
|
|
1133
|
+
if ($[16] !== customOnSuccess || $[17] !== finalId || $[18] !== queryClient || $[19] !== resourceId) {
|
|
1134
|
+
t9 = (data_0, ...t10) => {
|
|
1135
|
+
const args = t10;
|
|
1136
|
+
queryClient.setQueryData([resourceId, finalId], data_0);
|
|
1137
|
+
queryClient.invalidateQueries({
|
|
1138
|
+
queryKey: [resourceId],
|
|
1139
|
+
predicate: t11 => {
|
|
1140
|
+
const {
|
|
1141
|
+
queryKey
|
|
1142
|
+
} = t11;
|
|
1143
|
+
return String(queryKey[1]) !== String(finalId);
|
|
1144
|
+
}
|
|
1145
|
+
});
|
|
1146
|
+
if (customOnSuccess !== null) {
|
|
1147
|
+
return customOnSuccess(data_0, ...args);
|
|
1148
|
+
}
|
|
1101
1149
|
};
|
|
1102
|
-
$[
|
|
1103
|
-
$[
|
|
1104
|
-
$[
|
|
1150
|
+
$[16] = customOnSuccess;
|
|
1151
|
+
$[17] = finalId;
|
|
1152
|
+
$[18] = queryClient;
|
|
1153
|
+
$[19] = resourceId;
|
|
1154
|
+
$[20] = t9;
|
|
1105
1155
|
} else {
|
|
1106
|
-
|
|
1156
|
+
t9 = $[20];
|
|
1157
|
+
}
|
|
1158
|
+
let t10;
|
|
1159
|
+
if ($[21] !== otherOptions || $[22] !== t8 || $[23] !== t9) {
|
|
1160
|
+
t10 = {
|
|
1161
|
+
mutationFn: t8,
|
|
1162
|
+
onSuccess: t9,
|
|
1163
|
+
...otherOptions
|
|
1164
|
+
};
|
|
1165
|
+
$[21] = otherOptions;
|
|
1166
|
+
$[22] = t8;
|
|
1167
|
+
$[23] = t9;
|
|
1168
|
+
$[24] = t10;
|
|
1169
|
+
} else {
|
|
1170
|
+
t10 = $[24];
|
|
1107
1171
|
}
|
|
1108
|
-
const
|
|
1172
|
+
const t11 = useMutation(t10);
|
|
1109
1173
|
let isPending;
|
|
1110
1174
|
let mutate;
|
|
1111
1175
|
let mutateAsync;
|
|
1112
1176
|
let other;
|
|
1113
|
-
if ($[
|
|
1177
|
+
if ($[25] !== t11) {
|
|
1114
1178
|
({
|
|
1115
1179
|
mutate,
|
|
1116
1180
|
mutateAsync,
|
|
1117
1181
|
isPending,
|
|
1118
1182
|
...other
|
|
1119
|
-
} =
|
|
1120
|
-
$[
|
|
1121
|
-
$[
|
|
1122
|
-
$[
|
|
1123
|
-
$[
|
|
1124
|
-
$[
|
|
1183
|
+
} = t11);
|
|
1184
|
+
$[25] = t11;
|
|
1185
|
+
$[26] = isPending;
|
|
1186
|
+
$[27] = mutate;
|
|
1187
|
+
$[28] = mutateAsync;
|
|
1188
|
+
$[29] = other;
|
|
1125
1189
|
} else {
|
|
1126
|
-
isPending = $[
|
|
1127
|
-
mutate = $[
|
|
1128
|
-
mutateAsync = $[
|
|
1129
|
-
other = $[
|
|
1190
|
+
isPending = $[26];
|
|
1191
|
+
mutate = $[27];
|
|
1192
|
+
mutateAsync = $[28];
|
|
1193
|
+
other = $[29];
|
|
1130
1194
|
}
|
|
1131
|
-
let
|
|
1132
|
-
if ($[
|
|
1133
|
-
|
|
1195
|
+
let t12;
|
|
1196
|
+
if ($[30] !== isPending || $[31] !== mutate || $[32] !== mutateAsync || $[33] !== other) {
|
|
1197
|
+
t12 = {
|
|
1134
1198
|
update: mutate,
|
|
1135
1199
|
updateAsync: mutateAsync,
|
|
1136
1200
|
loading: isPending,
|
|
@@ -1139,15 +1203,15 @@ function useResourceUpdate(resource, t0, t1) {
|
|
|
1139
1203
|
isPending,
|
|
1140
1204
|
...other
|
|
1141
1205
|
};
|
|
1142
|
-
$[
|
|
1143
|
-
$[
|
|
1144
|
-
$[
|
|
1145
|
-
$[
|
|
1146
|
-
$[
|
|
1206
|
+
$[30] = isPending;
|
|
1207
|
+
$[31] = mutate;
|
|
1208
|
+
$[32] = mutateAsync;
|
|
1209
|
+
$[33] = other;
|
|
1210
|
+
$[34] = t12;
|
|
1147
1211
|
} else {
|
|
1148
|
-
|
|
1212
|
+
t12 = $[34];
|
|
1149
1213
|
}
|
|
1150
|
-
return
|
|
1214
|
+
return t12;
|
|
1151
1215
|
}
|
|
1152
1216
|
|
|
1153
1217
|
function useResourceClone(t0, t1, t2) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/data",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.84",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "d037c178f798b04867b02e3b7c142fabee936b39"
|
|
75
75
|
}
|