@milaboratories/pl-drivers 1.5.57 → 1.5.59
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/dist/clients/download.d.ts +6 -2
- package/dist/clients/download.d.ts.map +1 -1
- package/dist/clients/helpers.d.ts +2 -1
- package/dist/clients/helpers.d.ts.map +1 -1
- package/dist/drivers/download_blob/blob_key.d.ts +5 -0
- package/dist/drivers/download_blob/blob_key.d.ts.map +1 -0
- package/dist/drivers/download_blob/download_blob.d.ts +12 -9
- package/dist/drivers/download_blob/download_blob.d.ts.map +1 -1
- package/dist/drivers/download_blob/download_blob_task.d.ts +20 -9
- package/dist/drivers/download_blob/download_blob_task.d.ts.map +1 -1
- package/dist/drivers/helpers/download_remote_handle.d.ts.map +1 -1
- package/dist/drivers/types.d.ts +2 -1
- package/dist/drivers/types.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1846 -1802
- package/dist/index.mjs.map +1 -1
- package/dist/test_env.d.ts +6 -0
- package/dist/test_env.d.ts.map +1 -0
- package/package.json +10 -8
- package/src/clients/download.ts +7 -4
- package/src/clients/helpers.ts +3 -3
- package/src/drivers/download_blob/blob_key.ts +15 -0
- package/src/drivers/download_blob/download_blob.test.ts +122 -72
- package/src/drivers/download_blob/download_blob.ts +159 -81
- package/src/drivers/download_blob/download_blob_task.ts +69 -33
- package/src/drivers/helpers/download_remote_handle.ts +7 -6
- package/src/drivers/ls.test.ts +9 -6
- package/src/drivers/types.ts +13 -2
- package/src/drivers/upload.test.ts +3 -2
- package/src/test_env.ts +7 -0
package/src/drivers/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { InferSnapshot } from '@milaboratories/pl-tree';
|
|
3
3
|
import { rsSchema } from '@milaboratories/pl-tree';
|
|
4
|
+
import { RangeBytes } from '@milaboratories/pl-model-common';
|
|
4
5
|
|
|
5
6
|
//
|
|
6
7
|
// download
|
|
@@ -16,8 +17,18 @@ export const OnDemandBlobResourceSnapshot = rsSchema({
|
|
|
16
17
|
|
|
17
18
|
export type OnDemandBlobResourceSnapshot = InferSnapshot<typeof OnDemandBlobResourceSnapshot>;
|
|
18
19
|
|
|
19
|
-
export function getSize(bs: OnDemandBlobResourceSnapshot): number {
|
|
20
|
-
|
|
20
|
+
export function getSize(bs: OnDemandBlobResourceSnapshot, range?: RangeBytes): number {
|
|
21
|
+
const size = bs.kv['ctl/file/blobInfo'].sizeBytes;
|
|
22
|
+
if (range) {
|
|
23
|
+
const newSize = range.to - range.from;
|
|
24
|
+
if (newSize > size) {
|
|
25
|
+
throw new Error(`getSize: range (${JSON.stringify(range)}, newSize: ${newSize}) is greater than size (${size})`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return newSize;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return size;
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
//
|
|
@@ -11,6 +11,7 @@ import { expect, test } from 'vitest';
|
|
|
11
11
|
import { Computable } from '@milaboratories/computable';
|
|
12
12
|
import { SynchronizedTreeState } from '@milaboratories/pl-tree';
|
|
13
13
|
import type { ImportResourceSnapshot } from './types';
|
|
14
|
+
import * as env from '../test_env';
|
|
14
15
|
|
|
15
16
|
test('upload a blob', async () => {
|
|
16
17
|
await withTest(async ({ client, uploader, signer }: TestArg) => {
|
|
@@ -226,8 +227,8 @@ test('index a blob', async () => {
|
|
|
226
227
|
await withTest(async ({ client, uploader }: TestArg) => {
|
|
227
228
|
const uploadId = await createBlobIndex(
|
|
228
229
|
client,
|
|
229
|
-
'
|
|
230
|
-
|
|
230
|
+
'another_answer_to_the_ultimate_question.txt',
|
|
231
|
+
env.libraryStorage,
|
|
231
232
|
);
|
|
232
233
|
const handleRes = await getSnapshot(client, uploadId);
|
|
233
234
|
|
package/src/test_env.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** A storage where we keep all the assets.
|
|
2
|
+
* If you run tests locally, the storage should be named `library` and point
|
|
3
|
+
* to the `assets` directory in this repository,
|
|
4
|
+
* but in CI the storage is defined in env and it points to S3 bucket. */
|
|
5
|
+
export const libraryStorage = process.env.PL_TEST_STORAGE_ID
|
|
6
|
+
? process.env.PL_TEST_STORAGE_ID
|
|
7
|
+
: 'library';
|