@milaboratories/pl-model-common 1.15.0 → 1.15.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-model-common",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "Platforma SDK Model",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -25,7 +25,7 @@
25
25
  "eslint": "^9.25.1",
26
26
  "typescript": "~5.5.4",
27
27
  "vite": "^5.4.11",
28
- "vitest": "^2.1.8",
28
+ "vitest": "^2.1.9",
29
29
  "@platforma-sdk/eslint-config": "1.0.3",
30
30
  "@milaboratories/platforma-build-configs": "1.0.3"
31
31
  },
@@ -21,6 +21,29 @@ export interface BlobHandleAndSize<
21
21
  readonly size: number;
22
22
  }
23
23
 
24
+ /** Range in bytes, from should be less or equal than to. */
25
+ export type RangeBytes = {
26
+ /** Included left border. */
27
+ from: number;
28
+
29
+ /** Excluded right border. */
30
+ to: number;
31
+ };
32
+
33
+ export function newRangeBytesOpt(from?: number, to?: number): RangeBytes | undefined {
34
+ if (from == undefined || to == undefined) {
35
+ return undefined;
36
+ }
37
+
38
+ return { from, to };
39
+ }
40
+
41
+ export function validateRangeBytes(range: RangeBytes, errMsg: string) {
42
+ if (range.from < 0 || range.to < 0 || range.from >= range.to) {
43
+ throw new Error(`${errMsg}: invalid bytes range: ${range}`);
44
+ }
45
+ }
46
+
24
47
  /** Being configured inside the output structure provides information about
25
48
  * locally downloaded blob and means to retrieve it's content when needed. This
26
49
  * structure is created only after the blob's content is downloaded locally, and
@@ -37,5 +60,5 @@ export interface BlobDriver {
37
60
  /** Given the blob handle returns its content. Depending on the handle type,
38
61
  * content will be served from locally downloaded file, or directly from
39
62
  * remote platforma storage. */
40
- getContent(handle: LocalBlobHandle | RemoteBlobHandle): Promise<Uint8Array>;
63
+ getContent(handle: LocalBlobHandle | RemoteBlobHandle, range?: RangeBytes): Promise<Uint8Array>;
41
64
  }
@@ -241,7 +241,7 @@ export function isValueAbsent(absent: Uint8Array, index: number): boolean {
241
241
  return (absent[chunkIndex] & mask) > 0;
242
242
  }
243
243
 
244
- export const PTableAbsent = { type: 'absent' };
244
+ export const PTableAbsent = { type: 'absent' } as const;
245
245
  export type PTableAbsent = typeof PTableAbsent;
246
246
  export const PTableNA = null;
247
247
  export type PTableNA = typeof PTableNA;