@ardrive/turbo-sdk 1.31.0-alpha.1 → 1.31.0-alpha.3
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 +36 -2
- package/bundles/web.bundle.min.js +342 -475
- package/lib/cjs/cli/commands/uploadFolder.js +2 -1
- package/lib/cjs/cli/options.js +5 -0
- package/lib/cjs/cli/utils.js +1 -0
- package/lib/cjs/common/chunked.js +88 -27
- package/lib/cjs/common/http.js +39 -4
- package/lib/cjs/common/payment.js +2 -1
- package/lib/cjs/common/upload.js +5 -6
- package/lib/cjs/types.js +13 -1
- package/lib/cjs/utils/axiosClient.js +3 -37
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/commands/uploadFolder.js +2 -1
- package/lib/esm/cli/options.js +5 -0
- package/lib/esm/cli/utils.js +1 -0
- package/lib/esm/common/chunked.js +89 -28
- package/lib/esm/common/http.js +40 -5
- package/lib/esm/common/payment.js +2 -1
- package/lib/esm/common/upload.js +5 -6
- package/lib/esm/types.js +12 -0
- package/lib/esm/utils/axiosClient.js +3 -14
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/uploadFolder.d.ts.map +1 -1
- package/lib/types/cli/options.d.ts +13 -0
- package/lib/types/cli/options.d.ts.map +1 -1
- package/lib/types/cli/types.d.ts +1 -0
- package/lib/types/cli/types.d.ts.map +1 -1
- package/lib/types/cli/utils.d.ts +3 -10
- package/lib/types/cli/utils.d.ts.map +1 -1
- package/lib/types/common/chunked.d.ts +5 -1
- package/lib/types/common/chunked.d.ts.map +1 -1
- package/lib/types/common/http.d.ts +5 -3
- package/lib/types/common/http.d.ts.map +1 -1
- package/lib/types/common/payment.d.ts +1 -1
- package/lib/types/common/payment.d.ts.map +1 -1
- package/lib/types/common/upload.d.ts +2 -2
- package/lib/types/common/upload.d.ts.map +1 -1
- package/lib/types/types.d.ts +34 -2
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/utils/axiosClient.d.ts +8 -4
- package/lib/types/utils/axiosClient.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/lib/types/version.d.ts.map +1 -1
- package/package.json +9 -10
package/README.md
CHANGED
|
@@ -625,6 +625,40 @@ const uploadResult = await turbo.uploadFile({
|
|
|
625
625
|
});
|
|
626
626
|
```
|
|
627
627
|
|
|
628
|
+
##### Customize Multi-Part Upload Behavior
|
|
629
|
+
|
|
630
|
+
By default, the Turbo upload methods will split files into chunks that are larger than 10 MiB and send these chunks to the upload service multi-part endpoints. This behavior can be customized with the following inputs:
|
|
631
|
+
|
|
632
|
+
- `chunkByteCount`: The maximum size in bytes for each chunk. Must be between 5 MiB and 500 MiB. Defaults to 5 MiB.
|
|
633
|
+
- `maxChunkConcurrency`: The maximum number of chunks to upload concurrently. Defaults to 5. Reducing concurrency will slow down uploads, but reduce memory utilization and serialize network calls. Increasing it will upload faster, but can strain available resources.
|
|
634
|
+
- `chunkingMode`: The chunking mode to use. Can be 'auto', 'force', or 'disabled'. Defaults to 'auto'. Auto behavior means chunking is enabled if the file would be split into at least three chunks.
|
|
635
|
+
- `maxFinalizeMs`: The maximum time in milliseconds to wait for the finalization of all chunks after the last chunk is uploaded. Defaults to 1 minute per GiB of the total file size.
|
|
636
|
+
|
|
637
|
+
```typescript
|
|
638
|
+
// Customize chunking behavior
|
|
639
|
+
await turbo.upload({
|
|
640
|
+
...params,
|
|
641
|
+
chunkByteCount: 1024 * 1024 * 500, // Max chunk size
|
|
642
|
+
maxChunkConcurrency: 1, // Minimize concurrency
|
|
643
|
+
});
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
```typescript
|
|
647
|
+
// Disable chunking behavior
|
|
648
|
+
await turbo.upload({
|
|
649
|
+
...params,
|
|
650
|
+
chunkingMode: 'disabled',
|
|
651
|
+
});
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
```typescript
|
|
655
|
+
// Force chunking behavior
|
|
656
|
+
await turbo.upload({
|
|
657
|
+
...params,
|
|
658
|
+
chunkingMode: 'force',
|
|
659
|
+
});
|
|
660
|
+
```
|
|
661
|
+
|
|
628
662
|
#### `uploadFolder({ folderPath, files, dataItemOpts, signal, maxConcurrentUploads, throwOnFailure, manifestOptions })`
|
|
629
663
|
|
|
630
664
|
Signs and uploads a folder of files. For NodeJS, the `folderPath` of the folder to upload is required. For the browser, an array of `files` is required. The `dataItemOpts` is an optional object that can be used to configure tags, target, and anchor for the data item upload. The `signal` is an optional [AbortSignal] that can be used to cancel the upload or timeout the request. The `maxConcurrentUploads` is an optional number that can be used to limit the number of concurrent uploads. The `throwOnFailure` is an optional boolean that can be used to throw an error if any upload fails. The `manifestOptions` is an optional object that can be used to configure the manifest file, including a custom index file, fallback file, or whether to disable manifests altogether. Manifests are enabled by default.
|
|
@@ -765,8 +799,8 @@ Shares credits from the connected wallet to the provided native address and appr
|
|
|
765
799
|
```typescript
|
|
766
800
|
const { approvalDataItemId, approvedWincAmount } = await turbo.shareCredits({
|
|
767
801
|
approvedAddress: '2cor...VUa',
|
|
768
|
-
approvedWincAmount: 0.
|
|
769
|
-
expiresBySeconds: 3600,
|
|
802
|
+
approvedWincAmount: 800_000_000_000, // 0.8 Credits
|
|
803
|
+
expiresBySeconds: 3600, // Credits will expire back to original wallet in 1 hour
|
|
770
804
|
});
|
|
771
805
|
```
|
|
772
806
|
|