@devultur/core 1.2.0 → 1.3.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/README.md CHANGED
@@ -30,6 +30,10 @@ const { token } = await worker.issueToken("user_123");
30
30
  const src = buildMediaUrl("https://media.example.com", key, { token, width: 640, format: "webp" });
31
31
  ```
32
32
 
33
+ `worker.lock` reads and changes a file's retention and holds (`get`, `set`, `hold`, `release`, `holdAll`,
34
+ `releaseAll`), and a refusal surfaces as a `DevulturApiError` with its `code` and `details`. See
35
+ [Retention and holds](https://github.com/devultur/devultur/blob/main/docs/guides/object-lock.md).
36
+
33
37
  ## Documentation
34
38
 
35
39
  Guides and API reference: [github.com/devultur/devultur/tree/main/docs](https://github.com/devultur/devultur/tree/main/docs).
package/dist/index.js CHANGED
@@ -865,16 +865,25 @@ async function uploadParts(uploadUrl, file2, session, options) {
865
865
  );
866
866
  return parts.sort((a, b) => a.partNumber - b.partNumber);
867
867
  }
868
+ var COMPLETE_ATTEMPTS = 3;
869
+ var COMPLETE_RETRY_DELAY_MS = 1e3;
870
+ async function completeMultipart(uploadUrl, body, signal) {
871
+ for (let attempt = 1; ; attempt++) {
872
+ try {
873
+ return await postJson(multipartCompleteUrl(uploadUrl), body, signal);
874
+ } catch (error) {
875
+ const isUnverified = error instanceof DevulturApiError && error.code === "content_unverified";
876
+ if (!isUnverified || attempt >= COMPLETE_ATTEMPTS) throw error;
877
+ await new Promise((resolve) => setTimeout(resolve, COMPLETE_RETRY_DELAY_MS * attempt));
878
+ }
879
+ }
880
+ }
868
881
  async function uploadMultipart(uploadUrl, file2, options = {}) {
869
882
  const createBody = { size: file2.size, ...options.sha256 ? { sha256: options.sha256 } : {} };
870
883
  const session = await postJson(multipartCreateUrl(uploadUrl), createBody, options.signal);
871
884
  try {
872
885
  const parts = await uploadParts(uploadUrl, file2, session, options);
873
- const result = await postJson(
874
- multipartCompleteUrl(uploadUrl),
875
- { uploadId: session.uploadId, parts },
876
- options.signal
877
- );
886
+ const result = await completeMultipart(uploadUrl, { uploadId: session.uploadId, parts }, options.signal);
878
887
  options.onProgress?.(100);
879
888
  return result;
880
889
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devultur/core",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Shared config, types, storage path conventions, media references and URL signing for the Devultur media SDKs",
5
5
  "keywords": [
6
6
  "media",