@refinedev/core 4.46.0 → 4.46.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/CHANGELOG.md +109 -0
- package/dist/definitions/helpers/flatten-object-keys/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/accessControl/useCan/index.d.ts.map +1 -1
- package/dist/hooks/auditLog/useLogList/index.d.ts.map +1 -1
- package/dist/hooks/auth/useOnError/index.d.ts.map +1 -1
- package/dist/hooks/data/useCreate.d.ts.map +1 -1
- package/dist/hooks/data/useCreateMany.d.ts.map +1 -1
- package/dist/hooks/data/useDelete.d.ts.map +1 -1
- package/dist/hooks/data/useDeleteMany.d.ts.map +1 -1
- package/dist/hooks/data/useInfiniteList.d.ts.map +1 -1
- package/dist/hooks/data/useList.d.ts.map +1 -1
- package/dist/hooks/data/useMany.d.ts.map +1 -1
- package/dist/hooks/data/useOne.d.ts.map +1 -1
- package/dist/hooks/data/useUpdate.d.ts.map +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
- package/dist/hooks/router/use-go/index.d.ts +2 -0
- package/dist/hooks/router/use-go/index.d.ts.map +1 -1
- package/dist/hooks/useMeta/index.d.ts +2 -0
- package/dist/hooks/useMeta/index.d.ts.map +1 -1
- package/dist/iife/index.js +6 -6
- package/dist/iife/index.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/auth.d.ts +6 -6
- package/dist/interfaces/auth.d.ts.map +1 -1
- package/dist/interfaces/metaData/graphqlQueryOptions.d.ts +6 -0
- package/dist/interfaces/metaData/graphqlQueryOptions.d.ts.map +1 -0
- package/dist/interfaces/metaData/metaQuery.d.ts +2 -1
- package/dist/interfaces/metaData/metaQuery.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/definitions/helpers/flatten-object-keys/index.ts +2 -0
- package/src/hooks/accessControl/useCan/index.ts +10 -12
- package/src/hooks/auditLog/useLogList/index.ts +10 -12
- package/src/hooks/auth/useForgotPassword/index.ts +51 -54
- package/src/hooks/auth/useGetIdentity/index.ts +23 -26
- package/src/hooks/auth/useIsAuthenticated/index.ts +20 -20
- package/src/hooks/auth/useLogin/index.ts +33 -35
- package/src/hooks/auth/useLogout/index.ts +32 -34
- package/src/hooks/auth/useOnError/index.ts +29 -33
- package/src/hooks/auth/usePermissions/index.ts +19 -22
- package/src/hooks/auth/useRegister/index.ts +60 -66
- package/src/hooks/auth/useUpdatePassword/index.ts +51 -54
- package/src/hooks/data/useCreate.ts +115 -117
- package/src/hooks/data/useCreateMany.ts +113 -118
- package/src/hooks/data/useDelete.ts +212 -223
- package/src/hooks/data/useDeleteMany.ts +230 -244
- package/src/hooks/data/useInfiniteList.ts +36 -42
- package/src/hooks/data/useList.ts +56 -62
- package/src/hooks/data/useMany.ts +36 -37
- package/src/hooks/data/useOne.ts +54 -55
- package/src/hooks/data/useUpdate.ts +288 -311
- package/src/hooks/data/useUpdateMany.ts +294 -320
- package/src/hooks/menu/useMenu.tsx +1 -1
- package/src/hooks/router/use-go/index.tsx +3 -0
- package/src/interfaces/auth.tsx +6 -6
- package/src/interfaces/metaData/graphqlQueryOptions.ts +6 -0
- package/src/interfaces/metaData/metaQuery.ts +3 -1
|
@@ -140,8 +140,8 @@ export const useCreate = <
|
|
|
140
140
|
TError,
|
|
141
141
|
useCreateParams<TData, TError, TVariables>,
|
|
142
142
|
unknown
|
|
143
|
-
>(
|
|
144
|
-
({
|
|
143
|
+
>({
|
|
144
|
+
mutationFn: ({
|
|
145
145
|
resource: resourceName,
|
|
146
146
|
values,
|
|
147
147
|
meta,
|
|
@@ -164,134 +164,132 @@ export const useCreate = <
|
|
|
164
164
|
metaData: combinedMeta,
|
|
165
165
|
});
|
|
166
166
|
},
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const resourceSingular = textTransformers.singular(identifier);
|
|
167
|
+
onSuccess: (
|
|
168
|
+
data,
|
|
169
|
+
{
|
|
170
|
+
resource: resourceName,
|
|
171
|
+
successNotification: successNotificationFromProp,
|
|
172
|
+
dataProviderName: dataProviderNameFromProp,
|
|
173
|
+
invalidates = ["list", "many"],
|
|
174
|
+
values,
|
|
175
|
+
meta,
|
|
176
|
+
metaData,
|
|
177
|
+
},
|
|
178
|
+
) => {
|
|
179
|
+
const { resource, identifier } = select(resourceName);
|
|
180
|
+
const resourceSingular = textTransformers.singular(identifier);
|
|
182
181
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
const dataProviderName = pickDataProvider(
|
|
183
|
+
identifier,
|
|
184
|
+
dataProviderNameFromProp,
|
|
185
|
+
resources,
|
|
186
|
+
);
|
|
188
187
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
const combinedMeta = getMeta({
|
|
189
|
+
resource,
|
|
190
|
+
meta: pickNotDeprecated(meta, metaData),
|
|
191
|
+
});
|
|
193
192
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
const notificationConfig =
|
|
194
|
+
typeof successNotificationFromProp === "function"
|
|
195
|
+
? successNotificationFromProp(data, values, identifier)
|
|
196
|
+
: successNotificationFromProp;
|
|
198
197
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
198
|
+
handleNotification(notificationConfig, {
|
|
199
|
+
key: `create-${identifier}-notification`,
|
|
200
|
+
message: translate(
|
|
201
|
+
"notifications.createSuccess",
|
|
202
|
+
{
|
|
203
|
+
resource: translate(
|
|
204
|
+
`${identifier}.${identifier}`,
|
|
205
|
+
resourceSingular,
|
|
206
|
+
),
|
|
207
|
+
},
|
|
208
|
+
`Successfully created ${resourceSingular}`,
|
|
209
|
+
),
|
|
210
|
+
description: translate("notifications.success", "Success"),
|
|
211
|
+
type: "success",
|
|
212
|
+
});
|
|
214
213
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
214
|
+
invalidateStore({
|
|
215
|
+
resource: identifier,
|
|
216
|
+
dataProviderName,
|
|
217
|
+
invalidates,
|
|
218
|
+
});
|
|
220
219
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
220
|
+
publish?.({
|
|
221
|
+
channel: `resources/${resource.name}`,
|
|
222
|
+
type: "created",
|
|
223
|
+
payload: {
|
|
224
|
+
ids: data?.data?.id ? [data.data.id] : undefined,
|
|
225
|
+
},
|
|
226
|
+
date: new Date(),
|
|
227
|
+
meta: {
|
|
228
|
+
...combinedMeta,
|
|
229
|
+
dataProviderName,
|
|
230
|
+
},
|
|
231
|
+
});
|
|
233
232
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
},
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
onError: (
|
|
252
|
-
err: TError,
|
|
253
|
-
{
|
|
254
|
-
resource: resourceName,
|
|
255
|
-
errorNotification: errorNotificationFromProp,
|
|
256
|
-
values,
|
|
233
|
+
const {
|
|
234
|
+
fields: _fields,
|
|
235
|
+
operation: _operation,
|
|
236
|
+
variables: _variables,
|
|
237
|
+
...rest
|
|
238
|
+
} = combinedMeta || {};
|
|
239
|
+
log?.mutate({
|
|
240
|
+
action: "create",
|
|
241
|
+
resource: resource.name,
|
|
242
|
+
data: values,
|
|
243
|
+
meta: {
|
|
244
|
+
dataProviderName,
|
|
245
|
+
id: data?.data?.id ?? undefined,
|
|
246
|
+
...rest,
|
|
257
247
|
},
|
|
258
|
-
)
|
|
259
|
-
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
onError: (
|
|
251
|
+
err: TError,
|
|
252
|
+
{
|
|
253
|
+
resource: resourceName,
|
|
254
|
+
errorNotification: errorNotificationFromProp,
|
|
255
|
+
values,
|
|
256
|
+
},
|
|
257
|
+
) => {
|
|
258
|
+
checkError(err);
|
|
260
259
|
|
|
261
|
-
|
|
260
|
+
const { identifier } = select(resourceName);
|
|
262
261
|
|
|
263
|
-
|
|
262
|
+
const resourceSingular = textTransformers.singular(identifier);
|
|
264
263
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
264
|
+
const notificationConfig =
|
|
265
|
+
typeof errorNotificationFromProp === "function"
|
|
266
|
+
? errorNotificationFromProp(err, values, identifier)
|
|
267
|
+
: errorNotificationFromProp;
|
|
269
268
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
},
|
|
269
|
+
handleNotification(notificationConfig, {
|
|
270
|
+
key: `create-${identifier}-notification`,
|
|
271
|
+
description: err.message,
|
|
272
|
+
message: translate(
|
|
273
|
+
"notifications.createError",
|
|
274
|
+
{
|
|
275
|
+
resource: translate(
|
|
276
|
+
`${identifier}.${identifier}`,
|
|
277
|
+
resourceSingular,
|
|
278
|
+
),
|
|
279
|
+
statusCode: err.statusCode,
|
|
280
|
+
},
|
|
281
|
+
`There was an error creating ${resourceSingular} (status code: ${err.statusCode})`,
|
|
282
|
+
),
|
|
283
|
+
type: "error",
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
mutationKey: keys().data().mutation("create").get(preferLegacyKeys),
|
|
287
|
+
...mutationOptions,
|
|
288
|
+
meta: {
|
|
289
|
+
...mutationOptions?.meta,
|
|
290
|
+
...getXRay("useCreate", preferLegacyKeys),
|
|
293
291
|
},
|
|
294
|
-
);
|
|
292
|
+
});
|
|
295
293
|
|
|
296
294
|
const { elapsedTime } = useLoadingOvertime({
|
|
297
295
|
isLoading: mutation.isLoading,
|
|
@@ -113,8 +113,8 @@ export const useCreateMany = <
|
|
|
113
113
|
CreateManyResponse<TData>,
|
|
114
114
|
TError,
|
|
115
115
|
useCreateManyParams<TData, TError, TVariables>
|
|
116
|
-
>(
|
|
117
|
-
({
|
|
116
|
+
>({
|
|
117
|
+
mutationFn: ({
|
|
118
118
|
resource: resourceName,
|
|
119
119
|
values,
|
|
120
120
|
meta,
|
|
@@ -152,132 +152,127 @@ export const useCreateMany = <
|
|
|
152
152
|
);
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const resourcePlural = textTransformers.plural(identifier);
|
|
155
|
+
onSuccess: (
|
|
156
|
+
response,
|
|
157
|
+
{
|
|
158
|
+
resource: resourceName,
|
|
159
|
+
successNotification,
|
|
160
|
+
dataProviderName: dataProviderNameFromProp,
|
|
161
|
+
invalidates = ["list", "many"],
|
|
162
|
+
values,
|
|
163
|
+
meta,
|
|
164
|
+
metaData,
|
|
165
|
+
},
|
|
166
|
+
) => {
|
|
167
|
+
const { resource, identifier } = select(resourceName);
|
|
168
|
+
const resourcePlural = textTransformers.plural(identifier);
|
|
170
169
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
const dataProviderName = pickDataProvider(
|
|
171
|
+
identifier,
|
|
172
|
+
dataProviderNameFromProp,
|
|
173
|
+
resources,
|
|
174
|
+
);
|
|
176
175
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
const combinedMeta = getMeta({
|
|
177
|
+
resource,
|
|
178
|
+
meta: pickNotDeprecated(meta, metaData),
|
|
179
|
+
});
|
|
181
180
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
const notificationConfig =
|
|
182
|
+
typeof successNotification === "function"
|
|
183
|
+
? successNotification(response, values, identifier)
|
|
184
|
+
: successNotification;
|
|
186
185
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
186
|
+
handleNotification(notificationConfig, {
|
|
187
|
+
key: `createMany-${identifier}-notification`,
|
|
188
|
+
message: translate(
|
|
189
|
+
"notifications.createSuccess",
|
|
190
|
+
{
|
|
191
|
+
resource: translate(
|
|
192
|
+
`${identifier}.${identifier}`,
|
|
193
|
+
identifier,
|
|
194
|
+
),
|
|
195
|
+
},
|
|
196
|
+
`Successfully created ${resourcePlural}`,
|
|
197
|
+
),
|
|
198
|
+
description: translate("notifications.success", "Success"),
|
|
199
|
+
type: "success",
|
|
200
|
+
});
|
|
202
201
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
invalidateStore({
|
|
203
|
+
resource: identifier,
|
|
204
|
+
dataProviderName,
|
|
205
|
+
invalidates,
|
|
206
|
+
});
|
|
208
207
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
208
|
+
const ids = response?.data
|
|
209
|
+
.filter((item) => item?.id !== undefined)
|
|
210
|
+
.map((item) => item.id!);
|
|
211
|
+
publish?.({
|
|
212
|
+
channel: `resources/${resource.name}`,
|
|
213
|
+
type: "created",
|
|
214
|
+
payload: {
|
|
215
|
+
ids,
|
|
216
|
+
},
|
|
217
|
+
date: new Date(),
|
|
218
|
+
meta: {
|
|
219
|
+
...combinedMeta,
|
|
220
|
+
dataProviderName,
|
|
221
|
+
},
|
|
222
|
+
});
|
|
224
223
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
224
|
+
const {
|
|
225
|
+
fields: _fields,
|
|
226
|
+
operation: _operation,
|
|
227
|
+
variables: _variables,
|
|
228
|
+
...rest
|
|
229
|
+
} = combinedMeta || {};
|
|
230
|
+
log?.mutate({
|
|
231
|
+
action: "createMany",
|
|
232
|
+
resource: resource.name,
|
|
233
|
+
data: values,
|
|
234
|
+
meta: {
|
|
235
|
+
dataProviderName,
|
|
236
|
+
ids,
|
|
237
|
+
...rest,
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
},
|
|
241
|
+
onError: (
|
|
242
|
+
err: TError,
|
|
243
|
+
{ resource: resourceName, errorNotification, values },
|
|
244
|
+
) => {
|
|
245
|
+
const { identifier } = select(resourceName);
|
|
247
246
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
const notificationConfig =
|
|
248
|
+
typeof errorNotification === "function"
|
|
249
|
+
? errorNotification(err, values, identifier)
|
|
250
|
+
: errorNotification;
|
|
252
251
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
},
|
|
270
|
-
mutationKey: keys()
|
|
271
|
-
.data()
|
|
272
|
-
.mutation("createMany")
|
|
273
|
-
.get(preferLegacyKeys),
|
|
274
|
-
...mutationOptions,
|
|
275
|
-
meta: {
|
|
276
|
-
...mutationOptions?.meta,
|
|
277
|
-
...getXRay("useCreateMany", preferLegacyKeys),
|
|
278
|
-
},
|
|
252
|
+
handleNotification(notificationConfig, {
|
|
253
|
+
key: `createMany-${identifier}-notification`,
|
|
254
|
+
description: err.message,
|
|
255
|
+
message: translate(
|
|
256
|
+
"notifications.createError",
|
|
257
|
+
{
|
|
258
|
+
resource: translate(
|
|
259
|
+
`${identifier}.${identifier}`,
|
|
260
|
+
identifier,
|
|
261
|
+
),
|
|
262
|
+
statusCode: err.statusCode,
|
|
263
|
+
},
|
|
264
|
+
`There was an error creating ${identifier} (status code: ${err.statusCode}`,
|
|
265
|
+
),
|
|
266
|
+
type: "error",
|
|
267
|
+
});
|
|
279
268
|
},
|
|
280
|
-
|
|
269
|
+
mutationKey: keys().data().mutation("createMany").get(preferLegacyKeys),
|
|
270
|
+
...mutationOptions,
|
|
271
|
+
meta: {
|
|
272
|
+
...mutationOptions?.meta,
|
|
273
|
+
...getXRay("useCreateMany", preferLegacyKeys),
|
|
274
|
+
},
|
|
275
|
+
});
|
|
281
276
|
|
|
282
277
|
const { elapsedTime } = useLoadingOvertime({
|
|
283
278
|
isLoading: mutation.isLoading,
|