@milaboratories/pl-model-common 1.19.14 → 1.19.16
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/drivers/blob.cjs +7 -5
- package/dist/drivers/blob.cjs.map +1 -1
- package/dist/drivers/blob.d.ts +17 -4
- package/dist/drivers/blob.d.ts.map +1 -1
- package/dist/drivers/blob.js +7 -5
- package/dist/drivers/blob.js.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/util.cjs +8 -0
- package/dist/util.cjs.map +1 -1
- package/dist/util.d.ts +5 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +8 -1
- package/dist/util.js.map +1 -1
- package/package.json +5 -5
- package/src/drivers/blob.ts +38 -9
- package/src/index.ts +1 -0
- package/src/util.ts +8 -0
package/dist/drivers/blob.cjs
CHANGED
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
|
|
5
|
-
/** Range in bytes, from should be less
|
|
5
|
+
/** Range in bytes, from should be less than to. */
|
|
6
6
|
const RangeBytes = zod.z.object({
|
|
7
7
|
/** Included left border. */
|
|
8
|
-
from: zod.z.number(),
|
|
8
|
+
from: zod.z.number().min(0),
|
|
9
9
|
/** Excluded right border. */
|
|
10
|
-
to: zod.z.number(),
|
|
10
|
+
to: zod.z.number().min(1),
|
|
11
11
|
});
|
|
12
12
|
function newRangeBytesOpt(from, to) {
|
|
13
13
|
if (from == undefined || to == undefined) {
|
|
14
14
|
return undefined;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
const range = { from, to };
|
|
17
|
+
validateRangeBytes(range, 'newRangeBytesOpt');
|
|
18
|
+
return range;
|
|
17
19
|
}
|
|
18
20
|
function validateRangeBytes(range, errMsg) {
|
|
19
|
-
if (range.from < 0 || range.
|
|
21
|
+
if (range.from < 0 || range.from >= range.to) {
|
|
20
22
|
throw new Error(`${errMsg}: invalid bytes range: ${range}`);
|
|
21
23
|
}
|
|
22
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob.cjs","sources":["../../src/drivers/blob.ts"],"sourcesContent":["import type { Branded } from '../branding';\nimport { z } from 'zod';\n\n/** Handle of locally downloaded blob. This handle is issued only after the\n * blob's content is downloaded locally, and ready for quick access. */\nexport type LocalBlobHandle = Branded<string, 'LocalBlobHandle'>;\n\n/** Handle of remote blob. This handle is issued as soon as the data becomes\n * available on the remote server. */\nexport type RemoteBlobHandle = Branded<string, 'RemoteBlobHandle'>;\n\n/** Being configured inside the output structure provides information about\n * blob's content and means to retrieve it when needed. */\nexport interface BlobHandleAndSize<\n H extends LocalBlobHandle | RemoteBlobHandle = | LocalBlobHandle\n | RemoteBlobHandle,\n> {\n /** Handle to retrieve block content using {@link BlobDriver.getContent()} */\n readonly handle: H;\n\n /** Blob size in bytes. */\n readonly size: number;\n}\n\n/** Range in bytes, from should be less
|
|
1
|
+
{"version":3,"file":"blob.cjs","sources":["../../src/drivers/blob.ts"],"sourcesContent":["import type { Branded } from '../branding';\nimport { z } from 'zod';\n\n/** Handle of locally downloaded blob. This handle is issued only after the\n * blob's content is downloaded locally, and ready for quick access. */\nexport type LocalBlobHandle = Branded<string, 'LocalBlobHandle'>;\n\n/** Handle of remote blob. This handle is issued as soon as the data becomes\n * available on the remote server. */\nexport type RemoteBlobHandle = Branded<string, 'RemoteBlobHandle'>;\n\n/** Being configured inside the output structure provides information about\n * blob's content and means to retrieve it when needed. */\nexport interface BlobHandleAndSize<\n H extends LocalBlobHandle | RemoteBlobHandle = | LocalBlobHandle\n | RemoteBlobHandle,\n> {\n /** Handle to retrieve block content using {@link BlobDriver.getContent()} */\n readonly handle: H;\n\n /** Blob size in bytes. */\n readonly size: number;\n}\n\n/** Range in bytes, from should be less than to. */\nexport const RangeBytes = z.object({\n /** Included left border. */\n from: z.number().min(0),\n /** Excluded right border. */\n to: z.number().min(1),\n});\n\nexport type RangeBytes = z.infer<typeof RangeBytes>;\n\nexport function newRangeBytesOpt(from?: number, to?: number): RangeBytes | undefined {\n if (from == undefined || to == undefined) {\n return undefined;\n }\n\n const range = { from, to };\n validateRangeBytes(range, 'newRangeBytesOpt');\n\n return range;\n}\n\nexport function validateRangeBytes(range: RangeBytes, errMsg: string) {\n if (range.from < 0 || range.from >= range.to) {\n throw new Error(`${errMsg}: invalid bytes range: ${range}`);\n }\n}\n\n/** Being configured inside the output structure provides information about\n * locally downloaded blob and means to retrieve it's content when needed. This\n * structure is created only after the blob's content is downloaded locally, and\n * ready for quick access. */\nexport type LocalBlobHandleAndSize = BlobHandleAndSize<LocalBlobHandle>;\n\n/** Being configured inside the output structure provides information about\n * remote blob and means to retrieve it's content when needed. This structure\n * is created as soon as remote blob becomes available. */\nexport type RemoteBlobHandleAndSize = BlobHandleAndSize<RemoteBlobHandle>;\n\nexport type GetContentOptions = {\n /** Byte range in [from, to) format. */\n range?: RangeBytes;\n /** Signal to abort the operation early. */\n signal?: AbortSignal;\n};\n\nexport type ContentHandler<T> = (content: ReadableStream, size: number) => Promise<T>;\n\n/** Defines API of blob driver as it is seen from the block UI code. */\nexport interface BlobDriver {\n /**\n * Given the blob handle returns its content.\n * Depending on the handle type, content will be served from locally downloaded file,\n * or directly from remote platforma storage.\n */\n getContent(\n handle: LocalBlobHandle | RemoteBlobHandle,\n ): Promise<Uint8Array>;\n getContent(\n handle: LocalBlobHandle | RemoteBlobHandle,\n options?: GetContentOptions,\n ): Promise<Uint8Array>;\n /** @deprecated Use {@link getContent} with {@link GetContentOptions} instead */\n getContent(\n handle: LocalBlobHandle | RemoteBlobHandle,\n range?: RangeBytes,\n ): Promise<Uint8Array>;\n getContent(\n handle: LocalBlobHandle | RemoteBlobHandle,\n optionsOrRange?: GetContentOptions | RangeBytes,\n ): Promise<Uint8Array>;\n}\n"],"names":["z"],"mappings":";;;;AAwBA;AACO,MAAM,UAAU,GAAGA,KAAC,CAAC,MAAM,CAAC;;IAEjC,IAAI,EAAEA,KAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;;IAEvB,EAAE,EAAEA,KAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AACtB,CAAA;AAIK,SAAU,gBAAgB,CAAC,IAAa,EAAE,EAAW,EAAA;IACzD,IAAI,IAAI,IAAI,SAAS,IAAI,EAAE,IAAI,SAAS,EAAE;AACxC,QAAA,OAAO,SAAS;IAClB;AAEA,IAAA,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE;AAC1B,IAAA,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,CAAC;AAE7C,IAAA,OAAO,KAAK;AACd;AAEM,SAAU,kBAAkB,CAAC,KAAiB,EAAE,MAAc,EAAA;AAClE,IAAA,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,EAAE;QAC5C,MAAM,IAAI,KAAK,CAAC,CAAA,EAAG,MAAM,CAAA,uBAAA,EAA0B,KAAK,CAAA,CAAE,CAAC;IAC7D;AACF;;;;;;"}
|
package/dist/drivers/blob.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface BlobHandleAndSize<H extends LocalBlobHandle | RemoteBlobHandle
|
|
|
14
14
|
/** Blob size in bytes. */
|
|
15
15
|
readonly size: number;
|
|
16
16
|
}
|
|
17
|
-
/** Range in bytes, from should be less
|
|
17
|
+
/** Range in bytes, from should be less than to. */
|
|
18
18
|
export declare const RangeBytes: z.ZodObject<{
|
|
19
19
|
/** Included left border. */
|
|
20
20
|
from: z.ZodNumber;
|
|
@@ -39,11 +39,24 @@ export type LocalBlobHandleAndSize = BlobHandleAndSize<LocalBlobHandle>;
|
|
|
39
39
|
* remote blob and means to retrieve it's content when needed. This structure
|
|
40
40
|
* is created as soon as remote blob becomes available. */
|
|
41
41
|
export type RemoteBlobHandleAndSize = BlobHandleAndSize<RemoteBlobHandle>;
|
|
42
|
+
export type GetContentOptions = {
|
|
43
|
+
/** Byte range in [from, to) format. */
|
|
44
|
+
range?: RangeBytes;
|
|
45
|
+
/** Signal to abort the operation early. */
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
};
|
|
48
|
+
export type ContentHandler<T> = (content: ReadableStream, size: number) => Promise<T>;
|
|
42
49
|
/** Defines API of blob driver as it is seen from the block UI code. */
|
|
43
50
|
export interface BlobDriver {
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
51
|
+
/**
|
|
52
|
+
* Given the blob handle returns its content.
|
|
53
|
+
* Depending on the handle type, content will be served from locally downloaded file,
|
|
54
|
+
* or directly from remote platforma storage.
|
|
55
|
+
*/
|
|
56
|
+
getContent(handle: LocalBlobHandle | RemoteBlobHandle): Promise<Uint8Array>;
|
|
57
|
+
getContent(handle: LocalBlobHandle | RemoteBlobHandle, options?: GetContentOptions): Promise<Uint8Array>;
|
|
58
|
+
/** @deprecated Use {@link getContent} with {@link GetContentOptions} instead */
|
|
47
59
|
getContent(handle: LocalBlobHandle | RemoteBlobHandle, range?: RangeBytes): Promise<Uint8Array>;
|
|
60
|
+
getContent(handle: LocalBlobHandle | RemoteBlobHandle, optionsOrRange?: GetContentOptions | RangeBytes): Promise<Uint8Array>;
|
|
48
61
|
}
|
|
49
62
|
//# sourceMappingURL=blob.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/drivers/blob.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;uEACuE;AACvE,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAEjE;qCACqC;AACrC,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAEnE;0DAC0D;AAC1D,MAAM,WAAW,iBAAiB,CAChC,CAAC,SAAS,eAAe,GAAG,gBAAgB,GAAK,eAAe,GAC9D,gBAAgB;IAElB,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAEnB,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,
|
|
1
|
+
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/drivers/blob.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;uEACuE;AACvE,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAEjE;qCACqC;AACrC,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAEnE;0DAC0D;AAC1D,MAAM,WAAW,iBAAiB,CAChC,CAAC,SAAS,eAAe,GAAG,gBAAgB,GAAK,eAAe,GAC9D,gBAAgB;IAElB,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAEnB,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,mDAAmD;AACnD,eAAO,MAAM,UAAU;IACrB,4BAA4B;;IAE5B,6BAA6B;;;;;;;;EAE7B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CASnF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,QAInE;AAED;;;6BAG6B;AAC7B,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,eAAe,CAAC,CAAC;AAExE;;0DAE0D;AAC1D,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;AAE1E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,uCAAuC;IACvC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtF,uEAAuE;AACvE,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,UAAU,CACR,MAAM,EAAE,eAAe,GAAG,gBAAgB,GACzC,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,UAAU,CACR,MAAM,EAAE,eAAe,GAAG,gBAAgB,EAC1C,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,gFAAgF;IAChF,UAAU,CACR,MAAM,EAAE,eAAe,GAAG,gBAAgB,EAC1C,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,UAAU,CACR,MAAM,EAAE,eAAe,GAAG,gBAAgB,EAC1C,cAAc,CAAC,EAAE,iBAAiB,GAAG,UAAU,GAC9C,OAAO,CAAC,UAAU,CAAC,CAAC;CACxB"}
|
package/dist/drivers/blob.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
/** Range in bytes, from should be less
|
|
3
|
+
/** Range in bytes, from should be less than to. */
|
|
4
4
|
const RangeBytes = z.object({
|
|
5
5
|
/** Included left border. */
|
|
6
|
-
from: z.number(),
|
|
6
|
+
from: z.number().min(0),
|
|
7
7
|
/** Excluded right border. */
|
|
8
|
-
to: z.number(),
|
|
8
|
+
to: z.number().min(1),
|
|
9
9
|
});
|
|
10
10
|
function newRangeBytesOpt(from, to) {
|
|
11
11
|
if (from == undefined || to == undefined) {
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const range = { from, to };
|
|
15
|
+
validateRangeBytes(range, 'newRangeBytesOpt');
|
|
16
|
+
return range;
|
|
15
17
|
}
|
|
16
18
|
function validateRangeBytes(range, errMsg) {
|
|
17
|
-
if (range.from < 0 || range.
|
|
19
|
+
if (range.from < 0 || range.from >= range.to) {
|
|
18
20
|
throw new Error(`${errMsg}: invalid bytes range: ${range}`);
|
|
19
21
|
}
|
|
20
22
|
}
|
package/dist/drivers/blob.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob.js","sources":["../../src/drivers/blob.ts"],"sourcesContent":["import type { Branded } from '../branding';\nimport { z } from 'zod';\n\n/** Handle of locally downloaded blob. This handle is issued only after the\n * blob's content is downloaded locally, and ready for quick access. */\nexport type LocalBlobHandle = Branded<string, 'LocalBlobHandle'>;\n\n/** Handle of remote blob. This handle is issued as soon as the data becomes\n * available on the remote server. */\nexport type RemoteBlobHandle = Branded<string, 'RemoteBlobHandle'>;\n\n/** Being configured inside the output structure provides information about\n * blob's content and means to retrieve it when needed. */\nexport interface BlobHandleAndSize<\n H extends LocalBlobHandle | RemoteBlobHandle = | LocalBlobHandle\n | RemoteBlobHandle,\n> {\n /** Handle to retrieve block content using {@link BlobDriver.getContent()} */\n readonly handle: H;\n\n /** Blob size in bytes. */\n readonly size: number;\n}\n\n/** Range in bytes, from should be less
|
|
1
|
+
{"version":3,"file":"blob.js","sources":["../../src/drivers/blob.ts"],"sourcesContent":["import type { Branded } from '../branding';\nimport { z } from 'zod';\n\n/** Handle of locally downloaded blob. This handle is issued only after the\n * blob's content is downloaded locally, and ready for quick access. */\nexport type LocalBlobHandle = Branded<string, 'LocalBlobHandle'>;\n\n/** Handle of remote blob. This handle is issued as soon as the data becomes\n * available on the remote server. */\nexport type RemoteBlobHandle = Branded<string, 'RemoteBlobHandle'>;\n\n/** Being configured inside the output structure provides information about\n * blob's content and means to retrieve it when needed. */\nexport interface BlobHandleAndSize<\n H extends LocalBlobHandle | RemoteBlobHandle = | LocalBlobHandle\n | RemoteBlobHandle,\n> {\n /** Handle to retrieve block content using {@link BlobDriver.getContent()} */\n readonly handle: H;\n\n /** Blob size in bytes. */\n readonly size: number;\n}\n\n/** Range in bytes, from should be less than to. */\nexport const RangeBytes = z.object({\n /** Included left border. */\n from: z.number().min(0),\n /** Excluded right border. */\n to: z.number().min(1),\n});\n\nexport type RangeBytes = z.infer<typeof RangeBytes>;\n\nexport function newRangeBytesOpt(from?: number, to?: number): RangeBytes | undefined {\n if (from == undefined || to == undefined) {\n return undefined;\n }\n\n const range = { from, to };\n validateRangeBytes(range, 'newRangeBytesOpt');\n\n return range;\n}\n\nexport function validateRangeBytes(range: RangeBytes, errMsg: string) {\n if (range.from < 0 || range.from >= range.to) {\n throw new Error(`${errMsg}: invalid bytes range: ${range}`);\n }\n}\n\n/** Being configured inside the output structure provides information about\n * locally downloaded blob and means to retrieve it's content when needed. This\n * structure is created only after the blob's content is downloaded locally, and\n * ready for quick access. */\nexport type LocalBlobHandleAndSize = BlobHandleAndSize<LocalBlobHandle>;\n\n/** Being configured inside the output structure provides information about\n * remote blob and means to retrieve it's content when needed. This structure\n * is created as soon as remote blob becomes available. */\nexport type RemoteBlobHandleAndSize = BlobHandleAndSize<RemoteBlobHandle>;\n\nexport type GetContentOptions = {\n /** Byte range in [from, to) format. */\n range?: RangeBytes;\n /** Signal to abort the operation early. */\n signal?: AbortSignal;\n};\n\nexport type ContentHandler<T> = (content: ReadableStream, size: number) => Promise<T>;\n\n/** Defines API of blob driver as it is seen from the block UI code. */\nexport interface BlobDriver {\n /**\n * Given the blob handle returns its content.\n * Depending on the handle type, content will be served from locally downloaded file,\n * or directly from remote platforma storage.\n */\n getContent(\n handle: LocalBlobHandle | RemoteBlobHandle,\n ): Promise<Uint8Array>;\n getContent(\n handle: LocalBlobHandle | RemoteBlobHandle,\n options?: GetContentOptions,\n ): Promise<Uint8Array>;\n /** @deprecated Use {@link getContent} with {@link GetContentOptions} instead */\n getContent(\n handle: LocalBlobHandle | RemoteBlobHandle,\n range?: RangeBytes,\n ): Promise<Uint8Array>;\n getContent(\n handle: LocalBlobHandle | RemoteBlobHandle,\n optionsOrRange?: GetContentOptions | RangeBytes,\n ): Promise<Uint8Array>;\n}\n"],"names":[],"mappings":";;AAwBA;AACO,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;;IAEjC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;;IAEvB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AACtB,CAAA;AAIK,SAAU,gBAAgB,CAAC,IAAa,EAAE,EAAW,EAAA;IACzD,IAAI,IAAI,IAAI,SAAS,IAAI,EAAE,IAAI,SAAS,EAAE;AACxC,QAAA,OAAO,SAAS;IAClB;AAEA,IAAA,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE;AAC1B,IAAA,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,CAAC;AAE7C,IAAA,OAAO,KAAK;AACd;AAEM,SAAU,kBAAkB,CAAC,KAAiB,EAAE,MAAc,EAAA;AAClE,IAAA,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,EAAE;QAC5C,MAAM,IAAI,KAAK,CAAC,CAAA,EAAG,MAAM,CAAA,uBAAA,EAA0B,KAAK,CAAA,CAAE,CAAC;IAC7D;AACF;;;;"}
|
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ var query = require('./pool/query.cjs');
|
|
|
28
28
|
var ref = require('./ref.cjs');
|
|
29
29
|
var value_or_error = require('./value_or_error.cjs');
|
|
30
30
|
var base64 = require('./base64.cjs');
|
|
31
|
+
var util = require('./util.cjs');
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
|
|
@@ -150,4 +151,6 @@ exports.withEnrichments = ref.withEnrichments;
|
|
|
150
151
|
exports.mapValueInVOE = value_or_error.mapValueInVOE;
|
|
151
152
|
exports.base64Decode = base64.base64Decode;
|
|
152
153
|
exports.base64Encode = base64.base64Encode;
|
|
154
|
+
exports.assertNever = util.assertNever;
|
|
155
|
+
exports.uniqueBy = util.uniqueBy;
|
|
153
156
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,4 +26,5 @@ export { executePSpecPredicate } from './pool/query.js';
|
|
|
26
26
|
export { PlRef, createPlRef, isPlRef, plRefsEqual, withEnrichments } from './ref.js';
|
|
27
27
|
export { mapValueInVOE } from './value_or_error.js';
|
|
28
28
|
export { base64Decode, base64Encode } from './base64.js';
|
|
29
|
+
export { assertNever, uniqueBy } from './util.js';
|
|
29
30
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/util.cjs
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
function assertNever(x) {
|
|
4
4
|
throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Return unique entries of the array by the provided id
|
|
8
|
+
* For each id, the last entry is kept
|
|
9
|
+
*/
|
|
10
|
+
function uniqueBy(array, makeId) {
|
|
11
|
+
return [...new Map(array.map((e) => [makeId(e), e])).values()];
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
exports.assertNever = assertNever;
|
|
15
|
+
exports.uniqueBy = uniqueBy;
|
|
8
16
|
//# sourceMappingURL=util.cjs.map
|
package/dist/util.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.cjs","sources":["../src/util.ts"],"sourcesContent":["export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error\n}\n"],"names":[],"mappings":";;AAAM,SAAU,WAAW,CAAC,CAAQ,EAAA;IAClC,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;AAC7C
|
|
1
|
+
{"version":3,"file":"util.cjs","sources":["../src/util.ts"],"sourcesContent":["export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error\n}\n\n/**\n * Return unique entries of the array by the provided id\n * For each id, the last entry is kept\n */\nexport function uniqueBy<T>(array: T[], makeId: (entry: T) => string): T[] {\n return [...new Map(array.map((e) => [makeId(e), e])).values()];\n}\n"],"names":[],"mappings":";;AAAM,SAAU,WAAW,CAAC,CAAQ,EAAA;IAClC,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;AAC7C;AAEA;;;AAGG;AACG,SAAU,QAAQ,CAAI,KAAU,EAAE,MAA4B,EAAA;AAClE,IAAA,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;AAChE;;;;;"}
|
package/dist/util.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export declare function assertNever(x: never): never;
|
|
2
|
+
/**
|
|
3
|
+
* Return unique entries of the array by the provided id
|
|
4
|
+
* For each id, the last entry is kept
|
|
5
|
+
*/
|
|
6
|
+
export declare function uniqueBy<T>(array: T[], makeId: (entry: T) => string): T[];
|
|
2
7
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAE3C"}
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAE3C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,EAAE,CAEzE"}
|
package/dist/util.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
function assertNever(x) {
|
|
2
2
|
throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error
|
|
3
3
|
}
|
|
4
|
+
/**
|
|
5
|
+
* Return unique entries of the array by the provided id
|
|
6
|
+
* For each id, the last entry is kept
|
|
7
|
+
*/
|
|
8
|
+
function uniqueBy(array, makeId) {
|
|
9
|
+
return [...new Map(array.map((e) => [makeId(e), e])).values()];
|
|
10
|
+
}
|
|
4
11
|
|
|
5
|
-
export { assertNever };
|
|
12
|
+
export { assertNever, uniqueBy };
|
|
6
13
|
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sources":["../src/util.ts"],"sourcesContent":["export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error\n}\n"],"names":[],"mappings":"AAAM,SAAU,WAAW,CAAC,CAAQ,EAAA;IAClC,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;AAC7C;;;;"}
|
|
1
|
+
{"version":3,"file":"util.js","sources":["../src/util.ts"],"sourcesContent":["export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error\n}\n\n/**\n * Return unique entries of the array by the provided id\n * For each id, the last entry is kept\n */\nexport function uniqueBy<T>(array: T[], makeId: (entry: T) => string): T[] {\n return [...new Map(array.map((e) => [makeId(e), e])).values()];\n}\n"],"names":[],"mappings":"AAAM,SAAU,WAAW,CAAC,CAAQ,EAAA;IAClC,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;AAC7C;AAEA;;;AAGG;AACG,SAAU,QAAQ,CAAI,KAAU,EAAE,MAA4B,EAAA;AAClE,IAAA,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;AAChE;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-model-common",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.16",
|
|
4
4
|
"description": "Platforma SDK Model",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"zod": "~3.23.8",
|
|
21
21
|
"canonicalize": "~2.1.0",
|
|
22
|
-
"@milaboratories/pl-error-like": "1.12.
|
|
22
|
+
"@milaboratories/pl-error-like": "1.12.5"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"eslint": "^9.25.1",
|
|
26
26
|
"typescript": "~5.6.3",
|
|
27
27
|
"vitest": "^2.1.9",
|
|
28
|
-
"@milaboratories/build-configs": "1.0.8",
|
|
29
|
-
"@milaboratories/ts-builder": "1.0.5",
|
|
30
28
|
"@platforma-sdk/eslint-config": "1.0.3",
|
|
31
|
-
"@milaboratories/
|
|
29
|
+
"@milaboratories/build-configs": "1.0.8",
|
|
30
|
+
"@milaboratories/ts-configs": "1.0.6",
|
|
31
|
+
"@milaboratories/ts-builder": "1.0.5"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"type-check": "ts-builder types --target node",
|
package/src/drivers/blob.ts
CHANGED
|
@@ -22,12 +22,12 @@ export interface BlobHandleAndSize<
|
|
|
22
22
|
readonly size: number;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/** Range in bytes, from should be less
|
|
25
|
+
/** Range in bytes, from should be less than to. */
|
|
26
26
|
export const RangeBytes = z.object({
|
|
27
27
|
/** Included left border. */
|
|
28
|
-
from: z.number(),
|
|
28
|
+
from: z.number().min(0),
|
|
29
29
|
/** Excluded right border. */
|
|
30
|
-
to: z.number(),
|
|
30
|
+
to: z.number().min(1),
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
export type RangeBytes = z.infer<typeof RangeBytes>;
|
|
@@ -37,11 +37,14 @@ export function newRangeBytesOpt(from?: number, to?: number): RangeBytes | undef
|
|
|
37
37
|
return undefined;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const range = { from, to };
|
|
41
|
+
validateRangeBytes(range, 'newRangeBytesOpt');
|
|
42
|
+
|
|
43
|
+
return range;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export function validateRangeBytes(range: RangeBytes, errMsg: string) {
|
|
44
|
-
if (range.from < 0 || range.
|
|
47
|
+
if (range.from < 0 || range.from >= range.to) {
|
|
45
48
|
throw new Error(`${errMsg}: invalid bytes range: ${range}`);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
@@ -57,10 +60,36 @@ export type LocalBlobHandleAndSize = BlobHandleAndSize<LocalBlobHandle>;
|
|
|
57
60
|
* is created as soon as remote blob becomes available. */
|
|
58
61
|
export type RemoteBlobHandleAndSize = BlobHandleAndSize<RemoteBlobHandle>;
|
|
59
62
|
|
|
63
|
+
export type GetContentOptions = {
|
|
64
|
+
/** Byte range in [from, to) format. */
|
|
65
|
+
range?: RangeBytes;
|
|
66
|
+
/** Signal to abort the operation early. */
|
|
67
|
+
signal?: AbortSignal;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type ContentHandler<T> = (content: ReadableStream, size: number) => Promise<T>;
|
|
71
|
+
|
|
60
72
|
/** Defines API of blob driver as it is seen from the block UI code. */
|
|
61
73
|
export interface BlobDriver {
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Given the blob handle returns its content.
|
|
76
|
+
* Depending on the handle type, content will be served from locally downloaded file,
|
|
77
|
+
* or directly from remote platforma storage.
|
|
78
|
+
*/
|
|
79
|
+
getContent(
|
|
80
|
+
handle: LocalBlobHandle | RemoteBlobHandle,
|
|
81
|
+
): Promise<Uint8Array>;
|
|
82
|
+
getContent(
|
|
83
|
+
handle: LocalBlobHandle | RemoteBlobHandle,
|
|
84
|
+
options?: GetContentOptions,
|
|
85
|
+
): Promise<Uint8Array>;
|
|
86
|
+
/** @deprecated Use {@link getContent} with {@link GetContentOptions} instead */
|
|
87
|
+
getContent(
|
|
88
|
+
handle: LocalBlobHandle | RemoteBlobHandle,
|
|
89
|
+
range?: RangeBytes,
|
|
90
|
+
): Promise<Uint8Array>;
|
|
91
|
+
getContent(
|
|
92
|
+
handle: LocalBlobHandle | RemoteBlobHandle,
|
|
93
|
+
optionsOrRange?: GetContentOptions | RangeBytes,
|
|
94
|
+
): Promise<Uint8Array>;
|
|
66
95
|
}
|
package/src/index.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
export function assertNever(x: never): never {
|
|
2
2
|
throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error
|
|
3
3
|
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Return unique entries of the array by the provided id
|
|
7
|
+
* For each id, the last entry is kept
|
|
8
|
+
*/
|
|
9
|
+
export function uniqueBy<T>(array: T[], makeId: (entry: T) => string): T[] {
|
|
10
|
+
return [...new Map(array.map((e) => [makeId(e), e])).values()];
|
|
11
|
+
}
|