@chelone/vue 0.1.0 → 0.2.0
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/admin/admin-shell.vue.js +1 -1
- package/dist/admin/admin.vue.js +3 -2
- package/dist/components/admin/auth/auth-callback.vue.js +1 -1
- package/dist/components/admin/auth/login-form.vue.js +1 -1
- package/dist/components/admin/auth/login-with-email.vue.js +1 -1
- package/dist/components/admin/buttons/delete-button.vue.js +21 -1
- package/dist/components/admin/feedback/loading-indicator.vue.js +1 -1
- package/dist/components/admin/feedback/spinner.vue.js +1 -1
- package/dist/components/admin/list/calendar-header.vue.js +2 -2
- package/dist/components/admin/list/calendar-list.vue.js +1 -2
- package/dist/components/admin/list/count-spinner.vue.js +1 -1
- package/dist/components/admin/supabase/forgot-password-form.vue.js +1 -1
- package/dist/components/admin/supabase/set-password-form.vue.js +1 -1
- package/dist/components/maps-osm/osm-feature-operator.vue.js +1 -1
- package/dist/components/ui/spinner.vue.js +29 -1
- package/dist/components/ui/spinner2.vue.js +1 -29
- package/dist/controllers/use-infinite-list-controller.js +2 -13
- package/dist/controllers/use-list-controller.js +3 -13
- package/dist/data/create-chelone-hooks.d.ts +318 -4
- package/dist/data/mutations.d.ts +324 -5
- package/dist/data/mutations.js +55 -45
- package/dist/list/use-list.js +2 -13
- package/package.json +4 -4
package/dist/data/mutations.d.ts
CHANGED
|
@@ -14,7 +14,17 @@
|
|
|
14
14
|
* vanilla `startUndoableMutation` engine + an Undo notification. The default
|
|
15
15
|
* (`"pessimistic"`) path is unchanged.
|
|
16
16
|
*/
|
|
17
|
-
import { type DeleteManyParams, type DeleteParams, type MutationModeOptions, type RecordOf, type ResourceMap, type UpdateManyParams, type UpdateParams } from "@chelone/core";
|
|
17
|
+
import { type DeleteManyParams, type DeleteParams, type Identifier, type MutationModeOptions, type RecordOf, type ResourceMap, type UndoableCallbacks, type UndoableUpdateManyCallbacks, type UpdateManyParams, type UpdateParams } from "@chelone/core";
|
|
18
|
+
/**
|
|
19
|
+
* A mutation whose `mutate` / `mutateAsync` are swapped for the undoable pair,
|
|
20
|
+
* the state refs untouched. Naming it keeps the hook's inferred type
|
|
21
|
+
* declaration-emittable: spreading vue-query's refs over a generic record type
|
|
22
|
+
* would expand to `@vue/shared` types a `.d.ts` cannot name.
|
|
23
|
+
*/
|
|
24
|
+
type Undoable<TMutation, TParams, TData> = Omit<TMutation, "mutate" | "mutateAsync"> & {
|
|
25
|
+
mutate: (params: TParams, callbacks?: UndoableCallbacks<TData, TParams>) => void;
|
|
26
|
+
mutateAsync: (params: TParams) => Promise<void>;
|
|
27
|
+
};
|
|
18
28
|
/**
|
|
19
29
|
* Create mutation for `resource` — the Vue twin of `@chelone/react`'s
|
|
20
30
|
* `useCreate(resource)`. Call `.mutateAsync({ data })` to dispatch; the
|
|
@@ -98,7 +108,77 @@ export declare function useUpdate<TResources extends ResourceMap = ResourceMap,
|
|
|
98
108
|
meta: {} | null;
|
|
99
109
|
}];
|
|
100
110
|
manySnapshot: [readonly unknown[], unknown][];
|
|
101
|
-
}>, "reset" | "mutate"
|
|
111
|
+
}>, "reset" | "mutate">> | Undoable<import("@tanstack/vue-query").UseMutationReturnType<RecordOf<TResources, TName>, unknown, UpdateParams<RecordOf<TResources, TName>>, {
|
|
112
|
+
previous?: undefined;
|
|
113
|
+
key?: undefined;
|
|
114
|
+
manySnapshot?: undefined;
|
|
115
|
+
} | {
|
|
116
|
+
previous: RecordOf<TResources, TName> | undefined;
|
|
117
|
+
key: readonly [string, "getOne", {
|
|
118
|
+
id: string;
|
|
119
|
+
meta?: undefined;
|
|
120
|
+
} | {
|
|
121
|
+
id: string;
|
|
122
|
+
meta: {} | null;
|
|
123
|
+
}];
|
|
124
|
+
manySnapshot: [readonly unknown[], unknown][];
|
|
125
|
+
}, Omit<import("@tanstack/query-core").MutationObserverIdleResult<RecordOf<TResources, TName>, unknown, UpdateParams<RecordOf<TResources, TName>>, {
|
|
126
|
+
previous?: undefined;
|
|
127
|
+
key?: undefined;
|
|
128
|
+
manySnapshot?: undefined;
|
|
129
|
+
} | {
|
|
130
|
+
previous: RecordOf<TResources, TName> | undefined;
|
|
131
|
+
key: readonly [string, "getOne", {
|
|
132
|
+
id: string;
|
|
133
|
+
meta?: undefined;
|
|
134
|
+
} | {
|
|
135
|
+
id: string;
|
|
136
|
+
meta: {} | null;
|
|
137
|
+
}];
|
|
138
|
+
manySnapshot: [readonly unknown[], unknown][];
|
|
139
|
+
}>, "reset" | "mutate"> | Omit<import("@tanstack/query-core").MutationObserverLoadingResult<RecordOf<TResources, TName>, unknown, UpdateParams<RecordOf<TResources, TName>>, {
|
|
140
|
+
previous?: undefined;
|
|
141
|
+
key?: undefined;
|
|
142
|
+
manySnapshot?: undefined;
|
|
143
|
+
} | {
|
|
144
|
+
previous: RecordOf<TResources, TName> | undefined;
|
|
145
|
+
key: readonly [string, "getOne", {
|
|
146
|
+
id: string;
|
|
147
|
+
meta?: undefined;
|
|
148
|
+
} | {
|
|
149
|
+
id: string;
|
|
150
|
+
meta: {} | null;
|
|
151
|
+
}];
|
|
152
|
+
manySnapshot: [readonly unknown[], unknown][];
|
|
153
|
+
}>, "reset" | "mutate"> | Omit<import("@tanstack/query-core").MutationObserverErrorResult<RecordOf<TResources, TName>, unknown, UpdateParams<RecordOf<TResources, TName>>, {
|
|
154
|
+
previous?: undefined;
|
|
155
|
+
key?: undefined;
|
|
156
|
+
manySnapshot?: undefined;
|
|
157
|
+
} | {
|
|
158
|
+
previous: RecordOf<TResources, TName> | undefined;
|
|
159
|
+
key: readonly [string, "getOne", {
|
|
160
|
+
id: string;
|
|
161
|
+
meta?: undefined;
|
|
162
|
+
} | {
|
|
163
|
+
id: string;
|
|
164
|
+
meta: {} | null;
|
|
165
|
+
}];
|
|
166
|
+
manySnapshot: [readonly unknown[], unknown][];
|
|
167
|
+
}>, "reset" | "mutate"> | Omit<import("@tanstack/query-core").MutationObserverSuccessResult<RecordOf<TResources, TName>, unknown, UpdateParams<RecordOf<TResources, TName>>, {
|
|
168
|
+
previous?: undefined;
|
|
169
|
+
key?: undefined;
|
|
170
|
+
manySnapshot?: undefined;
|
|
171
|
+
} | {
|
|
172
|
+
previous: RecordOf<TResources, TName> | undefined;
|
|
173
|
+
key: readonly [string, "getOne", {
|
|
174
|
+
id: string;
|
|
175
|
+
meta?: undefined;
|
|
176
|
+
} | {
|
|
177
|
+
id: string;
|
|
178
|
+
meta: {} | null;
|
|
179
|
+
}];
|
|
180
|
+
manySnapshot: [readonly unknown[], unknown][];
|
|
181
|
+
}>, "reset" | "mutate">>, UpdateParams<RecordOf<TResources, TName>>, RecordOf<TResources, TName>>;
|
|
102
182
|
/**
|
|
103
183
|
* Delete-one mutation for `resource`. Returns vue-query's mutation object; call
|
|
104
184
|
* `.mutateAsync({ id, previousData })` to dispatch. Mirrors the React delete
|
|
@@ -177,7 +257,77 @@ export declare function useDelete<TResources extends ResourceMap = ResourceMap,
|
|
|
177
257
|
meta: {} | null;
|
|
178
258
|
}];
|
|
179
259
|
manySnapshot: [readonly unknown[], unknown][];
|
|
180
|
-
}>, "reset" | "mutate"
|
|
260
|
+
}>, "reset" | "mutate">> | Undoable<import("@tanstack/vue-query").UseMutationReturnType<RecordOf<TResources, TName>, unknown, DeleteParams<RecordOf<TResources, TName>>, {
|
|
261
|
+
previous?: undefined;
|
|
262
|
+
key?: undefined;
|
|
263
|
+
manySnapshot?: undefined;
|
|
264
|
+
} | {
|
|
265
|
+
previous: RecordOf<TResources, TName> | undefined;
|
|
266
|
+
key: readonly [string, "getOne", {
|
|
267
|
+
id: string;
|
|
268
|
+
meta?: undefined;
|
|
269
|
+
} | {
|
|
270
|
+
id: string;
|
|
271
|
+
meta: {} | null;
|
|
272
|
+
}];
|
|
273
|
+
manySnapshot: [readonly unknown[], unknown][];
|
|
274
|
+
}, Omit<import("@tanstack/query-core").MutationObserverIdleResult<RecordOf<TResources, TName>, unknown, DeleteParams<RecordOf<TResources, TName>>, {
|
|
275
|
+
previous?: undefined;
|
|
276
|
+
key?: undefined;
|
|
277
|
+
manySnapshot?: undefined;
|
|
278
|
+
} | {
|
|
279
|
+
previous: RecordOf<TResources, TName> | undefined;
|
|
280
|
+
key: readonly [string, "getOne", {
|
|
281
|
+
id: string;
|
|
282
|
+
meta?: undefined;
|
|
283
|
+
} | {
|
|
284
|
+
id: string;
|
|
285
|
+
meta: {} | null;
|
|
286
|
+
}];
|
|
287
|
+
manySnapshot: [readonly unknown[], unknown][];
|
|
288
|
+
}>, "reset" | "mutate"> | Omit<import("@tanstack/query-core").MutationObserverLoadingResult<RecordOf<TResources, TName>, unknown, DeleteParams<RecordOf<TResources, TName>>, {
|
|
289
|
+
previous?: undefined;
|
|
290
|
+
key?: undefined;
|
|
291
|
+
manySnapshot?: undefined;
|
|
292
|
+
} | {
|
|
293
|
+
previous: RecordOf<TResources, TName> | undefined;
|
|
294
|
+
key: readonly [string, "getOne", {
|
|
295
|
+
id: string;
|
|
296
|
+
meta?: undefined;
|
|
297
|
+
} | {
|
|
298
|
+
id: string;
|
|
299
|
+
meta: {} | null;
|
|
300
|
+
}];
|
|
301
|
+
manySnapshot: [readonly unknown[], unknown][];
|
|
302
|
+
}>, "reset" | "mutate"> | Omit<import("@tanstack/query-core").MutationObserverErrorResult<RecordOf<TResources, TName>, unknown, DeleteParams<RecordOf<TResources, TName>>, {
|
|
303
|
+
previous?: undefined;
|
|
304
|
+
key?: undefined;
|
|
305
|
+
manySnapshot?: undefined;
|
|
306
|
+
} | {
|
|
307
|
+
previous: RecordOf<TResources, TName> | undefined;
|
|
308
|
+
key: readonly [string, "getOne", {
|
|
309
|
+
id: string;
|
|
310
|
+
meta?: undefined;
|
|
311
|
+
} | {
|
|
312
|
+
id: string;
|
|
313
|
+
meta: {} | null;
|
|
314
|
+
}];
|
|
315
|
+
manySnapshot: [readonly unknown[], unknown][];
|
|
316
|
+
}>, "reset" | "mutate"> | Omit<import("@tanstack/query-core").MutationObserverSuccessResult<RecordOf<TResources, TName>, unknown, DeleteParams<RecordOf<TResources, TName>>, {
|
|
317
|
+
previous?: undefined;
|
|
318
|
+
key?: undefined;
|
|
319
|
+
manySnapshot?: undefined;
|
|
320
|
+
} | {
|
|
321
|
+
previous: RecordOf<TResources, TName> | undefined;
|
|
322
|
+
key: readonly [string, "getOne", {
|
|
323
|
+
id: string;
|
|
324
|
+
meta?: undefined;
|
|
325
|
+
} | {
|
|
326
|
+
id: string;
|
|
327
|
+
meta: {} | null;
|
|
328
|
+
}];
|
|
329
|
+
manySnapshot: [readonly unknown[], unknown][];
|
|
330
|
+
}>, "reset" | "mutate">>, DeleteParams<RecordOf<TResources, TName>>, RecordOf<TResources, TName> | undefined>;
|
|
181
331
|
/**
|
|
182
332
|
* Delete-many mutation for `resource` — the Vue twin of the bulk delete path
|
|
183
333
|
* `@chelone/react`'s `<BulkDeleteButton>` fires against
|
|
@@ -190,7 +340,91 @@ export declare function useDelete<TResources extends ResourceMap = ResourceMap,
|
|
|
190
340
|
* `mutateAsync` for the optimistic-with-Undo flow (remove the rows now, defer the
|
|
191
341
|
* server call until the Undo window closes) via the core `startUndoableMutation`.
|
|
192
342
|
*/
|
|
193
|
-
export declare function useDeleteMany<TResources extends ResourceMap = ResourceMap, TName extends keyof TResources & string = keyof TResources & string>(resource: TName, options?: MutationModeOptions): import("
|
|
343
|
+
export declare function useDeleteMany<TResources extends ResourceMap = ResourceMap, TName extends keyof TResources & string = keyof TResources & string>(resource: TName, options?: MutationModeOptions): (import("vue").ToRefs<Readonly<Omit<import("@tanstack/query-core").MutationObserverIdleResult<Identifier[], Error, DeleteManyParams, unknown>, "reset" | "mutate">>> & {
|
|
344
|
+
mutate: (variables: DeleteManyParams, options?: import("@tanstack/query-core").MutateOptions<Identifier[], Error, DeleteManyParams, unknown> | undefined) => void;
|
|
345
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<Identifier[], Error, DeleteManyParams, unknown>;
|
|
346
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
347
|
+
}) | (import("vue").ToRefs<Readonly<Omit<import("@tanstack/query-core").MutationObserverLoadingResult<Identifier[], Error, DeleteManyParams, unknown>, "reset" | "mutate">>> & {
|
|
348
|
+
mutate: (variables: DeleteManyParams, options?: import("@tanstack/query-core").MutateOptions<Identifier[], Error, DeleteManyParams, unknown> | undefined) => void;
|
|
349
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<Identifier[], Error, DeleteManyParams, unknown>;
|
|
350
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
351
|
+
}) | (import("vue").ToRefs<Readonly<Omit<import("@tanstack/query-core").MutationObserverErrorResult<Identifier[], Error, DeleteManyParams, unknown>, "reset" | "mutate">>> & {
|
|
352
|
+
mutate: (variables: DeleteManyParams, options?: import("@tanstack/query-core").MutateOptions<Identifier[], Error, DeleteManyParams, unknown> | undefined) => void;
|
|
353
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<Identifier[], Error, DeleteManyParams, unknown>;
|
|
354
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
355
|
+
}) | (import("vue").ToRefs<Readonly<Omit<import("@tanstack/query-core").MutationObserverSuccessResult<Identifier[], Error, DeleteManyParams, unknown>, "reset" | "mutate">>> & {
|
|
356
|
+
mutate: (variables: DeleteManyParams, options?: import("@tanstack/query-core").MutateOptions<Identifier[], Error, DeleteManyParams, unknown> | undefined) => void;
|
|
357
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<Identifier[], Error, DeleteManyParams, unknown>;
|
|
358
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
359
|
+
}) | {
|
|
360
|
+
mutate: (params: DeleteManyParams, callbacks?: UndoableCallbacks<Identifier[], DeleteManyParams>) => void;
|
|
361
|
+
mutateAsync: (params: DeleteManyParams) => Promise<void>;
|
|
362
|
+
data: import("vue").Ref<undefined, undefined>;
|
|
363
|
+
error: import("vue").Ref<null, null>;
|
|
364
|
+
status: import("vue").Ref<"idle", "idle">;
|
|
365
|
+
isError: import("vue").Ref<false, false>;
|
|
366
|
+
isPending: import("vue").Ref<false, false>;
|
|
367
|
+
isSuccess: import("vue").Ref<false, false>;
|
|
368
|
+
failureCount: import("vue").Ref<number, number>;
|
|
369
|
+
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
370
|
+
isPaused: import("vue").Ref<boolean, boolean>;
|
|
371
|
+
variables: import("vue").Ref<undefined, undefined>;
|
|
372
|
+
isIdle: import("vue").Ref<true, true>;
|
|
373
|
+
context: import("vue").Ref<unknown, unknown>;
|
|
374
|
+
submittedAt: import("vue").Ref<number, number>;
|
|
375
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
376
|
+
} | {
|
|
377
|
+
mutate: (params: DeleteManyParams, callbacks?: UndoableCallbacks<Identifier[], DeleteManyParams>) => void;
|
|
378
|
+
mutateAsync: (params: DeleteManyParams) => Promise<void>;
|
|
379
|
+
data: import("vue").Ref<undefined, undefined>;
|
|
380
|
+
error: import("vue").Ref<null, null>;
|
|
381
|
+
status: import("vue").Ref<"pending", "pending">;
|
|
382
|
+
isError: import("vue").Ref<false, false>;
|
|
383
|
+
isPending: import("vue").Ref<true, true>;
|
|
384
|
+
isSuccess: import("vue").Ref<false, false>;
|
|
385
|
+
failureCount: import("vue").Ref<number, number>;
|
|
386
|
+
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
387
|
+
isPaused: import("vue").Ref<boolean, boolean>;
|
|
388
|
+
variables: import("vue").Ref<DeleteManyParams, DeleteManyParams>;
|
|
389
|
+
isIdle: import("vue").Ref<false, false>;
|
|
390
|
+
context: import("vue").Ref<unknown, unknown>;
|
|
391
|
+
submittedAt: import("vue").Ref<number, number>;
|
|
392
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
393
|
+
} | {
|
|
394
|
+
mutate: (params: DeleteManyParams, callbacks?: UndoableCallbacks<Identifier[], DeleteManyParams>) => void;
|
|
395
|
+
mutateAsync: (params: DeleteManyParams) => Promise<void>;
|
|
396
|
+
data: import("vue").Ref<undefined, undefined>;
|
|
397
|
+
error: import("vue").Ref<Error, Error>;
|
|
398
|
+
status: import("vue").Ref<"error", "error">;
|
|
399
|
+
isError: import("vue").Ref<true, true>;
|
|
400
|
+
isPending: import("vue").Ref<false, false>;
|
|
401
|
+
isSuccess: import("vue").Ref<false, false>;
|
|
402
|
+
failureCount: import("vue").Ref<number, number>;
|
|
403
|
+
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
404
|
+
isPaused: import("vue").Ref<boolean, boolean>;
|
|
405
|
+
variables: import("vue").Ref<DeleteManyParams, DeleteManyParams>;
|
|
406
|
+
isIdle: import("vue").Ref<false, false>;
|
|
407
|
+
context: import("vue").Ref<unknown, unknown>;
|
|
408
|
+
submittedAt: import("vue").Ref<number, number>;
|
|
409
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
410
|
+
} | {
|
|
411
|
+
mutate: (params: DeleteManyParams, callbacks?: UndoableCallbacks<Identifier[], DeleteManyParams>) => void;
|
|
412
|
+
mutateAsync: (params: DeleteManyParams) => Promise<void>;
|
|
413
|
+
data: import("vue").Ref<Identifier[], Identifier[]>;
|
|
414
|
+
error: import("vue").Ref<null, null>;
|
|
415
|
+
status: import("vue").Ref<"success", "success">;
|
|
416
|
+
isError: import("vue").Ref<false, false>;
|
|
417
|
+
isPending: import("vue").Ref<false, false>;
|
|
418
|
+
isSuccess: import("vue").Ref<true, true>;
|
|
419
|
+
failureCount: import("vue").Ref<number, number>;
|
|
420
|
+
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
421
|
+
isPaused: import("vue").Ref<boolean, boolean>;
|
|
422
|
+
variables: import("vue").Ref<DeleteManyParams, DeleteManyParams>;
|
|
423
|
+
isIdle: import("vue").Ref<false, false>;
|
|
424
|
+
context: import("vue").Ref<unknown, unknown>;
|
|
425
|
+
submittedAt: import("vue").Ref<number, number>;
|
|
426
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
427
|
+
};
|
|
194
428
|
/**
|
|
195
429
|
* Update-many mutation for `resource` — the Vue twin of the bulk update path
|
|
196
430
|
* `@chelone/react`'s `<BulkUpdateButton>` fires against
|
|
@@ -199,4 +433,89 @@ export declare function useDeleteMany<TResources extends ResourceMap = ResourceM
|
|
|
199
433
|
* invalidates the resource's caches on settle. Call `.mutateAsync({ ids, data })`
|
|
200
434
|
* to dispatch; `<BulkUpdateButton>` then clears the selection + notifies.
|
|
201
435
|
*/
|
|
202
|
-
export declare function useUpdateMany<TResources extends ResourceMap = ResourceMap, TName extends keyof TResources & string = keyof TResources & string>(resource: TName, options?: MutationModeOptions): import("
|
|
436
|
+
export declare function useUpdateMany<TResources extends ResourceMap = ResourceMap, TName extends keyof TResources & string = keyof TResources & string>(resource: TName, options?: MutationModeOptions): (import("vue").ToRefs<Readonly<Omit<import("@tanstack/query-core").MutationObserverIdleResult<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown>, "reset" | "mutate">>> & {
|
|
437
|
+
mutate: (variables: UpdateManyParams<RecordOf<TResources, TName>>, options?: import("@tanstack/query-core").MutateOptions<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown> | undefined) => void;
|
|
438
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown>;
|
|
439
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
440
|
+
}) | (import("vue").ToRefs<Readonly<Omit<import("@tanstack/query-core").MutationObserverLoadingResult<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown>, "reset" | "mutate">>> & {
|
|
441
|
+
mutate: (variables: UpdateManyParams<RecordOf<TResources, TName>>, options?: import("@tanstack/query-core").MutateOptions<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown> | undefined) => void;
|
|
442
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown>;
|
|
443
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
444
|
+
}) | (import("vue").ToRefs<Readonly<Omit<import("@tanstack/query-core").MutationObserverErrorResult<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown>, "reset" | "mutate">>> & {
|
|
445
|
+
mutate: (variables: UpdateManyParams<RecordOf<TResources, TName>>, options?: import("@tanstack/query-core").MutateOptions<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown> | undefined) => void;
|
|
446
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown>;
|
|
447
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
448
|
+
}) | (import("vue").ToRefs<Readonly<Omit<import("@tanstack/query-core").MutationObserverSuccessResult<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown>, "reset" | "mutate">>> & {
|
|
449
|
+
mutate: (variables: UpdateManyParams<RecordOf<TResources, TName>>, options?: import("@tanstack/query-core").MutateOptions<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown> | undefined) => void;
|
|
450
|
+
mutateAsync: import("@tanstack/query-core").MutateFunction<Identifier[], Error, UpdateManyParams<RecordOf<TResources, TName>>, unknown>;
|
|
451
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
452
|
+
}) | {
|
|
453
|
+
mutate: (params: UpdateManyParams<RecordOf<TResources, TName>>, callbacks?: UndoableUpdateManyCallbacks<RecordOf<TResources, TName>>) => void;
|
|
454
|
+
mutateAsync: (params: UpdateManyParams<RecordOf<TResources, TName>>) => Promise<void>;
|
|
455
|
+
data: import("vue").Ref<undefined, undefined>;
|
|
456
|
+
error: import("vue").Ref<null, null>;
|
|
457
|
+
status: import("vue").Ref<"idle", "idle">;
|
|
458
|
+
isError: import("vue").Ref<false, false>;
|
|
459
|
+
isPending: import("vue").Ref<false, false>;
|
|
460
|
+
isSuccess: import("vue").Ref<false, false>;
|
|
461
|
+
failureCount: import("vue").Ref<number, number>;
|
|
462
|
+
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
463
|
+
isPaused: import("vue").Ref<boolean, boolean>;
|
|
464
|
+
variables: import("vue").Ref<undefined, undefined>;
|
|
465
|
+
isIdle: import("vue").Ref<true, true>;
|
|
466
|
+
context: import("vue").Ref<unknown, unknown>;
|
|
467
|
+
submittedAt: import("vue").Ref<number, number>;
|
|
468
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
469
|
+
} | {
|
|
470
|
+
mutate: (params: UpdateManyParams<RecordOf<TResources, TName>>, callbacks?: UndoableUpdateManyCallbacks<RecordOf<TResources, TName>>) => void;
|
|
471
|
+
mutateAsync: (params: UpdateManyParams<RecordOf<TResources, TName>>) => Promise<void>;
|
|
472
|
+
data: import("vue").Ref<undefined, undefined>;
|
|
473
|
+
error: import("vue").Ref<null, null>;
|
|
474
|
+
status: import("vue").Ref<"pending", "pending">;
|
|
475
|
+
isError: import("vue").Ref<false, false>;
|
|
476
|
+
isPending: import("vue").Ref<true, true>;
|
|
477
|
+
isSuccess: import("vue").Ref<false, false>;
|
|
478
|
+
failureCount: import("vue").Ref<number, number>;
|
|
479
|
+
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
480
|
+
isPaused: import("vue").Ref<boolean, boolean>;
|
|
481
|
+
variables: import("vue").Ref<UpdateManyParams<RecordOf<TResources, TName>>, UpdateManyParams<RecordOf<TResources, TName>>>;
|
|
482
|
+
isIdle: import("vue").Ref<false, false>;
|
|
483
|
+
context: import("vue").Ref<unknown, unknown>;
|
|
484
|
+
submittedAt: import("vue").Ref<number, number>;
|
|
485
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
486
|
+
} | {
|
|
487
|
+
mutate: (params: UpdateManyParams<RecordOf<TResources, TName>>, callbacks?: UndoableUpdateManyCallbacks<RecordOf<TResources, TName>>) => void;
|
|
488
|
+
mutateAsync: (params: UpdateManyParams<RecordOf<TResources, TName>>) => Promise<void>;
|
|
489
|
+
data: import("vue").Ref<undefined, undefined>;
|
|
490
|
+
error: import("vue").Ref<Error, Error>;
|
|
491
|
+
status: import("vue").Ref<"error", "error">;
|
|
492
|
+
isError: import("vue").Ref<true, true>;
|
|
493
|
+
isPending: import("vue").Ref<false, false>;
|
|
494
|
+
isSuccess: import("vue").Ref<false, false>;
|
|
495
|
+
failureCount: import("vue").Ref<number, number>;
|
|
496
|
+
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
497
|
+
isPaused: import("vue").Ref<boolean, boolean>;
|
|
498
|
+
variables: import("vue").Ref<UpdateManyParams<RecordOf<TResources, TName>>, UpdateManyParams<RecordOf<TResources, TName>>>;
|
|
499
|
+
isIdle: import("vue").Ref<false, false>;
|
|
500
|
+
context: import("vue").Ref<unknown, unknown>;
|
|
501
|
+
submittedAt: import("vue").Ref<number, number>;
|
|
502
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
503
|
+
} | {
|
|
504
|
+
mutate: (params: UpdateManyParams<RecordOf<TResources, TName>>, callbacks?: UndoableUpdateManyCallbacks<RecordOf<TResources, TName>>) => void;
|
|
505
|
+
mutateAsync: (params: UpdateManyParams<RecordOf<TResources, TName>>) => Promise<void>;
|
|
506
|
+
data: import("vue").Ref<Identifier[], Identifier[]>;
|
|
507
|
+
error: import("vue").Ref<null, null>;
|
|
508
|
+
status: import("vue").Ref<"success", "success">;
|
|
509
|
+
isError: import("vue").Ref<false, false>;
|
|
510
|
+
isPending: import("vue").Ref<false, false>;
|
|
511
|
+
isSuccess: import("vue").Ref<true, true>;
|
|
512
|
+
failureCount: import("vue").Ref<number, number>;
|
|
513
|
+
failureReason: import("vue").Ref<Error | null, Error | null>;
|
|
514
|
+
isPaused: import("vue").Ref<boolean, boolean>;
|
|
515
|
+
variables: import("vue").Ref<UpdateManyParams<RecordOf<TResources, TName>>, UpdateManyParams<RecordOf<TResources, TName>>>;
|
|
516
|
+
isIdle: import("vue").Ref<false, false>;
|
|
517
|
+
context: import("vue").Ref<unknown, unknown>;
|
|
518
|
+
submittedAt: import("vue").Ref<number, number>;
|
|
519
|
+
reset: import("@tanstack/query-core").MutationObserverResult<TData, TError, TVariables, TOnMutateResult>["reset"];
|
|
520
|
+
};
|
|
521
|
+
export {};
|
package/dist/data/mutations.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { updateMutationOptions, resourceKey, createMutationOptions, deleteMutationOptions,
|
|
1
|
+
import { updateMutationOptions, resourceKey, createMutationOptions, deleteMutationOptions, undoableCallbacks, undoableUpdateOptions, patchedRecord, undoableDeleteOptions } from "@chelone/core";
|
|
2
2
|
import { useMutation } from "@tanstack/vue-query";
|
|
3
3
|
import { useCheloneContext } from "../context.js";
|
|
4
4
|
import { useUndoable } from "./undoable.js";
|
|
@@ -11,45 +11,49 @@ function useUpdate(resource, options = {}) {
|
|
|
11
11
|
const runUndoable = useUndoable();
|
|
12
12
|
const mutation = useMutation(updateMutationOptions(ctx, resource, options));
|
|
13
13
|
if (options.mutationMode !== "undoable") return mutation;
|
|
14
|
-
const mutate = (params) => {
|
|
14
|
+
const mutate = (params, callbacks) => {
|
|
15
|
+
const settle = undoableCallbacks(params, callbacks);
|
|
15
16
|
runUndoable({
|
|
16
|
-
|
|
17
|
-
applyOptimistic: () => updateRecordsInCache(
|
|
17
|
+
...undoableUpdateOptions(
|
|
18
18
|
ctx.queryClient,
|
|
19
19
|
resource,
|
|
20
20
|
[params.id],
|
|
21
21
|
params.data
|
|
22
22
|
),
|
|
23
|
-
commit: () => ctx.dataProvider.update(resource, params)
|
|
24
|
-
message: "chelone.notification.updated",
|
|
25
|
-
messageArgs: { smart_count: 1 }
|
|
23
|
+
commit: settle.commit(() => ctx.dataProvider.update(resource, params))
|
|
26
24
|
});
|
|
25
|
+
settle.success(patchedRecord(params));
|
|
27
26
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
mutate
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const undoable = {
|
|
28
|
+
...mutation,
|
|
29
|
+
mutate,
|
|
30
|
+
mutateAsync: async (params) => {
|
|
31
|
+
mutate(params);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return undoable;
|
|
33
35
|
}
|
|
34
36
|
function useDelete(resource, options = {}) {
|
|
35
37
|
const ctx = useCheloneContext();
|
|
36
38
|
const runUndoable = useUndoable();
|
|
37
39
|
const mutation = useMutation(deleteMutationOptions(ctx, resource, options));
|
|
38
40
|
if (options.mutationMode !== "undoable") return mutation;
|
|
39
|
-
const mutate = (params) => {
|
|
41
|
+
const mutate = (params, callbacks) => {
|
|
42
|
+
const settle = undoableCallbacks(params, callbacks);
|
|
40
43
|
runUndoable({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
commit: () => ctx.dataProvider.delete(resource, params),
|
|
44
|
-
message: "chelone.notification.deleted",
|
|
45
|
-
messageArgs: { smart_count: 1 }
|
|
44
|
+
...undoableDeleteOptions(ctx.queryClient, resource, [params.id]),
|
|
45
|
+
commit: settle.commit(() => ctx.dataProvider.delete(resource, params))
|
|
46
46
|
});
|
|
47
|
+
settle.success(params.previousData);
|
|
47
48
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
mutate
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
const undoable = {
|
|
50
|
+
...mutation,
|
|
51
|
+
mutate,
|
|
52
|
+
mutateAsync: async (params) => {
|
|
53
|
+
mutate(params);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return undoable;
|
|
53
57
|
}
|
|
54
58
|
function useDeleteMany(resource, options = {}) {
|
|
55
59
|
const ctx = useCheloneContext();
|
|
@@ -62,20 +66,23 @@ function useDeleteMany(resource, options = {}) {
|
|
|
62
66
|
onSettled: () => ctx.queryClient.invalidateQueries({ queryKey: resourceKey(resource) })
|
|
63
67
|
});
|
|
64
68
|
if (options.mutationMode !== "undoable") return mutation;
|
|
65
|
-
const mutate = (params) => {
|
|
69
|
+
const mutate = (params, callbacks) => {
|
|
70
|
+
const settle = undoableCallbacks(params, callbacks);
|
|
66
71
|
runUndoable({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
messageArgs: { smart_count: params.ids.length }
|
|
72
|
+
...undoableDeleteOptions(ctx.queryClient, resource, params.ids),
|
|
73
|
+
commit: settle.commit(
|
|
74
|
+
() => ctx.dataProvider.deleteMany(resource, params)
|
|
75
|
+
)
|
|
72
76
|
});
|
|
77
|
+
settle.success(params.ids);
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
...mutation,
|
|
81
|
+
mutate,
|
|
82
|
+
mutateAsync: async (params) => {
|
|
83
|
+
mutate(params);
|
|
84
|
+
}
|
|
73
85
|
};
|
|
74
|
-
mutation.mutate = mutate;
|
|
75
|
-
mutation.mutateAsync = (async (params) => {
|
|
76
|
-
mutate(params);
|
|
77
|
-
});
|
|
78
|
-
return mutation;
|
|
79
86
|
}
|
|
80
87
|
function useUpdateMany(resource, options = {}) {
|
|
81
88
|
const ctx = useCheloneContext();
|
|
@@ -88,25 +95,28 @@ function useUpdateMany(resource, options = {}) {
|
|
|
88
95
|
onSettled: () => ctx.queryClient.invalidateQueries({ queryKey: resourceKey(resource) })
|
|
89
96
|
});
|
|
90
97
|
if (options.mutationMode !== "undoable") return mutation;
|
|
91
|
-
const mutate = (params) => {
|
|
98
|
+
const mutate = (params, callbacks) => {
|
|
99
|
+
const settle = undoableCallbacks(params, callbacks);
|
|
92
100
|
runUndoable({
|
|
93
|
-
|
|
94
|
-
applyOptimistic: () => updateRecordsInCache(
|
|
101
|
+
...undoableUpdateOptions(
|
|
95
102
|
ctx.queryClient,
|
|
96
103
|
resource,
|
|
97
104
|
params.ids,
|
|
98
105
|
params.data
|
|
99
106
|
),
|
|
100
|
-
commit:
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
commit: settle.commit(
|
|
108
|
+
() => ctx.dataProvider.updateMany(resource, params)
|
|
109
|
+
)
|
|
103
110
|
});
|
|
111
|
+
settle.success(params.ids);
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
...mutation,
|
|
115
|
+
mutate,
|
|
116
|
+
mutateAsync: async (params) => {
|
|
117
|
+
mutate(params);
|
|
118
|
+
}
|
|
104
119
|
};
|
|
105
|
-
mutation.mutate = mutate;
|
|
106
|
-
mutation.mutateAsync = (async (params) => {
|
|
107
|
-
mutate(params);
|
|
108
|
-
});
|
|
109
|
-
return mutation;
|
|
110
120
|
}
|
|
111
121
|
export {
|
|
112
122
|
useCreate,
|
package/dist/list/use-list.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createClientListController } from "@chelone/core";
|
|
1
|
+
import { createClientListController, listControllerActions } from "@chelone/core";
|
|
2
2
|
import { toValue, watch, reactive, computed } from "vue";
|
|
3
3
|
import { useMicroStore } from "../store/use-micro-store.js";
|
|
4
4
|
function useList(options = {}) {
|
|
@@ -40,18 +40,7 @@ function useList(options = {}) {
|
|
|
40
40
|
selectedIds: computed(() => state.value.selectedIds),
|
|
41
41
|
hasNextPage: computed(() => state.value.hasNextPage),
|
|
42
42
|
hasPreviousPage: computed(() => state.value.hasPreviousPage),
|
|
43
|
-
|
|
44
|
-
setPerPage: controller.setPerPage,
|
|
45
|
-
setSort: controller.setSort,
|
|
46
|
-
setFilters: controller.setFilters,
|
|
47
|
-
setParams: controller.setParams,
|
|
48
|
-
showFilter: controller.showFilter,
|
|
49
|
-
hideFilter: controller.hideFilter,
|
|
50
|
-
select: controller.select,
|
|
51
|
-
toggleItem: controller.toggleItem,
|
|
52
|
-
unselectAll: controller.unselectAll,
|
|
53
|
-
selectAll: controller.selectAll,
|
|
54
|
-
refetch: controller.refetch
|
|
43
|
+
...listControllerActions(controller)
|
|
55
44
|
});
|
|
56
45
|
}
|
|
57
46
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chelone/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"cronstrue": "^3.24.0",
|
|
59
59
|
"libphonenumber-js": "^1.13.8",
|
|
60
|
-
"@chelone/core": "0.
|
|
60
|
+
"@chelone/core": "0.2.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@guolao/vue-monaco-editor": "^1.6.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"terra-draw-maplibre-gl-adapter": "^1.5.0",
|
|
77
77
|
"vue": "^3.4.0",
|
|
78
78
|
"vue-router": "^4.0.0",
|
|
79
|
-
"@chelone/supabase": "0.
|
|
79
|
+
"@chelone/supabase": "0.2.0"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"@chelone/supabase": {
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"vue-router": "^4.0.0",
|
|
151
151
|
"vue-tsc": "^2.0.0",
|
|
152
152
|
"zod": "^3.24.0",
|
|
153
|
-
"@chelone/supabase": "0.
|
|
153
|
+
"@chelone/supabase": "0.2.0"
|
|
154
154
|
},
|
|
155
155
|
"scripts": {
|
|
156
156
|
"build": "vite build && vue-tsc -p tsconfig.build.json && node ../../scripts/strip-dts-css-imports.mjs dist && node ../../scripts/dts-extensions.mjs dist",
|