buckyos 0.7.149 → 0.7.151

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.
@@ -424,6 +424,44 @@ function bucketDataPlaneBase(serviceUrl) {
424
424
  const at = serviceUrl.indexOf("/kapi/");
425
425
  return at >= 0 ? serviceUrl.slice(0, at) : "";
426
426
  }
427
+ const ZONE_BUCKET_OWNER = "_";
428
+ const BUCKET_COMPONENT = /^[A-Za-z0-9._-]{1,128}$/;
429
+ function bucketComponent(what, value) {
430
+ if (!BUCKET_COMPONENT.test(value) || value === "." || value === "..")
431
+ throw new BucketError("invalid_argument", `invalid bucket ${what} '${value}'`);
432
+ return value;
433
+ }
434
+ function userBucketId(appid, owner, name) {
435
+ if (owner === ZONE_BUCKET_OWNER)
436
+ throw new BucketError("invalid_argument", "a user bucket needs a user owner");
437
+ return `user/${bucketComponent("appid", appid)}/${bucketComponent("owner", owner)}/${bucketComponent("name", name)}`;
438
+ }
439
+ function zoneBucketId(appid, name) {
440
+ return `zone/${bucketComponent("appid", appid)}/${ZONE_BUCKET_OWNER}/${bucketComponent("name", name)}`;
441
+ }
442
+ function parseBucketPath(path) {
443
+ const segments = path.split("/");
444
+ if (segments.length < 4)
445
+ return null;
446
+ const [scope, appid, owner, name] = segments;
447
+ if (scope !== "user" && scope !== "zone")
448
+ return null;
449
+ if (![appid, owner, name].every((v) => BUCKET_COMPONENT.test(v) && v !== "." && v !== ".."))
450
+ return null;
451
+ if (scope === "zone" !== (owner === ZONE_BUCKET_OWNER))
452
+ return null;
453
+ return { bucketId: `${scope}/${appid}/${owner}/${name}`, parts: { scope, appid, owner, name }, key: segments.slice(4).join("/") };
454
+ }
455
+ const BUCKET_OBJ_URL_PREFIX = "obj://bucket/";
456
+ function bucketObjUrl(bucketId, key) {
457
+ return `${BUCKET_OBJ_URL_PREFIX}${bucketId}/${key}`;
458
+ }
459
+ function parseBucketObjUrl(url) {
460
+ if (!url.startsWith(BUCKET_OBJ_URL_PREFIX))
461
+ return null;
462
+ const parsed = parseBucketPath(url.slice(BUCKET_OBJ_URL_PREFIX.length));
463
+ return parsed && parsed.key ? { bucketId: parsed.bucketId, key: parsed.key } : null;
464
+ }
427
465
  function bucketObjectPath(bucketId, key) {
428
466
  return `${BUCKET_DATA_PATH}${bucketId}/${key.split("/").map(encodeURIComponent).join("/")}`;
429
467
  }
@@ -441,6 +479,17 @@ class BucketClient {
441
479
  stat(bucketId) {
442
480
  return this.call("bucket.stat", { bucket_id: bucketId });
443
481
  }
482
+ /** Unbinds everything and drops the bucket; a documents / collected bucket takes the user's sudo session token. */
483
+ deleteBucket(bucketId, options = {}) {
484
+ return this.rpcClient.call("bucket.delete_bucket", { bucket_id: bucketId }, options.sessionToken ? { sessionToken: options.sessionToken } : {});
485
+ }
486
+ /**
487
+ * Disposes of an uninstalled app instance's buckets by data policy (control-panel or a Zone admin):
488
+ * documents / collected (and app_data with `keepAppData`) become orphans, the rest are deleted.
489
+ */
490
+ releaseApp(appid, owner, options = {}) {
491
+ return this.call("bucket.release_app", { appid, owner, keep_app_data: options.keepAppData ?? false });
492
+ }
444
493
  put(bucketId, req) {
445
494
  return this.call("bucket.put", { bucket_id: bucketId, ...req });
446
495
  }
@@ -599,11 +648,18 @@ const bucket_client = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defin
599
648
  __proto__: null,
600
649
  BUCKET_DATA_PATH,
601
650
  BUCKET_MAX_PUT_BYTES,
651
+ BUCKET_OBJ_URL_PREFIX,
602
652
  BUCKET_SERVICE_NAME,
603
653
  BucketClient,
604
654
  BucketError,
655
+ ZONE_BUCKET_OWNER,
605
656
  bucketDataPlaneBase,
606
- bucketObjectPath
657
+ bucketObjUrl,
658
+ bucketObjectPath,
659
+ parseBucketObjUrl,
660
+ parseBucketPath,
661
+ userBucketId,
662
+ zoneBucketId
607
663
  }, Symbol.toStringTag, { value: "Module" }));
608
664
  function serializeAuthTarget(target) {
609
665
  if (!target || typeof target !== "object") {
@@ -27987,7 +28043,8 @@ const browserProvider = {
27987
28043
  let settled = false;
27988
28044
  const cleanup = () => {
27989
28045
  var _a3;
27990
- window.removeEventListener("focus", onFocus);
28046
+ input.removeEventListener("change", onChange);
28047
+ input.removeEventListener("cancel", onCancel);
27991
28048
  (_a3 = options.signal) == null ? void 0 : _a3.removeEventListener("abort", onAbort);
27992
28049
  };
27993
28050
  const fail2 = (error) => {
@@ -27998,13 +28055,8 @@ const browserProvider = {
27998
28055
  reject(error);
27999
28056
  };
28000
28057
  const onAbort = () => fail2(new NdmError("USER_CANCELLED", "Import cancelled"));
28001
- const onFocus = () => {
28002
- setTimeout(() => {
28003
- if (!settled)
28004
- fail2(new NdmError("USER_CANCELLED", "User cancelled file selection"));
28005
- }, 500);
28006
- };
28007
- input.addEventListener("change", () => {
28058
+ const onCancel = () => fail2(new NdmError("USER_CANCELLED", "User cancelled file selection"));
28059
+ const onChange = () => {
28008
28060
  if (settled)
28009
28061
  return;
28010
28062
  const files = input.files;
@@ -28015,9 +28067,9 @@ const browserProvider = {
28015
28067
  settled = true;
28016
28068
  cleanup();
28017
28069
  resolve(Array.from(files));
28018
- });
28019
- input.addEventListener("cancel", onAbort);
28020
- window.addEventListener("focus", onFocus);
28070
+ };
28071
+ input.addEventListener("change", onChange);
28072
+ input.addEventListener("cancel", onCancel);
28021
28073
  if ((_a2 = options.signal) == null ? void 0 : _a2.aborted) {
28022
28074
  onAbort();
28023
28075
  return;
@@ -28744,7 +28796,7 @@ async function importSelectedFiles(selectedFiles, options, tree) {
28744
28796
  summary
28745
28797
  };
28746
28798
  if (options.autoStartUpload && uploadStatus === "not_started") {
28747
- startUpload(sessionId, { endpoint: options.endpoint, sessionToken: options.sessionToken, fetcher: options.fetcher, headers: options.headers, signal: options.signal }).catch(() => {
28799
+ startUpload(sessionId, { endpoint: options.endpoint, sessionToken: options.sessionToken, fetcher: options.fetcher, headers: options.headers, signal: options.signal, bind: options.bind }).catch(() => {
28748
28800
  });
28749
28801
  snapshot.uploadStatus = "uploading";
28750
28802
  }
@@ -29035,8 +29087,11 @@ async function doUpload(session, concurrency) {
29035
29087
  if (body.ready !== true || !Array.isArray(body.roots) || session.items.some((item) => !body.roots.some((root) => root.obj_id === item.objectId && root.ready === true))) {
29036
29088
  throw new NdmError("OBJECT_NOT_READY", "NDM did not confirm all root objects and their dependencies are ready");
29037
29089
  }
29038
- if (session.bind)
29090
+ if (session.bind) {
29091
+ if (!body.binding || typeof body.binding.obj_id !== "string")
29092
+ throw new NdmError("UPLOAD_FAILED", "finalize did not bind the imported root");
29039
29093
  session.binding = body.binding;
29094
+ }
29040
29095
  session.objectStatus = "ready";
29041
29096
  session.uploadStatus = session.transmittedBytes === 0 ? "not_required" : "completed";
29042
29097
  session.materializationStatus = "all_in_store";
@@ -30163,4 +30218,4 @@ export {
30163
30218
  NOTIFY_CHOICE_CONTROL_ID as y,
30164
30219
  NOTIFY_TEXT_CONTROL_ID as z
30165
30220
  };
30166
- //# sourceMappingURL=executor_client-06dad8a8.mjs.map
30221
+ //# sourceMappingURL=executor_client-dde508e1.mjs.map