@zaptek/application-livel 0.15.0 → 0.16.1

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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # @zaptek/application-livel
2
2
 
3
+ ## 0.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [53eb541]
8
+ - @zaptek/resource@0.4.0
9
+
10
+ ## 0.16.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 0a9c41d: Delete files with `useDeleteFiles` alone, given their ids (one or more): it deletes the file records under the member's rights, their bytes following once the deletion commits, as the platform no longer serves `files.delete_file` and `files.delete_files`. Breaking: `useDeleteFile` is gone; call `useDeleteFiles` with `[id]`.
15
+
16
+ ## 0.15.1
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [71b76f4]
21
+ - Updated dependencies [45ef07a]
22
+ - @zaptek/resource@0.3.0
23
+
3
24
  ## 0.15.0
4
25
 
5
26
  ### Minor Changes
@@ -46,6 +46,5 @@ export declare function useDownloadFile(): import("@tanstack/react-query").UseMu
46
46
  /** Uses Livel's signed upload ticket, then registers the Storage object. */
47
47
  export declare function useUploadFiles(): import("@tanstack/react-query").UseMutationResult<UploadedFile[], Error, UploadFilesInput, unknown>;
48
48
  export declare function useUpdateFile<TFile extends FileRecord = FileRecord>(): import("@tanstack/react-query").UseMutationResult<TFile, Error, UpdateFileInput, unknown>;
49
- export declare function useDeleteFile<TFile extends FileRecord = FileRecord>(): import("@tanstack/react-query").UseMutationResult<TFile, Error, string, unknown>;
50
49
  export declare function useDeleteFiles<TFile extends FileRecord = FileRecord>(): import("@tanstack/react-query").UseMutationResult<TFile[], Error, string[], unknown>;
51
50
  export declare function useChangeFileVisibility<TFile extends FileRecord = FileRecord>(): import("@tanstack/react-query").UseMutationResult<TFile, Error, ChangeFileVisibilityInput, unknown>;
@@ -71,12 +71,6 @@ export function getCompletedUploads(error) {
71
71
  ? uploadedFiles.map(requireUploadedFile)
72
72
  : [];
73
73
  }
74
- function requireFileRecords(value) {
75
- if (!Array.isArray(value)) {
76
- throw new Error("Livel returned an invalid file list");
77
- }
78
- return value.map(requireFileRecord);
79
- }
80
74
  function selectDownloadUrl(response) {
81
75
  if (!isRecord(response) || typeof response.url !== "string") {
82
76
  throw new Error("Livel returned an invalid file download URL");
@@ -242,33 +236,21 @@ export function useUpdateFile() {
242
236
  },
243
237
  });
244
238
  }
245
- export function useDeleteFile() {
246
- const { client, status } = useLivelApplication();
247
- const queryClient = useQueryClient();
248
- return useMutation({
249
- mutationFn: async (fileId) => {
250
- const connectedClient = requireConnectedClient(client, status);
251
- return requireFileRecord(await connectedClient.rpc.call(["files", "delete_file"], {
252
- file_id: fileId,
253
- }));
254
- },
255
- onSuccess: async () => {
256
- await invalidateFileQueries(queryClient, client?.workspace_id ?? null);
257
- },
258
- onError: async () => {
259
- await invalidateFileQueries(queryClient, client?.workspace_id ?? null);
260
- },
261
- });
262
- }
263
239
  export function useDeleteFiles() {
264
240
  const { client, status } = useLivelApplication();
265
241
  const queryClient = useQueryClient();
266
242
  return useMutation({
267
243
  mutationFn: async (fileIds) => {
268
244
  const connectedClient = requireConnectedClient(client, status);
269
- return requireFileRecords(await connectedClient.rpc.call(["files", "delete_files"], {
270
- file_ids: fileIds,
271
- }));
245
+ // Their bytes follow the records once the deletion commits.
246
+ const { data } = await connectedClient.supabase
247
+ .from("files")
248
+ .delete()
249
+ .in("id", fileIds)
250
+ .eq("workspace_id", connectedClient.workspace_id)
251
+ .select("*")
252
+ .throwOnError();
253
+ return data;
272
254
  },
273
255
  onSuccess: async () => {
274
256
  await invalidateFileQueries(queryClient, client?.workspace_id ?? null);
@@ -2,5 +2,5 @@ export { useReportError, useLivelApplication, } from "../components/livel-applic
2
2
  export type { LivelApplicationState, LivelApplicationStatus, } from "../components/livel-application.provider.js";
3
3
  export { useRpcQuery } from "./rpc.hooks.js";
4
4
  export type { RpcQueryOptions } from "./rpc.hooks.js";
5
- export { getCompletedUploads, useChangeFileVisibility, useDeleteFile, useDeleteFiles, useDownloadFile, useFile, useFileDownloadUrl, useFiles, useUpdateFile, useUploadFiles, } from "./files.hooks.js";
5
+ export { getCompletedUploads, useChangeFileVisibility, useDeleteFiles, useDownloadFile, useFile, useFileDownloadUrl, useFiles, useUpdateFile, useUploadFiles, } from "./files.hooks.js";
6
6
  export type { ChangeFileVisibilityInput, FileFilters, FileRecord, PaginationOptions, UpdateFileInput, UploadedFile, UploadFilesInput, } from "./files.hooks.js";
@@ -1,3 +1,3 @@
1
1
  export { useReportError, useLivelApplication, } from "../components/livel-application.provider.js";
2
2
  export { useRpcQuery } from "./rpc.hooks.js";
3
- export { getCompletedUploads, useChangeFileVisibility, useDeleteFile, useDeleteFiles, useDownloadFile, useFile, useFileDownloadUrl, useFiles, useUpdateFile, useUploadFiles, } from "./files.hooks.js";
3
+ export { getCompletedUploads, useChangeFileVisibility, useDeleteFiles, useDownloadFile, useFile, useFileDownloadUrl, useFiles, useUpdateFile, useUploadFiles, } from "./files.hooks.js";
package/docs/data.md CHANGED
@@ -16,7 +16,7 @@ adapt. The names in it are those of the database:
16
16
  carry the `x_` prefix (`x_broker`);
17
17
  - an amount is in cents, in `<field>_cents`;
18
18
  - a relation contains the referenced id, in `<field>_id`;
19
- - each record has `id`, `workspace_id`, `owner_workspace_member_id` (its
19
+ - each record has `id`, `workspace_id`, `owner_principal_id` (its
20
20
  owner), `owner_workspace_group_id` (its group), `created_at` and
21
21
  `updated_at`.
22
22
 
package/docs/files.md CHANGED
@@ -17,7 +17,7 @@ temporary: do not store it as a durable reference.
17
17
  | `useDownloadFile()` | Request a fresh download URL on click. |
18
18
  | `useUploadFiles()` | Upload files and record their metadata. |
19
19
  | `useUpdateFile()` | Change a file's metadata. |
20
- | `useDeleteFile()` / `useDeleteFiles()` | Delete one or more files. |
20
+ | `useDeleteFiles()` | Delete one or more files: their bytes follow. |
21
21
  | `useChangeFileVisibility()` | Change the public or private visibility. |
22
22
 
23
23
  Reads are TanStack Query queries; changes are TanStack Query
@@ -120,7 +120,6 @@ The SDK does not copy the full schema of the `files` table: it guarantees the
120
120
  | Mutation | Argument of `mutate` or `mutateAsync` |
121
121
  | --- | --- |
122
122
  | `useUpdateFile()` | `{ id, name?, metadata? }`; at least one field to change. |
123
- | `useDeleteFile()` | The file identifier. |
124
123
  | `useDeleteFiles()` | An array of identifiers. |
125
124
  | `useChangeFileVisibility()` | `{ id, is_public }`. |
126
125
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaptek/application-livel",
3
- "version": "0.15.0",
3
+ "version": "0.16.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "UNLICENSED",
@@ -42,7 +42,7 @@
42
42
  "@orpc/client": "^1.16.2",
43
43
  "@supabase/supabase-js": "^2.114.0",
44
44
  "penpal": "^8.0.1",
45
- "@zaptek/resource": "0.2.0"
45
+ "@zaptek/resource": "0.4.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@tanstack/react-query": "^5.90.21",
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "packageManager": "pnpm@10.34.0",
19
19
  "dependencies": {
20
- "@zaptek/application-livel": "0.15.0",
21
- "@zaptek/resource": "0.2.0",
20
+ "@zaptek/application-livel": "0.16.1",
21
+ "@zaptek/resource": "0.4.0",
22
22
  "@tanstack/react-query": "catalog:",
23
23
  "zod": "catalog:",
24
24
  "@base-ui/react": "catalog:",
@@ -20,7 +20,7 @@ catalog:
20
20
  "nitro": "^3.0.260311-beta"
21
21
  "react": "^19.2.3"
22
22
  "react-dom": "^19.2.3"
23
- "shadcn": "^4.21.0"
23
+ "shadcn": "^4.23.0"
24
24
  "tailwindcss": "^4.3.3"
25
25
  "tw-animate-css": "^1.2.4"
26
26
  "typescript": "^5.7.2"