@oddington/sdk 0.1.68 → 0.1.70

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/README.md CHANGED
@@ -715,8 +715,17 @@ expects the current enrichment's SHA-256 value. Reads return the successful Web
715
715
  Response without consuming its body. Local transfer is bounded and buffered
716
716
  before constructing that Response. Current workspace members can use every File in that workspace. A
717
717
  routine's `files: "read"` permits get/read; `files: "read-write"` also permits
718
- create/enrich/upload. References in Sources, Runs and Inbox items grant no
719
- additional access. Files has no public delete operation.
718
+ create/update/enrich/upload/delete. References in Sources, Runs and Inbox items grant no
719
+ additional access.
720
+
721
+ `await files.delete(id)` permanently removes one registered File's original and
722
+ all enrichments. The File becomes unavailable when deletion begins; successful
723
+ completion confirms physical removal from its managed storage. Retry the same ID
724
+ after interruption, including after a lost success reply. Completed deletion is
725
+ idempotent. Unknown and foreign IDs return `not_found`; a hosted caller without
726
+ the required local bytes receives `local_only`. The caller decides that existing
727
+ references no longer need the File. Deletion does not discover or rewrite those
728
+ references, cascade, or provide trash/recovery.
720
729
 
721
730
  `enrich` accepts a string encoded as UTF-8 or exact `Uint8Array` bytes, a safe
722
731
  flat filename, and an optional MIME hint. OS verifies text/Markdown/JSON or
package/dist/browser.js CHANGED
@@ -5054,6 +5054,23 @@ function isCanonicalOriginalMediaType(value) {
5054
5054
  return !1;
5055
5055
  }
5056
5056
  }
5057
+ function parseFileUpdate(value) {
5058
+ let invalid13 = (reason = "invalid_metadata") => {
5059
+ throw new FileOperationError("invalid_input", 400, !1, { reason });
5060
+ };
5061
+ if (!value || typeof value != "object" || Array.isArray(value)) return invalid13();
5062
+ let input = value, update = {};
5063
+ if (!Object.keys(input).length || Object.keys(input).some((key) => !["name", "path", "mediaType"].includes(key))) return invalid13();
5064
+ if (Object.hasOwn(input, "name")) {
5065
+ if (!safeFileName(input.name)) return invalid13("invalid_name");
5066
+ update.name = input.name;
5067
+ }
5068
+ if (Object.hasOwn(input, "path")) {
5069
+ if (!safeManagedFilePath(input.path)) return invalid13("invalid_path");
5070
+ update.path = input.path;
5071
+ }
5072
+ return Object.hasOwn(input, "mediaType") && (update.mediaType = declaredOriginalMediaType(input.mediaType)), update;
5073
+ }
5057
5074
  function parseFileCreateMetadata(value, maxBytes) {
5058
5075
  let invalid13 = (reason = "invalid_metadata") => {
5059
5076
  throw new FileOperationError("invalid_input", 400, !1, { reason });
@@ -8769,7 +8786,11 @@ async function send(suffix, init2, descriptor, initial, parent) {
8769
8786
  parseFileErrorDetail(error?.detail)
8770
8787
  ) : unavailable4();
8771
8788
  }
8772
- if (response2.status !== 200)
8789
+ if (descriptor === "void" && response2.status === 204 && response2.body === null) {
8790
+ checkCurrent();
8791
+ return;
8792
+ }
8793
+ if (descriptor === "void" || response2.status !== 200)
8773
8794
  throw response2.body?.cancel().catch(() => {
8774
8795
  }), unavailable4();
8775
8796
  try {
@@ -8944,6 +8965,14 @@ async function read(id3, names) {
8944
8965
  });
8945
8966
  }
8946
8967
  var files = {
8968
+ async update(id3, changes) {
8969
+ let path = idPath(id3), body = JSON.stringify(parseFileUpdate(changes));
8970
+ return operation(async (context, signal) => {
8971
+ let file2 = await send(path, { method: "PATCH", headers: { "content-type": "application/json" }, body }, !0, context, signal);
8972
+ if (file2.id !== id3) throw unavailable4();
8973
+ return file2;
8974
+ });
8975
+ },
8947
8976
  async upload(id3) {
8948
8977
  return operation(async (context, signal) => {
8949
8978
  let file2 = await send(`${idPath(id3)}/upload`, { method: "POST" }, !0, context, signal);
@@ -9052,6 +9081,10 @@ var files = {
9052
9081
  return result2;
9053
9082
  }, context);
9054
9083
  },
9084
+ async delete(id3) {
9085
+ let path = idPath(id3);
9086
+ return operation((context, signal) => send(path, { method: "DELETE" }, "void", context, signal));
9087
+ },
9055
9088
  async get(id3) {
9056
9089
  return operation((context, signal) => send(idPath(id3), { method: "GET" }, !0, context, signal));
9057
9090
  },