@milaboratories/pl-model-common 1.11.1 → 1.11.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/dist/block_state.d.ts.map +1 -1
- package/dist/common_types.d.ts +2 -0
- package/dist/common_types.d.ts.map +1 -1
- package/dist/driver_kit.d.ts.map +1 -1
- package/dist/drivers/blob.d.ts.map +1 -1
- package/dist/drivers/log.d.ts.map +1 -1
- package/dist/drivers/ls.d.ts.map +1 -1
- package/dist/drivers/pframe/column_filter.d.ts.map +1 -1
- package/dist/drivers/pframe/data.d.ts +1 -1
- package/dist/drivers/pframe/data.d.ts.map +1 -1
- package/dist/drivers/pframe/driver.d.ts +1 -1
- package/dist/drivers/pframe/driver.d.ts.map +1 -1
- package/dist/drivers/pframe/find_columns.d.ts.map +1 -1
- package/dist/drivers/pframe/pframe.d.ts.map +1 -1
- package/dist/drivers/pframe/table.d.ts.map +1 -1
- package/dist/drivers/pframe/table_calculate.d.ts.map +1 -1
- package/dist/drivers/pframe/table_common.d.ts.map +1 -1
- package/dist/drivers/pframe/unique_values.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -12
- package/dist/index.mjs.map +1 -1
- package/dist/pool/entry.d.ts.map +1 -1
- package/dist/pool/query.d.ts.map +1 -1
- package/dist/pool/spec.d.ts.map +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/value_or_error.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/base32-encode.ts +3 -3
- package/src/block_state.ts +3 -3
- package/src/common_types.ts +3 -0
- package/src/driver_kit.ts +1 -1
- package/src/drivers/blob.ts +3 -4
- package/src/drivers/log.ts +1 -1
- package/src/drivers/ls.ts +16 -16
- package/src/drivers/pframe/column_filter.ts +2 -2
- package/src/drivers/pframe/data.ts +21 -21
- package/src/drivers/pframe/driver.ts +14 -14
- package/src/drivers/pframe/find_columns.ts +2 -2
- package/src/drivers/pframe/pframe.ts +6 -6
- package/src/drivers/pframe/spec/selectors.ts +1 -1
- package/src/drivers/pframe/table.ts +2 -2
- package/src/drivers/pframe/table_calculate.ts +7 -7
- package/src/drivers/pframe/table_common.ts +10 -10
- package/src/drivers/pframe/type_util.ts +2 -2
- package/src/drivers/pframe/unique_values.ts +4 -4
- package/src/navigation.ts +1 -1
- package/src/pool/entry.ts +1 -1
- package/src/pool/query.ts +47 -45
- package/src/pool/spec.ts +7 -7
- package/src/ref.ts +11 -11
- package/src/util.ts +2 -1
- package/src/value_or_error.ts +7 -7
package/src/drivers/ls.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assertNever } from '../util';
|
|
2
|
-
import { Branded } from '../branding';
|
|
3
|
-
import { TableRange } from './pframe';
|
|
4
|
-
import { FileLike } from './interfaces';
|
|
2
|
+
import type { Branded } from '../branding';
|
|
3
|
+
import type { TableRange } from './pframe';
|
|
4
|
+
import type { FileLike } from './interfaces';
|
|
5
5
|
|
|
6
6
|
const uploadPrefix = 'upload://upload/';
|
|
7
7
|
const indexPrefix = 'index://index/';
|
|
@@ -14,7 +14,7 @@ export type ImportFileHandle = ImportFileHandleUpload | ImportFileHandleIndex;
|
|
|
14
14
|
export type LocalImportFileHandle = Branded<ImportFileHandle, 'Local'>;
|
|
15
15
|
|
|
16
16
|
export function isImportFileHandleUpload(
|
|
17
|
-
handle: ImportFileHandle
|
|
17
|
+
handle: ImportFileHandle,
|
|
18
18
|
): handle is ImportFileHandleUpload {
|
|
19
19
|
return handle.startsWith(uploadPrefix);
|
|
20
20
|
}
|
|
@@ -47,18 +47,18 @@ export type ListFilesResult = {
|
|
|
47
47
|
|
|
48
48
|
export type LsEntry =
|
|
49
49
|
| {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
type: 'dir';
|
|
51
|
+
name: string;
|
|
52
|
+
fullPath: string;
|
|
53
|
+
}
|
|
54
54
|
| {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
type: 'file';
|
|
56
|
+
name: string;
|
|
57
|
+
fullPath: string;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
/** This handle should be set to args... */
|
|
60
|
+
handle: ImportFileHandle;
|
|
61
|
+
};
|
|
62
62
|
|
|
63
63
|
export type OpenDialogFilter = {
|
|
64
64
|
/** Human-readable file type name */
|
|
@@ -127,11 +127,11 @@ export interface LsDriver {
|
|
|
127
127
|
export function getFilePathFromHandle(handle: ImportFileHandle): string {
|
|
128
128
|
if (isImportFileHandleIndex(handle)) {
|
|
129
129
|
const trimmed = handle.slice(indexPrefix.length);
|
|
130
|
-
const data = JSON.parse(decodeURIComponent(trimmed));
|
|
130
|
+
const data = JSON.parse(decodeURIComponent(trimmed)) as { path: string };
|
|
131
131
|
return data.path;
|
|
132
132
|
} else if (isImportFileHandleUpload(handle)) {
|
|
133
133
|
const trimmed = handle.slice(uploadPrefix.length);
|
|
134
|
-
const data = JSON.parse(decodeURIComponent(trimmed));
|
|
134
|
+
const data = JSON.parse(decodeURIComponent(trimmed)) as { localPath: string };
|
|
135
135
|
return data.localPath;
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValueType } from './spec/spec';
|
|
1
|
+
import type { ValueType } from './spec/spec';
|
|
2
2
|
|
|
3
3
|
/** Allows to search multiple columns in different contexts. */
|
|
4
4
|
export interface ColumnFilter {
|
|
@@ -10,7 +10,7 @@ export interface ColumnFilter {
|
|
|
10
10
|
* matching. */
|
|
11
11
|
readonly name?: string[];
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/** Match requires all the domains listed here to have corresponding values. */
|
|
14
14
|
readonly domainValue?: Record<string, string>;
|
|
15
15
|
|
|
16
16
|
/** Match requires all the annotations listed here to have corresponding values. */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ValueType } from './spec/spec';
|
|
1
|
+
import type { ValueType } from './spec/spec';
|
|
3
2
|
|
|
4
3
|
export const PValueIntNA = -2147483648;
|
|
5
4
|
export const PValueLongNA = -9007199254740991n;
|
|
@@ -26,8 +25,9 @@ export type NotNAPValue = number | bigint | string;
|
|
|
26
25
|
export type PValue =
|
|
27
26
|
| PValueInt
|
|
28
27
|
| PValueLong
|
|
29
|
-
|
|
30
|
-
|
|
|
28
|
+
// Doesn't differ from PValueInt, TODO: branded types for these PValue* types?
|
|
29
|
+
// | PValueFloat
|
|
30
|
+
// | PValueDouble
|
|
31
31
|
| PValueString
|
|
32
32
|
| PValueBytes;
|
|
33
33
|
|
|
@@ -69,9 +69,9 @@ export function isNotNAPValue(value: unknown): value is NotNAPValue;
|
|
|
69
69
|
export function isNotNAPValue(value: unknown, valueType?: ValueType): boolean {
|
|
70
70
|
if (!valueType)
|
|
71
71
|
return (
|
|
72
|
-
typeof value === 'string'
|
|
73
|
-
(typeof value === 'number' && isFinite(value))
|
|
74
|
-
typeof value === 'bigint'
|
|
72
|
+
typeof value === 'string'
|
|
73
|
+
|| (typeof value === 'number' && isFinite(value))
|
|
74
|
+
|| typeof value === 'bigint'
|
|
75
75
|
);
|
|
76
76
|
if (isValueNA(value, valueType)) return false;
|
|
77
77
|
switch (valueType) {
|
|
@@ -102,10 +102,10 @@ export function isPValue(value: unknown): value is PValue;
|
|
|
102
102
|
export function isPValue(value: unknown, valueType?: ValueType): boolean {
|
|
103
103
|
if (!valueType)
|
|
104
104
|
return (
|
|
105
|
-
value === null
|
|
106
|
-
typeof value === 'string'
|
|
107
|
-
typeof value === 'number'
|
|
108
|
-
typeof value === 'bigint'
|
|
105
|
+
value === null
|
|
106
|
+
|| typeof value === 'string'
|
|
107
|
+
|| typeof value === 'number'
|
|
108
|
+
|| typeof value === 'bigint'
|
|
109
109
|
);
|
|
110
110
|
if (isValueNA(value, valueType)) return true;
|
|
111
111
|
switch (valueType) {
|
|
@@ -146,10 +146,10 @@ export function toJsonSafePValue(value: PValue): PValueJsonSafe {
|
|
|
146
146
|
*/
|
|
147
147
|
export function safeConvertToPValue(value: unknown, checkType?: ValueType): PValue {
|
|
148
148
|
if (
|
|
149
|
-
value === null
|
|
150
|
-
typeof value === 'string'
|
|
151
|
-
typeof value === 'number'
|
|
152
|
-
typeof value === 'bigint'
|
|
149
|
+
value === null
|
|
150
|
+
|| typeof value === 'string'
|
|
151
|
+
|| typeof value === 'number'
|
|
152
|
+
|| typeof value === 'bigint'
|
|
153
153
|
) {
|
|
154
154
|
if (checkType && !isValueNA(value, checkType) && !isPValue(value, checkType))
|
|
155
155
|
throw new Error(`Unexpected value type, got ${typeof value}, expected ${checkType}`);
|
|
@@ -157,10 +157,10 @@ export function safeConvertToPValue(value: unknown, checkType?: ValueType): PVal
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
if (
|
|
160
|
-
typeof value === 'object'
|
|
161
|
-
value !== null
|
|
162
|
-
'bigint' in value
|
|
163
|
-
typeof value.bigint === 'string'
|
|
160
|
+
typeof value === 'object'
|
|
161
|
+
&& value !== null
|
|
162
|
+
&& 'bigint' in value
|
|
163
|
+
&& typeof value.bigint === 'string'
|
|
164
164
|
) {
|
|
165
165
|
if (checkType && checkType !== 'Long')
|
|
166
166
|
throw new Error(`Unexpected value type, got serialized bigint, expected ${checkType}`);
|
|
@@ -186,7 +186,7 @@ export function pValueToStringOrNumberOrNull(
|
|
|
186
186
|
value: PValue | PValueJsonSafe
|
|
187
187
|
): string | number | null;
|
|
188
188
|
export function pValueToStringOrNumberOrNull(
|
|
189
|
-
value: PValue | PValueJsonSafe
|
|
189
|
+
value: PValue | PValueJsonSafe,
|
|
190
190
|
): string | number | null {
|
|
191
191
|
value = safeConvertToPValue(value);
|
|
192
192
|
if (value === null) return null;
|
|
@@ -270,7 +270,7 @@ export type AbsentAndNAFill = {
|
|
|
270
270
|
export function pTableValue(
|
|
271
271
|
column: PTableVector,
|
|
272
272
|
row: number,
|
|
273
|
-
fill: AbsentAndNAFill = {}
|
|
273
|
+
fill: AbsentAndNAFill = {},
|
|
274
274
|
): PTableValue {
|
|
275
275
|
if (isValueAbsent(column.absent, row))
|
|
276
276
|
return fill.absent === undefined ? PTableAbsent : fill.absent;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Branded } from '../../branding';
|
|
2
|
-
import { PTable } from './table';
|
|
3
|
-
import { PFrame } from './pframe';
|
|
4
|
-
import { AddParameterToAllMethods } from './type_util';
|
|
5
|
-
import { PTableShape, PTableVector, TableRange } from './data';
|
|
6
|
-
import { FindColumnsRequest, FindColumnsResponse } from './find_columns';
|
|
7
|
-
import { PObjectId } from '../../pool';
|
|
8
|
-
import { PColumnIdAndSpec, PColumnSpec } from './spec/spec';
|
|
9
|
-
import {
|
|
1
|
+
import type { Branded } from '../../branding';
|
|
2
|
+
import type { PTable } from './table';
|
|
3
|
+
import type { PFrame } from './pframe';
|
|
4
|
+
import type { AddParameterToAllMethods } from './type_util';
|
|
5
|
+
import type { PTableShape, PTableVector, TableRange } from './data';
|
|
6
|
+
import type { FindColumnsRequest, FindColumnsResponse } from './find_columns';
|
|
7
|
+
import type { PObjectId } from '../../pool';
|
|
8
|
+
import type { PColumnIdAndSpec, PColumnSpec } from './spec/spec';
|
|
9
|
+
import type {
|
|
10
10
|
CalculateTableDataRequest,
|
|
11
|
-
CalculateTableDataResponse
|
|
11
|
+
CalculateTableDataResponse,
|
|
12
12
|
} from './table_calculate';
|
|
13
|
-
import { UniqueValuesRequest, UniqueValuesResponse } from './unique_values';
|
|
14
|
-
import { PTableColumnSpec } from './table_common';
|
|
13
|
+
import type { UniqueValuesRequest, UniqueValuesResponse } from './unique_values';
|
|
14
|
+
import type { PTableColumnSpec } from './table_common';
|
|
15
15
|
|
|
16
16
|
/** PFrame handle */
|
|
17
17
|
export type PFrameHandle = Branded<string, 'PFrame'>;
|
|
@@ -84,7 +84,7 @@ export interface PFrameDriver {
|
|
|
84
84
|
getData(
|
|
85
85
|
handle: PTableHandle,
|
|
86
86
|
columnIndices: number[],
|
|
87
|
-
range?: TableRange
|
|
87
|
+
range?: TableRange
|
|
88
88
|
): Promise<PTableVector[]>;
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -105,6 +105,6 @@ type ExpectedPFrameDriverType = ExpectedPFrameDriverTypeF &
|
|
|
105
105
|
ExpectedPFrameDriverTypeT;
|
|
106
106
|
|
|
107
107
|
type TypeEqualityGuard<A, B> = Exclude<A, B> | Exclude<B, A>;
|
|
108
|
-
function assert<
|
|
108
|
+
function assert<_T extends never>() {}
|
|
109
109
|
|
|
110
110
|
assert<TypeEqualityGuard<PFrameDriver, ExpectedPFrameDriverType>>();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ColumnFilter } from './column_filter';
|
|
2
|
-
import { AxisId, PColumnIdAndSpec } from './spec/spec';
|
|
1
|
+
import type { ColumnFilter } from './column_filter';
|
|
2
|
+
import type { AxisId, PColumnIdAndSpec } from './spec/spec';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Request to search among existing columns in the PFrame. Two filtering
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { PObjectId } from '../../pool';
|
|
2
|
-
import { FindColumnsRequest, FindColumnsResponse } from './find_columns';
|
|
3
|
-
import { PColumn, PColumnIdAndSpec, PColumnSpec } from './spec/spec';
|
|
4
|
-
import {
|
|
1
|
+
import type { PObjectId } from '../../pool';
|
|
2
|
+
import type { FindColumnsRequest, FindColumnsResponse } from './find_columns';
|
|
3
|
+
import type { PColumn, PColumnIdAndSpec, PColumnSpec } from './spec/spec';
|
|
4
|
+
import type {
|
|
5
5
|
CalculateTableDataRequest,
|
|
6
|
-
CalculateTableDataResponse
|
|
6
|
+
CalculateTableDataResponse,
|
|
7
7
|
} from './table_calculate';
|
|
8
|
-
import { UniqueValuesRequest, UniqueValuesResponse } from './unique_values';
|
|
8
|
+
import type { UniqueValuesRequest, UniqueValuesResponse } from './unique_values';
|
|
9
9
|
|
|
10
10
|
/** Read interface exposed by PFrames library */
|
|
11
11
|
export interface PFrame {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPColumnSpec, type PObjectSpec } from '../../../pool';
|
|
2
2
|
import type { AxisId, PColumnSpec, ValueType } from './spec';
|
|
3
|
-
import { getAxisId
|
|
3
|
+
import { getAxisId } from './spec';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Defines a pattern for matching axes within the PFrame data model.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PTableColumnSpec } from './table_common';
|
|
2
|
-
import { PTableShape, PTableVector, TableRange } from './data';
|
|
1
|
+
import type { PTableColumnSpec } from './table_common';
|
|
2
|
+
import type { PTableShape, PTableVector, TableRange } from './data';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Table view.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PTableColumnId, PTableColumnSpec } from './table_common';
|
|
2
|
-
import { PTableVector } from './data';
|
|
1
|
+
import type { PTableColumnId, PTableColumnSpec } from './table_common';
|
|
2
|
+
import type { PTableVector } from './data';
|
|
3
3
|
import { assertNever } from '../../util';
|
|
4
4
|
|
|
5
5
|
/** Defines a terminal column node in the join request tree */
|
|
@@ -310,32 +310,32 @@ export type CalculateTableDataResponse = FullPTableColumnData[];
|
|
|
310
310
|
|
|
311
311
|
export function mapPTableDef<C1, C2>(
|
|
312
312
|
def: PTableDef<C1>,
|
|
313
|
-
cb: (c: C1) => C2
|
|
313
|
+
cb: (c: C1) => C2,
|
|
314
314
|
): PTableDef<C2> {
|
|
315
315
|
return { ...def, src: mapJoinEntry(def.src, cb) };
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
export function mapJoinEntry<C1, C2>(
|
|
319
319
|
entry: JoinEntry<C1>,
|
|
320
|
-
cb: (c: C1) => C2
|
|
320
|
+
cb: (c: C1) => C2,
|
|
321
321
|
): JoinEntry<C2> {
|
|
322
322
|
switch (entry.type) {
|
|
323
323
|
case 'column':
|
|
324
324
|
return {
|
|
325
325
|
type: 'column',
|
|
326
|
-
column: cb(entry.column)
|
|
326
|
+
column: cb(entry.column),
|
|
327
327
|
};
|
|
328
328
|
case 'inner':
|
|
329
329
|
case 'full':
|
|
330
330
|
return {
|
|
331
331
|
type: entry.type,
|
|
332
|
-
entries: entry.entries.map((col) => mapJoinEntry(col, cb))
|
|
332
|
+
entries: entry.entries.map((col) => mapJoinEntry(col, cb)),
|
|
333
333
|
};
|
|
334
334
|
case 'outer':
|
|
335
335
|
return {
|
|
336
336
|
type: 'outer',
|
|
337
337
|
primary: mapJoinEntry(entry.primary, cb),
|
|
338
|
-
secondary: entry.secondary.map((col) => mapJoinEntry(col, cb))
|
|
338
|
+
secondary: entry.secondary.map((col) => mapJoinEntry(col, cb)),
|
|
339
339
|
};
|
|
340
340
|
default:
|
|
341
341
|
assertNever(entry);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { PObjectId } from '../../pool';
|
|
2
|
-
import { AxisId, AxisSpec, PColumnSpec } from './spec/spec';
|
|
1
|
+
import type { PObjectId } from '../../pool';
|
|
2
|
+
import type { AxisId, AxisSpec, PColumnSpec } from './spec/spec';
|
|
3
3
|
|
|
4
4
|
/** Unified spec object for axes and columns */
|
|
5
5
|
export type PTableColumnSpec =
|
|
6
6
|
| {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
type: 'axis';
|
|
8
|
+
id: AxisId;
|
|
9
|
+
spec: AxisSpec;
|
|
10
|
+
}
|
|
11
11
|
| {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
type: 'column';
|
|
13
|
+
id: PObjectId;
|
|
14
|
+
spec: PColumnSpec;
|
|
15
|
+
};
|
|
16
16
|
|
|
17
17
|
export type PTableColumnIdAxis = {
|
|
18
18
|
type: 'axis';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export type AddParameters<
|
|
2
2
|
TParameters extends [...args: any],
|
|
3
|
-
TFunction extends (...args: any) => any
|
|
3
|
+
TFunction extends (...args: any) => any,
|
|
4
4
|
> = (
|
|
5
5
|
...args: [...TParameters, ...Parameters<TFunction>]
|
|
6
6
|
) => ReturnType<TFunction>;
|
|
7
7
|
|
|
8
8
|
export type AddParameterToAllMethods<
|
|
9
9
|
Interface,
|
|
10
|
-
TParameters extends [...args: any]
|
|
10
|
+
TParameters extends [...args: any],
|
|
11
11
|
> = {
|
|
12
12
|
[Field in keyof Interface]: Interface[Field] extends (...args: any) => any
|
|
13
13
|
? AddParameters<TParameters, Interface[Field]>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AxisId } from './spec/spec';
|
|
2
|
-
import { PTableRecordFilter } from './table_calculate';
|
|
3
|
-
import { PTableVector } from './data';
|
|
4
|
-
import { PObjectId } from '../../pool';
|
|
1
|
+
import type { AxisId } from './spec/spec';
|
|
2
|
+
import type { PTableRecordFilter } from './table_calculate';
|
|
3
|
+
import type { PTableVector } from './data';
|
|
4
|
+
import type { PObjectId } from '../../pool';
|
|
5
5
|
|
|
6
6
|
/** Calculate set of unique values for a specific axis for the filtered set of records */
|
|
7
7
|
export interface UniqueValuesRequest {
|
package/src/navigation.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type BlockSectionLink = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/** Different variants for link section appearance */
|
|
22
|
-
export type BlockSectionLinkAppearance =
|
|
22
|
+
export type BlockSectionLinkAppearance =
|
|
23
23
|
/** Shows a section of type `link` with a `+` icon and a certain specific style */
|
|
24
24
|
'add-section';
|
|
25
25
|
|
package/src/pool/entry.ts
CHANGED
package/src/pool/query.ts
CHANGED
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
import { AxisId } from '../drivers';
|
|
2
|
-
import { PObjectSpec
|
|
1
|
+
import type { AxisId } from '../drivers';
|
|
2
|
+
import type { PObjectSpec } from './spec';
|
|
3
|
+
import { isPColumnSpec } from './spec';
|
|
3
4
|
|
|
4
5
|
export type PSpecPredicate =
|
|
5
6
|
| {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
type: 'and' | 'or';
|
|
8
|
+
operands: PSpecPredicate[];
|
|
9
|
+
}
|
|
9
10
|
| {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
type: 'not';
|
|
12
|
+
operand: PSpecPredicate;
|
|
13
|
+
}
|
|
13
14
|
| {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
type: 'name';
|
|
16
|
+
name: string;
|
|
17
|
+
}
|
|
17
18
|
| {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
type: 'name_pattern';
|
|
20
|
+
pattern: string;
|
|
21
|
+
}
|
|
21
22
|
| {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
type: 'annotation';
|
|
24
|
+
annotation: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}
|
|
26
27
|
| {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
type: 'annotation_pattern';
|
|
29
|
+
annotation: string;
|
|
30
|
+
pattern: string;
|
|
31
|
+
}
|
|
31
32
|
| {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
type: 'has_axes';
|
|
34
|
+
axes: Partial<AxisId>[];
|
|
35
|
+
};
|
|
35
36
|
|
|
36
37
|
function assertNever(x: never): never {
|
|
37
|
-
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
39
|
+
throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export function executePSpecPredicate(
|
|
41
43
|
predicate: PSpecPredicate,
|
|
42
|
-
spec: PObjectSpec
|
|
44
|
+
spec: PObjectSpec,
|
|
43
45
|
): boolean {
|
|
44
46
|
switch (predicate.type) {
|
|
45
47
|
case 'and':
|
|
@@ -58,33 +60,33 @@ export function executePSpecPredicate(
|
|
|
58
60
|
return isPColumnSpec(spec) && Boolean(spec.name.match(predicate.pattern));
|
|
59
61
|
case 'annotation':
|
|
60
62
|
return (
|
|
61
|
-
isPColumnSpec(spec)
|
|
62
|
-
spec.annotations !== undefined
|
|
63
|
-
spec.annotations[predicate.annotation] === predicate.value
|
|
63
|
+
isPColumnSpec(spec)
|
|
64
|
+
&& spec.annotations !== undefined
|
|
65
|
+
&& spec.annotations[predicate.annotation] === predicate.value
|
|
64
66
|
);
|
|
65
67
|
case 'annotation_pattern':
|
|
66
68
|
return (
|
|
67
|
-
isPColumnSpec(spec)
|
|
68
|
-
spec.annotations !== undefined
|
|
69
|
-
spec.annotations[predicate.annotation] !== undefined
|
|
70
|
-
Boolean(spec.annotations[predicate.annotation].match(predicate.pattern))
|
|
69
|
+
isPColumnSpec(spec)
|
|
70
|
+
&& spec.annotations !== undefined
|
|
71
|
+
&& spec.annotations[predicate.annotation] !== undefined
|
|
72
|
+
&& Boolean(spec.annotations[predicate.annotation].match(predicate.pattern))
|
|
71
73
|
);
|
|
72
74
|
case 'has_axes':
|
|
73
75
|
return (
|
|
74
|
-
isPColumnSpec(spec)
|
|
75
|
-
predicate.axes.every((matcher) =>
|
|
76
|
+
isPColumnSpec(spec)
|
|
77
|
+
&& predicate.axes.every((matcher) =>
|
|
76
78
|
spec.axesSpec.some(
|
|
77
79
|
(axisSpec) =>
|
|
78
|
-
(matcher.type === undefined || matcher.type === axisSpec.type)
|
|
79
|
-
(matcher.name === undefined || matcher.name === axisSpec.name)
|
|
80
|
-
(matcher.domain === undefined
|
|
81
|
-
Object.keys(matcher.domain).length === 0
|
|
82
|
-
(axisSpec.domain !== undefined
|
|
83
|
-
Object.entries(matcher.domain).every(
|
|
80
|
+
(matcher.type === undefined || matcher.type === axisSpec.type)
|
|
81
|
+
&& (matcher.name === undefined || matcher.name === axisSpec.name)
|
|
82
|
+
&& (matcher.domain === undefined
|
|
83
|
+
|| Object.keys(matcher.domain).length === 0
|
|
84
|
+
|| (axisSpec.domain !== undefined
|
|
85
|
+
&& Object.entries(matcher.domain).every(
|
|
84
86
|
([domain, domainValue]) =>
|
|
85
|
-
axisSpec.domain![domain] === domainValue
|
|
86
|
-
)))
|
|
87
|
-
)
|
|
87
|
+
axisSpec.domain![domain] === domainValue,
|
|
88
|
+
))),
|
|
89
|
+
),
|
|
88
90
|
)
|
|
89
91
|
);
|
|
90
92
|
default:
|
package/src/pool/spec.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Branded } from '../branding';
|
|
2
|
-
import { JoinEntry, PColumn, PColumnSpec } from '../drivers';
|
|
1
|
+
import type { Branded } from '../branding';
|
|
2
|
+
import type { JoinEntry, PColumn, PColumnSpec } from '../drivers';
|
|
3
3
|
import { assertNever } from '../util';
|
|
4
|
-
import { ResultPoolEntry } from './entry';
|
|
4
|
+
import type { ResultPoolEntry } from './entry';
|
|
5
5
|
|
|
6
6
|
/** Any object exported into the result pool by the block always have spec attached to it */
|
|
7
7
|
export interface PObjectSpec {
|
|
@@ -40,13 +40,13 @@ export function isPColumn<T>(obj: PObject<T>): obj is PColumn<T> {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export function isPColumnSpecResult(
|
|
43
|
-
r: ResultPoolEntry<PObjectSpec
|
|
43
|
+
r: ResultPoolEntry<PObjectSpec>,
|
|
44
44
|
): r is ResultPoolEntry<PColumnSpec> {
|
|
45
45
|
return isPColumnSpec(r.obj);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export function isPColumnResult<T>(
|
|
49
|
-
r: ResultPoolEntry<PObject<T
|
|
49
|
+
r: ResultPoolEntry<PObject<T>>,
|
|
50
50
|
): r is ResultPoolEntry<PColumn<T>> {
|
|
51
51
|
return isPColumnSpec(r.obj.spec);
|
|
52
52
|
}
|
|
@@ -68,13 +68,13 @@ export function mapPObjectData<D1, D2>(
|
|
|
68
68
|
): PObject<D2> | undefined;
|
|
69
69
|
export function mapPObjectData<D1, D2>(
|
|
70
70
|
pObj: PObject<D1> | undefined,
|
|
71
|
-
cb: (d: D1) => D2
|
|
71
|
+
cb: (d: D1) => D2,
|
|
72
72
|
): PObject<D2> | undefined {
|
|
73
73
|
return pObj === undefined
|
|
74
74
|
? undefined
|
|
75
75
|
: {
|
|
76
76
|
...pObj,
|
|
77
|
-
data: cb(pObj.data)
|
|
77
|
+
data: cb(pObj.data),
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
|
package/src/ref.ts
CHANGED
|
@@ -6,12 +6,12 @@ export const PlRef = z
|
|
|
6
6
|
.literal(true)
|
|
7
7
|
.describe('Crucial marker for the block dependency tree reconstruction'),
|
|
8
8
|
blockId: z.string().describe('Upstream block id'),
|
|
9
|
-
name: z.string().describe(
|
|
9
|
+
name: z.string().describe('Name of the output provided to the upstream block\'s output context'),
|
|
10
10
|
})
|
|
11
11
|
.describe(
|
|
12
|
-
'Universal reference type, allowing to set block connections. It is crucial that '
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
'Universal reference type, allowing to set block connections. It is crucial that '
|
|
13
|
+
+ '{@link __isRef} is present and equal to true, internal logic relies on this marker '
|
|
14
|
+
+ 'to build block dependency trees.',
|
|
15
15
|
)
|
|
16
16
|
.strict()
|
|
17
17
|
.readonly();
|
|
@@ -21,18 +21,18 @@ export type Ref = PlRef;
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Type guard to check if a value is a PlRef.
|
|
24
|
-
*
|
|
24
|
+
*
|
|
25
25
|
* @param value - The value to check.
|
|
26
26
|
* @returns True if the value is a PlRef, false otherwise.
|
|
27
27
|
*/
|
|
28
28
|
export function isPlRef(value: unknown): value is PlRef {
|
|
29
29
|
return (
|
|
30
|
-
typeof value === 'object'
|
|
31
|
-
value !== null
|
|
32
|
-
'__isRef' in value
|
|
33
|
-
(value as { __isRef: unknown }).__isRef === true
|
|
34
|
-
'blockId' in value
|
|
35
|
-
'name' in value
|
|
30
|
+
typeof value === 'object'
|
|
31
|
+
&& value !== null
|
|
32
|
+
&& '__isRef' in value
|
|
33
|
+
&& (value as { __isRef: unknown }).__isRef === true
|
|
34
|
+
&& 'blockId' in value
|
|
35
|
+
&& 'name' in value
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
|
package/src/util.ts
CHANGED
package/src/value_or_error.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export type ValueOrError<V, E> =
|
|
2
2
|
| {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
ok: true;
|
|
4
|
+
value: V;
|
|
5
|
+
}
|
|
6
6
|
| {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
ok: false;
|
|
8
|
+
error: E;
|
|
9
|
+
};
|
|
10
10
|
|
|
11
11
|
export function mapValueInVOE<V1, V2, E>(
|
|
12
12
|
voe: ValueOrError<V1, E>,
|
|
13
|
-
cb: (value: V1) => V2
|
|
13
|
+
cb: (value: V1) => V2,
|
|
14
14
|
): ValueOrError<V2, E> {
|
|
15
15
|
return voe.ok ? { ok: true, value: cb(voe.value) } : voe;
|
|
16
16
|
}
|