@milaboratories/pl-model-common 1.11.3 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drivers/pframe/data.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/{anchored_id.d.ts → anchored.d.ts} +20 -13
- package/dist/drivers/pframe/spec/anchored.d.ts.map +1 -0
- package/dist/drivers/pframe/spec/filtered_column.d.ts +31 -0
- package/dist/drivers/pframe/spec/filtered_column.d.ts.map +1 -0
- package/dist/drivers/pframe/spec/ids.d.ts +24 -0
- package/dist/drivers/pframe/spec/ids.d.ts.map +1 -0
- package/dist/drivers/pframe/spec/index.d.ts +3 -1
- package/dist/drivers/pframe/spec/index.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/selectors.d.ts +3 -3
- package/dist/drivers/pframe/spec/selectors.d.ts.map +1 -1
- package/dist/drivers/pframe/spec/spec.d.ts +2 -0
- package/dist/drivers/pframe/spec/spec.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +228 -196
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/drivers/pframe/data.ts +1 -0
- package/src/drivers/pframe/spec/{anchored_id.ts → anchored.ts} +63 -21
- package/src/drivers/pframe/spec/filtered_column.ts +39 -0
- package/src/drivers/pframe/spec/ids.ts +31 -0
- package/src/drivers/pframe/spec/index.ts +3 -1
- package/src/drivers/pframe/spec/selectors.ts +4 -3
- package/src/drivers/pframe/spec/spec.ts +6 -0
- package/dist/drivers/pframe/spec/anchored_id.d.ts.map +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PValue } from '../data';
|
|
2
|
+
import type { AnchoredPColumnId } from './selectors';
|
|
3
|
+
|
|
4
|
+
/** Axis filter by index */
|
|
5
|
+
export type AxisFilterByIdx = [number, PValue];
|
|
6
|
+
|
|
7
|
+
/** Axis filter by name */
|
|
8
|
+
export type AxisFilterByName = [string, PValue];
|
|
9
|
+
|
|
10
|
+
/** Axis filter */
|
|
11
|
+
export type AxisFilter = AxisFilterByIdx | AxisFilterByName;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Identifies a column derived from a CanonicalPColumnId by fixing values on certain axes,
|
|
15
|
+
* thus effectively reducing the dimensionality of the original column.
|
|
16
|
+
*/
|
|
17
|
+
export type FilteredPColumn<CID = AnchoredPColumnId, AFI = AxisFilter> = {
|
|
18
|
+
/** The original column identifier */
|
|
19
|
+
source: CID;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* List of fixed axes and their corresponding values.
|
|
23
|
+
* Each entry fixes one axis to a specific value, creating a slice of the multidimensional data.
|
|
24
|
+
* This effectively reduces the dimensionality by one for each fixed axis.
|
|
25
|
+
* Ordered by the axis index in canonical case.
|
|
26
|
+
*/
|
|
27
|
+
axisFilters: AFI[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type FilteredPColumnId = FilteredPColumn<AnchoredPColumnId, AxisFilterByIdx>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Checks if a given value is a FilteredPColumn
|
|
34
|
+
* @param id - The value to check
|
|
35
|
+
* @returns True if the value is a FilteredPColumn, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
export function isFilteredPColumn(id: unknown): id is FilteredPColumn {
|
|
38
|
+
return typeof id === 'object' && id !== null && 'source' in id && 'axisFilters' in id;
|
|
39
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Branded } from '../../../branding';
|
|
2
|
+
import type { AnchoredPColumnId } from './selectors';
|
|
3
|
+
import type { FilteredPColumnId } from './filtered_column';
|
|
4
|
+
import canonicalize from 'canonicalize';
|
|
5
|
+
/**
|
|
6
|
+
* Universal column identifier optionally anchored and optionally filtered.
|
|
7
|
+
*/
|
|
8
|
+
export type UniversalPColumnId = AnchoredPColumnId | FilteredPColumnId;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Canonically serialized {@link UniversalPColumnId}.
|
|
12
|
+
*/
|
|
13
|
+
export type SUniversalPColumnId = Branded<string, 'SUniversalPColumnId'>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Canonically serializes a {@link UniversalPColumnId} to a string.
|
|
17
|
+
* @param id - The column identifier to serialize
|
|
18
|
+
* @returns The canonically serialized string
|
|
19
|
+
*/
|
|
20
|
+
export function stringifyColumnId(id: UniversalPColumnId): SUniversalPColumnId {
|
|
21
|
+
return canonicalize(id)! as SUniversalPColumnId;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Parses a canonically serialized {@link UniversalPColumnId} from a string.
|
|
26
|
+
* @param str - The string to parse
|
|
27
|
+
* @returns The parsed column identifier
|
|
28
|
+
*/
|
|
29
|
+
export function parseColumnId(str: SUniversalPColumnId): UniversalPColumnId {
|
|
30
|
+
return JSON.parse(str) as UniversalPColumnId;
|
|
31
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isPColumnSpec, type PObjectSpec } from '../../../pool';
|
|
2
|
+
import type { AxisFilterByIdx, FilteredPColumn } from './filtered_column';
|
|
2
3
|
import type { AxisId, PColumnSpec, ValueType } from './spec';
|
|
3
4
|
import { getAxisId } from './spec';
|
|
4
5
|
|
|
@@ -88,7 +89,7 @@ export type AnchoredColumnMatchStrategy = 'expectSingle' | 'expectMultiple' | 't
|
|
|
88
89
|
* Matcher for PColumns in an anchored context
|
|
89
90
|
* Supports partial matching on axes, allowing for flexible column discovery
|
|
90
91
|
*/
|
|
91
|
-
export interface
|
|
92
|
+
export interface AnchoredPColumnSelector {
|
|
92
93
|
/** Optional name of the column to match; can't be used together with namePattern */
|
|
93
94
|
name?: string;
|
|
94
95
|
/** Optional regexp pattern for column name matching; can't be used together with name */
|
|
@@ -115,7 +116,7 @@ export interface APColumnSelector {
|
|
|
115
116
|
/**
|
|
116
117
|
* Matcher for PColumns in a non-anchored context
|
|
117
118
|
*/
|
|
118
|
-
export interface PColumnSelector extends
|
|
119
|
+
export interface PColumnSelector extends AnchoredPColumnSelector {
|
|
119
120
|
domainAnchor?: never;
|
|
120
121
|
domain?: Record<string, string>;
|
|
121
122
|
axes?: AxisSelector[];
|
|
@@ -125,7 +126,7 @@ export interface PColumnSelector extends APColumnSelector {
|
|
|
125
126
|
* Strict identifier for PColumns in an anchored context
|
|
126
127
|
* Unlike APColumnMatcher, this requires exact matches on domain and axes
|
|
127
128
|
*/
|
|
128
|
-
export interface
|
|
129
|
+
export interface AnchoredPColumnId extends AnchoredPColumnSelector {
|
|
129
130
|
/** Name is required for exact column identification */
|
|
130
131
|
name: string;
|
|
131
132
|
/** No namePattern in ID */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PObject, PObjectId, PObjectSpec } from '../../../pool';
|
|
2
|
+
import canonicalize from 'canonicalize';
|
|
2
3
|
|
|
3
4
|
/** PFrame columns and axes within them may store one of these types. */
|
|
4
5
|
export type ValueType = 'Int' | 'Long' | 'Float' | 'Double' | 'String' | 'Bytes';
|
|
@@ -151,6 +152,11 @@ export function getAxesId(spec: AxesSpec): AxesId {
|
|
|
151
152
|
return spec.map(getAxisId);
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
/** Canonicalizes axis id */
|
|
156
|
+
export function canonicalizeAxisId(id: AxisId): string {
|
|
157
|
+
return canonicalize(getAxisId(id))!;
|
|
158
|
+
}
|
|
159
|
+
|
|
154
160
|
/** Returns true if all domains from query are found in target */
|
|
155
161
|
function matchDomain(query?: Record<string, string>, target?: Record<string, string>) {
|
|
156
162
|
if (query === undefined) return target === undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"anchored_id.d.ts","sourceRoot":"","sources":["../../../../src/drivers/pframe/spec/anchored_id.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAU,WAAW,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,KAAK,EAAoD,UAAU,EAAE,gBAAgB,EAAgB,eAAe,EAAE,MAAM,aAAa,CAAC;AACjJ,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAkBjD,yGAAyG;AACzG,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;AAEvE;;;GAGG;AACH,qBAAa,eAAe;IAiBd,OAAO,CAAC,QAAQ,CAAC,OAAO;IAhBpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyC;IAC9D;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAkB;IAC9C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA6B;IAEhE;;;OAGG;gBAC0B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;IAwBjE;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU;IA6CrC;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,kBAAkB;CAIvD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAqC/G"}
|