@milaboratories/pl-model-common 1.11.1 → 1.11.2
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/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.map +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/type_util.d.ts.map +1 -1
- package/dist/drivers/pframe/unique_values.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- 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/value_or_error.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/base32-encode.ts +2 -2
- package/src/block_state.ts +3 -3
- 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 +14 -14
- package/src/drivers/pframe/column_filter.ts +2 -2
- package/src/drivers/pframe/data.ts +18 -19
- package/src/drivers/pframe/driver.ts +13 -13
- 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 +4 -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 +45 -44
- package/src/pool/spec.ts +7 -7
- package/src/ref.ts +11 -11
- package/src/value_or_error.ts +7 -7
|
@@ -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;
|
|
@@ -69,9 +68,9 @@ export function isNotNAPValue(value: unknown): value is NotNAPValue;
|
|
|
69
68
|
export function isNotNAPValue(value: unknown, valueType?: ValueType): boolean {
|
|
70
69
|
if (!valueType)
|
|
71
70
|
return (
|
|
72
|
-
typeof value === 'string'
|
|
73
|
-
(typeof value === 'number' && isFinite(value))
|
|
74
|
-
typeof value === 'bigint'
|
|
71
|
+
typeof value === 'string'
|
|
72
|
+
|| (typeof value === 'number' && isFinite(value))
|
|
73
|
+
|| typeof value === 'bigint'
|
|
75
74
|
);
|
|
76
75
|
if (isValueNA(value, valueType)) return false;
|
|
77
76
|
switch (valueType) {
|
|
@@ -102,10 +101,10 @@ export function isPValue(value: unknown): value is PValue;
|
|
|
102
101
|
export function isPValue(value: unknown, valueType?: ValueType): boolean {
|
|
103
102
|
if (!valueType)
|
|
104
103
|
return (
|
|
105
|
-
value === null
|
|
106
|
-
typeof value === 'string'
|
|
107
|
-
typeof value === 'number'
|
|
108
|
-
typeof value === 'bigint'
|
|
104
|
+
value === null
|
|
105
|
+
|| typeof value === 'string'
|
|
106
|
+
|| typeof value === 'number'
|
|
107
|
+
|| typeof value === 'bigint'
|
|
109
108
|
);
|
|
110
109
|
if (isValueNA(value, valueType)) return true;
|
|
111
110
|
switch (valueType) {
|
|
@@ -146,10 +145,10 @@ export function toJsonSafePValue(value: PValue): PValueJsonSafe {
|
|
|
146
145
|
*/
|
|
147
146
|
export function safeConvertToPValue(value: unknown, checkType?: ValueType): PValue {
|
|
148
147
|
if (
|
|
149
|
-
value === null
|
|
150
|
-
typeof value === 'string'
|
|
151
|
-
typeof value === 'number'
|
|
152
|
-
typeof value === 'bigint'
|
|
148
|
+
value === null
|
|
149
|
+
|| typeof value === 'string'
|
|
150
|
+
|| typeof value === 'number'
|
|
151
|
+
|| typeof value === 'bigint'
|
|
153
152
|
) {
|
|
154
153
|
if (checkType && !isValueNA(value, checkType) && !isPValue(value, checkType))
|
|
155
154
|
throw new Error(`Unexpected value type, got ${typeof value}, expected ${checkType}`);
|
|
@@ -157,10 +156,10 @@ export function safeConvertToPValue(value: unknown, checkType?: ValueType): PVal
|
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
if (
|
|
160
|
-
typeof value === 'object'
|
|
161
|
-
value !== null
|
|
162
|
-
'bigint' in value
|
|
163
|
-
typeof value.bigint === 'string'
|
|
159
|
+
typeof value === 'object'
|
|
160
|
+
&& value !== null
|
|
161
|
+
&& 'bigint' in value
|
|
162
|
+
&& typeof value.bigint === 'string'
|
|
164
163
|
) {
|
|
165
164
|
if (checkType && checkType !== 'Long')
|
|
166
165
|
throw new Error(`Unexpected value type, got serialized bigint, expected ${checkType}`);
|
|
@@ -186,7 +185,7 @@ export function pValueToStringOrNumberOrNull(
|
|
|
186
185
|
value: PValue | PValueJsonSafe
|
|
187
186
|
): string | number | null;
|
|
188
187
|
export function pValueToStringOrNumberOrNull(
|
|
189
|
-
value: PValue | PValueJsonSafe
|
|
188
|
+
value: PValue | PValueJsonSafe,
|
|
190
189
|
): string | number | null {
|
|
191
190
|
value = safeConvertToPValue(value);
|
|
192
191
|
if (value === null) return null;
|
|
@@ -270,7 +269,7 @@ export type AbsentAndNAFill = {
|
|
|
270
269
|
export function pTableValue(
|
|
271
270
|
column: PTableVector,
|
|
272
271
|
row: number,
|
|
273
|
-
fill: AbsentAndNAFill = {}
|
|
272
|
+
fill: AbsentAndNAFill = {},
|
|
274
273
|
): PTableValue {
|
|
275
274
|
if (isValueAbsent(column.absent, row))
|
|
276
275
|
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'>;
|
|
@@ -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,15 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
// TODO change to use unknown
|
|
1
3
|
export type AddParameters<
|
|
2
4
|
TParameters extends [...args: any],
|
|
3
|
-
TFunction extends (...args: any) => any
|
|
5
|
+
TFunction extends (...args: any) => any,
|
|
4
6
|
> = (
|
|
5
7
|
...args: [...TParameters, ...Parameters<TFunction>]
|
|
6
8
|
) => ReturnType<TFunction>;
|
|
7
9
|
|
|
8
10
|
export type AddParameterToAllMethods<
|
|
9
11
|
Interface,
|
|
10
|
-
TParameters extends [...args: any]
|
|
12
|
+
TParameters extends [...args: any],
|
|
11
13
|
> = {
|
|
12
14
|
[Field in keyof Interface]: Interface[Field] extends (...args: any) => any
|
|
13
15
|
? 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,37 +1,38 @@
|
|
|
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
|
throw new Error('Unexpected object: ' + x);
|
|
@@ -39,7 +40,7 @@ function assertNever(x: never): never {
|
|
|
39
40
|
|
|
40
41
|
export function executePSpecPredicate(
|
|
41
42
|
predicate: PSpecPredicate,
|
|
42
|
-
spec: PObjectSpec
|
|
43
|
+
spec: PObjectSpec,
|
|
43
44
|
): boolean {
|
|
44
45
|
switch (predicate.type) {
|
|
45
46
|
case 'and':
|
|
@@ -58,33 +59,33 @@ export function executePSpecPredicate(
|
|
|
58
59
|
return isPColumnSpec(spec) && Boolean(spec.name.match(predicate.pattern));
|
|
59
60
|
case 'annotation':
|
|
60
61
|
return (
|
|
61
|
-
isPColumnSpec(spec)
|
|
62
|
-
spec.annotations !== undefined
|
|
63
|
-
spec.annotations[predicate.annotation] === predicate.value
|
|
62
|
+
isPColumnSpec(spec)
|
|
63
|
+
&& spec.annotations !== undefined
|
|
64
|
+
&& spec.annotations[predicate.annotation] === predicate.value
|
|
64
65
|
);
|
|
65
66
|
case 'annotation_pattern':
|
|
66
67
|
return (
|
|
67
|
-
isPColumnSpec(spec)
|
|
68
|
-
spec.annotations !== undefined
|
|
69
|
-
spec.annotations[predicate.annotation] !== undefined
|
|
70
|
-
Boolean(spec.annotations[predicate.annotation].match(predicate.pattern))
|
|
68
|
+
isPColumnSpec(spec)
|
|
69
|
+
&& spec.annotations !== undefined
|
|
70
|
+
&& spec.annotations[predicate.annotation] !== undefined
|
|
71
|
+
&& Boolean(spec.annotations[predicate.annotation].match(predicate.pattern))
|
|
71
72
|
);
|
|
72
73
|
case 'has_axes':
|
|
73
74
|
return (
|
|
74
|
-
isPColumnSpec(spec)
|
|
75
|
-
predicate.axes.every((matcher) =>
|
|
75
|
+
isPColumnSpec(spec)
|
|
76
|
+
&& predicate.axes.every((matcher) =>
|
|
76
77
|
spec.axesSpec.some(
|
|
77
78
|
(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(
|
|
79
|
+
(matcher.type === undefined || matcher.type === axisSpec.type)
|
|
80
|
+
&& (matcher.name === undefined || matcher.name === axisSpec.name)
|
|
81
|
+
&& (matcher.domain === undefined
|
|
82
|
+
|| Object.keys(matcher.domain).length === 0
|
|
83
|
+
|| (axisSpec.domain !== undefined
|
|
84
|
+
&& Object.entries(matcher.domain).every(
|
|
84
85
|
([domain, domainValue]) =>
|
|
85
|
-
axisSpec.domain![domain] === domainValue
|
|
86
|
-
)))
|
|
87
|
-
)
|
|
86
|
+
axisSpec.domain![domain] === domainValue,
|
|
87
|
+
))),
|
|
88
|
+
),
|
|
88
89
|
)
|
|
89
90
|
);
|
|
90
91
|
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/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
|
}
|