@milaboratories/pl-model-common 1.25.1 → 1.25.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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/author_marker.d.ts +9 -6
- package/dist/base32_encode.cjs +40 -46
- package/dist/base32_encode.cjs.map +1 -1
- package/dist/base32_encode.js +40 -45
- package/dist/base32_encode.js.map +1 -1
- package/dist/base64.cjs +5 -4
- package/dist/base64.cjs.map +1 -1
- package/dist/base64.d.ts +10 -6
- package/dist/base64.js +5 -3
- package/dist/base64.js.map +1 -1
- package/dist/block_state.d.ts +21 -23
- package/dist/bmodel/block_config.cjs +9 -10
- package/dist/bmodel/block_config.cjs.map +1 -1
- package/dist/bmodel/block_config.d.ts +53 -72
- package/dist/bmodel/block_config.js +9 -9
- package/dist/bmodel/block_config.js.map +1 -1
- package/dist/bmodel/code.cjs +7 -6
- package/dist/bmodel/code.cjs.map +1 -1
- package/dist/bmodel/code.d.ts +17 -13
- package/dist/bmodel/code.js +6 -4
- package/dist/bmodel/code.js.map +1 -1
- package/dist/bmodel/container.d.ts +46 -44
- package/dist/bmodel/index.cjs +3 -0
- package/dist/bmodel/index.d.ts +5 -6
- package/dist/bmodel/index.js +3 -0
- package/dist/bmodel/normalization.cjs +90 -106
- package/dist/bmodel/normalization.cjs.map +1 -1
- package/dist/bmodel/normalization.d.ts +7 -3
- package/dist/bmodel/normalization.js +90 -105
- package/dist/bmodel/normalization.js.map +1 -1
- package/dist/bmodel/types.d.ts +4 -1
- package/dist/branding.d.ts +5 -5
- package/dist/common_types.d.ts +19 -15
- package/dist/driver_kit.d.ts +25 -17
- package/dist/drivers/ChunkedStreamReader.cjs +168 -203
- package/dist/drivers/ChunkedStreamReader.cjs.map +1 -1
- package/dist/drivers/ChunkedStreamReader.d.ts +104 -100
- package/dist/drivers/ChunkedStreamReader.js +168 -202
- package/dist/drivers/ChunkedStreamReader.js.map +1 -1
- package/dist/drivers/blob.cjs +15 -17
- package/dist/drivers/blob.cjs.map +1 -1
- package/dist/drivers/blob.d.ts +35 -35
- package/dist/drivers/blob.js +14 -15
- package/dist/drivers/blob.js.map +1 -1
- package/dist/drivers/index.cjs +18 -0
- package/dist/drivers/index.d.ts +29 -9
- package/dist/drivers/index.js +18 -0
- package/dist/drivers/interfaces.d.ts +17 -14
- package/dist/drivers/log.cjs +4 -3
- package/dist/drivers/log.cjs.map +1 -1
- package/dist/drivers/log.d.ts +52 -49
- package/dist/drivers/log.js +4 -2
- package/dist/drivers/log.js.map +1 -1
- package/dist/drivers/ls.cjs +16 -19
- package/dist/drivers/ls.cjs.map +1 -1
- package/dist/drivers/ls.d.ts +73 -76
- package/dist/drivers/ls.js +16 -17
- package/dist/drivers/ls.js.map +1 -1
- package/dist/drivers/pframe/column_filter.d.ts +19 -15
- package/dist/drivers/pframe/data_info.cjs +201 -252
- package/dist/drivers/pframe/data_info.cjs.map +1 -1
- package/dist/drivers/pframe/data_info.d.ts +84 -109
- package/dist/drivers/pframe/data_info.js +201 -250
- package/dist/drivers/pframe/data_info.js.map +1 -1
- package/dist/drivers/pframe/data_types.cjs +38 -63
- package/dist/drivers/pframe/data_types.cjs.map +1 -1
- package/dist/drivers/pframe/data_types.d.ts +91 -93
- package/dist/drivers/pframe/data_types.js +38 -61
- package/dist/drivers/pframe/data_types.js.map +1 -1
- package/dist/drivers/pframe/driver.cjs +7 -0
- package/dist/drivers/pframe/driver.cjs.map +1 -0
- package/dist/drivers/pframe/driver.d.ts +50 -45
- package/dist/drivers/pframe/driver.js +6 -0
- package/dist/drivers/pframe/driver.js.map +1 -0
- package/dist/drivers/pframe/filter_spec.d.ts +127 -123
- package/dist/drivers/pframe/find_columns.d.ts +21 -17
- package/dist/drivers/pframe/index.cjs +15 -0
- package/dist/drivers/pframe/index.d.ts +23 -16
- package/dist/drivers/pframe/index.js +15 -0
- package/dist/drivers/pframe/linker_columns.cjs +184 -238
- package/dist/drivers/pframe/linker_columns.cjs.map +1 -1
- package/dist/drivers/pframe/linker_columns.d.ts +45 -38
- package/dist/drivers/pframe/linker_columns.js +184 -236
- package/dist/drivers/pframe/linker_columns.js.map +1 -1
- package/dist/drivers/pframe/pframe.d.ts +26 -21
- package/dist/drivers/pframe/query/index.cjs +1 -0
- package/dist/drivers/pframe/query/index.d.ts +3 -4
- package/dist/drivers/pframe/query/index.js +1 -0
- package/dist/drivers/pframe/query/query_common.d.ts +205 -247
- package/dist/drivers/pframe/query/query_data.d.ts +25 -23
- package/dist/drivers/pframe/query/query_spec.d.ts +30 -29
- package/dist/drivers/pframe/query/utils.cjs +164 -183
- package/dist/drivers/pframe/query/utils.cjs.map +1 -1
- package/dist/drivers/pframe/query/utils.d.ts +13 -12
- package/dist/drivers/pframe/query/utils.js +164 -181
- package/dist/drivers/pframe/query/utils.js.map +1 -1
- package/dist/drivers/pframe/spec/anchored.cjs +178 -216
- package/dist/drivers/pframe/spec/anchored.cjs.map +1 -1
- package/dist/drivers/pframe/spec/anchored.d.ts +53 -49
- package/dist/drivers/pframe/spec/anchored.js +176 -214
- package/dist/drivers/pframe/spec/anchored.js.map +1 -1
- package/dist/drivers/pframe/spec/filtered_column.cjs +8 -7
- package/dist/drivers/pframe/spec/filtered_column.cjs.map +1 -1
- package/dist/drivers/pframe/spec/filtered_column.d.ts +20 -17
- package/dist/drivers/pframe/spec/filtered_column.js +8 -6
- package/dist/drivers/pframe/spec/filtered_column.js.map +1 -1
- package/dist/drivers/pframe/spec/ids.cjs +16 -14
- package/dist/drivers/pframe/spec/ids.cjs.map +1 -1
- package/dist/drivers/pframe/spec/ids.d.ts +13 -8
- package/dist/drivers/pframe/spec/ids.js +14 -12
- package/dist/drivers/pframe/spec/ids.js.map +1 -1
- package/dist/drivers/pframe/spec/index.cjs +6 -0
- package/dist/drivers/pframe/spec/index.d.ts +6 -7
- package/dist/drivers/pframe/spec/index.js +6 -0
- package/dist/drivers/pframe/spec/native_id.cjs +16 -16
- package/dist/drivers/pframe/spec/native_id.cjs.map +1 -1
- package/dist/drivers/pframe/spec/native_id.d.ts +9 -4
- package/dist/drivers/pframe/spec/native_id.js +13 -13
- package/dist/drivers/pframe/spec/native_id.js.map +1 -1
- package/dist/drivers/pframe/spec/selectors.cjs +72 -112
- package/dist/drivers/pframe/spec/selectors.cjs.map +1 -1
- package/dist/drivers/pframe/spec/selectors.d.ts +99 -94
- package/dist/drivers/pframe/spec/selectors.js +72 -110
- package/dist/drivers/pframe/spec/selectors.js.map +1 -1
- package/dist/drivers/pframe/spec/spec.cjs +282 -324
- package/dist/drivers/pframe/spec/spec.cjs.map +1 -1
- package/dist/drivers/pframe/spec/spec.d.ts +263 -272
- package/dist/drivers/pframe/spec/spec.js +281 -322
- package/dist/drivers/pframe/spec/spec.js.map +1 -1
- package/dist/drivers/pframe/table.d.ts +28 -24
- package/dist/drivers/pframe/table_calculate.cjs +117 -147
- package/dist/drivers/pframe/table_calculate.cjs.map +1 -1
- package/dist/drivers/pframe/table_calculate.d.ts +219 -220
- package/dist/drivers/pframe/table_calculate.js +117 -145
- package/dist/drivers/pframe/table_calculate.js.map +1 -1
- package/dist/drivers/pframe/table_common.cjs +13 -14
- package/dist/drivers/pframe/table_common.cjs.map +1 -1
- package/dist/drivers/pframe/table_common.d.ts +24 -19
- package/dist/drivers/pframe/table_common.js +13 -13
- package/dist/drivers/pframe/table_common.js.map +1 -1
- package/dist/drivers/pframe/unique_values.d.ts +23 -18
- package/dist/drivers/upload.d.ts +21 -18
- package/dist/drivers/urls.cjs +5 -6
- package/dist/drivers/urls.cjs.map +1 -1
- package/dist/drivers/urls.d.ts +12 -9
- package/dist/drivers/urls.js +5 -5
- package/dist/drivers/urls.js.map +1 -1
- package/dist/errors.cjs +65 -86
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +36 -33
- package/dist/errors.js +65 -85
- package/dist/errors.js.map +1 -1
- package/dist/flags/block_flags.cjs +7 -6
- package/dist/flags/block_flags.cjs.map +1 -1
- package/dist/flags/block_flags.d.ts +12 -8
- package/dist/flags/block_flags.js +7 -5
- package/dist/flags/block_flags.js.map +1 -1
- package/dist/flags/flag_utils.cjs +69 -108
- package/dist/flags/flag_utils.cjs.map +1 -1
- package/dist/flags/flag_utils.d.ts +40 -42
- package/dist/flags/flag_utils.js +70 -107
- package/dist/flags/flag_utils.js.map +1 -1
- package/dist/flags/type_utils.d.ts +12 -11
- package/dist/httpAuth.cjs +16 -20
- package/dist/httpAuth.cjs.map +1 -1
- package/dist/httpAuth.d.ts +10 -7
- package/dist/httpAuth.js +16 -19
- package/dist/httpAuth.js.map +1 -1
- package/dist/index.cjs +176 -179
- package/dist/index.d.ts +58 -20
- package/dist/index.js +37 -34
- package/dist/json.cjs +10 -8
- package/dist/json.cjs.map +1 -1
- package/dist/json.d.ts +18 -18
- package/dist/json.js +8 -6
- package/dist/json.js.map +1 -1
- package/dist/navigation.cjs +3 -2
- package/dist/navigation.cjs.map +1 -1
- package/dist/navigation.d.ts +18 -21
- package/dist/navigation.js +3 -1
- package/dist/navigation.js.map +1 -1
- package/dist/plid.cjs +16 -20
- package/dist/plid.cjs.map +1 -1
- package/dist/plid.d.ts +11 -7
- package/dist/plid.js +15 -18
- package/dist/plid.js.map +1 -1
- package/dist/pool/entry.d.ts +11 -11
- package/dist/pool/index.d.ts +3 -4
- package/dist/pool/query.cjs +21 -43
- package/dist/pool/query.cjs.map +1 -1
- package/dist/pool/query.d.ts +25 -20
- package/dist/pool/query.js +20 -40
- package/dist/pool/query.js.map +1 -1
- package/dist/pool/spec.cjs +40 -47
- package/dist/pool/spec.cjs.map +1 -1
- package/dist/pool/spec.d.ts +33 -31
- package/dist/pool/spec.js +40 -45
- package/dist/pool/spec.js.map +1 -1
- package/dist/ref.cjs +51 -71
- package/dist/ref.cjs.map +1 -1
- package/dist/ref.d.ts +36 -33
- package/dist/ref.js +50 -69
- package/dist/ref.js.map +1 -1
- package/dist/utag.d.ts +18 -14
- package/dist/util.cjs +8 -7
- package/dist/util.cjs.map +1 -1
- package/dist/util.d.ts +5 -2
- package/dist/util.js +8 -6
- package/dist/util.js.map +1 -1
- package/dist/value_or_error.cjs +7 -3
- package/dist/value_or_error.cjs.map +1 -1
- package/dist/value_or_error.d.ts +9 -6
- package/dist/value_or_error.js +7 -2
- package/dist/value_or_error.js.map +1 -1
- package/package.json +6 -6
- package/src/flags/block_flags.ts +2 -1
- package/src/flags/flag_utils.ts +0 -22
- package/dist/author_marker.d.ts.map +0 -1
- package/dist/base32_encode.d.ts +0 -8
- package/dist/base32_encode.d.ts.map +0 -1
- package/dist/base64.d.ts.map +0 -1
- package/dist/block_state.d.ts.map +0 -1
- package/dist/bmodel/block_config.d.ts.map +0 -1
- package/dist/bmodel/code.d.ts.map +0 -1
- package/dist/bmodel/container.d.ts.map +0 -1
- package/dist/bmodel/index.d.ts.map +0 -1
- package/dist/bmodel/normalization.d.ts.map +0 -1
- package/dist/bmodel/types.d.ts.map +0 -1
- package/dist/branding.d.ts.map +0 -1
- package/dist/common_types.d.ts.map +0 -1
- package/dist/driver_kit.d.ts.map +0 -1
- package/dist/drivers/ChunkedStreamReader.d.ts.map +0 -1
- package/dist/drivers/blob.d.ts.map +0 -1
- package/dist/drivers/index.d.ts.map +0 -1
- package/dist/drivers/interfaces.d.ts.map +0 -1
- package/dist/drivers/log.d.ts.map +0 -1
- package/dist/drivers/ls.d.ts.map +0 -1
- package/dist/drivers/pframe/column_filter.d.ts.map +0 -1
- package/dist/drivers/pframe/data_info.d.ts.map +0 -1
- package/dist/drivers/pframe/data_types.d.ts.map +0 -1
- package/dist/drivers/pframe/driver.d.ts.map +0 -1
- package/dist/drivers/pframe/filter_spec.d.ts.map +0 -1
- package/dist/drivers/pframe/find_columns.d.ts.map +0 -1
- package/dist/drivers/pframe/index.d.ts.map +0 -1
- package/dist/drivers/pframe/linker_columns.d.ts.map +0 -1
- package/dist/drivers/pframe/pframe.d.ts.map +0 -1
- package/dist/drivers/pframe/query/index.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_common.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_data.d.ts.map +0 -1
- package/dist/drivers/pframe/query/query_spec.d.ts.map +0 -1
- package/dist/drivers/pframe/query/utils.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/anchored.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/filtered_column.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/ids.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/index.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/native_id.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/selectors.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/spec.d.ts.map +0 -1
- package/dist/drivers/pframe/table.d.ts.map +0 -1
- package/dist/drivers/pframe/table_calculate.d.ts.map +0 -1
- package/dist/drivers/pframe/table_common.d.ts.map +0 -1
- package/dist/drivers/pframe/type_util.d.ts +0 -5
- package/dist/drivers/pframe/type_util.d.ts.map +0 -1
- package/dist/drivers/pframe/unique_values.d.ts.map +0 -1
- package/dist/drivers/upload.d.ts.map +0 -1
- package/dist/drivers/urls.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/flags/block_flags.d.ts.map +0 -1
- package/dist/flags/flag_utils.d.ts.map +0 -1
- package/dist/flags/index.d.ts +0 -4
- package/dist/flags/index.d.ts.map +0 -1
- package/dist/flags/type_utils.d.ts.map +0 -1
- package/dist/httpAuth.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/json.d.ts.map +0 -1
- package/dist/navigation.d.ts.map +0 -1
- package/dist/plid.d.ts.map +0 -1
- package/dist/pool/entry.d.ts.map +0 -1
- package/dist/pool/index.d.ts.map +0 -1
- package/dist/pool/query.d.ts.map +0 -1
- package/dist/pool/spec.d.ts.map +0 -1
- package/dist/ref.d.ts.map +0 -1
- package/dist/utag.d.ts.map +0 -1
- package/dist/util.d.ts.map +0 -1
- package/dist/value_or_error.d.ts.map +0 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { PObjectSpec } from "../../../pool/spec.js";
|
|
2
|
+
import "../../../pool/index.js";
|
|
3
|
+
import { AxisId, AxisValueType, Domain, PColumnSpec, ValueType } from "./spec.js";
|
|
4
|
+
|
|
5
|
+
//#region src/drivers/pframe/spec/selectors.d.ts
|
|
3
6
|
/**
|
|
4
7
|
* Defines a pattern for matching axes within the PFrame data model.
|
|
5
8
|
*
|
|
@@ -11,151 +14,151 @@ import type { AxisId, AxisValueType, Domain, PColumnSpec, ValueType } from "./sp
|
|
|
11
14
|
* This interface is used in various selection and matching operations
|
|
12
15
|
* throughout the PFrame system, such as column queries and axis lookups.
|
|
13
16
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
interface AxisSelector {
|
|
18
|
+
/**
|
|
19
|
+
* Optional value type to match against.
|
|
20
|
+
* When specified, only axes with this exact type will match.
|
|
21
|
+
* Can be a single type or an array of types to match against any of them.
|
|
22
|
+
* Valid types include: 'Int', 'Long', 'Float', 'Double', 'String', 'Bytes'.
|
|
23
|
+
*/
|
|
24
|
+
type?: ValueType | ValueType[];
|
|
25
|
+
/**
|
|
26
|
+
* Optional name to match against.
|
|
27
|
+
* When specified, only axes with this exact name will match.
|
|
28
|
+
*/
|
|
29
|
+
name?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Optional domain key-value pairs to match against.
|
|
32
|
+
* Domains provide additional context to uniquely identify an axis beyond its name and type.
|
|
33
|
+
* When specified, an axis will match only if it contains all the key-value pairs defined here.
|
|
34
|
+
* An axis with additional domain entries not present in this selector will still match.
|
|
35
|
+
*/
|
|
36
|
+
domain?: Record<string, string>;
|
|
34
37
|
}
|
|
35
38
|
/** Single axis selector */
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
interface SingleAxisSelector {
|
|
40
|
+
/** Axis name (required) */
|
|
41
|
+
name: string;
|
|
42
|
+
/** Axis type (optional) */
|
|
43
|
+
type?: AxisValueType;
|
|
44
|
+
/** Domain requirements (optional) */
|
|
45
|
+
domain?: Domain;
|
|
46
|
+
/** Parent axes requirements (optional) */
|
|
47
|
+
parentAxes?: SingleAxisSelector[];
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
47
50
|
* Reference to an axis by its numerical index within the anchor column's axes array
|
|
48
51
|
* Format: [anchorId, axisIndex]
|
|
49
52
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
type AnchorAxisRefByIdx = {
|
|
54
|
+
anchor: string;
|
|
55
|
+
idx: number;
|
|
53
56
|
};
|
|
54
57
|
/**
|
|
55
58
|
* Reference to an axis by its name within the anchor column
|
|
56
59
|
* Format: [anchorId, axisName]
|
|
57
60
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
type AnchorAxisRefByName = {
|
|
62
|
+
anchor: string;
|
|
63
|
+
name: string;
|
|
61
64
|
};
|
|
62
65
|
/**
|
|
63
66
|
* Reference to an axis using an AxisId matcher within the anchor
|
|
64
67
|
* Format: [anchorId, axisMatcher]
|
|
65
68
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
type AnchorAxisRefByMatcher = {
|
|
70
|
+
anchor: string;
|
|
71
|
+
id: AxisId;
|
|
69
72
|
};
|
|
70
73
|
/**
|
|
71
74
|
* Basic anchor axis reference that can be either by index or a direct AxisId
|
|
72
75
|
*/
|
|
73
|
-
|
|
76
|
+
type AnchorAxisIdOrRefBasic = AnchorAxisRefByIdx | AxisId;
|
|
74
77
|
/** Union of all possible ways to reference an axis in an anchored context */
|
|
75
|
-
|
|
78
|
+
type AnchorAxisRef = AnchorAxisRefByIdx | AnchorAxisRefByName | AnchorAxisRefByMatcher;
|
|
76
79
|
/** Reference to a domain value through an anchor */
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
type AnchorDomainRef = {
|
|
81
|
+
anchor: string;
|
|
79
82
|
};
|
|
80
83
|
/**
|
|
81
84
|
* Domain value that can be either a direct string value or a reference to a domain through an anchor
|
|
82
85
|
* Used to establish domain context that can be resolved relative to other anchored columns
|
|
83
86
|
*/
|
|
84
|
-
|
|
87
|
+
type ADomain = string | AnchorDomainRef;
|
|
85
88
|
/**
|
|
86
89
|
* Axis identifier that can be either a direct AxisId or a reference to an axis through an anchor
|
|
87
90
|
* Allows referring to axes in a way that can be resolved in different contexts
|
|
88
91
|
*/
|
|
89
|
-
|
|
92
|
+
type AAxisSelector = AxisSelector | AnchorAxisRef;
|
|
90
93
|
/**
|
|
91
94
|
* Match resolution strategy for PColumns
|
|
92
95
|
* Specifies how to handle when multiple columns match the criteria
|
|
93
96
|
* (default is "expectSingle")
|
|
94
97
|
*/
|
|
95
|
-
|
|
98
|
+
type AnchoredColumnMatchStrategy = "expectSingle" | "expectMultiple" | "takeFirst";
|
|
96
99
|
/**
|
|
97
100
|
* Matcher for PColumns in an anchored context
|
|
98
101
|
* Supports partial matching on axes, allowing for flexible column discovery
|
|
99
102
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
103
|
+
interface AnchoredPColumnSelector {
|
|
104
|
+
/** Optional name of the column to match; can't be used together with namePattern */
|
|
105
|
+
name?: string;
|
|
106
|
+
/** Optional regexp pattern for column name matching; can't be used together with name */
|
|
107
|
+
namePattern?: string;
|
|
108
|
+
/** Optional value type to match. If an array is provided, matches if the column's type is any of the specified types */
|
|
109
|
+
type?: ValueType | ValueType[];
|
|
110
|
+
/** If specified, the domain values must be anchored to this anchor */
|
|
111
|
+
domainAnchor?: string;
|
|
112
|
+
/** Optional domain values to match, can include anchored references, if domainAnchor is specified,
|
|
113
|
+
* interpreted as additional domains to domain from the anchor */
|
|
114
|
+
domain?: Record<string, ADomain>;
|
|
115
|
+
/** Optional axes to match, can include anchored references */
|
|
116
|
+
axes?: AAxisSelector[];
|
|
117
|
+
/** When true, allows matching if only a subset of axes match */
|
|
118
|
+
partialAxesMatch?: boolean;
|
|
119
|
+
/** Optional annotations to match with exact values */
|
|
120
|
+
annotations?: Record<string, string>;
|
|
121
|
+
/** Optional annotation patterns to match with regex patterns */
|
|
122
|
+
annotationPatterns?: Record<string, string>;
|
|
123
|
+
/** Match resolution strategy, default is "expectSingle" */
|
|
124
|
+
matchStrategy?: AnchoredColumnMatchStrategy;
|
|
122
125
|
}
|
|
123
126
|
/**
|
|
124
127
|
* Matcher for PColumns in a non-anchored context
|
|
125
128
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
interface PColumnSelector extends AnchoredPColumnSelector {
|
|
130
|
+
domainAnchor?: never;
|
|
131
|
+
domain?: Record<string, string>;
|
|
132
|
+
axes?: AxisSelector[];
|
|
130
133
|
}
|
|
131
134
|
/**
|
|
132
135
|
* Strict identifier for PColumns in an anchored context
|
|
133
136
|
* Unlike APColumnMatcher, this requires exact matches on domain and axes
|
|
134
137
|
*/
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
138
|
+
interface AnchoredPColumnId extends AnchoredPColumnSelector {
|
|
139
|
+
/** Name is required for exact column identification */
|
|
140
|
+
name: string;
|
|
141
|
+
/** No namePattern in ID */
|
|
142
|
+
namePattern?: never;
|
|
143
|
+
/** Type is not used in exact column identification */
|
|
144
|
+
type?: never;
|
|
145
|
+
/** Full axes specification using only basic references */
|
|
146
|
+
axes: AnchorAxisIdOrRefBasic[];
|
|
147
|
+
/** Partial axes matching is not allowed for exact identification */
|
|
148
|
+
partialAxesMatch?: never;
|
|
149
|
+
/** Annotations are not used in exact column identification */
|
|
150
|
+
annotations?: never;
|
|
151
|
+
/** Annotation patterns are not used in exact column identification */
|
|
152
|
+
annotationPatterns?: never;
|
|
153
|
+
/** "Id" implies single match strategy */
|
|
154
|
+
matchStrategy?: never;
|
|
152
155
|
}
|
|
153
156
|
/**
|
|
154
157
|
* Checks if a given value is an anchored column identifier
|
|
155
158
|
* @param id - The value to check
|
|
156
159
|
* @returns True if the value is an anchored column identifier, false otherwise
|
|
157
160
|
*/
|
|
158
|
-
|
|
161
|
+
declare function isAnchoredPColumnId(id: unknown): id is AnchoredPColumnId;
|
|
159
162
|
/**
|
|
160
163
|
* Determines if an axis ID matches an axis selector.
|
|
161
164
|
*
|
|
@@ -163,7 +166,7 @@ export declare function isAnchoredPColumnId(id: unknown): id is AnchoredPColumnI
|
|
|
163
166
|
* @param axis - The AxisId to check against the selector
|
|
164
167
|
* @returns true if the AxisId matches all specified criteria in the selector, false otherwise
|
|
165
168
|
*/
|
|
166
|
-
|
|
169
|
+
declare function matchAxis(selector: AxisSelector, axis: AxisId): boolean;
|
|
167
170
|
/**
|
|
168
171
|
* Determines if a given PColumnSpec matches a selector.
|
|
169
172
|
*
|
|
@@ -171,12 +174,14 @@ export declare function matchAxis(selector: AxisSelector, axis: AxisId): boolean
|
|
|
171
174
|
* @param selector - The selector criteria to match against
|
|
172
175
|
* @returns true if the PColumnSpec matches all criteria in the selector, false otherwise
|
|
173
176
|
*/
|
|
174
|
-
|
|
177
|
+
declare function matchPColumn(pcolumn: PColumnSpec, selector: PColumnSelector): boolean;
|
|
175
178
|
/**
|
|
176
179
|
* Convert a predicate or array of selectors to a single predicate function
|
|
177
180
|
* @param predicateOrSelectors - Either a function that takes a PColumnSpec and returns a boolean,
|
|
178
181
|
* or an array of PColumnSelectors, or a single PColumnSelector
|
|
179
182
|
* @returns A function that takes a PColumnSpec and returns a boolean
|
|
180
183
|
*/
|
|
181
|
-
|
|
184
|
+
declare function selectorsToPredicate(predicateOrSelectors: PColumnSelector | PColumnSelector[]): (spec: PObjectSpec) => boolean;
|
|
185
|
+
//#endregion
|
|
186
|
+
export { AAxisSelector, ADomain, AnchorAxisIdOrRefBasic, AnchorAxisRef, AnchorAxisRefByIdx, AnchorAxisRefByMatcher, AnchorAxisRefByName, AnchorDomainRef, AnchoredColumnMatchStrategy, AnchoredPColumnId, AnchoredPColumnSelector, AxisSelector, PColumnSelector, SingleAxisSelector, isAnchoredPColumnId, matchAxis, matchPColumn, selectorsToPredicate };
|
|
182
187
|
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -1,125 +1,87 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getAxisId } from "./spec.js";
|
|
2
|
+
import { isPColumnSpec } from "../../../pool/spec.js";
|
|
3
3
|
|
|
4
|
+
//#region src/drivers/pframe/spec/selectors.ts
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
* Checks if a given value is an anchored column identifier
|
|
7
|
+
* @param id - The value to check
|
|
8
|
+
* @returns True if the value is an anchored column identifier, false otherwise
|
|
9
|
+
*/
|
|
9
10
|
function isAnchoredPColumnId(id) {
|
|
10
|
-
|
|
11
|
-
return typeof id === "object" && id !== null && "name" in id && "axes" in id;
|
|
11
|
+
return typeof id === "object" && id !== null && "name" in id && "axes" in id;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
* Determines if an axis ID matches an axis selector.
|
|
15
|
+
*
|
|
16
|
+
* @param selector - The selector with criteria to match against
|
|
17
|
+
* @param axis - The AxisId to check against the selector
|
|
18
|
+
* @returns true if the AxisId matches all specified criteria in the selector, false otherwise
|
|
19
|
+
*/
|
|
20
20
|
function matchAxis(selector, axis) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// Match domain if specified - using existing logic from matchAxisId
|
|
35
|
-
if (selector.domain !== undefined) {
|
|
36
|
-
const axisDomain = axis.domain || {};
|
|
37
|
-
for (const [key, value] of Object.entries(selector.domain))
|
|
38
|
-
if (axisDomain[key] !== value)
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
21
|
+
if (selector.name !== void 0 && selector.name !== axis.name) return false;
|
|
22
|
+
if (selector.type !== void 0) {
|
|
23
|
+
if (Array.isArray(selector.type)) {
|
|
24
|
+
if (!selector.type.includes(axis.type)) return false;
|
|
25
|
+
} else if (selector.type !== axis.type) return false;
|
|
26
|
+
}
|
|
27
|
+
if (selector.domain !== void 0) {
|
|
28
|
+
const axisDomain = axis.domain || {};
|
|
29
|
+
for (const [key, value] of Object.entries(selector.domain)) if (axisDomain[key] !== value) return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
42
32
|
}
|
|
43
33
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
* Determines if a given PColumnSpec matches a selector.
|
|
35
|
+
*
|
|
36
|
+
* @param pcolumn - The PColumnSpec to check against the selector
|
|
37
|
+
* @param selector - The selector criteria to match against
|
|
38
|
+
* @returns true if the PColumnSpec matches all criteria in the selector, false otherwise
|
|
39
|
+
*/
|
|
50
40
|
function matchPColumn(pcolumn, selector) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
else {
|
|
84
|
-
// For exact matching, column must have the same number of axes and all must match
|
|
85
|
-
if (pcolumnAxes.length !== selector.axes.length)
|
|
86
|
-
return false;
|
|
87
|
-
// Each selector axis must match a corresponding column axis
|
|
88
|
-
for (let i = 0; i < selector.axes.length; i++)
|
|
89
|
-
if (!matchAxis(selector.axes[i], pcolumnAxes[i]))
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// Match annotations if specified
|
|
94
|
-
if (selector.annotations !== undefined) {
|
|
95
|
-
const columnAnnotations = pcolumn.annotations || {};
|
|
96
|
-
for (const [key, value] of Object.entries(selector.annotations))
|
|
97
|
-
if (columnAnnotations[key] !== value)
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
// Match annotation patterns if specified
|
|
101
|
-
if (selector.annotationPatterns !== undefined) {
|
|
102
|
-
const columnAnnotations = pcolumn.annotations || {};
|
|
103
|
-
for (const [key, pattern] of Object.entries(selector.annotationPatterns)) {
|
|
104
|
-
const value = columnAnnotations[key];
|
|
105
|
-
if (value === undefined || !new RegExp(pattern).test(value))
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return true;
|
|
41
|
+
if (selector.name !== void 0 && pcolumn.name !== selector.name) return false;
|
|
42
|
+
if (selector.namePattern !== void 0 && !new RegExp(selector.namePattern).test(pcolumn.name)) return false;
|
|
43
|
+
if (selector.type !== void 0) {
|
|
44
|
+
if (Array.isArray(selector.type)) {
|
|
45
|
+
if (!selector.type.includes(pcolumn.valueType)) return false;
|
|
46
|
+
} else if (selector.type !== pcolumn.valueType) return false;
|
|
47
|
+
}
|
|
48
|
+
if (selector.domain !== void 0) {
|
|
49
|
+
const columnDomain = pcolumn.domain || {};
|
|
50
|
+
for (const [key, value] of Object.entries(selector.domain)) if (columnDomain[key] !== value) return false;
|
|
51
|
+
}
|
|
52
|
+
if (selector.axes !== void 0) {
|
|
53
|
+
const pcolumnAxes = pcolumn.axesSpec.map(getAxisId);
|
|
54
|
+
if (selector.partialAxesMatch) {
|
|
55
|
+
for (const selectorAxis of selector.axes) if (!pcolumnAxes.some((columnAxis) => matchAxis(selectorAxis, columnAxis))) return false;
|
|
56
|
+
} else {
|
|
57
|
+
if (pcolumnAxes.length !== selector.axes.length) return false;
|
|
58
|
+
for (let i = 0; i < selector.axes.length; i++) if (!matchAxis(selector.axes[i], pcolumnAxes[i])) return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (selector.annotations !== void 0) {
|
|
62
|
+
const columnAnnotations = pcolumn.annotations || {};
|
|
63
|
+
for (const [key, value] of Object.entries(selector.annotations)) if (columnAnnotations[key] !== value) return false;
|
|
64
|
+
}
|
|
65
|
+
if (selector.annotationPatterns !== void 0) {
|
|
66
|
+
const columnAnnotations = pcolumn.annotations || {};
|
|
67
|
+
for (const [key, pattern] of Object.entries(selector.annotationPatterns)) {
|
|
68
|
+
const value = columnAnnotations[key];
|
|
69
|
+
if (value === void 0 || !new RegExp(pattern).test(value)) return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
110
73
|
}
|
|
111
74
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
75
|
+
* Convert a predicate or array of selectors to a single predicate function
|
|
76
|
+
* @param predicateOrSelectors - Either a function that takes a PColumnSpec and returns a boolean,
|
|
77
|
+
* or an array of PColumnSelectors, or a single PColumnSelector
|
|
78
|
+
* @returns A function that takes a PColumnSpec and returns a boolean
|
|
79
|
+
*/
|
|
117
80
|
function selectorsToPredicate(predicateOrSelectors) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
else
|
|
121
|
-
return (spec) => isPColumnSpec(spec) && matchPColumn(spec, predicateOrSelectors);
|
|
81
|
+
if (Array.isArray(predicateOrSelectors)) return (spec) => predicateOrSelectors.some((selector) => isPColumnSpec(spec) && matchPColumn(spec, selector));
|
|
82
|
+
else return (spec) => isPColumnSpec(spec) && matchPColumn(spec, predicateOrSelectors);
|
|
122
83
|
}
|
|
123
84
|
|
|
85
|
+
//#endregion
|
|
124
86
|
export { isAnchoredPColumnId, matchAxis, matchPColumn, selectorsToPredicate };
|
|
125
|
-
//# sourceMappingURL=selectors.js.map
|
|
87
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","sources":["../../../../src/drivers/pframe/spec/selectors.ts"],"sourcesContent":["import { isPColumnSpec, type PObjectSpec } from \"../../../pool\";\nimport type { AxisId, AxisValueType, Domain, PColumnSpec, ValueType } from \"./spec\";\nimport { getAxisId } from \"./spec\";\n\n/**\n * Defines a pattern for matching axes within the PFrame data model.\n *\n * AxisSelector provides a flexible way to identify axes based on their\n * properties. All fields are optional, allowing for partial matching.\n * When multiple properties are specified, all must match for an axis\n * to be selected (logical AND).\n *\n * This interface is used in various selection and matching operations\n * throughout the PFrame system, such as column queries and axis lookups.\n */\nexport interface AxisSelector {\n /**\n * Optional value type to match against.\n * When specified, only axes with this exact type will match.\n * Can be a single type or an array of types to match against any of them.\n * Valid types include: 'Int', 'Long', 'Float', 'Double', 'String', 'Bytes'.\n */\n type?: ValueType | ValueType[];\n\n /**\n * Optional name to match against.\n * When specified, only axes with this exact name will match.\n */\n name?: string;\n\n /**\n * Optional domain key-value pairs to match against.\n * Domains provide additional context to uniquely identify an axis beyond its name and type.\n * When specified, an axis will match only if it contains all the key-value pairs defined here.\n * An axis with additional domain entries not present in this selector will still match.\n */\n domain?: Record<string, string>;\n}\n\n/** Single axis selector */\nexport interface SingleAxisSelector {\n /** Axis name (required) */\n name: string;\n /** Axis type (optional) */\n type?: AxisValueType;\n /** Domain requirements (optional) */\n domain?: Domain;\n /** Parent axes requirements (optional) */\n parentAxes?: SingleAxisSelector[];\n}\n\n/**\n * Reference to an axis by its numerical index within the anchor column's axes array\n * Format: [anchorId, axisIndex]\n */\nexport type AnchorAxisRefByIdx = { anchor: string; idx: number };\n\n/**\n * Reference to an axis by its name within the anchor column\n * Format: [anchorId, axisName]\n */\nexport type AnchorAxisRefByName = { anchor: string; name: string };\n\n/**\n * Reference to an axis using an AxisId matcher within the anchor\n * Format: [anchorId, axisMatcher]\n */\nexport type AnchorAxisRefByMatcher = { anchor: string; id: AxisId };\n\n/**\n * Basic anchor axis reference that can be either by index or a direct AxisId\n */\nexport type AnchorAxisIdOrRefBasic = AnchorAxisRefByIdx | AxisId;\n\n/** Union of all possible ways to reference an axis in an anchored context */\nexport type AnchorAxisRef = AnchorAxisRefByIdx | AnchorAxisRefByName | AnchorAxisRefByMatcher;\n\n/** Reference to a domain value through an anchor */\nexport type AnchorDomainRef = { anchor: string };\n\n/**\n * Domain value that can be either a direct string value or a reference to a domain through an anchor\n * Used to establish domain context that can be resolved relative to other anchored columns\n */\nexport type ADomain = string | AnchorDomainRef;\n/**\n * Axis identifier that can be either a direct AxisId or a reference to an axis through an anchor\n * Allows referring to axes in a way that can be resolved in different contexts\n */\nexport type AAxisSelector = AxisSelector | AnchorAxisRef;\n\n/**\n * Match resolution strategy for PColumns\n * Specifies how to handle when multiple columns match the criteria\n * (default is \"expectSingle\")\n */\nexport type AnchoredColumnMatchStrategy = \"expectSingle\" | \"expectMultiple\" | \"takeFirst\";\n\n/**\n * Matcher for PColumns in an anchored context\n * Supports partial matching on axes, allowing for flexible column discovery\n */\nexport interface AnchoredPColumnSelector {\n /** Optional name of the column to match; can't be used together with namePattern */\n name?: string;\n /** Optional regexp pattern for column name matching; can't be used together with name */\n namePattern?: string;\n /** Optional value type to match. If an array is provided, matches if the column's type is any of the specified types */\n type?: ValueType | ValueType[];\n /** If specified, the domain values must be anchored to this anchor */\n domainAnchor?: string;\n /** Optional domain values to match, can include anchored references, if domainAnchor is specified,\n * interpreted as additional domains to domain from the anchor */\n domain?: Record<string, ADomain>;\n /** Optional axes to match, can include anchored references */\n axes?: AAxisSelector[];\n /** When true, allows matching if only a subset of axes match */\n partialAxesMatch?: boolean;\n /** Optional annotations to match with exact values */\n annotations?: Record<string, string>;\n /** Optional annotation patterns to match with regex patterns */\n annotationPatterns?: Record<string, string>;\n /** Match resolution strategy, default is \"expectSingle\" */\n matchStrategy?: AnchoredColumnMatchStrategy;\n}\n\n/**\n * Matcher for PColumns in a non-anchored context\n */\nexport interface PColumnSelector extends AnchoredPColumnSelector {\n domainAnchor?: never;\n domain?: Record<string, string>;\n axes?: AxisSelector[];\n}\n\n/**\n * Strict identifier for PColumns in an anchored context\n * Unlike APColumnMatcher, this requires exact matches on domain and axes\n */\nexport interface AnchoredPColumnId extends AnchoredPColumnSelector {\n /** Name is required for exact column identification */\n name: string;\n /** No namePattern in ID */\n namePattern?: never;\n /** Type is not used in exact column identification */\n type?: never;\n /** Full axes specification using only basic references */\n axes: AnchorAxisIdOrRefBasic[];\n /** Partial axes matching is not allowed for exact identification */\n partialAxesMatch?: never;\n /** Annotations are not used in exact column identification */\n annotations?: never;\n /** Annotation patterns are not used in exact column identification */\n annotationPatterns?: never;\n /** \"Id\" implies single match strategy */\n matchStrategy?: never;\n}\n\n/**\n * Checks if a given value is an anchored column identifier\n * @param id - The value to check\n * @returns True if the value is an anchored column identifier, false otherwise\n */\nexport function isAnchoredPColumnId(id: unknown): id is AnchoredPColumnId {\n // basic check, can be extended if needed\n return typeof id === \"object\" && id !== null && \"name\" in id && \"axes\" in id;\n}\n\n/**\n * Determines if an axis ID matches an axis selector.\n *\n * @param selector - The selector with criteria to match against\n * @param axis - The AxisId to check against the selector\n * @returns true if the AxisId matches all specified criteria in the selector, false otherwise\n */\nexport function matchAxis(selector: AxisSelector, axis: AxisId): boolean {\n // Match name if specified\n if (selector.name !== undefined && selector.name !== axis.name) return false;\n\n // Match type if specified\n if (selector.type !== undefined) {\n if (Array.isArray(selector.type)) {\n if (!selector.type.includes(axis.type)) return false;\n } else if (selector.type !== axis.type) {\n return false;\n }\n }\n\n // Match domain if specified - using existing logic from matchAxisId\n if (selector.domain !== undefined) {\n const axisDomain = axis.domain || {};\n for (const [key, value] of Object.entries(selector.domain))\n if (axisDomain[key] !== value) return false;\n }\n\n return true;\n}\n\n/**\n * Determines if a given PColumnSpec matches a selector.\n *\n * @param pcolumn - The PColumnSpec to check against the selector\n * @param selector - The selector criteria to match against\n * @returns true if the PColumnSpec matches all criteria in the selector, false otherwise\n */\nexport function matchPColumn(pcolumn: PColumnSpec, selector: PColumnSelector): boolean {\n // Match name if specified\n if (selector.name !== undefined && pcolumn.name !== selector.name) return false;\n\n // Match name pattern if specified\n if (selector.namePattern !== undefined && !new RegExp(selector.namePattern).test(pcolumn.name))\n return false;\n\n // Match type if specified\n if (selector.type !== undefined) {\n if (Array.isArray(selector.type)) {\n if (!selector.type.includes(pcolumn.valueType)) return false;\n } else if (selector.type !== pcolumn.valueType) {\n return false;\n }\n }\n\n // Match domain if specified\n if (selector.domain !== undefined) {\n const columnDomain = pcolumn.domain || {};\n for (const [key, value] of Object.entries(selector.domain))\n if (columnDomain[key] !== value) return false;\n }\n\n // Match axes if specified\n if (selector.axes !== undefined) {\n const pcolumnAxes = pcolumn.axesSpec.map(getAxisId);\n\n if (selector.partialAxesMatch) {\n // For partial matching, all selector axes must match at least one column axis\n for (const selectorAxis of selector.axes)\n if (!pcolumnAxes.some((columnAxis) => matchAxis(selectorAxis, columnAxis))) return false;\n } else {\n // For exact matching, column must have the same number of axes and all must match\n if (pcolumnAxes.length !== selector.axes.length) return false;\n\n // Each selector axis must match a corresponding column axis\n for (let i = 0; i < selector.axes.length; i++)\n if (!matchAxis(selector.axes[i], pcolumnAxes[i])) return false;\n }\n }\n\n // Match annotations if specified\n if (selector.annotations !== undefined) {\n const columnAnnotations = pcolumn.annotations || {};\n for (const [key, value] of Object.entries(selector.annotations))\n if (columnAnnotations[key] !== value) return false;\n }\n\n // Match annotation patterns if specified\n if (selector.annotationPatterns !== undefined) {\n const columnAnnotations = pcolumn.annotations || {};\n for (const [key, pattern] of Object.entries(selector.annotationPatterns)) {\n const value = columnAnnotations[key];\n if (value === undefined || !new RegExp(pattern).test(value)) return false;\n }\n }\n\n return true;\n}\n\n/**\n * Convert a predicate or array of selectors to a single predicate function\n * @param predicateOrSelectors - Either a function that takes a PColumnSpec and returns a boolean,\n * or an array of PColumnSelectors, or a single PColumnSelector\n * @returns A function that takes a PColumnSpec and returns a boolean\n */\nexport function selectorsToPredicate(\n predicateOrSelectors: PColumnSelector | PColumnSelector[],\n): (spec: PObjectSpec) => boolean {\n if (Array.isArray(predicateOrSelectors))\n return (spec) =>\n predicateOrSelectors.some((selector) => isPColumnSpec(spec) && matchPColumn(spec, selector));\n else return (spec) => isPColumnSpec(spec) && matchPColumn(spec, predicateOrSelectors);\n}\n"],"names":[],"mappings":";;;AA8JA;;;;AAIG;AACG,SAAU,mBAAmB,CAAC,EAAW,EAAA;;AAE7C,IAAA,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,IAAI,IAAI,MAAM,IAAI,EAAE,IAAI,MAAM,IAAI,EAAE;AAC9E;AAEA;;;;;;AAMG;AACG,SAAU,SAAS,CAAC,QAAsB,EAAE,IAAY,EAAA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B,CAAC;AACvF;;;;"}
|
|
1
|
+
{"version":3,"file":"selectors.js","names":[],"sources":["../../../../src/drivers/pframe/spec/selectors.ts"],"sourcesContent":["import { isPColumnSpec, type PObjectSpec } from \"../../../pool\";\nimport type { AxisId, AxisValueType, Domain, PColumnSpec, ValueType } from \"./spec\";\nimport { getAxisId } from \"./spec\";\n\n/**\n * Defines a pattern for matching axes within the PFrame data model.\n *\n * AxisSelector provides a flexible way to identify axes based on their\n * properties. All fields are optional, allowing for partial matching.\n * When multiple properties are specified, all must match for an axis\n * to be selected (logical AND).\n *\n * This interface is used in various selection and matching operations\n * throughout the PFrame system, such as column queries and axis lookups.\n */\nexport interface AxisSelector {\n /**\n * Optional value type to match against.\n * When specified, only axes with this exact type will match.\n * Can be a single type or an array of types to match against any of them.\n * Valid types include: 'Int', 'Long', 'Float', 'Double', 'String', 'Bytes'.\n */\n type?: ValueType | ValueType[];\n\n /**\n * Optional name to match against.\n * When specified, only axes with this exact name will match.\n */\n name?: string;\n\n /**\n * Optional domain key-value pairs to match against.\n * Domains provide additional context to uniquely identify an axis beyond its name and type.\n * When specified, an axis will match only if it contains all the key-value pairs defined here.\n * An axis with additional domain entries not present in this selector will still match.\n */\n domain?: Record<string, string>;\n}\n\n/** Single axis selector */\nexport interface SingleAxisSelector {\n /** Axis name (required) */\n name: string;\n /** Axis type (optional) */\n type?: AxisValueType;\n /** Domain requirements (optional) */\n domain?: Domain;\n /** Parent axes requirements (optional) */\n parentAxes?: SingleAxisSelector[];\n}\n\n/**\n * Reference to an axis by its numerical index within the anchor column's axes array\n * Format: [anchorId, axisIndex]\n */\nexport type AnchorAxisRefByIdx = { anchor: string; idx: number };\n\n/**\n * Reference to an axis by its name within the anchor column\n * Format: [anchorId, axisName]\n */\nexport type AnchorAxisRefByName = { anchor: string; name: string };\n\n/**\n * Reference to an axis using an AxisId matcher within the anchor\n * Format: [anchorId, axisMatcher]\n */\nexport type AnchorAxisRefByMatcher = { anchor: string; id: AxisId };\n\n/**\n * Basic anchor axis reference that can be either by index or a direct AxisId\n */\nexport type AnchorAxisIdOrRefBasic = AnchorAxisRefByIdx | AxisId;\n\n/** Union of all possible ways to reference an axis in an anchored context */\nexport type AnchorAxisRef = AnchorAxisRefByIdx | AnchorAxisRefByName | AnchorAxisRefByMatcher;\n\n/** Reference to a domain value through an anchor */\nexport type AnchorDomainRef = { anchor: string };\n\n/**\n * Domain value that can be either a direct string value or a reference to a domain through an anchor\n * Used to establish domain context that can be resolved relative to other anchored columns\n */\nexport type ADomain = string | AnchorDomainRef;\n/**\n * Axis identifier that can be either a direct AxisId or a reference to an axis through an anchor\n * Allows referring to axes in a way that can be resolved in different contexts\n */\nexport type AAxisSelector = AxisSelector | AnchorAxisRef;\n\n/**\n * Match resolution strategy for PColumns\n * Specifies how to handle when multiple columns match the criteria\n * (default is \"expectSingle\")\n */\nexport type AnchoredColumnMatchStrategy = \"expectSingle\" | \"expectMultiple\" | \"takeFirst\";\n\n/**\n * Matcher for PColumns in an anchored context\n * Supports partial matching on axes, allowing for flexible column discovery\n */\nexport interface AnchoredPColumnSelector {\n /** Optional name of the column to match; can't be used together with namePattern */\n name?: string;\n /** Optional regexp pattern for column name matching; can't be used together with name */\n namePattern?: string;\n /** Optional value type to match. If an array is provided, matches if the column's type is any of the specified types */\n type?: ValueType | ValueType[];\n /** If specified, the domain values must be anchored to this anchor */\n domainAnchor?: string;\n /** Optional domain values to match, can include anchored references, if domainAnchor is specified,\n * interpreted as additional domains to domain from the anchor */\n domain?: Record<string, ADomain>;\n /** Optional axes to match, can include anchored references */\n axes?: AAxisSelector[];\n /** When true, allows matching if only a subset of axes match */\n partialAxesMatch?: boolean;\n /** Optional annotations to match with exact values */\n annotations?: Record<string, string>;\n /** Optional annotation patterns to match with regex patterns */\n annotationPatterns?: Record<string, string>;\n /** Match resolution strategy, default is \"expectSingle\" */\n matchStrategy?: AnchoredColumnMatchStrategy;\n}\n\n/**\n * Matcher for PColumns in a non-anchored context\n */\nexport interface PColumnSelector extends AnchoredPColumnSelector {\n domainAnchor?: never;\n domain?: Record<string, string>;\n axes?: AxisSelector[];\n}\n\n/**\n * Strict identifier for PColumns in an anchored context\n * Unlike APColumnMatcher, this requires exact matches on domain and axes\n */\nexport interface AnchoredPColumnId extends AnchoredPColumnSelector {\n /** Name is required for exact column identification */\n name: string;\n /** No namePattern in ID */\n namePattern?: never;\n /** Type is not used in exact column identification */\n type?: never;\n /** Full axes specification using only basic references */\n axes: AnchorAxisIdOrRefBasic[];\n /** Partial axes matching is not allowed for exact identification */\n partialAxesMatch?: never;\n /** Annotations are not used in exact column identification */\n annotations?: never;\n /** Annotation patterns are not used in exact column identification */\n annotationPatterns?: never;\n /** \"Id\" implies single match strategy */\n matchStrategy?: never;\n}\n\n/**\n * Checks if a given value is an anchored column identifier\n * @param id - The value to check\n * @returns True if the value is an anchored column identifier, false otherwise\n */\nexport function isAnchoredPColumnId(id: unknown): id is AnchoredPColumnId {\n // basic check, can be extended if needed\n return typeof id === \"object\" && id !== null && \"name\" in id && \"axes\" in id;\n}\n\n/**\n * Determines if an axis ID matches an axis selector.\n *\n * @param selector - The selector with criteria to match against\n * @param axis - The AxisId to check against the selector\n * @returns true if the AxisId matches all specified criteria in the selector, false otherwise\n */\nexport function matchAxis(selector: AxisSelector, axis: AxisId): boolean {\n // Match name if specified\n if (selector.name !== undefined && selector.name !== axis.name) return false;\n\n // Match type if specified\n if (selector.type !== undefined) {\n if (Array.isArray(selector.type)) {\n if (!selector.type.includes(axis.type)) return false;\n } else if (selector.type !== axis.type) {\n return false;\n }\n }\n\n // Match domain if specified - using existing logic from matchAxisId\n if (selector.domain !== undefined) {\n const axisDomain = axis.domain || {};\n for (const [key, value] of Object.entries(selector.domain))\n if (axisDomain[key] !== value) return false;\n }\n\n return true;\n}\n\n/**\n * Determines if a given PColumnSpec matches a selector.\n *\n * @param pcolumn - The PColumnSpec to check against the selector\n * @param selector - The selector criteria to match against\n * @returns true if the PColumnSpec matches all criteria in the selector, false otherwise\n */\nexport function matchPColumn(pcolumn: PColumnSpec, selector: PColumnSelector): boolean {\n // Match name if specified\n if (selector.name !== undefined && pcolumn.name !== selector.name) return false;\n\n // Match name pattern if specified\n if (selector.namePattern !== undefined && !new RegExp(selector.namePattern).test(pcolumn.name))\n return false;\n\n // Match type if specified\n if (selector.type !== undefined) {\n if (Array.isArray(selector.type)) {\n if (!selector.type.includes(pcolumn.valueType)) return false;\n } else if (selector.type !== pcolumn.valueType) {\n return false;\n }\n }\n\n // Match domain if specified\n if (selector.domain !== undefined) {\n const columnDomain = pcolumn.domain || {};\n for (const [key, value] of Object.entries(selector.domain))\n if (columnDomain[key] !== value) return false;\n }\n\n // Match axes if specified\n if (selector.axes !== undefined) {\n const pcolumnAxes = pcolumn.axesSpec.map(getAxisId);\n\n if (selector.partialAxesMatch) {\n // For partial matching, all selector axes must match at least one column axis\n for (const selectorAxis of selector.axes)\n if (!pcolumnAxes.some((columnAxis) => matchAxis(selectorAxis, columnAxis))) return false;\n } else {\n // For exact matching, column must have the same number of axes and all must match\n if (pcolumnAxes.length !== selector.axes.length) return false;\n\n // Each selector axis must match a corresponding column axis\n for (let i = 0; i < selector.axes.length; i++)\n if (!matchAxis(selector.axes[i], pcolumnAxes[i])) return false;\n }\n }\n\n // Match annotations if specified\n if (selector.annotations !== undefined) {\n const columnAnnotations = pcolumn.annotations || {};\n for (const [key, value] of Object.entries(selector.annotations))\n if (columnAnnotations[key] !== value) return false;\n }\n\n // Match annotation patterns if specified\n if (selector.annotationPatterns !== undefined) {\n const columnAnnotations = pcolumn.annotations || {};\n for (const [key, pattern] of Object.entries(selector.annotationPatterns)) {\n const value = columnAnnotations[key];\n if (value === undefined || !new RegExp(pattern).test(value)) return false;\n }\n }\n\n return true;\n}\n\n/**\n * Convert a predicate or array of selectors to a single predicate function\n * @param predicateOrSelectors - Either a function that takes a PColumnSpec and returns a boolean,\n * or an array of PColumnSelectors, or a single PColumnSelector\n * @returns A function that takes a PColumnSpec and returns a boolean\n */\nexport function selectorsToPredicate(\n predicateOrSelectors: PColumnSelector | PColumnSelector[],\n): (spec: PObjectSpec) => boolean {\n if (Array.isArray(predicateOrSelectors))\n return (spec) =>\n predicateOrSelectors.some((selector) => isPColumnSpec(spec) && matchPColumn(spec, selector));\n else return (spec) => isPColumnSpec(spec) && matchPColumn(spec, predicateOrSelectors);\n}\n"],"mappings":";;;;;;;;;AAmKA,SAAgB,oBAAoB,IAAsC;AAExE,QAAO,OAAO,OAAO,YAAY,OAAO,QAAQ,UAAU,MAAM,UAAU;;;;;;;;;AAU5E,SAAgB,UAAU,UAAwB,MAAuB;AAEvE,KAAI,SAAS,SAAS,UAAa,SAAS,SAAS,KAAK,KAAM,QAAO;AAGvE,KAAI,SAAS,SAAS,QACpB;MAAI,MAAM,QAAQ,SAAS,KAAK,EAC9B;OAAI,CAAC,SAAS,KAAK,SAAS,KAAK,KAAK,CAAE,QAAO;aACtC,SAAS,SAAS,KAAK,KAChC,QAAO;;AAKX,KAAI,SAAS,WAAW,QAAW;EACjC,MAAM,aAAa,KAAK,UAAU,EAAE;AACpC,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,OAAO,CACxD,KAAI,WAAW,SAAS,MAAO,QAAO;;AAG1C,QAAO;;;;;;;;;AAUT,SAAgB,aAAa,SAAsB,UAAoC;AAErF,KAAI,SAAS,SAAS,UAAa,QAAQ,SAAS,SAAS,KAAM,QAAO;AAG1E,KAAI,SAAS,gBAAgB,UAAa,CAAC,IAAI,OAAO,SAAS,YAAY,CAAC,KAAK,QAAQ,KAAK,CAC5F,QAAO;AAGT,KAAI,SAAS,SAAS,QACpB;MAAI,MAAM,QAAQ,SAAS,KAAK,EAC9B;OAAI,CAAC,SAAS,KAAK,SAAS,QAAQ,UAAU,CAAE,QAAO;aAC9C,SAAS,SAAS,QAAQ,UACnC,QAAO;;AAKX,KAAI,SAAS,WAAW,QAAW;EACjC,MAAM,eAAe,QAAQ,UAAU,EAAE;AACzC,OAAK,MAAM,CAAC,KAA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