@burdenoff/fe-libs 2026.1112.3 → 2026.1112.4

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.
@@ -6,6 +6,8 @@ export { SaveToFilesDialog } from './SaveToFilesDialog';
6
6
  export { useSaveToFiles } from './useSaveToFiles';
7
7
  export type { SavedFile, UseSaveToFilesResult } from './useSaveToFiles';
8
8
  export { uploadBlobToFiles, FILES_AFTER_SAVE_REFETCH } from './uploadBlob';
9
+ export { fileUploadVisibility } from './uploadVisibility';
10
+ export type { FileUploadVisibility } from './uploadVisibility';
9
11
  export type { UploadBlobParams, UploadedFile, SaveToFilesStep, SaveToFilesRetryNotice, } from './uploadBlob';
10
12
  export { classifyFilesError, decideFilesRetry, runWithFilesRetry, COLD_START_MAX_ATTEMPTS, COLD_START_RETRY_DELAYS_MS, COLD_START_RETRY_BUDGET_MS, } from './retryPolicy';
11
13
  export type { FilesRetryKind, FilesRetryDecision, FilesRetryNotice, FilesRetryContext, } from './retryPolicy';
@@ -3,8 +3,9 @@ import { SaveToFilesButton as t } from "./SaveToFilesButton.js";
3
3
  import { SaveToFilesDialog as n } from "./SaveToFilesDialog.js";
4
4
  import { useSaveToFiles as r } from "./useSaveToFiles.js";
5
5
  import { FILES_AFTER_SAVE_REFETCH as i, uploadBlobToFiles as a } from "./uploadBlob.js";
6
- import { COLD_START_MAX_ATTEMPTS as o, COLD_START_RETRY_BUDGET_MS as s, COLD_START_RETRY_DELAYS_MS as c, classifyFilesError as l, decideFilesRetry as u, runWithFilesRetry as d } from "./retryPolicy.js";
7
- import { FILES_WARMUP_COOLDOWN_MS as f, useFilesServiceWarmup as p, warmFilesService as m } from "./warmFilesService.js";
8
- import { FILES_STORAGE_QUOTA_NAME as h, FilesPortAbortError as g, FilesPortError as _, createApolloFilesPort as v } from "./filesPort.js";
9
- import { createPinnedFilesPort as y } from "./pinnedFilesPort.js";
10
- export { o as COLD_START_MAX_ATTEMPTS, s as COLD_START_RETRY_BUDGET_MS, c as COLD_START_RETRY_DELAYS_MS, i as FILES_AFTER_SAVE_REFETCH, h as FILES_STORAGE_QUOTA_NAME, f as FILES_WARMUP_COOLDOWN_MS, g as FilesPortAbortError, _ as FilesPortError, t as SaveToFilesButton, n as SaveToFilesDialog, e as StorageFolderPicker, l as classifyFilesError, v as createApolloFilesPort, y as createPinnedFilesPort, u as decideFilesRetry, d as runWithFilesRetry, a as uploadBlobToFiles, p as useFilesServiceWarmup, r as useSaveToFiles, m as warmFilesService };
6
+ import { fileUploadVisibility as o } from "./uploadVisibility.js";
7
+ import { COLD_START_MAX_ATTEMPTS as s, COLD_START_RETRY_BUDGET_MS as c, COLD_START_RETRY_DELAYS_MS as l, classifyFilesError as u, decideFilesRetry as d, runWithFilesRetry as f } from "./retryPolicy.js";
8
+ import { FILES_WARMUP_COOLDOWN_MS as p, useFilesServiceWarmup as m, warmFilesService as h } from "./warmFilesService.js";
9
+ import { FILES_STORAGE_QUOTA_NAME as g, FilesPortAbortError as _, FilesPortError as v, createApolloFilesPort as y } from "./filesPort.js";
10
+ import { createPinnedFilesPort as b } from "./pinnedFilesPort.js";
11
+ export { s as COLD_START_MAX_ATTEMPTS, c as COLD_START_RETRY_BUDGET_MS, l as COLD_START_RETRY_DELAYS_MS, i as FILES_AFTER_SAVE_REFETCH, g as FILES_STORAGE_QUOTA_NAME, p as FILES_WARMUP_COOLDOWN_MS, _ as FilesPortAbortError, v as FilesPortError, t as SaveToFilesButton, n as SaveToFilesDialog, e as StorageFolderPicker, u as classifyFilesError, y as createApolloFilesPort, b as createPinnedFilesPort, d as decideFilesRetry, o as fileUploadVisibility, f as runWithFilesRetry, a as uploadBlobToFiles, m as useFilesServiceWarmup, r as useSaveToFiles, h as warmFilesService };
@@ -1,5 +1,6 @@
1
1
  import { ApolloClient } from '@apollo/client';
2
2
  import { extractErrorMessage, FilesRetryNotice } from './retryPolicy';
3
+ import { FileUploadVisibility } from './uploadVisibility';
3
4
  export { extractErrorMessage };
4
5
  /**
5
6
  * Apollo invalidations every "Save to Files" caller benefits from — pulled
@@ -18,6 +19,8 @@ export interface UploadBlobParams {
18
19
  filename: string;
19
20
  mimeType: string;
20
21
  folderId: string;
22
+ /** Omitted means PRIVATE. WORKSPACE is an intentional audience, never PUBLIC. */
23
+ visibility?: FileUploadVisibility;
21
24
  onProgress?: (pct: number) => void;
22
25
  /**
23
26
  * Fired before each retry wait. The upload is still running — this exists so the UI
@@ -1,7 +1,8 @@
1
1
  import { extractErrorMessage as e, runWithFilesRetry as t } from "./retryPolicy.js";
2
- import { gql as n } from "@apollo/client";
2
+ import { fileUploadVisibility as n } from "./uploadVisibility.js";
3
+ import { gql as r } from "@apollo/client";
3
4
  // src/storage/uploadBlob.ts
4
- var r = n`
5
+ var i = r`
5
6
  mutation SaveToFiles_InitiateUpload($input: InitiateUploadInput!) {
6
7
  initiateUpload(input: $input) {
7
8
  session {
@@ -10,7 +11,7 @@ var r = n`
10
11
  uploadUrl
11
12
  }
12
13
  }
13
- `, i = n`
14
+ `, a = r`
14
15
  mutation SaveToFiles_CompleteUpload($input: CompleteUploadInput!) {
15
16
  completeUpload(input: $input) {
16
17
  file {
@@ -20,27 +21,28 @@ var r = n`
20
21
  }
21
22
  }
22
23
  }
23
- `, a = [
24
+ `, o = [
24
25
  "GetFilesRootBrowsePage",
25
26
  "GetFilesFolderBrowsePage",
26
27
  "GetFilesRecentPage",
27
28
  "GetFiles"
28
29
  ];
29
- async function o(n) {
30
- let { client: o, blob: s, filename: c, mimeType: l, folderId: u, onProgress: d, onRetry: f } = n, p = c.includes(".") ? c.substring(c.lastIndexOf(".") + 1) : "", m = {
31
- ...n.now ? { now: n.now } : {},
32
- ...n.sleep ? { sleep: n.sleep } : {}
30
+ async function s(r) {
31
+ let { client: s, blob: c, filename: l, mimeType: u, folderId: d, onProgress: f, onRetry: p } = r, m = n(r.visibility), h = l.includes(".") ? l.substring(l.lastIndexOf(".") + 1) : "", g = {
32
+ ...r.now ? { now: r.now } : {},
33
+ ...r.sleep ? { sleep: r.sleep } : {}
33
34
  };
34
- d?.(0);
35
- let h = await t(async () => {
36
- let e = await o.mutate({
37
- mutation: r,
35
+ f?.(0);
36
+ let _ = await t(async () => {
37
+ let e = await s.mutate({
38
+ mutation: i,
38
39
  variables: { input: {
39
- fileName: c,
40
- fileSize: String(s.size),
41
- mimeType: l,
42
- extension: p,
43
- folderId: u
40
+ fileName: l,
41
+ fileSize: String(c.size),
42
+ mimeType: u,
43
+ extension: h,
44
+ folderId: d,
45
+ visibility: m
44
46
  } }
45
47
  }), t = e.data?.initiateUpload?.session, n = e.data?.initiateUpload?.uploadUrl;
46
48
  return t && n ? {
@@ -54,34 +56,34 @@ async function o(n) {
54
56
  error: e.error
55
57
  };
56
58
  }, {
57
- ...m,
58
- ...f ? { onRetry: (e) => f({
59
+ ...g,
60
+ ...p ? { onRetry: (e) => p({
59
61
  ...e,
60
62
  step: "initiate"
61
63
  }) } : {}
62
64
  });
63
- if (!h.value) throw Error(e(h.error) ?? "initiateUpload did not return a presigned URL");
64
- let { session: g, uploadUrl: _ } = h.value;
65
- d?.(10), await new Promise((e, t) => {
65
+ if (!_.value) throw Error(e(_.error) ?? "initiateUpload did not return a presigned URL");
66
+ let { session: v, uploadUrl: y } = _.value;
67
+ f?.(10), await new Promise((e, t) => {
66
68
  let n = new XMLHttpRequest();
67
69
  n.upload.addEventListener("progress", (e) => {
68
70
  if (e.lengthComputable) {
69
71
  let t = 10 + Math.round(e.loaded / e.total * 80);
70
- d?.(t);
72
+ f?.(t);
71
73
  }
72
74
  }), n.addEventListener("load", () => {
73
- n.status >= 200 && n.status < 300 ? (d?.(90), e()) : t(/* @__PURE__ */ Error(`Upload PUT failed with status ${n.status}`));
74
- }), n.addEventListener("error", () => t(/* @__PURE__ */ Error("Upload PUT network error"))), n.addEventListener("abort", () => t(/* @__PURE__ */ Error("Upload PUT aborted"))), n.open("PUT", _), n.setRequestHeader("Content-Type", l), n.send(s);
75
+ n.status >= 200 && n.status < 300 ? (f?.(90), e()) : t(/* @__PURE__ */ Error(`Upload PUT failed with status ${n.status}`));
76
+ }), n.addEventListener("error", () => t(/* @__PURE__ */ Error("Upload PUT network error"))), n.addEventListener("abort", () => t(/* @__PURE__ */ Error("Upload PUT aborted"))), n.open("PUT", y), n.setRequestHeader("Content-Type", u), n.send(c);
75
77
  });
76
- let v = await t(async () => {
77
- let e = await o.mutate({
78
- mutation: i,
78
+ let b = await t(async () => {
79
+ let e = await s.mutate({
80
+ mutation: a,
79
81
  variables: { input: {
80
- sessionId: g.id,
81
- fileSize: String(s.size),
82
- folderId: u
82
+ sessionId: v.id,
83
+ fileSize: String(c.size),
84
+ folderId: d
83
85
  } },
84
- refetchQueries: a
86
+ refetchQueries: o
85
87
  }), t = e.data?.completeUpload?.file;
86
88
  return t ? {
87
89
  ok: !0,
@@ -92,13 +94,13 @@ async function o(n) {
92
94
  };
93
95
  }, {
94
96
  allow: ["cold-start", "transient-blip"],
95
- ...m,
96
- ...f ? { onRetry: (e) => f({
97
+ ...g,
98
+ ...p ? { onRetry: (e) => p({
97
99
  ...e,
98
100
  step: "complete"
99
101
  }) } : {}
100
102
  });
101
- if (!v.value) throw Error(e(v.error) ?? "completeUpload did not return a file");
102
- return d?.(100), v.value;
103
+ if (!b.value) throw Error(e(b.error) ?? "completeUpload did not return a file");
104
+ return f?.(100), b.value;
103
105
  }
104
- export { a as FILES_AFTER_SAVE_REFETCH, e as extractErrorMessage, o as uploadBlobToFiles };
106
+ export { o as FILES_AFTER_SAVE_REFETCH, e as extractErrorMessage, s as uploadBlobToFiles };
@@ -0,0 +1,3 @@
1
+ /** A deliberate workspace audience is distinct from publishing a public asset. */
2
+ export type FileUploadVisibility = 'PRIVATE' | 'WORKSPACE';
3
+ export declare function fileUploadVisibility(value?: unknown): FileUploadVisibility;
@@ -0,0 +1,6 @@
1
+ // src/storage/uploadVisibility.ts
2
+ function e(e = "PRIVATE") {
3
+ if (e !== "PRIVATE" && e !== "WORKSPACE") throw Error("Upload visibility must be PRIVATE or WORKSPACE");
4
+ return e;
5
+ }
6
+ export { e as fileUploadVisibility };
@@ -1,5 +1,6 @@
1
1
  import { ApolloClient } from '@apollo/client';
2
2
  import { SaveToFilesSource } from './SaveToFilesButton';
3
+ import { FileUploadVisibility } from './uploadVisibility';
3
4
  import { SaveToFilesRetryNotice } from './uploadBlob';
4
5
  export interface SavedFile {
5
6
  id: string;
@@ -10,6 +11,8 @@ export interface UseSaveToFilesResult {
10
11
  save: (params: {
11
12
  source: SaveToFilesSource;
12
13
  folderPath: string;
14
+ /** Applies to blob uploads; sandbox copies currently support PRIVATE only. */
15
+ visibility?: FileUploadVisibility;
13
16
  /**
14
17
  * Fired before each retry wait. Purely informational — the save is still in
15
18
  * flight. Exists so a caller rendering its own chip can say why a cold start is
@@ -1,10 +1,11 @@
1
- import { extractErrorMessage as e, runWithFilesRetry as t } from "./retryPolicy.js";
2
- import { FILES_AFTER_SAVE_REFETCH as n, uploadBlobToFiles as r } from "./uploadBlob.js";
3
- import { useState as i } from "react";
4
- import { gql as a } from "@apollo/client";
5
- import { useApolloClient as o } from "@apollo/client/react";
1
+ import { fileUploadVisibility as e } from "./uploadVisibility.js";
2
+ import { extractErrorMessage as t, runWithFilesRetry as n } from "./retryPolicy.js";
3
+ import { FILES_AFTER_SAVE_REFETCH as r, uploadBlobToFiles as i } from "./uploadBlob.js";
4
+ import { useState as a } from "react";
5
+ import { gql as o } from "@apollo/client";
6
+ import { useApolloClient as s } from "@apollo/client/react";
6
7
  // src/storage/useSaveToFiles.ts
7
- var s = a`
8
+ var c = o`
8
9
  mutation SaveToFiles_EnsureFolderByPath($path: String!) {
9
10
  ensureFolderByPath(path: $path) {
10
11
  id
@@ -12,7 +13,7 @@ var s = a`
12
13
  path
13
14
  }
14
15
  }
15
- `, c = a`
16
+ `, l = o`
16
17
  mutation SaveToFiles_SaveSandboxArtifact($input: SaveSandboxArtifactInput!) {
17
18
  saveSandboxArtifactToFiles(input: $input) {
18
19
  id
@@ -21,18 +22,18 @@ var s = a`
21
22
  }
22
23
  }
23
24
  `;
24
- async function l(n, r, i = {}) {
25
- let a = await t(async () => {
26
- let e = await n.mutate({
27
- mutation: s,
25
+ async function u(e, r, i = {}) {
26
+ let a = await n(async () => {
27
+ let t = await e.mutate({
28
+ mutation: c,
28
29
  variables: { path: r }
29
- }), t = e.data?.ensureFolderByPath?.id;
30
- return t ? {
30
+ }), n = t.data?.ensureFolderByPath?.id;
31
+ return n ? {
31
32
  ok: !0,
32
- value: t
33
+ value: n
33
34
  } : {
34
35
  ok: !1,
35
- error: e.error
36
+ error: t.error
36
37
  };
37
38
  }, {
38
39
  ...i.onRetry ? { onRetry: (e) => i.onRetry?.({
@@ -43,56 +44,59 @@ async function l(n, r, i = {}) {
43
44
  ...i.sleep ? { sleep: i.sleep } : {}
44
45
  });
45
46
  if (a.value !== void 0) return a.value;
46
- throw Error(e(a.error) ?? `Could not resolve folder for path: ${r}`);
47
+ throw Error(t(a.error) ?? `Could not resolve folder for path: ${r}`);
47
48
  }
48
- function u() {
49
- let t = o(), [a, s] = i(!1), [u, d] = i(null), [f, p] = i(0), [m, h] = i(null);
49
+ function d() {
50
+ let n = s(), [o, c] = a(!1), [d, f] = a(null), [p, m] = a(0), [h, g] = a(null);
50
51
  return {
51
- save: async (i) => {
52
- s(!0), d(null), p(0), h(null);
53
- let a = (e) => {
54
- h(e), i.onRetry?.(e);
52
+ save: async (a) => {
53
+ c(!0), f(null), m(0), g(null);
54
+ let o = (e) => {
55
+ g(e), a.onRetry?.(e);
55
56
  };
56
57
  try {
57
- let o = await l(t, i.folderPath, { onRetry: a });
58
- if (h(null), i.source.kind === "sandbox-artifact") {
59
- let r = await t.mutate({
60
- mutation: c,
58
+ let s = e(a.visibility);
59
+ if (a.source.kind !== "blob" && s !== "PRIVATE") throw Error("Sandbox artifact saves do not support WORKSPACE visibility");
60
+ let c = await u(n, a.folderPath, { onRetry: o });
61
+ if (g(null), a.source.kind === "sandbox-artifact") {
62
+ let e = await n.mutate({
63
+ mutation: l,
61
64
  variables: { input: {
62
- sandboxId: i.source.sandboxId,
63
- sessionId: i.source.sessionId,
64
- path: i.source.path,
65
- folderId: o,
66
- filename: i.source.filename ?? null
65
+ sandboxId: a.source.sandboxId,
66
+ sessionId: a.source.sessionId,
67
+ path: a.source.path,
68
+ folderId: c,
69
+ filename: a.source.filename ?? null
67
70
  } },
68
- refetchQueries: n
69
- }), a = r.data?.saveSandboxArtifactToFiles;
70
- if (!a) throw Error(e(r.error) ?? "saveSandboxArtifactToFiles returned no file");
71
- return p(100), a;
71
+ refetchQueries: r
72
+ }), i = e.data?.saveSandboxArtifactToFiles;
73
+ if (!i) throw Error(t(e.error) ?? "saveSandboxArtifactToFiles returned no file");
74
+ return m(100), i;
72
75
  }
73
- let s = await i.source.getBlob();
74
- if (!s) throw Error("Cancelled: no bytes to save");
75
- let u = s.blob, d = s.filename ?? i.source.filename, f = s.mimeType ?? i.source.mimeType;
76
- return await r({
77
- client: t,
78
- blob: u,
79
- filename: d,
80
- mimeType: f,
81
- folderId: o,
82
- onProgress: p,
83
- onRetry: a
76
+ let d = await a.source.getBlob();
77
+ if (!d) throw Error("Cancelled: no bytes to save");
78
+ let f = d.blob, p = d.filename ?? a.source.filename, h = d.mimeType ?? a.source.mimeType;
79
+ return await i({
80
+ client: n,
81
+ blob: f,
82
+ filename: p,
83
+ mimeType: h,
84
+ folderId: c,
85
+ onProgress: m,
86
+ visibility: s,
87
+ onRetry: o
84
88
  });
85
89
  } catch (e) {
86
90
  let t = e instanceof Error ? e : Error(String(e));
87
- throw d(t), t;
91
+ throw f(t), t;
88
92
  } finally {
89
- s(!1), h(null);
93
+ c(!1), g(null);
90
94
  }
91
95
  },
92
- isPending: a,
93
- error: u,
94
- progress: f,
95
- retry: m
96
+ isPending: o,
97
+ error: d,
98
+ progress: p,
99
+ retry: h
96
100
  };
97
101
  }
98
- export { l as resolveFolderIdByPath, u as useSaveToFiles };
102
+ export { u as resolveFolderIdByPath, d as useSaveToFiles };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/fe-libs",
3
- "version": "2026.1112.3",
3
+ "version": "2026.1112.4",
4
4
  "description": "Burdenoff frontend primitives and domain libraries",
5
5
  "repository": {
6
6
  "type": "git",